Skip to content

Instantly share code, notes, and snippets.

Jim Weirich:

This is how I explain it… Ruby has Procs and Lambdas. Procs are created with Proc.new { }, lambdas are created with lambda {} and ->() {}.

In Ruby 1.8, proc {} creates lambda, and Ruby 1.9 it creates procs (don't ask).

Lambdas use method semantics when handling parameters, procs use assignment semantics when handling parameters.

This means lambdas, like methods, will raise an ArgumentError when called with fewer arguments than they were defined with. Procs will simply assign nil to variables for arguments that were not passed in.

@rafacv
rafacv / apt-init.pp
Created December 24, 2012 13:53 — forked from fnando/apt-init.pp
class apt-get::update {
exec { "apt-get update":
command => "apt-get update"
}
}
@rafacv
rafacv / skype-search
Created October 18, 2012 01:54 — forked from leandro/skype-search
Search Skype history for given terms
@rafacv
rafacv / bf-ansic.c
Created September 27, 2010 13:29 — forked from lifthrasiir/bf.c
s[999],*r=s,*d,c;main(a,b){char*v=1[d=b];for(;c=*v++%93;)for(b=c%7?a&&(c&17?c&1?
(*r-=c-44):(r+=c-61):c&2?putchar(*r):(*r=getchar()),0):v;b&&c|a**r;v=d)main(!c,&
b-1);d=v;}
@rafacv
rafacv / fakecassandra.py
Created April 23, 2010 19:17 — forked from mmalone/fakecassandra.py
In-memory Cassandra-ish thingy
# In-memory Cassandra-ish thingy... useful for unit tests. Maybe useful for other
# stuff too? No support for SuperColumns, but that should be easy enough to add.
import bisect
import copy
from cassandra.ttypes import NotFoundException, Column, ColumnPath, ColumnOrSuperColumn
class SSTable(object):
@rafacv
rafacv / redis_pubsub_demo.rb
Created March 30, 2010 16:43 — forked from pietern/redis_pubsub_demo.rb
Simple demo to showcase Redis PubSub with EventMachine
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
# - a browser with WebSocket support
#
# Usage:
# ruby redis_pubsub_demo.rb
#
@rafacv
rafacv / vipy.sh
Created March 3, 2010 13:20 — forked from mmalone/vipy.sh
Simple shell script that locates a Python module and opens it in vi.
#!/bin/bash
if [ $# -ne 1 ]; then
echo "Usage: vipy <python module>"
exit 1
fi
MODULE_LOCATION=`python -c "import $1; print $1.__file__.rstrip('c')"`
if [ -z $MODULE_LOCATION ]; then