Skip to content

Instantly share code, notes, and snippets.

View bakineggs's full-sized avatar

Dan Barry bakineggs

View GitHub Profile
<html>
<head>
<title>
Test Observers
</title>
<style type="text/css">
#tests .test.observed {
background-color: #0f0;
}
#tests .test.error {
@bakineggs
bakineggs / gist:956682
Created May 5, 2011 07:41
prettier syntax for K
see https://gist.github.com/369171
# spawn new thread
Thread: # node must be matched
K:: # node must be matched, the :: means that children are ordered (default is unordered)
-Spawn: # node must be matched, the - means that this node will be removed
*: S # makes S a variable that is any kind of node (makes a variable because it's a matched node)
Env: E
+Thread: # node not matched against, the + means this node will be added
K::
[01:00:53] dan ~ $ long_process # so i got the prompt at 1:00:53
Some program output
[03:07:24] dan ~ $ # finished at 3:07:24, but what time did I hit enter?
class Module
def trace_callers method
alias_method :"#{method}_without_trace", method
define_method method do |*args, &blk|
puts "Invocation of #{method}:"
puts caller.map {|line| " #{line}"}
send :"#{method}_without_trace", *args, &blk
end
end
end
module Enumerable
def sum
inject(0) {|s, v| s + v}
end
def avg
sum / length
end
end
<html>
<head>
<script type="text/javascript">
// the function we're actually testing
function mark(range) {
}
function assert(func) {
var result;
try { result = func(); } catch(e) {}
Gibran-Sloanes-MacBook-Pro:Solace Fathom$ df -h
Filesystem Size Used Avail Capacity Mounted on
/dev/disk0s3 47Gi 13Gi 35Gi 27% /
devfs 108Ki 108Ki 0Bi 100% /dev
map -hosts 0Bi 0Bi 0Bi 100% /net
map auto_home 0Bi 0Bi 0Bi 100% /home
/dev/disk0s2 250Gi 243Gi 7.4Gi 98% /Volumes/Solace
Gibran-Sloanes-MacBook-Pro:Solace Fathom$ sudo du -hs /Volumes/Solace
Password:
164G /Volumes/Solace
# hack written for rspec 1.3.0
# lets you Ctrl-c to cancel tests in progress and get partial results from those that have run
# for rspec 2.0, see http://gist.github.com/473157
trap 'INT' do
module Spec::Example::ExampleMethods
def execute(run_options, instance_variables); end
end
module Spec::Example::BeforeAndAfterHooks
def before_each_parts; [] end
# hack written for rspec 2.0.0.beta.17
# lets you Ctrl-c to cancel tests in progress and get partial results from those that have run
# for rspec 1.3.0, see http://gist.github.com/473175
trap 'INT' do
class RSpec::Core::Example
def run(example_group_instance, reporter); end
end
raise 'Interrupted before example finished'
end
# some blackjack tables in Vegas were standing on soft 17, so it made me wonder what were the probable outcomes of hitting soft 17. if you want to see the possible outcomes of a different starting scenario, change the initial contents of "processing"
class Deck
def initialize counts = nil, total = nil
unless counts.nil?
@counts = counts
@total = total
return
end
@counts = {}