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 LuhnChecksum | |
attr_accessor :number | |
def initialize(number = "") | |
@number = number | |
end | |
def valid? | |
calculate_checksum % 10 == 0 | |
end |
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
Saddle point found at: [1, 3] | |
No saddle points found | |
Saddle point found at: [1, 3] |
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 'net/ldap' | |
class SimpleEdAuthenticator | |
HOST, PORT, BASE_DN = 'authn.directory.vt.edu', 636, 'ou=People,dc=vt,dc=edu' | |
def initialize(options = {}) | |
@authenticated = false | |
@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
class LogProducer | |
attr_accessor :streams | |
def initialize(options = {}) | |
@streams = Hash.new | |
@filename = options[:filename] | |
add_stream(options[:stream]) | |
end | |
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
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
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
#!/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
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
require 'rubygems' | |
require 'active_model' | |
require 'active_support' | |
class Model | |
include ActiveModel::Validations | |
include ActiveModel::Conversion | |
extend ActiveModel::Naming | |
def initialize(attributes = {}) |