Skip to content

Instantly share code, notes, and snippets.

View jpr5's full-sized avatar
💭
committing badassery

Jordan Ritter jpr5

💭
committing badassery
View GitHub Profile
@jpr5
jpr5 / config.ru
Created January 28, 2010 01:06
Script demonstrating that latest Sinatra doesn't invoke before hooks on static files
`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
@jpr5
jpr5 / 1_SELECT_construction_logic.txt
Created January 14, 2010 19:19
JOIN logic assessment, logic and fails (0.9x-current)
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 / fucked_dm_joins.rb
Created January 14, 2010 06:14
problem with joins in DM post-0.10.2
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@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 / DM-specs-memleak.patch
Created December 2, 2009 05:51
patch + output demonstrating that DM specs have a serious memory leak
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('.')
@jpr5
jpr5 / rubygems.rb
Created November 24, 2009 05:30
RubyGems Defanger
# 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 / Server Output
Created August 9, 2009 02:47
Sinatra / DM Scavenger Thread issue
== 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