Skip to content

Instantly share code, notes, and snippets.

View agius's full-sized avatar
🐐
goat rodeo

Andrew Evans agius

🐐
goat rodeo
View GitHub Profile
@agius
agius / gist:1468681
Created December 12, 2011 19:26 — forked from danielgwood/gist:1244903
MongoDB shell cheatsheet
// A bunch of functions you can use in the MongoDB shell
// taken from http://api.mongodb.org/js/1.8.2/index.html
// amongst other sources
// Used in place of print() to view the contents of objects
printjson(x);
printjsononeline(x);
// File system interaction
ls(...);
@agius
agius / hash_extension.rb
Created October 6, 2011 00:17
Useful methods for ruby hashes
class Hash
# gets hash-nested values, returns nil if any key is missing
def dig(*path)
path.inject(self) do |location, key|
location.respond_to?(:keys) ? location[key] : nil
end
end
# Deletes key from self and returns self
def kill(key)
^([^:]+:\/\/)([^@]+\@)?([^:\/]+)(:\d+)?(\/[^\s\?\#]+)+(\?([^\n\#]+)(\#\S+)?|(\#\S+))?$