Skip to content

Instantly share code, notes, and snippets.

View jcf's full-sized avatar
❤️

James Conroy-Finn jcf

❤️
View GitHub Profile
@jcf
jcf / snippet.sh
Created December 10, 2008 00:23 — forked from anonymous/snippet.sh
Open important Rails directories with TextMate's mate link
function rmate {
if [[ $# -eq 1 ]]; then
mate "${1}/app" "${1}/config" "${1}/lib" "${1}/public" "${1}/spec" "${1}/stories"
else
mate "app" "config" "lib" "public" "spec" "stories"
fi
}
#!/opt/local/bin/bash
# .git/hooks/commit-msg
exec < /dev/tty
commit_message=$1
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
branch=${ref#refs/heads/}
# Exit if commit message empty
# exhibit a
{:conditions => case f.to_s
when 'active' then {:state => @@states[2]}
when 'disabled' then {:state => @@states[0..1]}
when 'all' then {}
else {:state => @@states[3]}
end}
# exhibit b
case f.to_s
Ruby Wins
by James CF
C#m G#m F#m A
Use a block to print your name,
Use equality to test the same,
Blocks and lambdas you can call,
Private methods, send from all.
@jcf
jcf / gist:156139
Created July 27, 2009 10:57 — forked from jamierumbelow/gist:154644
Just having some fun with a song about love and my Ruby
Ruby Wins
by James CF
C#m G#m F#m A
Use a block to print your name,
Use equality to test the same,
Blocks and lambdas you can call,
Private methods, send from all.
def build_message
message = PORTFOLIO_FIELDS.graph{|field, _| [field, send(field)] }
self.message = message.delete_if { |_, value| value.nil? }
end
module Math
def self.factorial(f)
f == 0 ? 1 : f * factorial(f - 1)
end
end
# Or we can extend an instance of Fixnum so we can do 5.factorial :)
class Fixnum
def factorial
self == 0 ? 1 : self * (self - 1).factorial
module Math
def self.factorial(f)
f == 0 ? 1 : f * factorial(f - 1)
end
end
# Or we can extend an instance of Fixnum so we can do 5.factorial :)
class Fixnum
def factorial
self == 0 ? 1 : self * (self - 1).factorial
// An Unobtrusive Javascript (UJS) driver based on explicit behavior definitions. Just
// put a "data-behaviors" attribute on your view elements, and then assign callbacks
// for those named behaviors via Behaviors.add.
var Behaviors = {
add: function(event, behavior, callback) {
return $('*[data-behaviors~=' + behavior + ']').bind(event, callback);
}
};
@jcf
jcf / factories.rb
Created September 8, 2010 08:25 — forked from jferris/factories.rb
Factory.define :post do |post_factory|
post_factory.user { Factory.build(:user) }
end