LoginSignup
13
10

More than 1 year has passed since last update.

Gitfitiで芝生アート

Last updated at Posted at 2021-04-02

草を生やす とはご存知、GitHubに毎日何かしらコントリビュートしてグラフに色を付けていこうという話。GitHub 芝生入門/芝生応用 では草を生やすことそのものを遊ぶGitfityというプログラムが紹介されている。ということでそれをやってみたという小話。
image.png

Gitfiti

  1. Create a new github repo to store your handiwork.
  1. Run gitfiti.py and follow the prompts for username, art selection, offset, and repo name.

  2. Run the generated gitfiti.sh or gitfiti.ps1 from your home directory (or any non-git tracked dir) and watch it go to work.

  3. 作成した作品を保存するために、新しいgithub repoを作成します。

  4. gitfiti.py を実行し、ユーザ名、アートの選択、オフセット、リポジトリ名を入力するプロンプトに従います。

  5. 生成された gitfiti.sh または gitfiti.ps1 をホームディレクトリ (または git 以外のディレクトリ) で実行し、作業が始まるのを確認します。

という手順。

手順詳細

まずリポジトリ準備: https://github.com/e99h2121/shibafu-art

対話式でこたえていく。

  • Enter GitHub URL (leave blank to use https://github.com/):
    • GitHubのURL。そのままで良い。
  • Enter your GitHub username:
    • GitHubのUsername。私の場合: e99h2121
  • Enter the name of the repository to use by gitfiti:
    • 用意したリポジトリ名。私の場合: shibafu-art
  • Enter the number of weeks to offset the image (from the left):
    • グラフの左端から数えて何列目から絵を書きたいか。私の場合: 2
  • By default gitfiti.py matches the darkest pixel to the highest number of commits found in your GitHub commit/activity calendar, Currently this is: 22 commits Enter the word "gitfiti" to exceed your max(this option generates WAY more commits) Any other input will cause the default matching behavior
    • Gitfity.py は最大コミット数(最も濃い色)を見て色の調整をかけてくれる。その最大を越えさせるか。私の場合: まあ越えなくしたいのでそのままにした。
  • Enter file(s) to load images from (blank if not applicable)
    • オリジナルな絵を読み込みたい場合。一旦つかわない。
  • Enter the image name to gitfiti Images: kitty, oneup, oneup2, hackerschool, octocat, octocat2, hello, heart1, heart2, hireme, oneup_str, beer, gliders, heart, heart_shiny
    • 用意されているアートの名前。私の場合: kitty
  • Enter the target shell (bash or powershell):
    • bash

全体は以下。

root@d545fa0ed72b:~/opt# python gitfity.py

          _ __  _____ __  _
   ____ _(_) /_/ __(_) /_(_)
  / __ `/ / __/ /_/ / __/ /
 / /_/ / / /_/ __/ / /_/ /
 \__, /_/\__/_/ /_/\__/_/
/____/

Enter GitHub URL (leave blank to use https://github.com/):
Enter your GitHub username: e99h2121
Enter the name of the repository to use by gitfiti: shibafu-art
Enter the number of weeks to offset the image (from the left): 2
By default gitfiti.py matches the darkest pixel to the highest
number of commits found in your GitHub commit/activity calendar,

Currently this is: 22 commits

Enter the word "gitfiti" to exceed your max
(this option generates WAY more commits)
Any other input will cause the default matching behavior
>
Enter file(s) to load images from (blank if not applicable)
>
Enter the image name to gitfiti
Images: kitty, oneup, oneup2, hackerschool, octocat, octocat2, hello, heart1, heart2, hireme, oneup_str, beer, gliders, heart, heart_shiny
> kitty
Enter the target shell (bash or powershell): bash
gitfiti.sh saved.
Create a new(!) repo named shibafu-art at https://github.com/ and run the script

これで gitfiti.sh が完成したので中身を見てみます。

Gitへのcommitスクリプトができた

#!/usr/bin/env bash
REPO=shibafu-art
git init $REPO
cd $REPO
touch README.md
git add README.md
touch gitfiti
git add gitfiti

GIT_AUTHOR_DATE=2020-08-03T12:00:00 GIT_COMMITTER_DATE=2020-08-03T12:00:00 git commit --allow-empty -m "gitfiti" > /dev/null
GIT_AUTHOR_DATE=2020-08-03T12:00:00 GIT_COMMITTER_DATE=2020-08-03T12:00:00 git commit --allow-empty -m "gitfiti" > /dev/null

## (中略) 

GIT_AUTHOR_DATE=2020-10-01T12:00:00 GIT_COMMITTER_DATE=2020-10-01T12:00:00 git commit --allow-empty -m "gitfiti" > /dev/null
GIT_AUTHOR_DATE=2020-10-01T12:00:00 GIT_COMMITTER_DATE=2020-10-01T12:00:00 git commit --allow-empty -m "gitfiti" > /dev/null
GIT_AUTHOR_DATE=2020-10-01T12:00:00 GIT_COMMITTER_DATE=2020-10-01T12:00:00 git commit --allow-empty -m "gitfiti" > /dev/null
GIT_AUTHOR_DATE=2020-10-01T12:00:00 GIT_COMMITTER_DATE=2020-10-01T12:00:00 git commit --allow-empty -m "gitfiti" > /dev/null
GIT_AUTHOR_DATE=2020-10-01T12:00:00 GIT_COMMITTER_DATE=2020-10-01T12:00:00 git commit --allow-empty -m "gitfiti" > /dev/null
GIT_AUTHOR_DATE=2020-10-01T12:00:00 GIT_COMMITTER_DATE=2020-10-01T12:00:00 git commit --allow-empty -m "gitfiti" > /dev/null
GIT_AUTHOR_DATE=2020-10-01T12:00:00 GIT_COMMITTER_DATE=2020-10-01T12:00:00 git commit --allow-empty -m "gitfiti" > /dev/null
GIT_AUTHOR_DATE=2020-10-01T12:00:00 GIT_COMMITTER_DATE=2020-10-01T12:00:00 git commit --allow-empty -m "gitfiti" > /dev/null
GIT_AUTHOR_DATE=2020-10-01T12:00:00 GIT_COMMITTER_DATE=2020-10-01T12:00:00 git commit --allow-empty -m "gitfiti" > /dev/null
GIT_AUTHOR_DATE=2020-10-01T12:00:00 GIT_COMMITTER_DATE=2020-10-01T12:00:00 git commit --allow-empty -m "gitfiti" > /dev/null

git branch -M main
git remote add origin git@github.com:e99h2121/$REPO.git
git pull origin main
git push -u origin main

これを実行すればできあがり。

私の完成形

image.png
shibafu-art リポジトリを消せば、元通りになる。

余談

作れる絵の中には HIREME というのもありますね。

gitfity.py
HIREME = [
  [1,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  [2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
  [3,3,3,0,2,0,3,3,3,0,2,3,3,0,0,3,3,0,3,0,0,2,3,3],
  [4,0,4,0,4,0,4,0,0,0,4,0,4,0,0,4,0,4,0,4,0,4,0,4],
  [3,0,3,0,3,0,3,0,0,0,3,3,3,0,0,3,0,3,0,3,0,3,3,3],
  [2,0,2,0,2,0,2,0,0,0,2,0,0,0,0,2,0,2,0,2,0,2,0,0],
  [1,0,1,0,1,0,1,0,0,0,1,1,1,0,0,1,0,1,0,1,0,1,1,1],
]

でも話題になっていたが

It's cool, but I'd be quicker to hire the person who wrote the tool to generate that history

といわれている。笑。

その他

See the Pen Gitfiti Painter by Sebastiaan Deckers (@sebdeckers) on CodePen.

- その他色々

芝生、愛されているようです。
芝生応用 で書かれている通り、Gitfity.py はソースコードリーディングによさそう。
以上お楽しみいただければさいわいです。

追記: GitHubプロフィールをカッコ良くする方法

13
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
10