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 WeakHash | |
def initialize(cache = Hash.new) | |
@cache = cache | |
@key_map = {} | |
@reclaim_key = lambda do |key_id| | |
delete(@key_map[key_id]) unless @cache.empty? | |
end | |
end | |
def [](key) |
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 WeakHash | |
def initialize(cache = Hash.new) | |
@cache = cache | |
@key_map = {} | |
@rev_cache = Hash.new{|h,k| h[k] = {}} | |
@reclaim_value = lambda do |value_id| | |
if value = @rev_cache.delete(value_id) | |
value.each_key{|key| @cache.delete key} | |
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
rails/master | |
| AR | | |
------------------------------------------------------------------ | |
Model#id x100000 | 0.726 | | |
Model.new (instantiation) x10000 | 0.296 | | |
Model.new (setting attributes) x10000 | 0.718 | | |
Model.first x10000 | 3.346 | | |
Model.all limit(100) x1000 | 8.772 | |
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
IM | |
| AR | | |
------------------------------------------------------------------ | |
Model#id x100000 | 0.796 | | |
Model.new (instantiation) x10000 | 0.303 | | |
Model.new (setting attributes) x10000 | 0.746 | | |
Model.first x10000 | 3.740 | | |
Model.all limit(100) x1000 | 13.367 | | |
Model.all limit(100) with relationship x1000 | 16.412 | | |
Model.all limit(10,000) x10 | 12.141 | |
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
$:.unshift("/Users/miloops/Workspace/github/miloops/rails/activerecord/lib") | |
$:.unshift("/Users/miloops/Workspace/github/railsarel/lib") | |
require 'active_record' | |
ActiveRecord::Base.establish_connection( | |
:adapter => "sqlite3", | |
:database => ":memory:" | |
) | |
ActiveRecord::Schema.define 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
$:.unshift(File.expand_path("~/.rvm/lib")) | |
require 'rvm/capistrano' | |
require 'bundler/capistrano' | |
set :rvm_ruby_string, '1.9.2-p0' | |
if ENV['STAGE'] == 'staging' | |
set :rvm_type, :user | |
set :branch, "jammit" | |
set :application, "app_name_staging" |
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
" Add me to gvimrc :-) | |
map <D-1> :tabn 1<CR> | |
map <D-2> :tabn 2<CR> | |
map <D-3> :tabn 3<CR> | |
map <D-4> :tabn 4<CR> | |
map <D-5> :tabn 5<CR> | |
map <D-6> :tabn 6<CR> | |
map <D-7> :tabn 7<CR> | |
map <D-8> :tabn 8<CR> |
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 test_does_not_delete_association_if_it_was_removed | |
author_address = AuthorAddress.first | |
author = author_address.author | |
author.author_address_id = nil | |
assert author.save | |
author.destroy | |
assert AuthorAddress.find(author_address.id) |
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
(function(a,b){function O(a){for(var b=0;b<J.bundles.length;b++)for(var c in J.bundles[b])if(c!=a&&v(J.bundles[b][c],a)>-1)return c}function N(){a.using=m,a.provide=n,a.define=o,a.loadrunner=p;return M}function L(a){var b,c;for(var d=0,e;e=J.matchers[d];d++){var f=e[0],g=e[1];if(b=a.match(f))return g(a)}throw new Error(a+" was not recognised by loader")}function K(a,b){var c=[];for(var d=0,e;e=a[d];d++)typeof e=="string"&&(e=L(e)),u(e)&&(e=new C(K(e,b),b)),c.push(e);return c}function J(){var a=t(arguments),b,c;typeof a[a.length-1]=="function"&&(b=a.pop()),typeof a[a.length-1]=="boolean"&&(c=a.pop());var d=new B(K(a,c),c);b&&d.then(b);return d}function I(){var a=t(arguments),b=[],c,d;typeof a[0]=="string"&&(c=a.shift()),u(a[0])&&(b=a.shift()),d=a.shift();return E(c,function(a){function f(){var e=H(t(b),c),f;typeof d=="function"?f=d.apply(c,e):f=d,typeof f=="undefined"&&(f=c.exports),a(f)}var c=this,e=[];for(var g=0,h=b.length;g<h;g++){var i=b[g];v(["require","exports"],i)==-1&&e.push(G(i,c))}e.length>0?J.apply |
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
login = 'mail...' | |
password = 'pass...' | |
require "net/http" | |
require "net/https" | |
uri = URI.parse("https://eventioz.com/session.json") | |
http = Net::HTTP.new(uri.host, uri.port) | |
http.use_ssl = true |