Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Joe Martinez capitalist

🎯
Focusing
Block or report user

Report or block capitalist

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View implementation.rb
module PythonishDecorator
def method_added(name)
return unless @decorations
decorations = @decorations.dup
@decorations = nil
alias_method "undecorated_#{name}", name
define_method(name) do |*args|
View gist:175871
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"
View active_resource_json_root_initializer.rb
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
View environment.rb
# 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|
View sql_scanner.rb
require 'strscan'
require 'set'
class SqlQuery < Struct.new(:table, :where, :order)
def to_json
[table, where, order].to_json
end
end
class SqlScanner
View scope_steps.rb
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
View fake_web_recorder.rb
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.
#
View no_shoulds_punk_formatter.rb
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 = []
View gist:404539
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
You can’t perform that action at this time.