Skip to content

Instantly share code, notes, and snippets.

Avatar
🌈
It's complicated?

Ryan Davis zenspider

🌈
It's complicated?
View GitHub Profile
@zenspider
zenspider / register.rb
Created Jul 31, 2011 — forked from postmodern/register.rb
not hard and not terribly useful.
View register.rb
#!/usr/bin/ruby -w
require 'rubygems'
require 'minitest/autorun'
# From: http://rubylearning.com/blog/2011/07/28/how-do-i-test-my-code-with-minitest/
class CashRegister
attr_reader :items
@zenspider
zenspider / gist:1119075
Created Aug 1, 2011 — forked from deanh/gist:1112154
Get some jamz
View gist:1119075
#!/bin/bash
PARTY_DIR=subpop_cascadia
command -v curl || (echo "No curl in path." && exit 1)
mkdir -p $PARTY_DIR
cd $PARTY_DIR
curl https://s3.amazonaws.com/subpop-public/assets/audio/JAMIFEST.txt | sort -n | xargs -P 4 -n 1 curl -O
@zenspider
zenspider / unit.diff
Created Nov 29, 2011
Current version of tagged filtering
View unit.diff
diff -r old/lib/minitest/unit.rb new/lib/minitest/unit.rb
--- old/lib/minitest/unit.rb
+++ new/lib/minitest/unit.rb
@@ -880,6 +880,10 @@
options[:filter] = a
end
+ opts.on '--tags DIR', "Load tag files from DIR to filter tests." do |a|
+ ENV['TAG_BASE'] = a
+ end
@zenspider
zenspider / mock.diff
Created Apr 27, 2012
change minitest/mock to use indexed access to expected_calls. Big semantic difference but seems more understandable
View mock.diff
diff -r old/lib/minitest/mock.rb new/lib/minitest/mock.rb
--- old/lib/minitest/mock.rb
+++ new/lib/minitest/mock.rb
@@ -78,25 +78,30 @@
[sym, @expected_calls.keys.sort_by(&:to_s)]
end
- expected_calls = @expected_calls[sym].select { |call| call[:args].size == args.size }
+ index = @actual_calls[sym].length
+ expected_call = @expected_calls[sym][index]
View sausage.scm
(use posix)
(define (make-serialport file)
(let ((fileno
(file-open
file
(bitwise-ior open/rdwr open/noctty open/nonblock))))
; Enable blocking reads on the FD
(let ((current-fl (file-control fileno fcntl/getfl 0)))
View *vc-diff*.diff
diff --git a/Library/Formula/graphviz.rb b/Library/Formula/graphviz.rb
index 303fdb1..a790fd5 100644
--- a/Library/Formula/graphviz.rb
+++ b/Library/Formula/graphviz.rb
@@ -1,7 +1,15 @@
require 'formula'
+def with_option name
+ ARGV.include? "--with-#{name}" and not ARGV.include? "--without-#{name}"
+end
View ohmygems.sh
export ORIG_GEM_PATH=${GEM_PATH:-}
export ORIG_GEM_HOME=${GEM_HOME:-}
export ORIG_PATH=${PATH}
ohmygems() {
name=${1:-}
if [ -z "$name" ]; then
echo "usage: ohmygems <name or reset>"
echo
View Rakefile.rb
task :default => :testall
desc "haha"
task :make => "Makefile" do
sh "make -j 8 main"
end
def new_logfile
b, d, x = "test", File.basename(Dir.pwd), "txt"
n = Dir["#{b}.#{d}.*.#{x}"].map { |s| s[/\d+/].to_i }.max + 1 rescue 1
@zenspider
zenspider / gist:4305780
Created Dec 16, 2012
datamapper warnings
View gist:4305780
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -w -Ilib:bin:test:. -e 'require "rubygems"; gem "minitest"; require "minitest/autorun"; require "test/test_noms.rb"' --
/Users/ryan/Work/p4/zss/src/noms/dev/tmp/isolate/ruby-1.8/gems/dm-core-1.2.0/lib/dm-core/query/conditions/comparison.rb:278: warning: private attribute?
/Users/ryan/Work/p4/zss/src/noms/dev/tmp/isolate/ruby-1.8/gems/dm-core-1.2.0/lib/dm-core/resource/persistence_state.rb:40: warning: private attribute?
/Users/ryan/Work/p4/zss/src/noms/dev/tmp/isolate/ruby-1.8/gems/dm-core-1.2.0/lib/dm-core/associations/relationship.rb:433: warning: private attribute?
/Users/ryan/Work/p4/zss/src/noms/dev/tmp/isolate/ruby-1.8/gems/dm-core-1.2.0/lib/dm-core/associations/relationship.rb:436: warning: private attribute?
/Users/ryan/Work/p4/zss/src/noms/dev/tmp/isolate/ruby-1.8/gems/dm-core-1.2.0/lib/dm-core/associations/one_to_one.rb:67: warning: private attribute?
/Users/ryan/Work/p4/zss/src/noms/dev/tmp/isolate/ruby-1.8/gems/dm-core-1.2.0/lib/
View maglevbug01.rb
class X
def self.inherited klass
super
klass.boom!
end
def self.boom!
@anything = nil
end
end
You can’t perform that action at this time.