Class names are CamelCase
.
Methods and variables are snake_case
.
Methods with a ?
suffix will return a boolean.
# memoized fibonacci in Ruby | |
class Fibber | |
attr_accessor :hash | |
def initialize | |
@hash = {} | |
end | |
def memo_fib(n) | |
for number in 0..n | |
if number < 2 | |
@hash[number] = number |
#!/bin/sh | |
. git-sh-setup # for die | |
git-diff-index -p -M --cached HEAD -- | grep '^+' | grep -n '# debug' && die 'Blocking commit: debug detected in code' | |
: |
$.fn.rememberSelectedTab = (tabSelector = "aria_controls")-> | |
selectedTab = window.location.hash.replace "#", "" | |
if selectedTab && selectedTab != "" | |
$("[#{tabSelector}='#{selectedTab}']").click() | |
@each -> | |
$(@).find("ul.nav-tabs li").click -> | |
name = $(@).find("a").attr tabSelector | |
window.location.hash = name |
# | |
# Heroku helpers | |
# Example Usage: hcommand app-name | |
# | |
# open a Heroku rails console for an app | |
hcon() { | |
appName=$(ensureHasArg $1) | |
heroku run rails console -a $appName | |
} |
hcon() { | |
appName=$1 | |
if [ -z "$appName" ] | |
then | |
echo "fucking provide a Heroku app name" | |
exit 1 | |
fi | |
heroku run rails console -a $appName |
thing = if something? | |
"this" | |
else | |
"that" | |
end | |
puts thing | |
# => "this" or "that" |
def loop_size(node) | |
0.tap do |idx| | |
begin | |
if node.instance_variable_get :@idx | |
return idx - node.instance_variable_get(:@idx) | |
else | |
node.instance_variable_set :@idx, idx | |
idx += 1 | |
end | |
end while node = node.next |
ROUTES = { | |
"GET /" => ["RootController", :show], | |
"GET /home" => ["HomeController", :index], | |
"GET /posts/:slug/comments/:id/edit" => ["CommentsController", :edit], | |
"POST /posts/:slug/comments" => ["CommentsController", :create], | |
"PUT /posts/:slug" => ["PostsController", :update] | |
} | |
router = Router.new ROUTES |
window.lastScroll = 0; | |
$(function() { | |
var lastSnap, isAnimating, | |
snaps = $(".snap-to"), | |
$window = $(window); | |
var heights = snaps.map(function() { | |
return $(this).offset().top; | |
}); |