Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

Last active March 19, 2022 01:17
Show Gist options
  • Star 35 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save briandoll/4612306 to your computer and use it in GitHub Desktop.
Save briandoll/4612306 to your computer and use it in GitHub Desktop.
Toasts! - scripts to convert images attached to GitHub issues into an animated gif for serious celebratory purposes

To toast:

  • Make sure you have ImageMagick installed (brew install imagemagick)
  • Change line 7 of toast.rb to the repository name you're working with
  • toast!
$ bundle install
$ ./get_token [user] [pass]
$ export GHUSER=[myuser]
$ export GHTOKEN=[token]
$ bundle exec ./toast.rb
source ""
gem "octokit"
gem "awesome_print"
gem "gifme"
# sh user pass
curl -s -d '{"scopes":["repo"],"note":"toast script"}' -u "$1:$2" -XPOST | grep token
echo 'export GHUSER=[youruser]'
echo 'export GHTOKEN=[above-token]'
#! /usr/bin/env ruby
require 'octokit'
require 'awesome_print'
require 'open-uri'
client = => ENV['GHUSER'], :oauth_token => ENV['GHTOKEN'])
repo = 'username/reponame' # change to the repository you want to gifify
Dir.mkdir('build') if !File.exists?('build')
def build_issue(client, repo, number)
comments = client.issue_comments(repo, number)
num = 0
comments.each do |comment|
if m = comment.body.match(/\!\[(.*?)\]\((.*?)\)/)
Dir.mkdir("build/#{number}") if !File.exists?("build/#{number}")
uri = m[2]
puts " getting #{uri}"
open(uri) do |f|
num += 1
ext = 'png'
ext = 'jpg' if f.content_type == 'image/jpeg'
file = "#{num}.#{ext}"
s ="build/#{number}/#{file}", "w+")
Dir.chdir("build/#{number}") do
puts " building gif"
`gifme -o toast.gif *`
file = "build/#{number}/toast.gif"
if File.exists?(file)
return file
return false
toasts = client.list_issues(repo)
toasts.each do |issue|
puts "Building ##{issue.number}: '#{issue.title}'"
build_issue(client, repo, issue.number)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment