These are various bits and pieces I've extracted from the application I worked on which were copied just too many times, but yet too small to be in the separate gems.
Django F() And Q() Objects For Rails
ShellOut
provides a convenient feature-rich way to "shell out" to external commands.
Most useful features come from using PTY
to execute the command. Not available
on Windows, Kernel#system
will be used instead. Tries to stay compatible
between system
and PTY
backends.
Formats the Exception so that it looks familiar, i.e. exactly like your
interpreter does it. Port of MRI native error_print
function.
Simple Net::HTTP
mumbo jumbo we all have to use occasionally.
Correct alias_method_chain_once
implementation.
Safe way to intercept IO stream where just replacing STDOUT doesn't work.
Turns on Net::HTTP debugging globally so that you know whatever underlying library is accessing network and what it does.
My solution of Guarded Evaluation problem . Everyone has that :)
My attempt at abstracting acts_as_*
pattern. Need to get rid of InstanceMethods
class to make it year 2010 compatible.
puts
for web application debugging.
Whenever writing one-off script it is much nicer to just
require "dolzenko/all"
than to keep repeating same require
thing again and
again. Turns out this is expensive luxury with 1.9.2.
require "English"
require "yaml"
require "open-uri"
autoload :FileUtils, "fileutils"
autoload :OptionParser, "optparse"
module Net
autoload :HTTP, "net/http"
end
require "active_support/all"
require "facets"
require "require_gist"
require_gist "371861/abc6d24346864e5cb33b4eab330569565b1dd8c2/shell_out.rb", "72b19c8955f87f9b408a92a77440cda987b1a01f" # http://gist.github.com/371861
require_gist "375386/642be35e02a09b7dc5736f462ea1d8368864ffa8/error_print.rb", "12f893f4abd1f0ea19d198f6ff1ac66d8b8675ea" # http://gist.github.com/375386
> time ruby -v -W2 -e 'require "dolzenko"'
ruby 1.8.7 (2009-12-24 patchlevel 248) [i686-linux], MBARI 0x8770, Ruby Enterprise Edition 2010.01
real 0.89 user 0.40 sys 0.48
ruby 1.8.7 (2010-01-10 patchlevel 249) [i686-linux]
real 0.78 user 0.40 sys 0.36
ruby 1.8.7 (2008-08-11 patchlevel 72) [i386-mswin32]
real 3.75 user 0.00 sys 0.01
ruby 1.9.2dev (2010-04-02 trunk 27162) [i686-linux]
real 7.17 user 6.32 sys 0.72
# WTF??? http://redmine.ruby-lang.org/issues/show/3010 ?