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 'rubygems' | |
require 'beanstalk-client' | |
require 'pp' | |
require 'digest/md5' | |
beanstalk = Beanstalk::Connection.new('127.0.0.1:11300') | |
while true do | |
job = beanstalk.reserve |
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
describe "test" do | |
it "should return and then raise error" do | |
mock = mock("Test") | |
crazy = 0 | |
mock.should_receive(:blah).twice do | |
if crazy > 0 | |
raise StandardError | |
end | |
crazy += 1 | |
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
class Test | |
def blah | |
"woohoo!" | |
end | |
end | |
describe "count received but return normal value" do | |
it "should return its normal value" do | |
t = Test.new | |
t.should_receive(:blah) |
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
describe "playing with blocks" do | |
it "should check the block" do | |
log_mock = mock("Logger") | |
log_mock.should_receive(:something) { |*args| puts args.size } | |
log_mock.something { "blah" } | |
end | |
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
module LionO | |
class Test | |
end | |
describe Test do | |
def myclass | |
self.class | |
end | |
it "should print the class" 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
#!/usr/bin/env ruby | |
f = File.open("test.file", "w") | |
f.write("blah\n") | |
f = nil | |
#ObjectSpace.garbage_collect | |
puts File.readlines("test.file") |
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
Copyright (c) 2005-2007 Thomas Uehlinger | |
Permission is hereby granted, free of charge, to any person | |
obtaining a copy of this software and associated documentation | |
files (the "Software"), to deal in the Software without | |
restriction, including without limitation the rights to use, | |
copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the | |
Software is furnished to do so, subject to the following | |
conditions: |
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 'pp' | |
require 'rubygems' | |
require 'mongo' | |
db = XGen::Mongo::Driver::Mongo.new("localhost").db("test") | |
original = db.collection("original") | |
original.remove | |
original.insert( { "test" => 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
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'beanstalk-client' | |
JOB_SIZE = 64000 | |
beanstalk = Beanstalk::Connection.new('127.0.0.1:11300') | |
job_data = 'x' * JOB_SIZE |
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
> db.t.remove() | |
> db.t.insert( { players: [ {player_name: "m", player_position: 3}, {player_name: "blah", player_position: 3} ] } ) | |
> db.t.insert( { players: [ {player_name: "another", player_position: 3}, {player_name: "m", player_position: 5} ] } ) | |
> db.t.find( { "players": { player_name: "m", "player_position": 3 }} ) | |
{ "_id" : ObjectId("4b4eaf902976dc62f4b0f9de"), "players" : [ | |
{ | |
"player_name" : "m", | |
"player_position" : 3 | |
}, | |
{ |
OlderNewer