gem install rubyist-aasm
include AASM
brandon:six-emoji{master}$ rake spec | |
(in /usr/local/src/workspace/six-emoji) | |
....FFFFF.............................. | |
1) | |
NoMethodError in 'Emojicon should be creatable (sanity check)' | |
You have a nil object when you didn't expect it! | |
You might have expected an instance of Array. | |
The error occurred while evaluating nil.include? | |
/usr/local/src/workspace/six-emoji/spec/fixjour_builders.rb:6:in `__bind_1247435905_341143' |
# Execute a block +number+ times. Block should be a predicate (return true/false) | |
# | |
# Use procs/lambdas to define callbacks: | |
# :success => ... | |
# :retry => ... | |
# :failure => ... | |
def do_over(number, options = {}, &block) | |
options = { | |
:success => lambda { puts "SUCCESS" }, | |
:retry => lambda { puts "RETRY" }, |
class Object | |
TEST_FORMATTER_FILE_REGEX = /_formatter/ unless defined?(TEST_FORMATTER_FILE_REGEX) | |
alias :original_puts :puts | |
def puts(string ="") | |
if caller.first =~ TEST_FORMATTER_FILE_REGEX | |
super string | |
else | |
super string.to_s + "\s(#{caller.first.match(/(\w+\.\w+:\d+)|Rakefile:\d+/)[0]})" | |
end |
module Enumerable | |
def halve | |
midpoint = (size / 2.0).ceil | |
partition {|x| index(x) < midpoint} | |
end | |
end |
class Calc | |
MINUTE = 60 | |
HOUR = 3600 | |
DAY = 86400 | |
WEEK = 604800 | |
class << self | |
def time_of_day_weighted(value, time = Time.now.utc) | |
value.to_f * (time.seconds_since_midnight / DAY) | |
end |
Figure 4. Cornsweet effect makes identical regions look differently bright when separated by opposing luminance gradients that meet at an edge. Various stimuli, including a spinning black and white disk (a), can create this effect. The region adjacent to the lighter gradient appears brighter than the region next to the darker gradient (b), which is the opposite effect of the standard simultaneous brightness contrast. A graph of relative luminance (c) shows that the two areas on either side of the edge are physically identical, but a graph of the perception of brightness (d) indicates that the right side seems brighter than the left, which is the Cornsweet effect. Blocks showing the Cornsweet effect in a scene (e) enhance the illusion because the information presented increases the probability that the two blocks are differently reflective surfaces under different illuminants. The upper block now looks much darker than the lower one, even though they are identical. |
// set term png | |
// set xlabel 'Samples' | |
// set ylabel 'MB' | |
// set output 'name.png' | |
// plot | |
// "name.dat" using 1:($2/1e6) title 'Sys' with lines, | |
// "name.dat" using 1:($3/1e6) title 'Alloc' with lines, | |
// "name.dat" using 1:($4/1e6) title 'Idle' with lines | |
type chart struct { | |
filename string |
package main | |
import ( | |
"errors" | |
"fmt" | |
"time" | |
) | |
var realError = errors.New("real") | |
var timeoutError = errors.New("timeout") |
var uuidFunc = uuidV4 // for swapping in test | |
func uuidV4() string { | |
b := make([]byte, 16) | |
_, err := io.ReadFull(rand.Reader, b) | |
if err != nil { | |
panic(err) | |
} | |
b[6] = (b[6] & 0x0F) | 0x40 | |
b[8] = (b[8] &^ 0x40) | 0x80 |