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
ctrl-z | |
bg | |
touch /tmp/stdout | |
touch /tmp/stderr | |
gdb -p $! | |
# In GDB | |
p dup2(open("/tmp/stdout", 1), 1) | |
p dup2(open("/tmp/stderr", 1), 2) |
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
Objector = lambda do |properties| | |
lambda do |meth| | |
properties[meth] | |
end | |
end | |
def Objector.new(props); self[props] 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
~/projects ➔ gem install cloby | |
Successfully installed cloby-0.0.1-java | |
1 gem installed | |
Installing ri documentation for cloby-0.0.1-java... | |
Installing RDoc documentation for cloby-0.0.1-java... | |
~/projects ➔ cat simple.rb | |
require 'cloby' | |
class MyClojureObj < Clojure::Object |
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
require 'rubygems' | |
require 'rack' | |
class Object | |
def webapp | |
class << self | |
define_method :call do |env| | |
func, *attrs = env['PATH_INFO'].split('/').reject(&:empty?) | |
[200, {}, send(func, *attrs)] | |
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
using System; | |
using System.Globalization; | |
using System.Web.Mvc; | |
namespace Zomg.Web.ModelBinders | |
{ | |
public class Iso8601DateTimeBinder : DefaultModelBinder | |
{ | |
public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) | |
{ |
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
describe SomeClass do | |
freeze { 1.day.from_now } | |
it "does some stuff with time" do | |
end | |
end | |
# this actually does... | |
describe SomeClass do | |
around { |example| Timecop.freeze(1.day.from_now, &example) } |
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
~/Code/rubygems /master > gem list gemcutter | |
*** LOCAL GEMS *** | |
gemcutter (0.6.1, 0.5.0) | |
~/Code/rubygems /master > irb -rubygems | |
ruby-1.8.7-p299 > Gem.find_files "rubygems_plugin" | |
=> ["/Users/wycats/.rvm/gems/ruby-1.8.7-p299/gems/gem-open-0.1.2/lib/rubygems_plugin.rb", "/Users/wycats/.rvm/gems/ruby-1.8.7-p299/gems/gemcutter-0.5.0/lib/rubygems_plugin.rb", "/Users/wycats/.rvm/gems/ruby-1.8.7-p299/gems/gemcutter-0.6.1/lib/rubygems_plugin.rb"] | |
ruby-1.8.7-p299 > Gem.loaded_specs.map {|k,v| v.full_name } | |
=> ["gem-open-0.1.2", "gemcutter-0.5.0", "json_pure-1.4.6"] |
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
Capybara.current_session.driver.current_session.instance_eval { @rack_mock_session }.cookie_jar |
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
# place in features/support | |
require 'ephemeral_response' | |
EphemeralResponse.configure do |config| | |
config.expiration = lambda { one_day * 30 } | |
config.white_list = ['localhost', '127.0.0.1'] | |
config.register('api.twitter.com') do |request| | |
if oauth_token_match = request['authorization'].match(/oauth_token=\"\d+-\w+"/) | |
"#{request.uri.to_s}#{request.method}#{oauth_token_match[0]}" | |
else |
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
require 'fileutils' | |
class File | |
def self.finalizer(path) | |
lambda do | |
FileUtils.rm(path) | |
end | |
end | |
def tempify! |