This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'active_model' | |
require 'active_support' | |
class Model | |
include ActiveModel::Validations | |
include ActiveModel::Conversion | |
extend ActiveModel::Naming | |
def initialize(attributes = {}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'httparty' | |
module Google | |
module Geocode | |
class RequestDenied < StandardError; end | |
class Client | |
include HTTParty |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'net/http' | |
require 'rexml/document' | |
module Ride4Ruby | |
GOOGLE_MAPS_API_KEY = "your google key" | |
@states = ["Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut", "Delaware", "District of Columbia", "Florida", "Georgia", "Idaho", "Illinois", "Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana", "Maine", "Maryland", "Massachusetts", "Michigan", "Minnesota", "Mississippi", "Missouri", "Montana", "Nebraska", "Nevada", "New Hampshire", "New Jersey", "New Mexico", "New York", "North Carolina", "North Dakota", "Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island", "South Carolina", "South Dakota", "Tennessee", "Texas", "Utah", "Vermont", "Virginia", "Washington", "West Virginia", "Wisconsin", "Wyoming"] | |
class Location |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.observe('dom:loaded', function(){ | |
$('click_me').observe('click', function(event) { | |
activateDialog(event); | |
}); | |
}); | |
function activateDialog(event) { | |
var element = Event.findElement(event); | |
fetchDialogContent(element.href); | |
event.stop(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "test/unit" | |
class TestFibonachi < Test::Unit::TestCase | |
def test_fibonachi_numbers | |
numbers = [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765] | |
numbers.each_with_index { |number, index| | |
assert_equal number, Fibonachi.number(index) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'net/smtp' | |
require 'optparse' | |
module SendFile | |
class CommandlineOptions | |
attr_accessor :options |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LogProducer | |
attr_accessor :streams | |
def initialize(options = {}) | |
@streams = Hash.new | |
@filename = options[:filename] | |
add_stream(options[:stream]) | |
end | |
OlderNewer