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
# A sample Gemfile | |
source "http://rubygems.org" | |
source 'http://gems.rubyforge.org/' | |
gem "dm-core" | |
gem "dm-validations" | |
gem "dm-migrations" | |
gem "dm-transactions" | |
gem "dm-sqlite-adapter" | |
gem "dm-aggregates" |
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
fs.open(path, "a", 0666, function (error, file) { | |
fs.write(file, "worker 10 starting at" + time, null, "utf-8", function () { | |
forEachoftheFirstOneMillionHitsOnGoogleFor(word, function(url) { | |
getHtmlSource(url, function(html) { | |
foo(bar(html)) | |
}) | |
}) | |
}) | |
}) |
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
a = lambda { puts "hello #{name}"} | |
class Foo | |
def name | |
"manson" | |
end | |
end | |
Foo.new.instance_eval(&a) #hello manson |
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
source 'http://gems.github.com' | |
source 'http://gems.rubyforge.org/' | |
gem "bunny" | |
gem "activesupport" | |
gem "actionmailer" | |
gem "DanaDanger-syslog_logger", :require => "syslog_logger" | |
gem "dm-core" | |
gem "dm-validations" |
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 fs = require('fs'); | |
var sys = require("sys"); | |
var files = ['data1', 'data2', 'data3']; | |
var data = {} | |
var AllDone = function() { return files.every(function(file) {return data[file] })} | |
var Biggest = function() { return files.reduce(function(big, file) { | |
return big.length > data[file].length ? big : data[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
require 'rubygems' | |
require 'dm-core' | |
require 'dm-migrations' | |
require 'dm-validations' | |
class Human | |
include DataMapper::Resource | |
property :id, Serial | |
validates_with_block :foo 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
class Pet | |
include DataMapper::Resource | |
belongs_to :owner, Human | |
property :id Serial | |
property :status, String, :set => ['asleep', 'awake'] | |
validators.contexts[:without_assocs] = validators.contexts[:default].reject{|v| v.field_name == :owner_id} | |
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
def step(name, *lambdas) | |
s = lambdas.reverse.inject(lambda{|p| p.call}) do |acc, l| | |
func = lambda { |*args| acc.call(*args) } | |
create_parallel_method(func) | |
a = Struct.new(name).new(func) | |
lambda { |*args| a.instance_exec(*args, &l)} | |
end | |
s.call | |
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 Foo | |
include DataMapper::Resource | |
has 1, :bar | |
property :id, Serial | |
property :name, String | |
end | |
class Bar |
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 'dm-core' | |
require 'dm-migrations' | |
require 'dm-validations' | |
class Pet | |
include DataMapper::Resource | |
belongs_to :human |