Skip to content

Instantly share code, notes, and snippets.

@huydx
Last active January 3, 2016 08:49
Show Gist options
  • Save huydx/8438905 to your computer and use it in GitHub Desktop.
Save huydx/8438905 to your computer and use it in GitHub Desktop.
ascii.rb
require 'date'
require 'rugged'
data = File.read('./source.txt').split("\n")
dist = data[0].size.times.map {|i| data.map {|n| n[i] } }.flatten
date = Date.today - 366
date += 1 until date.wday.zero?
Dir.chdir('./dist') do
repo = Rugged::Repository.init_at('.')
dist.each do |char|
date += 1
next if char == ' '
index = Rugged::Index.new
options = {}
options[:author] = { email: "[email protected]", name: '[email protected]', time: date.to_time }
options[:committer] = { email: "[email protected]", name: '[email protected]', time: date.to_time }
options[:message] = '[email protected]'
options[:update_ref] = 'HEAD'
70.times do
options[:parents] = repo.empty? ? [] : [ repo.head.target ].compact
options[:tree] = index.write_tree(repo)
Rugged::Commit.create(repo, options)
end
end
end
====================== source.txt:
# # # # # #
# # # # # #
# # # # # #
######## # # ##
# # # # #
# # # # #
# # ####### #
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment