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
<table class="ages"> | |
<tr class="person"><td class="name">John</td><td class="age">24</td></tr> | |
<tr class="person"><td class="name">Dean</td><td class="age">30</td></tr> | |
</table> |
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
<div class="ages"> | |
<div class="person"><div class="name">John</div><div class="age">24</div></div> | |
<div class="person"><div class="name">Dean</div><div class="age">30</div></div> | |
</div> | |
.ages { display: table; } | |
.person { display: table-row; } | |
.name { display: table-cell; } | |
.age { display: table-cell; } |
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
<ages> | |
<person><name>John</name><age>24</age></person> | |
<person><name>Dean</name><age>30</age></person> | |
</ages> | |
ages { display: table; } | |
person { display: table-row; } | |
name { display: table-cell; } | |
age { display: table-cell; } |
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
# Turn a YAML document into an object via method_missing delegation. | |
# This is a pretty useless idea since you can just use OpenStruct. | |
# | |
# OpenStruct.new(YAML.load(yaml)) | |
# | |
class YAMLStruct < BasicObject | |
def initialize( stream ) | |
@yaml = YAML::load( stream ) | |
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
# Quickly create shadow methods, eg. #__foo__ from #foo. | |
# This has a very limited use case, just use alias_method instead. | |
class Module | |
# Define a shadow alias for a method. | |
# | |
# class X | |
# shadow_method( :class ) | |
# 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
# Fixnum Constants | |
# Constants providing the numerical limitations of Fixnum class. | |
# | |
class Fixnum | |
N_BYTES = [42].pack('i').size | |
N_BITS = N_BYTES * 8 | |
MAX = 2 ** (N_BITS - 2) - 1 | |
MIN = -MAX - 1 | |
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
# This is the first reusable ruby lib I ever wrote. | |
# It is pretty useless now, and in hindsight not so well | |
# written either, but I've gist it for posterity. | |
# TomsLib - Tom's Ruby Support Library | |
# Copyright (c) 2002 Thomas Sawyer, LGPL | |
# | |
# FetchFile | |
# | |
# For purposes of this library a url is defined as both |
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
# Binding-of-Caller, Copyright (c) 2003 Florian Gross | |
# (No longer works with Ruby after version 1.8+) | |
class Continuation; end # :nodoc: # for RDoc | |
def Continuation.create(*args, &block) # :nodoc: | |
cc = nil; result = callcc {|c| cc = c; block.call(cc) if block and args.empty?} | |
result ||= args | |
return *[cc, *result] | |
end | |
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
# EnumeratedType lets you create enumerated types like this: | |
# | |
# class OutputType < EnumeratedType | |
# AUTODETECT | |
# UNKNOWN | |
# NOSOUND | |
# WAVWRITER | |
# DSOUND | |
# WINMM | |
# ASIO |
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
# Gem.active?, Gem.gemspec and Gem.gempath. | |
# These are RubyGems extensions I created a while back. | |
# I'm not sure how relevant they are any longer however. | |
# Does RubyGems now have other means to do these? | |
module Gem | |
def self.active?(gemname) | |
@loaded_specs ||= Hash.new | |
@loaded_specs.key? gemname |
OlderNewer