Skip to content

Instantly share code, notes, and snippets.

//map:
function(doc) {
if(doc.type == "document") {
emit(doc._id, doc);
}
else if(doc.type == "version") {
emit(doc.document_id, 1);
}
}
# Define a method for the following:
print_these_strings do
"hello"
"goodbye"
end
# ... which returns "hello and goodbye"
# bonus points:
get = function(callback) {
print("WRONG")
callback()
}
var resource = function(name, callback) {
var get = function(callback) {
print("CORRECT")
callback()
}
fab = require( "fab" );
module.exports = fab
( /^\/(css|scripts|pics)\/.+$/ )
(fab.nodejs.fs, "public/css/master.css")
~ $ brew install -v nspr [23:17]{private}
==> Build Environment
CC: /usr/bin/cc => /usr/bin/gcc-4.0
CXX: /usr/bin/c++ => /usr/bin/c++-4.0
LD: /usr/bin/cc => /usr/bin/gcc-4.0
CFLAGS: -O3 -march=nocona -mfpmath=sse -w -pipe
CXXFLAGS: -O3 -march=nocona -mfpmath=sse -w -pipe
MAKEFLAGS: -j2
==> Downloading http://ftp.mozilla.org/pub/mozilla.org/nspr/releases/v4.8.4/src/nspr-4.8.4.tar.gz
File already downloaded and cached to /Users/agroves/Library/Caches/Homebrew
@addywaddy
addywaddy / semi-colons.js
Created October 28, 2010 07:41
Sometimes semi-colons are indeed necessary in Javascript
function echo (str) {
return str
}
echo("Hello")
(function() {
echo("Goodbye")
})
# list all changed spec files
alias d_specs='git diff --name-only | grep _spec.rb|sed -E "s/(.*)/\.\/\1/"'
# list all changed *.rb filenames without path and extension
alias diffrb='git diff --name-only|xargs basename -s .rb'
# diffrb.map { |s| "#{s}_spec"}.join('|')
alias any_diffrb="diffrb | tr '\n' '|'|sed -E \"s/^(.*).$/\1_spec/\""
# list all spec files that correspond to changed *.rb files (assuming they share the same prefix)
alias d_specs_more='find ./spec -name *_spec.rb|grep -E "(`any_diffrb`)"'
# find a spec by path-less name
function find_spec() {
@addywaddy
addywaddy / policy
Created March 9, 2012 12:29
Installing Varnish on Lenny
Would like to install a newer version of Varnish than but
apt-get install varnish
always installs the 1.1.2 version. Any ideas?
`apt-cache` show's that 3.0.2 is available:
staging:~# apt-cache show varnish
@addywaddy
addywaddy / gist:2049843
Created March 16, 2012 12:18
'using' - an alternative to the 'with' statement
function using (obj) {
var _keys = Object.keys || function(obj) {
if (obj !== Object(obj)) {
throw new TypeError('Invalid object');
}
var keys = [];
for (var key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)(obj, key)) {
keys[keys.length] = key;
@addywaddy
addywaddy / regexp_hash.rb
Created May 22, 2012 07:55
RegexpHash: Hash subclass for building nested regular expressions
class RegexpHash < Hash
def add_word(word, hsh = nil)
hsh ||= self
return unless (word && word.length > 0)
key = word.slice(0..0)
hsh[key] ||= {}
add_word(word.slice(1..-1), hsh[key])
end