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 Enumerable | |
def forked_each(n = 50, &block) | |
self.each_slice(n) do |items| | |
fork do | |
GC.disable | |
items.each { |item| block.call(item) } | |
end | |
Process.wait | |
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
development: | |
adapter: master_slave | |
master: | |
adapter: mysql | |
database: master | |
host: master_server | |
slave: | |
adapter: mysql | |
database: slave | |
host: localhost |
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' | |
class Person | |
include DataMapper::Resource | |
property :id, Serial | |
property :first_name, String | |
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
require 'rubygems' | |
require 'dm-core' | |
gem 'dm-core', '0.10.2' | |
class Post | |
include DataMapper::Resource | |
# !> method redefined; discarding old one? | |
property :id, Serial | |
property :title, String | |
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 macruby | |
unless Kernel.respond_to? :framework | |
exec 'macruby', *ARGV.unshift(__FILE__) | |
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
ubuntu$ echo "Iñtërnâtiônàlizætiøn" | iconv -t 'ascii//translit//ignore' -f 'utf-8' | |
Internationalizaeti?n | |
osx$ echo "Iñtërnâtiônàlizætiøn" | iconv -t 'ascii//translit//ignore' -f 'utf-8' | |
I~nt"ern^ati^on`alizaetion |
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' | |
gem 'dm-core', '0.10.0' | |
require 'dm-core' | |
class Post | |
include DataMapper::Resource | |
def self.default_repository_name | |
:post |
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
$ sudo gem install rip | |
Password: | |
ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError) | |
bad response Not Found 404 (http://gems.rubyforge.vm.bytemark.co.uk/gems/rip-0.0.1.gem) |
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 'forwardable' | |
module DataMapper::Adapters | |
class MasterSlaveAdapter < AbstractAdapter | |
extend Forwardable | |
extend DataMapper::Migrations::SingletonMethods | |
def_delegators :@master, :storage_exists?, :field_exists?, | |
:upgrade_model_storage, :create_model_storage, :destroy_model_storage, :alter_model_storage, |
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' | |
# built off of next | |
gem 'dm-core', '0.10.0' | |
require 'dm-core' | |
DataMapper.setup(:default, :adapter => :in_memory) | |
module Blog | |
NewerOlder