This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//map: | |
function(doc) { | |
if(doc.type == "document") { | |
emit(doc._id, doc); | |
} | |
else if(doc.type == "version") { | |
emit(doc.document_id, 1); | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Define a method for the following: | |
print_these_strings do | |
"hello" | |
"goodbye" | |
end | |
# ... which returns "hello and goodbye" | |
# bonus points: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
get = function(callback) { | |
print("WRONG") | |
callback() | |
} | |
var resource = function(name, callback) { | |
var get = function(callback) { | |
print("CORRECT") | |
callback() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fab = require( "fab" ); | |
module.exports = fab | |
( /^\/(css|scripts|pics)\/.+$/ ) | |
(fab.nodejs.fs, "public/css/master.css") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~ $ 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function echo (str) { | |
return str | |
} | |
echo("Hello") | |
(function() { | |
echo("Goodbye") | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
OlderNewer