Skip to content

Instantly share code, notes, and snippets.

View practicingruby's full-sized avatar

Gregory Brown practicingruby

View GitHub Profile
module AntSim
class World
def initialize(size)
@size = size
@data = size.times.map { size.times.map { Cell.new(0,0,0) } }
end
def [](location)
x,y = location
module AntSim
class World
def initialize(size)
@size = size
@data = size.times.map { size.times.map { Cell.new(0,0) } }
end
def [](location)
x,y = location
## 1.9.3
>> RUBY_VERSION
=> "1.9.3"
>> Proc.new { |a,b| [a,b] }.call
=> [nil, nil]
>> proc { |a,b| [a,b] }.call
=> [nil, nil]
>> lambda { |a,b| [a,b] }.call
ArgumentError: wrong number of arguments (0 for 2)
require "celluloid"
class Cell
include Celluloid
def initialize
@pheremone = 0
# .. other variables
end
module Contractor
FailedContract = Class.new(StandardError)
class << self
attr_accessor :enabled
end
def precondition(method, &block)
constraint = Module.new do
define_method method do |*a,&b|
module Contractor
def precondition(method, &block)
constraint = Module.new do
define_method method do |*a,&b|
raise unless instance_exec(*a, b, &block)
super(*a, &b)
end
end
Hi there!
Back in August, we started working on switching our payment and email
provider for Practicing Ruby. As part of that process, we disabled
payments for new subscribers and re-subscribers temporarily so that we
wouldn't send more people through the bad old process we used to have.
Our records show that you are one of about 400 people who received a
temporarily free account during this transition.
I'm happy to say that as of today (November 15), we are now able to
$ ruby -e "p ObjectSpace.each_object(Class).select { |e| e.ancestors.include?(Enumerable) }"
[Enumerator::Generator, Enumerator, Struct::Tms, Dir, File, ARGF.class, IO, Range, Struct, Hash, Array]
require "simple_uuid"
class UUIDTracer < SimpleUUID::UUID
def initialize(*a, &b)
p [a, b] # replace this with a logger
super
end
end
SimpleUUID::UUID = UUIDTracer
#!/usr/bin/env ruby
PATTERNS = { "gg" => "http://google.com/search?q=",
"gmap" => "http://maps.google.com/maps?q=",
"wp" => "http://en.wikipedia.org/?search=",
"m" => "http://www.google.com/movies?near=" }
app = lambda do |env|
command, *args = URI.unescape(env["QUERY_STRING"]).gsub("+", " ").split