This file contains hidden or 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
# Just so I'm clear on the issue... | |
class Donut < ActiveRecord::Base | |
# ... | |
end | |
# This encounters the issue with fiber-local variables... | |
class Homer | |
include Celluloid |
This file contains hidden or 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 'fiber18' | |
require 'celluloid' | |
require 'zip/zipfilesystem' | |
require 'uri' | |
require 'net/http' | |
class ZipManifest | |
include Celluloid | |
def initialize(filename) |
This file contains hidden or 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
[mboeh@orz:~] % rvm ree-1.8.7-2011.03 do ruby /tmp/nokogiri-jruby-outer-xml-test.rb | |
Loaded suite /tmp/nokogiri-jruby-outer-xml-test | |
Started | |
. | |
Finished in 0.000513 seconds. | |
1 tests, 3 assertions, 0 failures, 0 errors | |
[mboeh@orz:~] % rvm jruby-1.6.6 do ruby /tmp/nokogiri-jruby-outer-xml-test.rb | |
Loaded suite /tmp/nokogiri-jruby-outer-xml-test | |
Started |
This file contains hidden or 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 SettingReader | |
def initialize hash | |
# You may want to consider doing a deep copy of the hash and then #freeze-ing it | |
@hash = hash.nil? ? {} : hash | |
raise ArgumentError, "must pass a hash or nil" unless @hash.kind_of? Hash | |
end | |
def get key, default = nil | |
h = @hash | |
for subkey in key.split(".") | |
h = h[subkey] |
This file contains hidden or 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
# Messing with some experimental statistical analysis for infinitely exploding dice | |
def roll_die(d) | |
rand(d) + 1 | |
end | |
def roll_exploding_die(d) | |
r = roll_die(d) | |
if r == d | |
r + roll_exploding_die(d) |
This file contains hidden or 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
# mboeh's zshrc | |
# Where history is stored. | |
HISTFILE=~/.histfile | |
# Up to 2500 lines of history will be stored in a given shell session... | |
HISTSIZE=2500 | |
# ... and up to 2500 will be saved when the shell exits. | |
SAVEHIST=2500 | |
# Append new history lines to .histfile when the shell closes (instead of clobbering it). | |
# A must-have for someone who uses a lot of ZSH sessions (I have 5-10 open at any given time). |
This file contains hidden or 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
#!/bin/sh | |
capture () { | |
echo $SSH_AUTH_SOCK > /tmp/$(whoami)-auth-sock-path | |
} | |
clean () { | |
rm /tmp/$(whoami)-auth-sock-path | |
} |
This file contains hidden or 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.version | |
=> "2.1.2" | |
>> AbstractThingy < ActiveRecord::Base | |
=> true | |
>> AbstractThingy.record_timestamps | |
=> true | |
>> OneOfManyThingies < AbstractThingies | |
=> true | |
>> OneOfManyThingies.record_timestamps | |
=> nil |
This file contains hidden or 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
# Ruby syntax never fails to amaze me, casefile whatever. | |
# Yes, this could be accomplished more elegantly another way. But this is fun. | |
require 'ostruct' | |
def DStruct(*a) | |
klass = Struct.new(*a) | |
defs = Hash.new | |
yield defs | |
klass.send :define_method, :initialize do |*a| |
This file contains hidden or 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
[alias] | |
# Cheap fast way of getting the current branch for, say, your shell prompt | |
cbranch = !cat .git/HEAD | cut -d/ -f3-4 | |
st = status | |
# A pattern I find myself using a lot | |
up = !git fetch && git rebase origin/$(git cbranch) | |
# The current staged patch | |
di = diff --cached | |
# checkout is so long, and co means something sort of different to me | |
sw = checkout |
NewerOlder