Skip to content

Instantly share code, notes, and snippets.

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 November 18, 2010 23:03
BEST TEST EVER!
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)
@robotarmy
robotarmy / MemoryWatch.rb
Created November 18, 2010 23:12
simple effective
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 December 2, 2010 06:51
OpenBSD support for RVM
--- 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")
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 January 17, 2011 00:46
strange animation - what is happening to the machine?
.arm
.align
.global initSystem
.global main
initSystem:
bx lr
main:
mov r0,#0x04000000 @ I/O space offset
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)"
@robotarmy
robotarmy / main.s
Created February 28, 2011 00:52
..
.arm
.align
.global initSystem
.global main
.mdata:
@ 4bytes *8
.word 0x4430
.word 0x4430
.word 0x4430
@robotarmy
robotarmy / javascript-instance-based-inheritance-v8console.txt
Created March 14, 2011 18:23
javascript-instance-based-inheritance-v8console.js
> a = function() {}
function () {}
> print(a)
function () {}
> b = function(){}
function (){}
> b.prototype = a
function () {}
> a.my_hi = function() { print('my_hi') }
function () { print('my_hi') }
require 'spec_helper'
describe FeedbackController do
describe "actions" do
it "#create" do
questions = ['what do you like most?','what is your favorite colour?'],
answers = ['I like life!', 'I like green'],
comment = %%Blue is also nice, Red is the colour of blood, tomatoes,
and sunsets over the ocean when the light is just right%,
page_url = %%http://url%