Skip to content

Instantly share code, notes, and snippets.

document.body.addEventListener('keydown', function(e) {
([37, 39].indexOf(e.keyCode) > -1) && pres[{37:'prev',39:'next'}[e.keyCode]]();
});
// VERSUS
document.body.addEventListener('keydown', function(e) {
switch(e.keyCode) {
case 37: pres.prev(); break;
case 39: pres.next(); break;
@fronx
fronx / scooby-doo.rb
Created September 24, 2010 14:40 — forked from awendt/scooby-doo.rb
def scooby
`say #{yield}`
end
scooby do
"be-doo-be-doo"
end
# Include an anonymous module
#
# Useful for defining a class with a base module. So, instead of:
#
# class Foo
# module Base
# def bar
# # ...
# end
# end
@fronx
fronx / omg.rb
Created March 16, 2010 06:32 — forked from wycats/omg.rb
require ".bundle/environment"
Bundler.setup
require "action_controller/railtie"
class FooController < ActionController::Base
def bar
self.response_body = "HELLO"
end
end
@fronx
fronx / README.txt
Created March 15, 2010 21:33 — forked from rmm5t/README.md
You can represent time statements in most western languages where
a prefix and/or suffix is used.
The default case is to use suffix only (as in English), which you
do by providing the `suffixAgo` and `suffixFromNow` settings in
the strings hash (earlier versions of timeago used the deprecated
`ago` and `fromNow` options). If present, they are used.
2 minutes [suffixAgo]
2 minutes [suffixFromNow]
@fronx
fronx / gist:281436
Created January 19, 2010 23:40 — forked from dhh/gist:281420
class Notifier < ActionMailer::Base
delivers_from '[email protected]'
def welcome(user)
@user = user # available to the view
mail(:subject => 'Welcome!', :to => user.email_address)
# auto renders both welcome.text.erb and welcome.html.erb
end
def goodbye(user)
@fronx
fronx / url_dsl.rb
Created December 14, 2009 22:31 — forked from defunkt/url_dsl.rb
require 'open-uri'
# url dsl -- the ultimate url dsl!
#
# You just can't beat this:
#
# $ irb -r url_dsl
# >> include URLDSL
# => Object
# >> http://github.com/defunkt.json
class String
@@all = []
def /(other)
@@all << "#{self} #{other}"
@@all.join(' and ')
end
def self.reset
@@all = []
end