Skip to content

Instantly share code, notes, and snippets.

Avatar

Wilson Bilkovich wilson

View GitHub Profile
View gist:46919
本拠> rake rspec:pre_commit ~/code/rspec-dev/example_rails_app
(in /Users/wilson/code/rspec-dev/example_rails_app)
running against rails 2.2.2
#####################################################
running pre_commit against rails 2.2.2
#####################################################
HEAD is now at ff56137... Doc updates
#####################################################
rm -rf db/*.db
#####################################################
@wilson
wilson / gist:92453
Created Apr 9, 2009
mongrel_object_track.conf
View gist:92453
# Original code by Robert Klemme
OUT=open("objects.log","w")
OUT.sync = true
$last_stat = nil
$run_count = 0
OUT.puts "run,classname,last,count,delta"
class ObjectTrackFilter < Mongrel::HttpHandler
def process(request,response)
View gist:156671
words = %w(one two three lol zarglezargle one two six jambo)
p words.select {|word| word if (word.length > 3)..(word.length > 5) }
# output:
# ["three", "lol", "zarglezargle", "jambo"]
# 'one' and 'two' are skipped because they are not > 3 characters in length
# 'three' triggers the left side of the flip-flop condition
# 'lol' is selected because the left side has triggered, but not the right side
# 'zarglezargle' triggers the right side condition, and 'turns off' the flip-flop
# Because we used '..' here instead of '...' in the flip-flop, the condition returns true
View gist:174421
# > {:x => 4, :y => 7}.keys_sorted_by_value
# [:y, :x]
class Hash
def keys_sorted_by_value
to_a.sort_by {|tuple| rand - tuple.last.to_i}.map {|tuple| tuple.first}
end
end
View gist:202553
(gdb) r
Starting program: /Users/wilson/code/rbx/bin/rbx -P stuff.rb
Reading symbols for shared libraries +++. done
Reading symbols for shared libraries ... done
Reading symbols for shared libraries . done
Catchpoint 1 (exception thrown).
Catchpoint 1 (exception caught), throw location vm/exception.cpp:25, catch location unknown, exception type rubinius::TypeError
0x00007fff85953b9d in __cxa_throw ()
(gdb) bt
View gist:202512
data = {}
choices = ('a'..'z').to_a
100_000.times do |i|
data[i] = choices[rand(26)]
end
data.sort_by {|k,v| k}
View blah.rb
obj = "something"
method_name = "foo"
obj.instance_eval <<-CODE
def #{method_name}
"blah"
end
CODE
# ... or..
View gist:213793
<DescribeInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2009-08-15/">
<reservationSet>
<item>
<reservationId>r-44a5402d</reservationId>
<ownerId>UYY3TLBUXIEON5NQVUUX6OMPWBZIQNFM</ownerId>
<groupSet>
<item>
<groupId>default</groupId>
</item>
</groupSet>
View gist:214533
---
gem: --no-ri --no-rdoc
:benchmark: false
:backtrace: true
:update_sources: true
:verbose: really
:sources:
- http://gemcutter.org
- http://gems.rubyforge.org
- http://gems.github.com
View gist:214626
# Run the bundler directly instead of relying on Rake to do it
if ARGV.any? {|task_name| task_name =~ /^gems:bundle$/}
system "gem bundle"
end
require(File.join(File.dirname(__FILE__), 'config', 'boot'))
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'