Skip to content

Instantly share code, notes, and snippets.

View tom-pang's full-sized avatar
💭
greetings

Tom Pang tom-pang

💭
greetings
View GitHub Profile
module Kernel
def an(value)
Thingy.new(value)
end
def none
Nothing.new
end
end
(unfinished bar)
(defn foo [stuff incoming]
(first
(filter
(fn [a-thing]
(bar a-thing incoming))
stuff)))
;; this actually calls bar
module Blog
Routes = Raptor.routes(Blog) do
show :to => 'Post.find', :if => :post_not_cached
end
class PostNotCached
def match?(id, cache_control)
post = Post.find(id)
post.updated_at =< cache_control
end
module Blog
Routes = Raptor.routes(Blog) do
show :to => 'Post.find', :http_cache_requirement => :post_cached
end
class PostCached
def match?(id, cache_control)
post = Post.find(id)
post.updated_at =< cache_control
end
# caching constraint
module Blog
Routes = Raptor.routes(Blog) do
show :to => 'Post.find', :unless :post_cached
show :responder => NoContentResponder
end
class PostCached
def match?(id, cache_control)
post = Post.find(id)
#!/bin/bash
# assuming `origin (push)` is a github url,
# this opens the current branch on github's site,
# ready for a pull request
# only works on macs right now (it uses `open`)
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/' -e 's/)//' -e 's/(//'
}
Isolation vs Rails: More Fastererer Speedy Mk II Edition
There is a vast set of tools and patches to speed up Rails boot time. What happens if, instead of testing inside Rails, we isolate our specs from Rails? What benefits can be gained from isolating our testing? Whilst test execution time is an obvious benefit, there are more subtle nuances to isolation.
from Quartz import *
import time as time
KEYCODES = {
#q12
#w13
#e14
@tom-pang
tom-pang / gist:1646808
Created January 20, 2012 11:22
failbundler
pc-3-97:raptor(8161m|master) $ bundle
ERRRO: Gem bundler is not installed, run `gem install bundler` first.
pc-3-97:raptor(8161m|master) $ gem install bundler
Successfully installed bundler-1.0.21
1 gem installed
Installing ri documentation for bundler-1.0.21...
Installing RDoc documentation for bundler-1.0.21...
pc-3-97:raptor(8161m|master) $ bundle
ERRRO: Gem bundler is not installed, run `gem install bundler` first.
pc-3-97:raptor(8161m|master) $ cd ..
{
:current_user => "CurrentUser.current_user"
}