Skip to content

Instantly share code, notes, and snippets.

View thinkerbot's full-sized avatar

Simon Chiang thinkerbot

View GitHub Profile
@thinkerbot
thinkerbot / signal_check.rb
Created April 30, 2009 13:08
Signals on different platforms.
######################################################
# This is to check what signals are available from the
# command line on different platforms.
#
# === Results
#
# Mac:
# ctrl-T: INFO
# ctrl-\: QUIT
# ctrl-Z: TSTP
@thinkerbot
thinkerbot / env_inheritance.rb
Created May 6, 2009 05:20
a check of ENV inheritance
# This script demonstrates that ENV variables are inherited
# in system calls. The printout (assuming VARIABLE is not
# set beforehand) is:
#
# % ruby env_inheritance.rb
# before:
# reset: blue
# system: blue
# popen: blue
# after: blue
@thinkerbot
thinkerbot / rack_utils_optimizations.rb
Created May 15, 2009 14:57
rack utils optimizations
require 'benchmark'
require 'rack'
include Rack::Utils
# This illustrates the little optimizations to Rack::Utils that you might
# consider. The parse_query optimization prevents the regeneration of the
# default separator regexp:
#
# /[#{d}] */n
@thinkerbot
thinkerbot / README
Created May 16, 2009 03:54
a jquery issue in firefox extensions
== JQuery Extension
Illustrates that something in jquery > 1.2.6 causes toolbars in other
extensions to disappear. To see the issue, first install an extension that
will disappear like Web Developer (link below). Web Developer adds a toolbar
all across the top of the browser.
Then enable this extension by moving the 'jquery_ext@tap.rubyforge.org' file
into your Firefox profile directory (be sure to add the full path to this
directory into the file first). For example:
@thinkerbot
thinkerbot / .gitignore
Created May 17, 2009 08:39
ruby core benchmarks
*.rbc
@thinkerbot
thinkerbot / yaml_domain_type.rb
Created May 27, 2009 01:22
add a domain type to YAML
# Demonstrates how to add a domain type to YAML. Note
# that the namespace and year have to be as written...
# "tap.rubyforge.org,2009" doesn't work, for instance.
require 'yaml'
YAML::add_domain_type( "tap.yaml.org,2002", "object" ) do |type, val|
"loaded: #{type} (#{val})"
end
puts YAML.load("!tap/object foo")
@thinkerbot
thinkerbot / sample.rb
Created June 18, 2009 05:10
A stand-alone Task executable
#! /usr/bin/env ruby
require 'rubygems'
require 'tap/task'
# Sample::task a sample task
#
# This is a sample of a task used as an executable. This is a sample of a
# task used as an executable. This is a sample of a task used as an
# executable.
@thinkerbot
thinkerbot / .gitignore
Created June 19, 2009 18:57
20090619 ECM data extraction
data
results
config
@thinkerbot
thinkerbot / Rapfile
Created June 19, 2009 22:09
20090619 Peptide Mass Calculation
require 'ms/in_silico/digester'
require 'ms/fasta/archive'
require 'molecules'
require 'tap'
# PeptideMasses::task
#
# % rap peptide_masses <fasta_file>
#
class PeptideMasses < Tap::Task
@thinkerbot
thinkerbot / anonymous_class.rb
Created August 14, 2009 21:30
Danger of accessing constant name during inheritance
# This illustrates the danger of accessing the constant name
# of a child class during inheritance (ex by to_s). The
# constant name will not be set at the time of inheritance
# if the class was is using Class.new.
class A
class << self
attr_accessor :const_name
def inherited(child)