petrosh / snippetrosh

Notes with Issues
MIT License
1 stars 3 forks source link

GitHub #2

Open petrosh opened 8 years ago

petrosh commented 8 years ago
petrosh commented 7 years ago

GitHub API

414 Request-URI Too Large

API Links

test user

octokat.js

Get first commit of a repository

var url = 'https://api.github.com/repos/' + username + '/' + githubRepository;
cb = function issues(json){
  console.log(json.created_at);
  var url1 = 'https://api.github.com/repos/' + username + '/' + githubRepository + '/commits?per_page=1&until=' + json.created_at;
  var cb1 = function first(json){
    console.log(json);
  };
  go(url1,cb1);
};
go(url,cb);

Append <script>

<html>
<head>
  <script type="text/javascript">
    function foo(response) {
      var meta = response.meta;
      var data = response.data;
      console.log(meta);
      console.log(data);
    }
    var script = document.createElement('script');
    script.src = 'https://api.github.com?callback=foo';
    document.getElementsByTagName('head')[0].appendChild(script);
  </script>
</head>
<body>
  <p>Open up your browser's console.</p>
</body>
</html>

Gist embed GitHub

<script src="https://gist.github.com/mbostock/4063550.js?file=flare.json"></script>
<!-- https://gist.github.com/<USERNAME>/<GIST ID>.js?file=<FILENAME> -->

Wikis

https://raw.github.com/wiki/[owner]/[repository]/[page].md

Wiki Page URL

https://github.com/owner/repository/wiki/Wiki-Page

Append .md

https://github.com/owner/repository/wiki/Wiki-Page.md

Redirected to raw URL

https://raw.githubusercontent.com/wiki/owner/repository/Wiki-Page.md

Example: https://github.com/reinterpretcat/utymap/wiki/Install-on-Linux

Hovercard

Hovercard API v3

GET /users/:username/hovercard?subject_type=repository&subject_id=1300192

by organization owner to a repository

{
  "contexts": [
    {
      "message": "Committed to this repository in the past week",
      "octicon": "git-commit"
    },
    {
      "message": "Member of @riminino and 5 more",
      "octicon": "organization"
    }
  ]
}

by guest logged with public_repo token scope

Hovercard error Not Found

by guest logged with repo token scope needed for "contextual information API"

{
  "contexts": [

  ]
}
petrosh commented 7 years ago

gh-pages

Usage limits

Publishing with GitHub Pages, now as easy as 1, 2, 3

Dependency versions

Gem version
jekyll Gem Version
jekyll-swiss Gem Version

Simpler GitHub Pages publishing

Better discoverability for GitHub Pages sites

By simply adding the {% seo %} tag to your site's template Jekyll will automatically add the appropriate search engine metadata to each page.

<html>
  <head>
    {% include head.html %}
    {% seo %}
  </head>
</html>

Exposed metadata

Pages API

Usage limits

petrosh commented 7 years ago

Terminal

Links

List of all files changed in a commit

git diff-tree --no-commit-id --name-only -r <commit-ish>

Curl

Branches

git.io

tags

petrosh commented 7 years ago

Submodules

git submodule add https://github.com/petrosh/submodules-posts _posts
git submodule update --remote --merge
git commit -am "ok" && git push
petrosh commented 7 years ago
# ----------
# .gitignore
# ----------

# Windows image file caches
Thumbs.db
ehthumbs.db

# Folder config file
Desktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msm
*.msp

# Windows shortcuts
*.lnk

# =========================
# Operating System Files
# =========================

# OSX
# =========================

.DS_Store
.AppleDouble
.LSOverride

# Thumbnails
._*

# Files that might appear on external disk
.Spotlight-V100
.Trashes

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
petrosh commented 7 years ago

Web UI

Bottom of the page anchor

[bottom page](#partial-new-comment-form-actions)

Search files in repository

https://github.com/:owner/:repository/find/:branch

Search repos with multiple topics

topic:"rpg" "rpg-engine"

Prefilling GitHub file create

https://github.com/:owner/:repo/new/:branch?filename=:filename.ext&value=:content&message=:commit_message&description=:commit_description

ProTip™: You can pre-fill the filename field using just the URL. Typing ?filename=yournewfile.txt at the end of the URL will pre-fill the filename field with the name yournewfile.txt.

Example: https://github.com/starsystem/starsystem.github.io/new/master?filename=ciccio.md&value=ennamo-2&message=criostato&description=unduetre

Remember to encode_uri so space is %20, newline is %0A ...

Prefilling GitHub Issues

Example: https://github.com/starsystem/starsystem.github.io/issues/new?labels[]=bug&labels[]=duplicate&title=People&milestone=Nadaal&assignee=petrosh&body=This%20is%20a%20prefilled%20issue

Prefilling GitHub comments

Add #new_comment_field to focus on textarea.

petrosh commented 7 years ago

Markdown

petrosh commented 7 years ago

Hooks

petrosh commented 6 years ago

Identicons

trasparente commented 4 years ago

GraphQL

Code

$.ajaxSetup
  url: "{{ site.github.api_url }}/graphql"
  headers: "Authorization": "token #{storage.get 'login.token'}"
  type: "POST"

jery = $.ajax data: JSON.stringify { query:
  'query{viewer{login}repository(owner:"riminino", name:"graf"){viewerPermission isFork}}'
} 
jery.done (data, status) -> console.log data, status
jery.fail (request, status, error) -> console.log status, error

Viewer

query{
   viewer{
      login
   }
}
{
  "data": {
    "viewer": {
      "login": "trasparente"
    }
  }
}

All fields

query {
   __type (name: "Repository") {
      fields {
         name
         description
      }  
   }
}

Repository

query {
   repository (owner: "riminino", name: "barebone") {
      viewerCanAdminister
      viewerPermission
   }
}
{
  "data": {
    "repository": {
      "viewerCanAdminister": true,
      "viewerPermission": "ADMIN"
    }
  }
}

Deployments

query{
   repository(owner:"riminino", name:"barebone") {
        deployments(last: 1) {
          edges {
            node {
            commit {
              oid
            }
            task
              updatedAt
            }
          }
        }
   }
}
{
  "data": {
    "repository": {
      "deployments": {
        "edges": [
          {
            "node": {
              "commit": {
                "oid": "119d18999a0908097358500fa47ca29d2c4bd1c7"
              },
              "task": "deploy",
              "updatedAt": "2020-04-15T14:04:32Z"
            }
          }
        ]
      }
    }
  }
}

Rate limit

query{
   rateLimit{
    cost
    limit
    nodeCount
    remaining
    resetAt
  }
}
{
  "data": {
    "rateLimit": {
      "cost": 1,
      "limit": 5000,
      "nodeCount": 0,
      "remaining": 4990,
      "resetAt": "2020-04-15T21:32:32Z"
    }
  }
}