Skip to content

Instantly share code, notes, and snippets.

View roryokane's full-sized avatar

Rory O’Kane roryokane

View GitHub Profile
@roryokane
roryokane / readme.md
Last active August 29, 2015 14:16 — forked from anonymous/readme.txt
Pegs in PuzzleScript – version hosted for puzzlescript.net
@roryokane
roryokane / original_with_test_harness.rb
Created August 3, 2012 17:57 — forked from jcasimir/gist:3247167
test harness for posted code wanting refactoring
class LocaleChooser
LOOKUP_CHAIN = [:params, :user, :session, :http, :default]
def self.set_by(inputs)
locale = nil
LOOKUP_CHAIN.each do |lookup|
locale = send("by_#{lookup}", inputs[lookup])
break if locale
@roryokane
roryokane / implementation_in_class.rb
Created August 3, 2012 17:51 — forked from jcasimir/gist:3247167
refactoring posted code by creating Enumerable#find_mapped
LOOKUP_CHAIN = [:params, :user, :session, :http, :default]
def self.set_by(inputs)
LOOKUP_CHAIN.find_mapped do |lookup|
locale = send("by_#{lookup}", inputs[lookup])
end
end
@roryokane
roryokane / scramble.rb
Created May 9, 2012 23:23 — forked from jescalan/scramble.rb
Sensical sentence scrambler
# ---------------------------
# Sensical Sentence Scrambler
# ---------------------------
# This short program takes any word longer than three characters and randomly shuffles all the characters
# except for the first and the last. Strangely enough, sentences are still quite readable like this.
# **Usage**
# Save the file on your computer as 'scramble.rb'.
# From the command line, run `ruby scramble.rb "Here's my sentence."`, and it should output
@roryokane
roryokane / example.rb
Created June 7, 2011 13:17 — forked from cararemixed/example.rb
Better routes (just a fork, haven’t used personally) (doesn’t seem to work with Rails 3)
uri 'contacts', name: 'contacts' do
get 'contacts#index'
end
uri 'contacts/:id/addresses', name: 'contact_addresses' do
put 'contact_addresses#replace'
post 'contact_addresses#create'
delete 'contact_addresses#delete'
end