Skip to content

Instantly share code, notes, and snippets.

View anolson's full-sized avatar
👋

Andrew Olson anolson

👋
View GitHub Profile
@anolson
anolson / random_pronounceable_string.rb
Created December 20, 2010 00:37
Create random pronounceable strings
module RandomPronounceableString
VOWELS = "aeiou"
CONSONANTS = "bcdfghjklmnprstvwyz"
def random_pronounceable
%(#{random_consonant}#{random_vowel}#{random_consonant}#{random_vowel}#{random_consonant}#{random_vowel})
end
def random_vowel
random_letter(VOWELS)
@anolson
anolson / application_controller.rb
Created November 16, 2010 21:22
Rails navigation helpers
module ApplicationHelper
def navigation(collection)
content_tag :ul do
build_navigation_items(collection)
end
end
def build_navigation_items(collection)
content = ""
collection.each do |item|
@anolson
anolson / application_controller.rb
Created November 16, 2010 16:11
Rails set mobile format.
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :redirect_mobile_device
before_filter :set_mobile_format
private
def redirect_mobile_device
if is_mobile_device?