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 Someone | |
class << self | |
def say | |
$stdin.each_line do |line| | |
$stdout << "someone says '#{line}' @ #{Time.now}" | |
end | |
end | |
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
# instead of Time.now (or watever class methods of Time), we use: | |
LocalTime.now |
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
module RailsBestPractices | |
module Macros | |
def self.included(base) | |
# Calling of "include RailsBestPractices::Macros" will make all macros available as | |
# class methods within describe { ... } | |
base.extend(ClassMethods) | |
end | |
module ClassMethods |
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
unless ENV['RAILS_ENV'] == 'production' | |
module Resque | |
class << self | |
alias_method :orig_enqueue, :enqueue | |
def Resque.enqueue(*args) ; end | |
end | |
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
# This script shows how a single xpath can be used for matching a specific row in an html | |
# table, taking into account the the header text <th/> and cell text <td/>. It is able to | |
# handle case-sensitivity & nested inner text. | |
# | |
# Pls note that in order to test out case-sensitivity, u need to tweak IS_CASE_SENSITIVE & | |
# the html string. | |
# | |
# BTW, let me know how the generated xpath can be more elegant than it currently is. | |
# | |
require 'rubygems' |
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 LocalTime | |
@@zone = Time.zone | |
class << self | |
def method_missing(method, *args) | |
args.empty? ? @@zone.send(method) : @@zone.send(method, *args) | |
end | |
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
{:gdb_debug=>true} | |
=> Hijacking...> (no debugging symbols found) | |
> Attaching to program: /usr/bin/ruby1.8, process 9433 | |
> Reading symbols from /usr/lib/libruby1.8.so.1.8...(no debugging symbols found)...done. | |
> Loaded symbols for /usr/lib/libruby1.8.so.1.8 | |
> Reading symbols from /lib/libpthread.so.0...(no debugging symbols found)...done. | |
> [Thread debugging using libthread_db enabled] | |
> [New Thread 0x7fea191b16f0 (LWP 9433)] | |
> [New Thread 0x7fea14f2f950 (LWP 9852)] | |
> Loaded symbols for /lib/libpthread.so.0 |
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
module Steam | |
module Matchers | |
module HtmlUnit | |
class HasContent #:nodoc: | |
# nothing interesting, the original content remains | |
end | |
### | |
# Directly extracted from Webrat::Matchers::HaveXpath with minor edits to avoid | |
# calling webrat stuff |
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
ActionMailer::Base.class_eval do | |
DELIVERIES_CACHE_PATH =⋅ | |
File.join(RAILS_ROOT,'tmp','cache','action_mailer_acceptance_deliveries.cache') | |
def perform_delivery_acceptance(mail) | |
deliveries << mail | |
File.open(DELIVERIES_CACHE_PATH,'w') do |f| | |
Marshal.dump(deliveries, f) | |
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
#!/usr/bin/ruby | |
`cat ~/.bash_aliases | egrep '^alias' | sed 's/alias//'`.split("\n").each do |line| | |
parts = line.strip.split(/=/) | |
name, cmd = parts[0], parts[1].gsub(/('|")/,'') | |
file = '/home/%s/.config/fish/functions/%s.fish' % [`whoami`.strip, name] | |
content = [ 'function %s' % name, ' %s $argv;' % cmd, 'end' ].join("\n") | |
File.open(file, 'w+'){|io| io.write(content) } | |
end |