Skip to content

Instantly share code, notes, and snippets.

View brentdodell's full-sized avatar

Brent Odell brentdodell

View GitHub Profile
@brentdodell
brentdodell / Hash.rb
Last active December 23, 2018 17:22
Hash extensions
class Hash
def sample(n = 1)
Hash[to_a.sample(n)]
end
def deep_flatten
flat_map { |k, v| [k, *(v.respond_to?(:deep_flatten) ? v.deep_flatten : v)] }
end
def flat_join_keys(prefix: nil, separator: '-', memo: {})
@brentdodell
brentdodell / 0_reuse_code.js
Created March 10, 2016 19:56
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console