Skip to content

Instantly share code, notes, and snippets.

@domwom
domwom / collect_iteratable.php
Created April 29, 2009 12:45
map iteratables in php
public function collect($function)
{
$result = array();
foreach ($this as $key => $value) {
array_push($result,call_user_func(array($value,$function),$value));
}
return $result;
}
@domwom
domwom / .gitconfig
Created April 6, 2009 21:37
gitconfig
[color]
diff = auto
status = auto
branch = auto
interactive = auto
ui = true
pager = true
[color "branch"]
current = yellow reverse
@domwom
domwom / gist:90676
Created April 6, 2009 08:58
Facebook-ish "people you may know" thingie
class User < ActiveRecord::Base
has_many :friends, :through => :friendships
has_many :friendships, :dependent => :destroy
def getMutualFriendsWith user
intersection = friends() & user.friends()
end
def getNumberOfMutualFriendsWith user
getMutualFriendsWith(user).length()