Skip to content

Instantly share code, notes, and snippets.

@athaeryn
Created May 29, 2014 16:47
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 athaeryn/b73fe77f7788819db545 to your computer and use it in GitHub Desktop.
Save athaeryn/b73fe77f7788819db545 to your computer and use it in GitHub Desktop.
Ruby String -> hex color
require "digest/sha2"
class String
def to_hex_color
"\##{(::Digest::SHA2.new << self).to_s[0...6]}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment