Who among us hasn't wanted to play the Towers of Hanoi on the Github commit-history graph?
I made some changes to my Hanoi Jane gem:
- I added a new formatter which renders the output to a 52*7 grid, suitable for the Github graph
- I enabled serialisation and deserialisation so it can be run as a cronjob or similar
I then built Gitpaint, which allows you paint whatever 52*7, 5-grayscale data you want onto the Github graph
And then I brought it all together with this, orchestrated by Rake. The default Rake task will:
Deserialise the saved Towers
Or spawn a new set if a save-file can't be found
Render the output to Github
Which means:
- Deleting the existing repo from Github
- Making a new local repo
- Making the correct commits to draw the pixels (using the Github-formatted output from Hanoi Jane)
- Making a new Github repo
- Pushing the local repo to Github
Sleep for 10 seconds
To allow Github time to refresh
Take a screenshot
There's some heavily cargo-culted Node which takes the screenshots using Chromium
Broadcast the screenshot
To Mastodon, using the Ternary values from Hanoi Jane as the text
Move and serialise the towers
Ready for the next run
Configuration
This all requires quite a lot of configuration, as you might expect, which
          should go in config/config.yaml:
Gitpaint
Needs:
- A Github usernameandemail, so the commits will be credited and counted correctly (I'm doing this on a separate, dedicated Github account)
- The name of a (disposable) repoto work with: this will be created locally at/tmp/#{repo}and remotely athttps://github.com/#{github_user}/#{repo}(and it will be mercilessly deleted from both places between runs)
- A Github personal access
              token that has the repoprivileges and, crucially, the separatedelete repoprivilege
- The path to an ssh_keythat can commit to the#{github_user}account
- A scale_factor, by which each commit count will be multiplied
- A project_urlwhich will be added to the social media transmissions
Hanoi Jane
Needs:
- A save_path, for saving and loading the towers between runs
- A discsvalue (between 2 and 7)
Mastodon
Needs:
- A token
- The base_urlof your Mastodon instance
- Your account_id(which you can get by clicking on your@namefrom some places in the Mastodon UI)
(copy config/config-example.yaml to
          config/config.yaml and fill in as required)
Timescale
It takes 2187 moves to solve the 7-disc Towers of Hanoi (3**7). I've currently got this running 4 times a day, which means it will take ~546 days to finish