Skip to content

Instantly share code, notes, and snippets.

@probablycorey
Forked from pjhyett/colors.rb
Created April 18, 2011 18:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save probablycorey/925933 to your computer and use it in GitHub Desktop.
Save probablycorey/925933 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
lines = `git log -n 400 --format=oneline`.split("\n")
lines.map! do |line|
sha, *msg = line.split
msg = msg.join(' ') # unused
colors = sha.scan(/[a-z0-9]{8}/)
stops = colors.map do |color|
rgba = color.scan(/[a-z0-9]{2}/).map {|o| o.to_i(16)}
"rgba(#{rgba.join ','})"
end
style = "background-image: -webkit-linear-gradient(180deg, #{stops.join(',')})"
%{<div class="box" style="#{style}"></div>}
end
File.open('colors.html', 'w') do |f|
f.puts <<-HTML
<style>
body { margin:0; padding:0; }
.box { width:100%; height:5px}
</style>
#{lines}
HTML
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment