Skip to content

Instantly share code, notes, and snippets.

View raggi's full-sized avatar

James Tucker raggi

View GitHub Profile
# Example of the implementation
class Template
module CompileSite; end
def compile(klass, name, source)
klass.class_eval <<-RUBY
lambda {}.binding.__send__ :eval, <<-RB
def \#{name}(locals)
\#{source}
@raggi
raggi / rspec_assert.rb
Created July 28, 2010 11:07
assert implemented in rspec
# Someone was using a test helper of mine that relies on a simple assert
# method. As this doesn't exist in rspec, I had to make one, but I wanted the
# messages to work, so, it blew up a little.
module Assert
class Matcher
def initialize(object, message = nil)
@object, @message = object, message
end
@raggi
raggi / oldcodes.rb
Created August 19, 2010 21:06
happy whyday
p(%|#{<<-''}|[?\0...-0x0_2]<<% == <<%< ><<%&#{?../ 0.0_0 }&)
A Big Number Divided By Zero
ruby &= { :spirit => :creative }
A = [8, -21, 8, 2].zip(self.inspect.scan(/./)).map { |a,b| (b[0] - a).chr }.join
B = <<-B
011010000111010001110100011100000011101000101111001011110110011101101001011101
000110100001110101011000100010111001100011011011110110110100101111011000100111
001001111001011000010110111001110111011011110110111101100100011100110010111101
101011011010010111010001110100011110010010111101110010011000010111011100101111
011011010110000101110011011101000110010101110010001011110110001001101001011011
10001011110110101101101001011101000111010001111001
B
require %w[6f70656e2d757269].pack('H*')
@raggi
raggi / bbsterm.rb
Created September 3, 2010 11:26 — forked from erikh/bbsterm.rb
require 'eventmachine'
require 'kconv'
class BBSTerm < EM::Connection
def post_init
@read_buffer = ""
@initialization = true
end
def receive_data(data)
class Proc; alias ending call; end
story = never'ending'
story =-> { never.ending }
never =-> { story.ending }
story === never.ending
@raggi
raggi / _README.md
Created October 16, 2010 02:14
RubyGems master installer
@raggi
raggi / roflscale.txt
Created November 3, 2010 02:05
sekrets of the roflscale sauce
08:58 Defi_: can anyone tell me if there are any obvious disadvantages to patching a blocking library to use fibers at the socket level?
08:58 Defi_: its far too much effort to have to rewrite large chunks of every library just to make it async and fiber-aware
08:59 raggi: if it uses non-stack stored state you could end up with concurrency issues (read: race conditions)
08:59 raggi: fibers as implemented in MRI have limited size stacks (4kb)
09:00 Defi_: hmm alright :/
09:01 raggi: if the library is trying to be thread safe, it can make a real mess too
09:01 raggi: Defi_: just use threads.
09:02 Defi_: raggi: not gonna happen...
09:02 Defi_: even if this was a personal project, i wouldnt use threads
09:03 Defi_: guess ill just have to continue rewriting parts of a bunch of libs as i go
@raggi
raggi / plugins.txt
Created December 23, 2010 16:38
a list of all rubygems_plugin.rb files in the wild as of about 2 months ago
gemmirror/code/a/autobundle-1.0.0.pre1/lib/rubygems_plugin.rb
gemmirror/code/a/autobundle-1.0.0.pre2/lib/rubygems_plugin.rb
gemmirror/code/a/authoxy-1.2.1/lib/rubygems_plugin.rb
gemmirror/code/s/specific_install-0.2.2/lib/rubygems_plugin.rb
gemmirror/code/s/specific_install-0.2.1/lib/rubygems_plugin.rb
gemmirror/code/s/specific_install-0.2.3/lib/rubygems_plugin.rb
gemmirror/code/s/show_gem-0.0.1/lib/rubygems_plugin.rb
gemmirror/code/s/show_gem-0.0.2/lib/rubygems_plugin.rb
gemmirror/code/s/shway-3.0.1/lib/rubygems_plugin.rb
gemmirror/code/s/shway-3.0/lib/rubygems_plugin.rb
@raggi
raggi / gc.c
Created January 10, 2011 06:49
someone's description of gc.c
gc_mark_children()
{
cthulhu:
fthagn()
fthagn!()
goto cthulhu;
}