Skip to content

Instantly share code, notes, and snippets.

Bradley Schaefer soulcutter

Block or report user

Report or block soulcutter

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
soulcutter / gist:2314814
Created Apr 5, 2012
Overriding instance methods
View gist:2314814
module WizardSkills
module InstanceMethods
def trick
puts "The #{self.class} turned a man into a rabbit"
module MagicianSkills
soulcutter / rubyprof.rake
Created Apr 14, 2012
Ruby profiling rake task
View rubyprof.rake
require 'ruby-prof'
require 'ruby-prof/task' do |t|
t.test_files = FileList['test/integration/**/patients_test.rb']
t.output_dir = File.join(Rails.root, 'tmp')
t.printer = :graph_html
t.min_percent = 10
soulcutter / gist:2458278
Created Apr 22, 2012
irbrc helper to print documentation
View gist:2458278
class Object
# list methods which aren't in superclass
def local_methods(obj = self)
(obj.methods - obj.class.superclass.instance_methods).sort
# print documentation
# ri 'Array#pop'
# Array.ri
soulcutter / gist:2477448
Created Apr 24, 2012
Saxerator example
View gist:2477448
require 'saxerator'
# The parser takes any IO object (or String) - a File is a common choice
parser = Saxerator.parser(bookshelf_xml)
# Simplest usage, parses every <book></book> in the document
parser.for_tag(:book).each do |book|
# Your book hash might look something like
{ 'title' => 'Rails 3 In Action', 'author' => ['Ryan Bigg', 'Yehuda Katz'] }
View gist:2705200
describe Article do
subject(:article) { }
it "validates presence of :title" do
article.should validate_presence_of(:title)
soulcutter / gist:3671893
Created Sep 8, 2012
JRuby NPE using Symbol#to_proc with --1.9
View gist:3671893
➜ saxerator git:(master) ✗ ruby -v
jruby 1.7.0.preview2 (1.9.3p203) 2012-09-07 f4306fa on Java HotSpot(TM) 64-Bit Server VM 1.6.0_33-b03-424-11M3720 [darwin-x86_64]
➜ saxerator git:(master) rspec spec/lib/dsl/for_tag_spec.rb
/Users/soulcutter/.rvm/gems/jruby-head@saxerator/gems/rspec-core-2.11.1/lib/rspec/core/example.rb:274 warning: singleton on non-persistent Java type Java::JavaLang::NullPointerException (
1) Saxerator::DSL#for_tag should only select the specified tag
Failure/Error: Unable to find matching line from backtrace
soulcutter / gist:3718477
Created Sep 13, 2012
ssh-agent launcher
View gist:3718477
function start_agent {
echo "Initializing new SSH agent..."
/usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
echo succeeded
chmod 600 "${SSH_ENV}"
soulcutter / gist:3738320
Created Sep 17, 2012
Adding magic encoding comments to ruby files
View gist:3738320
for file in $(awk 'FNR == 1 && !/^#\!/ { print FILENAME; nextfile }' **/*.rb); do
echo $file
sed -i 1i'# encoding: utf-8' $file
soulcutter / gist:3873662
Created Oct 11, 2012
Spring ActiveProfiles injection question
View gist:3873662
// Question: Can you do something like this without using interface-based injection?
public class FakeDownloadUtilTest extends BaseTest {
DownloadUtil downloadUtil;
public void testFaked() {
soulcutter / gist:4003852
Created Nov 2, 2012
Installing savon under jruby 1.6.3
View gist:4003852
➜ ~ rvm install jruby-1.6.3
jruby-1.6.3 - #downloading jruby-bin-1.6.3, this may take a while depending on your connection...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 14.7M 100 14.7M 0 0 459k 0 0:00:32 0:00:32 --:--:-- 410k
jruby-1.6.3 - #extracting jruby-bin-1.6.3 to /Users/brschaefer/.rvm/src/jruby-1.6.3
jruby-1.6.3 - #extracted to /Users/brschaefer/.rvm/src/jruby-1.6.3
Building Nailgun
jruby-1.6.3 - #installing to /Users/brschaefer/.rvm/rubies/jruby-1.6.3
jruby-1.6.3 - adjusting #shebangs for (jrubyc jirb_swing jirb jgem rdoc ri spec autospec testrb ast generate_yaml_index.rb).
You can’t perform that action at this time.