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_helper' | |
class CheckinProcessingTest < ActionController::IntegrationTest | |
context "a user filling out the checkin form" do | |
should "do his thing" do | |
visit '/' | |
#fill out the account form | |
select 'No', :from => 'account[prev_cust_claim]' | |
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 | |
# | |
# A one file test to show ... | |
require 'rubygems' | |
require 'dm-core' | |
# setup the logger | |
DataMapper::Logger.new(STDOUT, :debug) |
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 'optparse' | |
require 'rest_client' | |
require 'open-uri' | |
CLIENT_LOGIN_URI = URI.parse('https://www.google.com/accounts/ClientLogin') | |
CLIENT_LOGIN_HEADERS = {'Content-type' => 'application/x-www-form-urlencoded'} | |
SERVICE = 'mail' | |
ACCOUNT_TYPE = 'GOOGLE' | |
SOURCE = 'myaname-myprogram-0.0.1' |
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
ORG $1000 | |
START: ; first instruction of program | |
green_t EQU 60 | |
yello_t EQU 5 | |
lights EQU $2000 | |
timer EQU $2001 | |
n_ymask EQU %100010 ; EW will be red when NS yellow | |
n_gmask EQU %100001 | |
e_ymask EQU %010100 | |
e_gmask EQU %001100 |
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 MyDir < Dir | |
class << self | |
def [](args) | |
super(args).collect {|entry| do_junk(entry)} | |
end | |
end | |
end | |
describe MyDir | |
before do |
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 'dbi' | |
@dbh = DBI.connect("DBI:SQLite3:files.db") | |
@dbh.do("CREATE TABLE IF NOT EXISTS files (filename VARCHAR PRIMARY KEY, x INTEGER, y INTEGER, mtime INTEGER)") | |
@dbh.do("CREATE TABLE IF NOT EXISTS dir (id INTEGER PRIMARY KEY AUTOINCREMENT, mtime INTEGER)") | |
@dbh.disconnect |
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
var map = function() { emit(this._id, {amount: this.amount, qty: this.qty})} | |
var reduce = function(price_id, vals) { | |
var min = vals[0].amount; | |
var max = min; | |
var E_w = vals[0].qty; | |
var E_v = max; | |
for (var i = 1; i < vals.length; i++) { | |
vals[i].amount < min && (min = vals[i].amount); | |
vals[i].amount > max && (max = vals[i].amount); | |
E_w += vals[i].qty; |
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
# Hive::Client is a mysql data store with datamapper, Client is a mongo data store with mongomapper | |
hive_client_ids = Hive::Client.all(:fields => [:hive_id]).collect(&:hive_id) | |
=> [16, 26, 50, 52, 53, 54, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109] | |
# ~ (0.000074) SELECT `id` FROM `clients` ORDER BY `id` | |
Client.all(:hive_id => 16) | |
=> [] | |
# MONGODB crystalmetrics_development['clients'].find({:hive_id=>16}, {}) |
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
# Call and output | |
prod = Product.create(:hive_id => 1214241241414241, :name => "whatever") | |
res = prod.min_max_avg | |
# Error | |
Failure/Error: res = prod.min_max_avg | |
keys must be strings or symbols | |
# /home/michael/.rvm/gems/ruby-1.8.7-p249/gems/bson-1.0.3/lib/../lib/bson/bson_c.rb:24:in `serialize' | |
# /home/michael/.rvm/gems/ruby-1.8.7-p249/gems/bson-1.0.3/lib/../lib/bson/bson_c.rb:24:in `serialize' |
OlderNewer