#dom_id => #to_s # defaults to :id in AMo and does some yet to find out default in dm
And to make the following change in action_controller
# action_controller/record_identifier:63 if record_id = record.to_model.dom_id
Spec::Runner.configure do |config| | |
config.before do | |
repository do |r| | |
transaction = DataMapper::Transaction.new(r) | |
transaction.begin | |
r.adapter.push_transaction(transaction) | |
end | |
end | |
class ShardingMiddleware | |
def initialize(app) | |
@app = app | |
end | |
def call(env) | |
env['warden'].authenticate! | |
repo_name = env['warden'].account.repository_name | |
result = nil |
#dom_id => #to_s # defaults to :id in AMo and does some yet to find out default in dm
And to make the following change in action_controller
# action_controller/record_identifier:63 if record_id = record.to_model.dom_id
# Don't use this in production code! Extending lots of objects during runtime | |
# will have a negative impact on performance/memory because ruby clears out | |
# the method cache. | |
# | |
# A better approach to implement this is to write a custom DataMapper::Type that | |
# delegates all methods to the underlying BigDecimal and just overwrites #to_s | |
# Why on earth haven't I thought about that before! Thx dkubb :P | |
# | |
# | |
# When this module is activated, it will round all BigDecimal property values |
require 'rubygems' | |
require 'dm-core' | |
DataMapper::Logger.new($stdout, :debug) | |
DataMapper.setup(:default, 'sqlite3::memory:') | |
class Person | |
include DataMapper::Resource | |
property :id, Serial | |
property :name , String, :required => true |
#!/usr/bin/env ruby | |
# Collects trace stats using mtr. Accepts the following environment variables | |
# and delegates all real arguments to the underlying call to the mtr program. | |
# | |
# VERBOSE=true REPORT_DIR=/path/to/report ENDPOINTS=foo.com,bar.com THRESHOLD=10.0 ./rmtr.rb foo.com -r -c 1000 | |
require 'fileutils' | |
THRESHOLD = ENV['THRESHOLD' ].to_i || 10 |
require ".bundle/environment" | |
Bundler.setup | |
require "action_controller/railtie" | |
class FooController < ActionController::Base | |
def bar | |
self.response_body = "HELLO" | |
end | |
end |
#!/bin/bash | |
FROM=$1 | |
TO=$2 | |
echo "Spliting '$TO' from '$FROM'" | |
git clone --no-hardlinks $FROM $TO | |
cd $TO | |
git filter-branch --subdirectory-filter $TO HEAD -- --all | |
git reset --hard | |
git gc --aggressive | |
git prune |
#!/usr/bin/ruby | |
# rewrite_history.rb | |
# Jonathan D. Stott <[email protected]> | |
require 'fileutils' | |
adapters = %w{ | |
mysql_adapter.rb | |
postgres_adapter.rb | |
sqlite3_adapter.rb | |
oracle_adapter.rb |
#!/bin/bash | |
ADAPTER=$1 | |
if [ ! -d dm-more ]; then | |
echo "Cloning solnic's adapter" | |
git clone git://github.com/solnic/dm-more.git | |
cd dm-more | |
git fetch | |
git checkout -b adapters_import origin/adapters_import | |
cd .. |