Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
committing badassery

Jordan Ritter jpr5

💭
committing badassery
View GitHub Profile
@jpr5
jpr5 / Server Output
Created Aug 9, 2009
Sinatra / DM Scavenger Thread issue
View Server Output
== Sinatra/0.10.1 has taken the stage on 4000 for development with backup from Mongrel
Sun, 09 Aug 2009 03:47:26 GMT ~ debug ~ (0.000587) SELECT "id", "session_id", "data", "updated_at" FROM "sessions" WHERE ("session_id" = 'true') ORDER BY "id" LIMIT 1
Sun, 09 Aug 2009 03:47:26 GMT ~ debug ~ (0.000054) SELECT "id", "session_id", "data", "updated_at" FROM "sessions" WHERE ("session_id" = 'true') ORDER BY "id" LIMIT 1
127.0.0.1 - - [08/Aug/2009 20:47:26] "GET /flows HTTP/1.1" 200 155 0.0080
127.0.0.1 - - [08/Aug/2009 20:47:27] "GET /favicon.ico HTTP/1.1" 200 32 0.0014
^CSat Aug 08 20:47:27 -0700 2009: Reaping 1 threads for slow workers because of 'shutdown'
Waiting for 1 requests to finish, could take 60.0 seconds.
== Sinatra has ended his set (crowd applauds)
^C
@jpr5
jpr5 / rubygems.rb
Created Nov 24, 2009
RubyGems Defanger
View rubygems.rb
# Populate $BASE with symlinks to what you want, and put the rubygems.rb file at its root.
function rubylib {
if [ -n "$1" ]; then BASE="$1/"; else BASE="/proj/work/rubylib"; fi
export BASE
echo RUBYLIB will use base: $BASE
export RUBYLIB=$BASE:`ruby -e 'puts Dir["#{ENV["BASE"]}/*/**/lib"].join(":")'`:$RUBYLIB
}
alias rl=rubylib
@jpr5
jpr5 / DM-specs-memleak.patch
Created Dec 2, 2009
patch + output demonstrating that DM specs have a serious memory leak
View DM-specs-memleak.patch
diff --git a/spec/lib/rspec_immediate_feedback_formatter.rb b/spec/lib/rspec_immediate_feedback_formatter.rb
index 95051ee..9068d87 100644
--- a/spec/lib/rspec_immediate_feedback_formatter.rb
+++ b/spec/lib/rspec_immediate_feedback_formatter.rb
@@ -38,14 +38,27 @@ module Spec
output.flush
end
- def example_passed(*)
- output.print green('.')
View output.txt
jpr5@finesse(tmp)$ ruby foo.rb
2148181980 born
2148181820 born
2148181660 born
2148181500 born
2148181340 born
nuke class constant
done
calling GC.start
done
@jpr5
jpr5 / fucked_dm_joins.rb
Created Jan 14, 2010
problem with joins in DM post-0.10.2
View fucked_dm_joins.rb
require "do_mysql"
require "dm-core"
require 'rubygems'
require 'ruby-debug'
Debugger.start
DataMapper::Logger.new(STDOUT, :debug)
DataMapper.setup(:default, "mysql://root@localhost/foo")
@jpr5
jpr5 / 1_SELECT_construction_logic.txt
Created Jan 14, 2010
JOIN logic assessment, logic and fails (0.9x-current)
View 1_SELECT_construction_logic.txt
See associated gist for simple definitions of Project, User, Task, Answer models
referenced herein.
Summary:
I believe the logic about how JOINs are constructed needs to fundamentally
change. In order to create the correct JOIN SQL, the logic needs to be
aware of and account for how an individual query param's "links" are related
to each other *only*, instead of how they the query param's themselves
relate to each other (which is how I intepret how it works now).
@jpr5
jpr5 / config.ru
Created Jan 28, 2010
Script demonstrating that latest Sinatra doesn't invoke before hooks on static files
View config.ru
`git clone git://github.com/sinatra/sinatra.git` unless File.exists?('sinatra')
`mkdir -p public`
`touch public/favicon.ico`
$: << 'sinatra/lib'
require 'rack'
require 'sinatra/base'
class Server < ::Sinatra::Base
set :public, Dir.pwd + '/public'; enable :static
View gist:455046
require 'thread'
m = Mutex.new
m.lock
wt2 = Thread.new do
m.lock
sleep 2
m.unlock
end
View 1_output.txt
# dm-core 0.10.2 <- our current point
creating 20 models took: 0.890000 0.250000 1.140000 ( 1.147287)
# dm-core v1.0.0
creating 20 models took: 1.350000 0.440000 1.790000 ( 1.791719)
# dm-core e7b5f186 <- somewhere after 1.0.0, time is climbing
creating 20 models took: 1.540000 0.520000 2.060000 ( 2.061627)
# dm-core ad298724 <- git bisect tells me this is the bad one
View monkey.rb
# The default DM property doesn't support serials, so we add it in here
module DataMapper
class Property
class String
accept_options :serial
end
end
end
module DataMapper::Salesforce