View mspec stricter
This file contains 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
diff --git a/lib/mspec/expectations/should.rb b/lib/mspec/expectations/should.rb | |
index 6a37401..6cd7030 100644 | |
--- a/lib/mspec/expectations/should.rb | |
+++ b/lib/mspec/expectations/should.rb | |
@@ -1,8 +1,9 @@ | |
class Object | |
- def should(matcher=nil) | |
+ NO_MATCHER_GIVEN = Object.new | |
+ def should(matcher=NO_MATCHER_GIVEN) | |
MSpec.expectation |
View Enumerator#size combined
This file contains 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
diff --git a/array.c b/array.c | |
index 51d3ad2..29f2ca0 100644 | |
--- a/array.c | |
+++ b/array.c | |
@@ -22,7 +22,7 @@ | |
VALUE rb_cArray; | |
-static ID id_cmp; | |
+static ID id_cmp, id_div, id_power; |
View gitlinestat.rb
This file contains 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
#!/usr/bin/env ruby | |
# A simple script to get stats on number of lines added/removed per commit | |
# Accepts -v option for verbose mode | |
# Accepts other git options, in particular path. | |
# | |
# E.g.: | |
# | |
# linestat -v app lib |
View gist:3422303
This file contains 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
# Hi # Hi | |
# For this interview, we'd like you to | |
# Write fizz buzz | |
# Ok: | |
def go | |
fizzy = ->(n){ n % 3 == 0 } | |
buzzy = ->(n){ n % 5 == 0 } | |
fizzbuzzy = ->(n){ n % 15 == 0 } |
View gist:3498470
This file contains 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
# Prompt | |
function parse_git_branch { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/' | |
} | |
function proml { | |
local BLUE="\[\033[0;34m\]" | |
local RED="\[\033[0;31m\]" | |
local LIGHT_RED="\[\033[1;31m\]" | |
local GREEN="\[\033[0;32m\]" |
View gist:3498506
This file contains 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
#!bash | |
# | |
# bash/zsh completion support for core Git. | |
# | |
# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org> | |
# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/). | |
# Distributed under the GNU General Public License, version 2.0. | |
# | |
# The contained completion routines provide support for completing: | |
# |
View billion.rb
This file contains 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
# We deal with the problem by writing classes of numbers in tree form. | |
# Leaves can be a specific number (Centile), a generic centile (GenericValue) or a subtree (another GenericNumber). | |
# Each such GenericNumber can be expanded one level by replacing the leftmost GenericValue by specific values. | |
# This is done using GenericNumber.each; the other important method is children, which calculates recursively | |
# information about all the children: sum, size of strings, number. | |
# All language dependent constants: | |
TO_TWENTY = { 0 => '', 1 => 'one', 2 => 'two', 3 => 'three', 4 => 'four', | |
5 => 'five', 6 => 'six', 7 => 'seven', 8 => 'eight', 9 => 'nine', | |
10 => 'ten', 11 => 'eleven', 12 => 'twelve', 13 => 'thirteen', 14 => 'fourteen', |
View digest.rb
This file contains 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
# Quick and dirty script to compare builtin methods between two rubyies | |
# Usage: | |
# | |
# ruby_old digest.rb | ruby_new digest.rb | |
def class_signature(klass) | |
Hash[ | |
{instance: klass, singleton: klass.singleton_class}.to_a | |
.product([:private, :public, :protected]) | |
.map{ |(level, obj), access| ["#{access} #{level} methods", obj.send("#{access}_instance_methods", false)] } |
View gist:5028319
This file contains 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
$ rvm install rbx --debug | |
rbx - install | |
Searching for binary rubies, this might take some time. | |
Remote file does not exist https://rvm.io/binaries/osx/10.6/i386/rbx-head.tar.bz2 | |
Remote file does not exist http://jruby.org.s3.amazonaws.com/downloads/rbx-head.tar.bz2 | |
Remote file does not exist http://binaries.rubini.us/osx/10.6/i386/rbx-head.tar.bz2 | |
rvm_remote_server_url3 not found | |
No remote file name found | |
No binary rubies available for: osx/10.6/i386/rbx-head. | |
Continuing with compilation. Please read 'rvm mount' to get more information on binary rubies. |
View caller_locations_benchmark.rb
This file contains 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
require 'fruity' | |
def whoze_there_using_caller | |
caller[0][/`([^']*)'/, 1] | |
end | |
def whoze_there_using_locations | |
caller_locations(1,1)[0].label | |
end |
OlderNewer