Vanilla:
sp, ^W s, ^W S, ^W ^S
it "should know one another" do | |
# Code in the cdb block is executed if and only if it hasn't already been run. | |
cdb do | |
p1, p2 = Player.stock(:name => "p1"), Player.stock(:name => "p2") | |
p1.acquaint p2 | |
end | |
p1.should know(p2) # p1 and p2 are methods that load players by names p1 and p2 | |
p2.should know(p1) | |
end |
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'relaxdb' | |
require 'Ruby2Ruby' | |
require 'spec/spec_models' | |
c = Module.const_get ARGV[0] | |
s = RubyToRuby.translate c | |
puts s |
#!/bin/bash | |
# Use the HOST_ENV variable to set the prompt color so the environment | |
# is obvious at the prompt | |
# Add it to .bashrc and optionally /etc/skel/.bashrc | |
function setprompt { | |
# Format is ESC[Value;...;Valuem |
// Example 1 | |
function (clientCallback) { | |
redis.set('foo1', 'bar1'); | |
redis.set('foo2', 'bar2', clientCallback); | |
} | |
// Example 2 | |
function (clientCallback) { | |
redis.set('foo1', 'bar1', function () { | |
redis.set('foo2', 'bar2', clientCallback); |
#!/usr/bin/env ruby | |
STD_IMG_REF = '/Users/paulcarey/.std_desktop_image.txt' | |
IMG_SRC = '/Users/paulcarey/dev/images/ir_black_bg.png' | |
def current_img | |
cmd = "defaults read com.apple.Desktop Background | grep ImageFilePath | tail -n 2 | head -n 1" | |
res = `#{cmd}` | |
res = res.split('=')[1].strip | |
res[1, res.size - 3] |
data Tree a = Empty | Branch a (Tree a) (Tree a) deriving (Show, Eq) | |
breadthFirst :: (a -> b) -> Tree a -> [b] | |
breadthFirst f Empty = [] | |
breadthFirst f t = breadthFirst' f ([], [t]) | |
breadthFirst' :: (a -> b) -> ([b], [Tree a]) -> [b] | |
breadthFirst' f (bs, []) = bs | |
breadthFirst' f (bs, as) = bs ++ breadthFirst' f (bsForAs, nextAs) | |
where (bsForAs, nextAs) = breadthFirst'' f as |
#!/bin/bash | |
# | |
# This script serves as a useful base for generating a list of ignore-dirs | |
# for ack. | |
# It's slow to run (e.g. 30 sec on a 3000 file project on a 2010 MBA) | |
# and emits no output until complete. | |
# | |
# create the list of dirs tracked by git |
javascript:(function%20()%20{%20var%20$%20=%20document.createElement('script');%20$.src%20=%20'http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js';%20$.type%20=%20'text/javascript';%20document.getElementsByTagName('head')[0].appendChild($);%20var%20_%20=%20document.createElement('script');%20_.src%20=%20'http://documentcloud.github.com/underscore/underscore-min.js';%20_.type%20=%20'text/javascript';%20document.getElementsByTagName('head')[0].appendChild(_);%20})() |
require 'restclient' | |
# Create the list from the course page by running the following JavaScript | |
# snippet, and copying and paste the results in here. I _think_ the Content-Type | |
# of the pdfs prevents them from being downloaded directly in JavaScript. | |
# $('.course-lectures-list ul:eq(2) a[href$="pdf"]').map(function () { return $(this).attr('href') }) | |
urls = ["https://d19vezwu8eufl6.cloudfront.net/compdata/slides%2Flecture3.pdf", | |
"https://d19vezwu8eufl6.cloudfront.net/compdata/slides%2Ffunctions.pdf", |