This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example code and benchmark harness for http://blog.gregspurrier.com/articles/arbitrary-reordering-of-ruby-arrays | |
require 'rubygems' | |
require 'rspec' | |
module Enumerable | |
def reorder_by1(order, &key_proc) | |
order.map do |x| | |
find {|obj| key_proc.call(obj) == x} | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Benchmark code an results for: | |
# http://blog.gregspurrier.com/articles/relative-performance-of-symbol-to-proc-in-popular-ruby-implementations | |
require 'benchmark' | |
class Dummy | |
def one | |
1 | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gspurrie-mn:~% rvm --version | |
rvm 1.6.2 by Wayne E. Seguin ([email protected]) [https://rvm.beginrescueend.com/] | |
gspurrie-mn:~% rvm install ree-1.8.6 | |
Installing Ruby Enterprise Edition from source to: /Users/gspurrie/.rvm/rubies/ree-1.8.6-20090610 | |
ree-1.8.6-20090610 - #fetching (ruby-enterprise-1.8.6-20090610) | |
ree-1.8.6-20090610 - #extracting ruby-enterprise-1.8.6-20090610 to /Users/gspurrie/.rvm/src/ree-1.8.6-20090610 | |
ree-1.8.6-20090610 - #installing | |
Removing old Rubygems files... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gspurrie-mn:proj% rvm use ruby-1.8.7@rspec_bug --create | |
Using /Users/gspurrie/.rvm/gems/ruby-1.8.7-p352 with gemset rspec_bug | |
gspurrie-mn:proj% gem install bundler | |
Fetching: bundler-1.0.21.gem (100%)1.0.21.gem | |
Successfully installed bundler-1.0.21 | |
1 gem installed | |
Installing ri documentation for bundler-1.0.21... | |
Installing RDoc documentation for bundler-1.0.21... | |
gspurrie-mn:proj% gem install rails |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Hash | |
# Returns a new hash that does not contain the specified keys | |
# | |
# {:a => 1, :b => 2, :c =>3, :d => 4}.without(:a, :b) | |
# => {:c=>3, :d=>4} | |
def without(*keys) | |
dup.tap { |h| keys.each { |k| h.delete(k) } } | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Atoms: | |
a string | |
is self-evaluating | |
a symbol | |
is self-evaluating | |
may include any of the legal characters for symbol | |
may begin with any legal character other than a digit | |
may not begin with a digit | |
numbers |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Testing KLamba specification compliance of: | |
Shen 2010, copyright (C) 2010 Mark Tarver | |
released under the Shen license | |
www.shenlanguage.org, version 11 | |
running under Common Lisp, implementation: CLisp | |
port 1.5 ported by Mark Tarver | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
= Some document | |
== Huzzah | |
[source,ruby] | |
---- | |
# This should be ruby code | |
1.times do | |
puts "hello world" | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.collection.immutable.Queue | |
val q = Queue(1, 2, 3) | |
// When pattern matching against a sequence, the sequence wildcard _* | |
// can be used as the last pattern and will match an arbitrary number of | |
// elements. To bind the matched sequence to a variable, use the form | |
// `x @ _*`: | |
val restSeq = q match { case Queue(x, xs @ _*) => xs } | |
// --> rest: Seq[Int] = Queue(2, 3) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Send the paste-buffer to the open command | |
bind u run-shell "tmux show-buffer | xargs open" |
OlderNewer