Skip to content

Instantly share code, notes, and snippets.

View stormbrew's full-sized avatar

stormbrew stormbrew

  • Edmonton, Alberta, Canada
View GitHub Profile
@stormbrew
stormbrew / coroutine.c9s
Created September 10, 2011 00:29
Ridiculously contrived coroutine example for Channel9
var ho
var hi = () {
var cont = ho
var count = 0
while (count != 1000) {
"hi " + count.to_string_primitive -> $stdout
// send count + 1 to cont, save its return address in cont
count = (count + 1 -> cont : cont)
}
}
@stormbrew
stormbrew / gist:1184811
Created August 31, 2011 21:47
my tmux config
set -g prefix C-a
unbind C-b
bind a send-prefix
bind C-a last-window
unbind %
bind | split-window -h
bind - split-window -v
set-window-option -g window-status-current-bg red
#<ExchangeBitcoins::Trade:0xa7d4 @id=3766 @date=Wed Jul 06 10:09:29 -0700 2011 @amount=0.2124 @price=15.69>,
211 + #<ExchangeBitcoins::Trade:0xa7ec @id=3767 @date=Wed Jul 06 10:09:30 -0700 2011 @amount=0.2612 @price=15.69>,
212 #<ExchangeBitcoins::Trade:0xa7dc @id=3769 @date=Wed Jul 06 10:09:30 -0700 2011 @amount=5.181 @price=15.69>,
213 #<ExchangeBitcoins::Trade:0xa7e4 @id=3768 @date=Wed Jul 06 10:09:30 -0700 2011 @amount=0.3246 @price=15.69>,
214 - #<ExchangeBitcoins::Trade:0xa7ec @id=3767 @date=Wed Jul 06 10:09:30 -0700 2011 @amount=0.2612 @price=15.69>,
215 #<ExchangeBitcoins::Trade:0xa7f4 @id=3770 @date=Wed Jul 06 10:09:57 -0700 2011 @amount=4.629 @price=15.69>,
class Y; end
class X
class Y; end
end
class X::Z
puts self, Y # Guess the output.
end
class Z
end
class B
puts self, Z # => "B, Z"
end
class A
class Z; end
class ::B
@stormbrew
stormbrew / gist:863096
Created March 9, 2011 21:58
Benchmark of faster version of Hash#reject.
graham-battys-macbook:rubinius-master graham (perf-hash)$ bin/rbx benchmark/bin/benchmark -tx -tr benchmark/core/hash/bench_reject.rb
=== bin/rbx ===
reject string 91940.6 (±14.1%) i/s - 445500 in 5.020721s (cycle=2750)
reject numbers 220166.2 (±7.9%) i/s - 1092648 in 4.999565s (cycle=10308)
reject! string 94992.6 (±7.4%) i/s - 476934 in 5.052189s (cycle=5482)
reject! numbers 199148.9 (±6.9%) i/s - 995456 in 5.025582s (cycle=11312)
=== ruby ===
reject string 51115.8 (±12.1%) i/s - 252488 in 5.011600s (cycle=3412)
reject numbers 63331.0 (±12.9%) i/s - 311360 in 5.005070s (cycle=3892)
reject! string 98969.8 (±11.5%) i/s - 492195 in 5.039376s (cycle=5181)
# A tree structure that contains parse error messages. This can be used to
# give the user a detailed report on what went wrong during a parse.
#
class(Parslet) ErrorTree: {
# The parslet that caused the error stored here.
attr_reader(parslet)
# All errors that were encountered when parsing part of this +parslet+.
attr_reader(children)
def initialize:(parslet, *children) { # :nodoc:
backend neogaf_user {
.host = "php2";
.port = "80";
.max_connections = 200;
.connect_timeout = 600s;
.first_byte_timeout = 600s;
.between_bytes_timeout = 600s;
}
/*backend neogaf_guest {
.host = "php2";
% cumulative self self total
time seconds seconds calls ms/call ms/call name
------------------------------------------------------------
4.10 0.88 0.88 140000 0.01 0.01 Rubinius::VM.reset_method_cache
4.08 2.02 0.88 530001 0.00 0.00 Hash#find_entry
3.83 2.09 0.83 60000 0.01 0.03 String#tr_trans
2.37 0.65 0.51 557501 0.00 0.00 Hash::Entry#match?
2.10 0.55 0.45 100000 0.00 0.01 Hash::Iterator#next
1.99 0.57 0.43 800000 0.00 0.00 Type.coerce_to
1.79 0.83 0.39 200000 0.00 0.00 Rubinius::Tuple#dup
% cumulative self self total
time seconds seconds calls ms/call ms/call name
------------------------------------------------------------
4.08 1.77 1.51 3646050 0.00 0.00 Kernel#===
3.35 1.79 1.24 700613 0.00 0.00 Array#[]
2.77 4.50 1.02 144276 0.01 0.03 String#each_byte
2.60 0.95 0.96 145632 0.01 0.01 Rubinius::VM.reset_method_cache
2.53 1.45 0.94 316669 0.00 0.00 String#[]
2.52 2.13 0.93 546247 0.00 0.00 Hash#find_entry
2.26 2.18 0.84 60606 0.01 0.04 String#tr_trans