Skip to content

Instantly share code, notes, and snippets.

View capitalist's full-sized avatar
🎯
Focusing

Joe Martinez capitalist

🎯
Focusing
View GitHub Profile
rvm install 1.8.7 --debug -C --with-readline-dir=$HOME/.rvm/usr,--with-iconv-dir=$HOME/.rvm/usr,--enable-shared
rvm 1.8.7
wget http://downloads.sourceforge.net/project/rubycocoa/RubyCocoa/1.0.1/RubyCocoa-1.0.1.tar.gz?use_mirror=superb-sea2
tar zxf RubyCocoa-1.0.1.tar.gz
cd RubyCocoa-1.0.1
ruby install.rb config --target-archs=x86_64
ruby install.rb setup
rvmsudo ruby install.rb install
gem install xrefresh-server
require 'spec/runner/formatter/progress_bar_formatter'
# Put this in spec/support and run with:
# spec spec --require spec/support/no_shoulds_punk_formatter.rb --format NoShouldsPunkFormatter
class NoShouldsPunkFormatter < Spec::Runner::Formatter::ProgressBarFormatter
def initialize(options, output)
super
@examples_with_should = []
require 'webrick'
require 'webrick/httpproxy'
require 'fileutils'
require 'md5'
###
# FakeWebRecorder is an HTTP Proxy that records sessions as calls to FakeWeb.
# The code that FakeWebRecorder generates should be suitable for testing
# interaction with a particular website.
#
When /^(.*) in the "([^\"]*)" section$/ do |action, title|
within "//*[(h1|h2|h3|h4|h5|h6|legend|caption)/descendant-or-self::*[contains(text(), '#{title}')]]" do
When action
end
end
When /^(.*) in the "([^\"]*)" row$/ do |action, title|
within "//*[(th|td)/descendant-or-self::*[contains(text(), '#{title}')]]" do
When action
end
require 'strscan'
require 'set'
class SqlQuery < Struct.new(:table, :where, :order)
def to_json
[table, where, order].to_json
end
end
class SqlScanner
# Neater Github gem dependencies for Rails
module GithubGem
def github_gem(gem_name, opts={})
lib_name = gem_name.split('-', 2)[1]
self.gem gem_name, {:lib => lib_name, :source => 'http://gems.github.com'}.merge(opts)
end
end
Rails::Initializer.run do |config|
if defined?(ActiveResource)
# Makes activeresource properly encode records
class ActiveResource::Base
cattr_accessor :include_root_in_json, :instance_writer => false
def encode(options={})
case self.class.format
when ActiveResource::Formats::XmlFormat
self.class.format.encode(attributes, {:root => self.class.element_name}.merge(options))
when ActiveResource::Formats::JsonFormat
function edithosts {
if [ -x "`which $EDITOR`" ] || [ -x "`which $1`" ]
then
if [ -x "`which $EDITOR`" ]
then
export TEMP_EDIT="`which $EDITOR`"
else
export TEMP_EDIT="`which $1`"
fi
echo "* Using ${TEMP_EDIT} as editor"
module PythonishDecorator
def method_added(name)
return unless @decorations
decorations = @decorations.dup
@decorations = nil
alias_method "undecorated_#{name}", name
define_method(name) do |*args|