View profile_load_time.rb
# = Description | |
# A load time profiler script, useful for identifying requires | |
# that slow down the loading of a script. | |
# | |
# Oftentimes we use but don't always need what we require in | |
# scripts. This can dramatically slow load times, which can be | |
# annoying. Use this script to identify slow-loading parts of | |
# a script and then consider using autoloading to defer | |
# the require until you really need it. | |
# |
View a basic webrick cgi server and script
#!/usr/bin/env ruby | |
################################################################ | |
# A basic cgi script. To run, set up the following: | |
# | |
# /dir | |
# |- cgi-bin | |
# | `- this_script.cgi | |
# `- the_webrick_script.rb | |
# |
View redirect_http.js
////////////////////////////////////////////////////////////////////////////// | |
// | |
// RedirectHttp | |
// | |
// Note Ubiquity makes these objects available (the list is incomplete, but | |
// contains the objects that are used in this script): | |
// | |
// - Application:: the FUEL[http://developer.mozilla.org/en/FUEL] Application object | |
// - CmdUtils:: Ubiquity command utilities | |
// |
View mascot_mass_calc.rb
# These are a number of tasks to calculate peptide masses | |
# using a variety of algorithms. The intent is to find | |
# the algorithm used by Mascot to calculate peptide mass. | |
# | |
# Correct algorithm: unknown | |
# Dependencies: tap, molecules | |
# | |
require 'rubygems' | |
require 'tap' |
View simple_yaml.rb
# = Description | |
# | |
# SimpleYaml provides methods to dump and load simple configurations. | |
# Support is limited strings, symbols, booleans, nil, and numbers. | |
# Values may include non-nested arrays. Nested hashes are not | |
# supported anywhere. | |
# | |
# include SimpleYaml | |
# hash = { | |
# :sym => 'str', |
View manual_includes.rb
require 'rubygems' | |
require 'minitest/spec' | |
module A | |
module B | |
end | |
end | |
class DirectInclude | |
include A |
View http_echo_server.rb
# usage: ruby echo_server.rb | |
# | |
# Launches a WEBRick server that echos http requests back. This can be | |
# useful when debugging HTTP requests. | |
# | |
require 'webrick' | |
# Setup server configuration | |
logger = WEBrick::Log.new |
View tap-ubiquity.js
////////////////////////////////////////////////////////////////////////////// | |
// | |
// Tap | |
// | |
// Note Ubiquity makes these objects available (the list is incomplete, but | |
// contains the objects that are used in this script): | |
// | |
// - Application:: the FUEL[http://developer.mozilla.org/en/FUEL] Application object | |
// - jQuery:: http://docs.jquery.com/Main_Page | |
// - Utils:: Ubiquity utilities |
View io_duplicate_danger.rb
# This illustrates how IO duplicates flush separately. | |
# The danger is that this can result in disordered | |
# output. Run this from the command line: | |
# | |
# % ruby io_duplicate_danger.rb | |
# 1 | |
# 2 | |
# 3 | |
# | |
# You get what you expect. Now try with redirection: |
View Trying to best YAML - fail
# Setting options for to_yaml doesn't work. | |
# * http://www.arkanis-development.de/weblog/2007/6/20/options-for-rubys-@to_yaml@-method | |
# * http://groups.google.com/group/ruby-talk-google/browse_thread/thread/b9bd01242f7d67ae/7186dd14f9e1e3ff#7186dd14f9e1e3ff | |
# | |
# This is an attempt to workaround by directly setting a flag in the | |
# emitter. Fail. If I recall right, trying to set/modify the @options | |
# hash also does not work. | |
# | |
# :UseHeader => false | |
# |
OlderNewer