This file contains hidden or 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
| /* | |
| * This is the Towers of Hanoi example from the prolog tutorial [1] | |
| * converted into Scala, using implicits to unfold the algorithm at | |
| * compile-time. | |
| * | |
| * [1] http://www.csupomona.edu/~jrfisher/www/prolog_tutorial/2_3.html | |
| */ | |
| object TowersOfHanoi { | |
| import scala.reflect.Manifest |
This file contains hidden or 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/ruby | |
| require 'net/smtp' | |
| PRINT_RESULTS = false # Print results to screen? | |
| EMAIL_RESULTS = true # email the results? | |
| pool = %w{[email protected] [email protected] [email protected]} | |
| avail = pool.dup |
This file contains hidden or 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 'sinatra' | |
| require 'phone.rb' | |
| set :environment, :production | |
| root_dir = File.dirname(__FILE__) | |
| set :root, root_dir | |
| FileUtils.mkdir_p 'log' unless File.exists?('log') | |
| log = File.new("log/sinatra.log", "a") |
This file contains hidden or 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 God | |
| module Conditions | |
| class FileTouched < PollCondition | |
| attr_accessor :path | |
| def initialize | |
| super | |
| self.path = nil | |
| end |
This file contains hidden or 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
| [~]$ ruby test_state_machine_callbacks.rb | |
| TestActiveRecord: starting to do_a. done a already? false | |
| TestActiveRecord: starting to do_a. done a already? true | |
| TestActiveRecord: done with do_a | |
| TestActiveRecord: done with do_a | |
| Caught error: 'SQLite3::SQLException: PRIMARY KEY must be unique: INSERT INTO "test_active_records" ("id", "state") VALUES(1, 'done_with_b')' | |
| TestMongoMapper: starting to do_a. done a already? false | |
| TestMongoMapper: starting to do_a. done a already? true | |
| TestMongoMapper: done with do_a | |
| TestMongoMapper: done with do_a |
This file contains hidden or 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
| diff --git a/test/unit/integrations/active_record_test.rb b/test/unit/integrations/active_record_test.rb | |
| index 639f1f0..d90c7a7 100644 | |
| --- a/test/unit/integrations/active_record_test.rb | |
| +++ b/test/unit/integrations/active_record_test.rb | |
| @@ -1749,6 +1749,34 @@ module ActiveRecordTest | |
| else | |
| $stderr.puts 'Skipping ActiveRecord Scope tests. `gem install active_record` >= v2.1.0 and try again.' | |
| end | |
| + | |
| + class MachineWithBeforeCreateCallbackTest < BaseTestCase |
This file contains hidden or 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 Appname | |
| class Application < Rails::Application | |
| # ...lots of stuff... | |
| config.middleware.use Rack::Auth::Basic, "My Realm", &(Proc.new {|user,pass| [user,pass] == ["foo","bar"]}) | |
| end | |
| end |
This file contains hidden or 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
| # mongo_template.rb | |
| # fork of Ben Scofield's Rails MongoMapper Template (http://gist.github.com/181842) | |
| # | |
| # To use: | |
| # rails project_name -m http://gist.github.com/gists/219223.txt | |
| # remove unneeded defaults | |
| run "rm public/index.html" | |
| run "rm public/images/rails.png" | |
| run "rm public/javascripts/controls.js" |
This file contains hidden or 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 AgeValidationTest | |
| require 'date' | |
| def self.valid_age_string(age_string) | |
| d, m, y = age_string[0,2].to_i, age_string[2,2].to_i, age_string[4,2].to_i | |
| Date.valid_civil?(y, m, d) && y.between?(11,89) | |
| end | |
| def self.random_age_string | |
| age_string = "" | |
| 6.times { age_string << rand(10).to_s } | |
| age_string |
This file contains hidden or 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
| var http = require('http'); | |
| var connection_count = 0; | |
| var client_id = 0; | |
| function createClient() { | |
| client_id++; | |
| var _client_id = client_id; | |
| var google = http.createClient(8080, '184.72.131.24'); | |
| var request = google.request('GET', '/', {'host': '184.72.131.24'}); |