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 Array | |
def zip(a, &b) | |
if b | |
r = [] | |
bs = lambda{ |x| r << b.call(*x) } | |
super(a, &bs) | |
return r | |
else | |
super(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
--- | |
/: | |
tag: <tag:clarkevans.com,2002:invoice> | |
invoice: &mandatoryint | |
type: int | |
required: true | |
date: | |
type: date | |
required: true | |
bill-to: &billing-schema-alias |
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 'thread' | |
module RAML | |
def self.load(io, options={}) | |
case io | |
when String | |
file = '(eval)' | |
code = io | |
when File |
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
trans@logisys:ansi$ redline test | |
ANSI v1.2.6 /home/trans/Documents/programs/github.com/rubyworks/ansi | |
qed Test | |
Started | |
..............................I, [2011-05-09T15:32:44.350689 #15187] INFO -- : Info logs are green. |
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
# Recorder, Copyright (c) 2006 Thomas Sawyer | |
require 'facets/kernel/object_class' | |
# = Recorder | |
# | |
# The Recorder class is a <i>method probe</i>. It records everything | |
# that happens to it, building an internal action tree. You can then | |
# pass a substitute object and apply the recording to it. Or you can | |
# analyze the action tree. |
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
# Run 1000000 Times: | |
# | |
# ruby 1.8.7 (2010-01-10 patchlevel 249) [x86_64-linux] | |
# | |
# Simple Read : 0.217292 seconds | |
# Or Equals : 0.31042 seconds | |
# | |
# ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-linux] | |
# | |
# Simple Read : 0.113411725 seconds |
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
# AutoArray | |
# Copyright (c) 2005 Brian Schröder | |
# TODO: Use or integrate with SparseArray | |
# An Array that automatically expands dimensions as needed. | |
# | |
# a = Autoarray.new | |
# a[1][2][3] = 12 | |
# a #=> [nil, [nil, nil, [nil, nil, nil, 12]]] | |
# a[2][3][4] #=> [] |
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
# TITLE: | |
# | |
# HashBuilder | |
# | |
# DESCRIPTION: | |
# | |
# Build a hash programmatically via missing method calls. | |
# | |
# COPYRIGHT: | |
# |
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
# = Snapshot | |
# | |
# A lightweight single-depth object state capture. | |
# The #take_snapshot method reads the object's state, | |
# which is generally it's collection of instance variables, | |
# and returns them in a hash. The state can be restored | |
# with #apply_snapshot. | |
# | |
# == Todo | |
# |
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
# The idea here is that #succ could take an optional parameter | |
# to help optimize certain (albeit rare) cases when skipping steps | |
# is required. | |
class Fixnum | |
# Allows #succ to take _n_ increments. | |
# | |
# 3.succ(2) #=> 5 | |
# |