Skip to content

Instantly share code, notes, and snippets.

# Getting a list of unique values and their counts in Ruby
languages = ["Ruby", "PHP", "Ruby", "Ruby", "Shell", "PHP", "Ruby", nil, "VimL", "Ruby", "Ruby", "PowerShell", "JavaScript", nil, nil, "PowerShell", "CSS", nil, nil, "Ruby", "PowerShell", "Ruby", "VimL"]
########## The ugly way ##########
hash = Hash.new(0)
languages.each do |language|
hash[language] += 1
end
counts = hash
@antichris
antichris / about.md
Created October 21, 2013 14:55
Fork your own Gist

Fork your own Gist

This is a bookmarklet that adds a fully functional Fork button to your own Gist.

If a Fork button is already present in the page, this bookmarklet will set focus to it instead of adding another one.

The change is temporary and the button will disappear as soon as you navigate away from that Gist (clicking the Fork button does this for you as well).