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
#http://github.com/ahoward/open4 is an alternative that handles pid and exit status | |
#http://github.com/ahoward/session a more fleshed our shell utility | |
require 'open3' | |
Open3.popen3("dc") do |stdin, stdout, stderr| | |
t = Thread.new(stderr) do |terr| | |
while (line = terr.gets) | |
puts "stderr: #{line}" | |
end | |
end |
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 Wizard | |
# class << self | |
# self.class_eval do | |
# define_method :convene_council do | |
# puts "The council is in session!" | |
# end | |
# end | |
# end | |
def self.metaclass |
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
public class HelloWorld { | |
public String hello() { | |
return "Hello cruel world"; | |
} | |
} |
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 in config/environment.rb before init starts | |
#require 'config/add_explicit_path_to_config_gem' | |
#Rails::Initializer.run do |config| | |
#config.gem 'my_gem', :version => '0.0.1', :explicit_path => "#{RAILS_ROOT}/vendor/local_gemfiles/my_gem-0.0.1.gem" #or | |
#config.gem 'my_gem', :version => '0.0.1', :explicit_path => "http://github.com/myname/myrepo/raw/master/mygem.gem" #or | |
module Rails | |
class GemDependency < Gem::Dependency | |
def initialize(name, options = {}) | |
require 'rubygems' unless Object.const_defined?(:Gem) |
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
#a variation of this:http://ozmm.org/posts/z_cache_bang.html | |
#def rankings | |
# @rankings ||= rankings! | |
#end | |
#def rankings! | |
# # compute expensive rankings | |
#end | |
def rankings |
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
irb(main):001:0> :my_new_symbol.to_i | |
=> 16073 | |
irb(main):002:0> 16073.to_sym | |
=> :my_new_symbol | |
irb(main):001:0> Symbol.all_symbols.length | |
=> 1709 | |
irb(main):002:0> def my_new_method | |
irb(main):003:1> end |
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
// DR1.0 :: domReady | |
// ***************************************************** | |
// DOM scripting by brothercake -- http://www.brothercake.com/ | |
// GNU Lesser General Public License -- http://www.gnu.org/licenses/lgpl.html | |
//****************************************************** | |
//DOM-ready watcher | |
function domReady() |
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 AbstractScraper | |
def initialize(username, password) | |
@agent = WWW::Mechanize.new | |
@agent.user_agent_alias = "Windows Mozilla" | |
@agent.keep_alive = false | |
login(username, password) | |
end | |
end | |
class NormalAScraper < AbstractScraper |