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 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() |
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
[color] | |
diff = auto | |
status = auto | |
branch = auto | |
interactive = auto | |
ui = true | |
pager = true | |
[color "branch"] | |
current = yellow reverse |
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
public function collect($function) | |
{ | |
$result = array(); | |
foreach ($this as $key => $value) { | |
array_push($result,call_user_func(array($value,$function),$value)); | |
} | |
return $result; | |
} |
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
export TERM=xterm-color | |
export LSCOLORS=dxfxcxdxbxegedabagacad | |
alias ls='ls -G' | |
alias ll='ls -l' | |
alias l='ls -la' | |
alias la='ls -a' | |
alias gs='git status' | |
# tweak bash tab completion |
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
# Delete unnecessary files | |
run "rm README" | |
run "rm public/index.html" | |
run "rm public/favicon.ico" | |
run "rm public/robots.txt" | |
run "rm -f public/javascripts/*" | |
gitignoreItems = %w( | |
.DS_Store | |
log/*.log |
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
# SUPER DARING APP TEMPLATE 1.0 | |
# By Peter Cooper | |
# Link to local copy of edge rails | |
inside('vendor') { run 'ln -s ~/dev/rails/rails rails' } | |
# Delete unnecessary files | |
run "rm README" | |
run "rm public/index.html" | |
run "rm public/favicon.ico" |
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
/* | |
* Twita@talinkahashifyer | |
* http://www.dustindiaz.com | |
* http://www.dustindiaz.com/basement/ify.html | |
* | |
* Copyright (c) 2009 Dustin Diaz | |
* licensed under public BSD | |
*/ | |
var ify = function() { | |
return { |
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
require 'rubygems' | |
require 'twitter' | |
auth = Twitter::HTTPAuth.new('username', 'password') | |
base = Twitter::Base.new(auth) | |
guilty = base.friend_ids - base.follower_ids | |
puts "There are #{guilty.size} People you follow who do not follow you" | |
guilty.each do |user_id| |
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
## some dummy data | |
x <- seq(as.Date("2008-01-01"), as.Date("2009-10-31"), by = "day") | |
set.seed(1234) | |
y <- cumsum(rnorm(length(x))) | |
## plot, but suppress axes | |
plot(y ~ x, type = "l", axes = FALSE) | |
## add in axis on side 2 | |
axis(2) |
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 make_bitly_url($url, $login, $appkey, $format='xml', $history=1, $version='2.0.1') | |
{ | |
//create the URL | |
$bitly = 'http://api.bit.ly/shorten'; | |
$param = 'version='.$version.'&longUrl='.urlencode($url).'&login=' | |
.$login.'&apiKey='.$appkey.'&format='.$format.'&history='.$history; | |
//get the url | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, $bitly . "?" . $param); |
OlderNewer