@kyanny's blog

My thoughts, my life. Views/opinions are my own.

Pull Requestのbase branchがmasterとdevelop以外のときブランチ名を目立たせる

blog.sushi.money

デフォルトブランチが msater のリポジトリと develop のリポジトリがあるので、これを少しだけ改造した。

/* 

Pull Requestのbase branchがmaster以外のときブランチ名を目立たせる - hitode909の日記
http://blog.sushi.money/entry/2017/07/21/104650

*/

.gh-header-meta .commit-ref:first-of-type {
  background: #dbab09;
}
.gh-header-meta .commit-ref:first-of-type[title*='master'] {
  background: #eff7ff !important;
}
.gh-header-meta .commit-ref:first-of-type[title*='develop'] {
  background: #eff7ff !important;
}

f:id:a666666:20170727174123p:plainf:id:a666666:20170727174130p:plainf:id:a666666:20170727174135p:plain

GitHub でプライベートリポジトリを目立たせるユーザースクリプト

仕事でもっぱら GitHub のプライベートリポジトリを使っている。たまに会社の Organization 配下にあるパブリックリポジトリを使うことがあって、インターネットに公開されているのでうっかり社内向けのノリでログとか貼り付けてしまわないように気を使わないといけない。ずっと気を張ると疲れるので、プライベートリポジトリだったらばかでかいアイコンをずっと表示させることにした。パブリックリポジトリだとアイコンがでないので、どっちをみてるのか一目でわかる。

f:id:a666666:20170716022947p:plain f:id:a666666:20170716023011p:plain

せっかくなので Greasy Fork で公開してみた。 https://github.com/kyanny/userscripts/raw/master/emphasize-private-repo-for-github.user.js のような URL を開くとTampermonkey が勝手に検知してくれるし、たぶん自動アップデートも面倒みてくれるので Greasy Fork を介する必要は無いけど。

Emphasize private repo for GitHub

画面をスクロールしても左上に貼り付く。 :has() セレクタが使えれば CSS だけでできたかもしれないけど、 Stylish ではシンタックスエラーになってしまった。

f:id:a666666:20170716023027g:plain

GitHub の issue に label をつけたときに飛ぶ webhook

  • Issues event を選ぶとこの webhook が飛ぶ https://developer.github.com/webhooks/
  • イシューを新規作成するときにラベルをつけても ok
  • ラベルを複数つけると webhook も付けたラベルと同じ数だけ飛ぶ
  • webhook payload の label に付与されたラベルの情報が入る(ラベル名は label.name に入る) https://developer.github.com/v3/activity/events/types/#issuesevent
  • labels にはそのイシューについている全てのラベルの情報が入る
    • Array/List で入るので、これをうまくデータ構造としてパースできないクライアントもある。 Zapier とか。

Headers

Request URL: https://requestb.in/11bqcme1
Request method: POST
content-type: application/json
Expect: 
User-Agent: GitHub-Hookshot/eba7944
X-GitHub-Delivery: a549c020-6645-11e7-9dac-30a99e652a6c
X-GitHub-Event: issues

Payload

{
  "action": "labeled",
  "issue": {
    "url": "https://api.github.com/repos/kyanny/test/issues/9",
    "repository_url": "https://api.github.com/repos/kyanny/test",
    "labels_url": "https://api.github.com/repos/kyanny/test/issues/9/labels{/name}",
    "comments_url": "https://api.github.com/repos/kyanny/test/issues/9/comments",
    "events_url": "https://api.github.com/repos/kyanny/test/issues/9/events",
    "html_url": "https://github.com/kyanny/test/issues/9",
    "id": 242069249,
    "number": 9,
    "title": "test",
    "user": {
      "login": "kyanny",
      "id": 10515,
      "avatar_url": "https://avatars0.githubusercontent.com/u/10515?v=3",
      "gravatar_id": "",
      "url": "https://api.github.com/users/kyanny",
      "html_url": "https://github.com/kyanny",
      "followers_url": "https://api.github.com/users/kyanny/followers",
      "following_url": "https://api.github.com/users/kyanny/following{/other_user}",
      "gists_url": "https://api.github.com/users/kyanny/gists{/gist_id}",
      "starred_url": "https://api.github.com/users/kyanny/starred{/owner}{/repo}",
      "subscriptions_url": "https://api.github.com/users/kyanny/subscriptions",
      "organizations_url": "https://api.github.com/users/kyanny/orgs",
      "repos_url": "https://api.github.com/users/kyanny/repos",
      "events_url": "https://api.github.com/users/kyanny/events{/privacy}",
      "received_events_url": "https://api.github.com/users/kyanny/received_events",
      "type": "User",
      "site_admin": false
    },
    "labels": [
      {
        "id": 12613657,
        "url": "https://api.github.com/repos/kyanny/test/labels/bug",
        "name": "bug",
        "color": "fc2929",
        "default": true
      },
      {
        "id": 12613658,
        "url": "https://api.github.com/repos/kyanny/test/labels/duplicate",
        "name": "duplicate",
        "color": "cccccc",
        "default": true
      }
    ],
    "state": "open",
    "locked": false,
    "assignee": null,
    "assignees": [

    ],
    "milestone": null,
    "comments": 0,
    "created_at": "2017-07-11T14:31:36Z",
    "updated_at": "2017-07-11T14:31:36Z",
    "closed_at": null,
    "body": ""
  },
  "label": {
    "id": 12613657,
    "url": "https://api.github.com/repos/kyanny/test/labels/bug",
    "name": "bug",
    "color": "fc2929",
    "default": true
  },
  "repository": {
    "id": 5584868,
    "name": "test",
    "full_name": "kyanny/test",
    "owner": {
      "login": "kyanny",
      "id": 10515,
      "avatar_url": "https://avatars0.githubusercontent.com/u/10515?v=3",
      "gravatar_id": "",
      "url": "https://api.github.com/users/kyanny",
      "html_url": "https://github.com/kyanny",
      "followers_url": "https://api.github.com/users/kyanny/followers",
      "following_url": "https://api.github.com/users/kyanny/following{/other_user}",
      "gists_url": "https://api.github.com/users/kyanny/gists{/gist_id}",
      "starred_url": "https://api.github.com/users/kyanny/starred{/owner}{/repo}",
      "subscriptions_url": "https://api.github.com/users/kyanny/subscriptions",
      "organizations_url": "https://api.github.com/users/kyanny/orgs",
      "repos_url": "https://api.github.com/users/kyanny/repos",
      "events_url": "https://api.github.com/users/kyanny/events{/privacy}",
      "received_events_url": "https://api.github.com/users/kyanny/received_events",
      "type": "User",
      "site_admin": false
    },
    "private": false,
    "html_url": "https://github.com/kyanny/test",
    "description": null,
    "fork": false,
    "url": "https://api.github.com/repos/kyanny/test",
    "forks_url": "https://api.github.com/repos/kyanny/test/forks",
    "keys_url": "https://api.github.com/repos/kyanny/test/keys{/key_id}",
    "collaborators_url": "https://api.github.com/repos/kyanny/test/collaborators{/collaborator}",
    "teams_url": "https://api.github.com/repos/kyanny/test/teams",
    "hooks_url": "https://api.github.com/repos/kyanny/test/hooks",
    "issue_events_url": "https://api.github.com/repos/kyanny/test/issues/events{/number}",
    "events_url": "https://api.github.com/repos/kyanny/test/events",
    "assignees_url": "https://api.github.com/repos/kyanny/test/assignees{/user}",
    "branches_url": "https://api.github.com/repos/kyanny/test/branches{/branch}",
    "tags_url": "https://api.github.com/repos/kyanny/test/tags",
    "blobs_url": "https://api.github.com/repos/kyanny/test/git/blobs{/sha}",
    "git_tags_url": "https://api.github.com/repos/kyanny/test/git/tags{/sha}",
    "git_refs_url": "https://api.github.com/repos/kyanny/test/git/refs{/sha}",
    "trees_url": "https://api.github.com/repos/kyanny/test/git/trees{/sha}",
    "statuses_url": "https://api.github.com/repos/kyanny/test/statuses/{sha}",
    "languages_url": "https://api.github.com/repos/kyanny/test/languages",
    "stargazers_url": "https://api.github.com/repos/kyanny/test/stargazers",
    "contributors_url": "https://api.github.com/repos/kyanny/test/contributors",
    "subscribers_url": "https://api.github.com/repos/kyanny/test/subscribers",
    "subscription_url": "https://api.github.com/repos/kyanny/test/subscription",
    "commits_url": "https://api.github.com/repos/kyanny/test/commits{/sha}",
    "git_commits_url": "https://api.github.com/repos/kyanny/test/git/commits{/sha}",
    "comments_url": "https://api.github.com/repos/kyanny/test/comments{/number}",
    "issue_comment_url": "https://api.github.com/repos/kyanny/test/issues/comments{/number}",
    "contents_url": "https://api.github.com/repos/kyanny/test/contents/{+path}",
    "compare_url": "https://api.github.com/repos/kyanny/test/compare/{base}...{head}",
    "merges_url": "https://api.github.com/repos/kyanny/test/merges",
    "archive_url": "https://api.github.com/repos/kyanny/test/{archive_format}{/ref}",
    "downloads_url": "https://api.github.com/repos/kyanny/test/downloads",
    "issues_url": "https://api.github.com/repos/kyanny/test/issues{/number}",
    "pulls_url": "https://api.github.com/repos/kyanny/test/pulls{/number}",
    "milestones_url": "https://api.github.com/repos/kyanny/test/milestones{/number}",
    "notifications_url": "https://api.github.com/repos/kyanny/test/notifications{?since,all,participating}",
    "labels_url": "https://api.github.com/repos/kyanny/test/labels{/name}",
    "releases_url": "https://api.github.com/repos/kyanny/test/releases{/id}",
    "deployments_url": "https://api.github.com/repos/kyanny/test/deployments",
    "created_at": "2012-08-28T11:26:35Z",
    "updated_at": "2017-06-17T17:34:36Z",
    "pushed_at": "2017-06-17T17:34:35Z",
    "git_url": "git://github.com/kyanny/test.git",
    "ssh_url": "git@github.com:kyanny/test.git",
    "clone_url": "https://github.com/kyanny/test.git",
    "svn_url": "https://github.com/kyanny/test",
    "homepage": null,
    "size": 6,
    "stargazers_count": 0,
    "watchers_count": 0,
    "language": "Ruby",
    "has_issues": true,
    "has_projects": true,
    "has_downloads": true,
    "has_wiki": true,
    "has_pages": true,
    "forks_count": 0,
    "mirror_url": null,
    "open_issues_count": 3,
    "forks": 0,
    "open_issues": 3,
    "watchers": 0,
    "default_branch": "master"
  },
  "sender": {
    "login": "kyanny",
    "id": 10515,
    "avatar_url": "https://avatars0.githubusercontent.com/u/10515?v=3",
    "gravatar_id": "",
    "url": "https://api.github.com/users/kyanny",
    "html_url": "https://github.com/kyanny",
    "followers_url": "https://api.github.com/users/kyanny/followers",
    "following_url": "https://api.github.com/users/kyanny/following{/other_user}",
    "gists_url": "https://api.github.com/users/kyanny/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/kyanny/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/kyanny/subscriptions",
    "organizations_url": "https://api.github.com/users/kyanny/orgs",
    "repos_url": "https://api.github.com/users/kyanny/repos",
    "events_url": "https://api.github.com/users/kyanny/events{/privacy}",
    "received_events_url": "https://api.github.com/users/kyanny/received_events",
    "type": "User",
    "site_admin": false
  }
}

UWP Hosted Web Apps

いわゆるガワネイティブアプリも Windows App Studio で作れるので、生きてるうちに試してみた。

https://kyanny.github.io/uwp-hosted-web-app/

Windows 10 Mobile 実機からアクセスするとボタンが押せて、押すと通知が飛ぶ。テキストエディタと JavaScript と GitHub Pages でネイティブな機能を呼び出せるのはやっぱり面白い。他のプラットフォームでも同様の(もっと良い)技術はたくさんあるだろうけど。

f:id:a666666:20170710024426p:plain

github.com

↓のサイトからリンクされてる Codepen のサンプルコードそのまま。 manifest.json は無くても動いた。

docs.microsoft.com

https://codepen.io/seksenov/pen/wBbVyb?editors=101

他、参考にしたページ

browser.hatenablog.com

browser.hatenablog.com

github.com