ピタゴラスイッチの人気コーナー「めかぬか」をHTMLで作ってみた。
- 書き順つき SVG として KanjiVG というプロジェクトがあった。これのおかげで実現できてる。
- SVGのパスをアニメーションで描く方法はなんか有名なのがあるらしい: How SVG Line Animation Works | CSS-Tricks。
- CSS を JavaScript で生成するのは JSS でやった。
@keyframe
も動的に生成できて便利。
目下新マシンの開発環境をセットアップ中なんだけど、clone しないといけないリポジトリがけっこうたくさんある。このリポジトリ群っていうのが git submodule によってモジュールを共有していて、つまり同じリポジトリを何度も fetch してくることになる。これって無駄じゃないですか?
というわけで submodule update 時にキャッシュを生成し、それを利用して以降の同コマンドを高速化するコマンドを書きました。
https://github.com/motemen/git-shared-submodule-update
git submodule update
の代わりに使います。
# git submodule update --init の代わりに… git shared-submodule-update --init
簡単ですね。
git submodule update
の中で呼ばれる git clone
には --reference <repository>
というオプションがあって、これを指定すると git の持つデータの実体である object をローカルのリポジトリから借用することができます。つまり、リモートとの通信量をそのぶん減らせるわけですね。イメージ的には git 界におけるシンボリックリンクを張っているような状態です。なので借用先のリポジトリが消えたり git gc によって縮退したりすると借用元のリポジトリはぶっ壊れるわけですが、ここでさらに --dissociate
というオプションを与えると、clone 後にシンボリックリンクを解消して実データを新しいリポジトリにコピーし、参照を切り離すことができます。
以上はちょっと細かい話でしたが、この仕組みを利用するために、clone 前にキャッシュ的なリポジトリを作っているだけです。実は5年くらい前に似ようなことをするやつを書いてたんだけど、ちょっと大げさすぎたので、そこから submodule 部分だけ切り出したかたちです。
以下は参考文献。
Google Apps Script でメールの自動アーカイブの続編です。
https://github.com/motemen/gas-gmail-scripts/blob/master/dist/label-github-issue-status.js
GitHub のリポジトリにやってくるイシューや Pull Request って、対応する心的コストがばかにならないので放置しがちなんだけど、すでにクローズとかマージされたものに関しては気楽に流し読みしていいはず。そういうシグナルで自分を解き放っていきます。
Gmail 本体のフィルタルールでもできそうなものだけど、"Closed" を含む〜みたいなルールだとわりと誤爆するので、GAS で書く。
こんな感じにラベルがつけられて、便利ですね。
メールの本文を見て処理を行うだけなら簡単なんだけど、"Closed #42." みたいなのを勝手に書いた場合と区別がつかないので、(現実的にはないことだろうとはいえ)ちょっと気持ち悪い。というか、メタデータ的なものがあってしかるべきって感もある。
そこで GitHub から届いたメールを見てみると、どうもメタデータらしきものが text/html パートに埋め込まれている様子……。
<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"********************************","name":"GitHub"},"entity":{"external_key":"github/motemen/test-repository","title":"motemen/test-repository","subtitle":"GitHub repository","main_image_url":"https://github.githubassets.com/images/email/message_cards/header.png","avatar_image_url":"https://github.githubassets.com/images/email/message_cards/avatar.png","action":{"name":"Open in GitHub","url":"https://github.com/motemen/test-repository"}},"updates":{"snippets":[{"icon":"DESCRIPTION","message":"Closed #34."}],"action":{"name":"View Issue","url":"https://github.com/motemen/test-repository/issues/34#event-2043751833"}}}</script>
{ "api_version": "1.0", "publisher": { "api_key": "********************************", "name": "GitHub" }, "entity": { "external_key": "github/motemen/test-repository", "title": "motemen/test-repository", "subtitle": "GitHub repository", "main_image_url": "https://github.githubassets.com/images/email/message_cards/header.png", "avatar_image_url": "https://github.githubassets.com/images/email/message_cards/avatar.png", "action": { "name": "Open in GitHub", "url": "https://github.com/motemen/test-repository" } }, "updates": { "snippets": [ { "icon": "DESCRIPTION", "message": "Closed #34." } ], "action": { "name": "View Issue", "url": "https://github.com/motemen/test-repository/issues/34#event-2043751833" } } }
(api_key
は公開のものっぽいけど、読んでる側がビビるのでマスクしてます)
ちなみに、イシューのクローズじゃなく勝手なコメントをつけた場合は以下のようになる。
<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"********************************","name":"GitHub"},"entity":{"external_key":"github/motemen/test-repository","title":"motemen/test-repository","subtitle":"GitHub repository","main_image_url":"https://github.githubassets.com/images/email/message_cards/header.png","avatar_image_url":"https://github.githubassets.com/images/email/message_cards/avatar.png","action":{"name":"Open in GitHub","url":"https://github.com/motemen/test-repository"}},"updates":{"snippets":[{"icon":"PERSON","message":"@motemen in #34: Closed #34."}],"action":{"name":"View Issue","url":"https://github.com/motemen/test-repository/issues/34#issuecomment-449838417"}}}</script>
{ "api_version": "1.0", "publisher": { "api_key": "********************************", "name": "GitHub" }, "entity": { "external_key": "github/motemen/test-repository", "title": "motemen/test-repository", "subtitle": "GitHub repository", "main_image_url": "https://github.githubassets.com/images/email/message_cards/header.png", "avatar_image_url": "https://github.githubassets.com/images/email/message_cards/avatar.png", "action": { "name": "Open in GitHub", "url": "https://github.com/motemen/test-repository" } }, "updates": { "snippets": [ { "icon": "PERSON", "message": "@motemen in #34: Closed #34." } ], "action": { "name": "View Issue", "url": "https://github.com/motemen/test-repository/issues/34#issuecomment-449838417" } } }
diff はこんな感じ。
"updates": { "snippets": [ { - "icon": "DESCRIPTION", - "message": "Closed #34." + "icon": "PERSON", + "message": "@motemen in #34: Closed #34." } ], "action": { "name": "View Issue", - "url": "https://github.com/motemen/test-repository/issues/34#event-2043751833" + "url": "https://github.com/motemen/test-repository/issues/34#issuecomment-449838417" } } }
これがまあまあ使えそうですね。名前てきには Inbox by Gmail のためのマークアップなんではないかと予想するけど、特に公式なドキュメントはないので、いつまで使えるのかは神のみぞ知るです。