Skip to content

Instantly share code, notes, and snippets.

@robotarmy
robotarmy / Fake Web Helper.rb
Created Jul 9, 2010
Cache Fake Web Content to Disk and Register a URI
View Fake Web Helper.rb
# Example
# fan = Factory(:fan)
# FakeWeb.register(:get,"http://www.google.com/",fan.class)
# fan.visit_google #successive calls read cache
#
# recommended to put into spec/support
#
require 'fakeweb'
require 'open-uri'
View gist:628697
test "has one user status" do
r = make_review_with_book
assert {
r.user_status == nil
}
us = UserStatus.make(:user => r.user, :book => r.book)
assert {
r.user_status.user == r.user
}
us2 = UserStatus.make(:user => r.user, :book => r.book)
View gist:628698
test "has one user status" do
r = make_review_with_book
assert {
r.user_status == nil
}
us = UserStatus.make(:user => r.user, :book => r.book)
assert {
r.user_status.user == r.user
}
us2 = UserStatus.make(:user => r.user, :book => r.book)
@robotarmy
robotarmy / gist:705850
Created Nov 18, 2010
BEST TEST EVER!
View gist:705850
require 'test/unit'
require 'rubygems'
require 'wrong'
require 'wrong/adapters/test_unit'
require 'memory_watch'
class MemoryWatchTest < Test::Unit::TestCase
def test_watches_self
cmd = %q{ruby memory_watch.rb --delay 999999 --num_cycles 9900000099}
pid = fork { %x{#{cmd}} }
Process.detach(pid)
View MemoryWatch.rb
class MemoryWatch
attr_accessor :watch_string,:high_water_pids,:callback,:high_water_mb,:delay,:num_cycles,:num_over_marks,:pids
def initialize(options)
self.callback = options[:callback] || lambda {|pid| p pid}
self.watch_string = (options[:watch] || "this poem is a pomme").strip
self.delay = options[:delay] || 60
self.num_cycles = options[:num_cycles] || 3
self.num_over_marks = options[:num_over_marks] || 2
self.high_water_mb = options[:high_water_mb] || 700
self.high_water_pids = {}
@robotarmy
robotarmy / gist:724906
Created Dec 2, 2010
OpenBSD support for RVM
View gist:724906
--- no-obsd Fri Dec 3 15:45:25 2010
+++ with-obsd Fri Dec 3 15:44:13 2010
@@ -42,6 +42,7 @@
echo "Creating the group '$1'"
case "$os_type" in
+ "OpenBSD") groupadd "$rvm_group_name";;
"FreeBSD") pw groupadd -q "$rvm_group_name";;
"Linux") groupadd -f "$rvm_group_name";;
"Darwin")
View ConsoleOut.txt
o_o:bunuq/ (master✗) $ vows test/unit/speak_to_test.js --spec
♢ SpeakTo
EVENT EMIT
no args
✓ nothing happens
no messages
✓ nothing happens
EVENT EMIT
TOPIC
@robotarmy
robotarmy / nintendo-ds.s
Created Jan 17, 2011
strange animation - what is happening to the machine?
View nintendo-ds.s
.arm
.align
.global initSystem
.global main
initSystem:
bx lr
main:
mov r0,#0x04000000 @ I/O space offset
View gist:845722
o_o:~/ $ rvm info [15:00:39]
__rvm_rm_rf:local:2: path: can't assign initial value for array
system:
system:
uname: "Darwin nancydrew 10.6.0 Darwin Kernel Version 10.6.0: Wed Nov 10 18:13:17 PST 2010; root:xnu-1504.9.26~3/RELEASE_I386 i386 i386"
bash: "/bin/bash => GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin10.0)"
zsh: "/bin/zsh => zsh 4.3.9 (i386-apple-darwin10.0)"
View main.s
.arm
.align
.global initSystem
.global main
.mdata:
@ 4bytes *8
.word 0x4430
.word 0x4430
.word 0x4430