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
# Configuration file for the slate window management tool for OS X. | |
# For more information see: https://github.com/jigish/slate | |
# | |
# Config by Nathan Fritz. Updated 2014-01. | |
# settings {{{ | |
# | |
# instruct slate to base nudges and resizes on current screensize and to | |
# use an 8x8 grid for the layout popup | |
# |
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
# put the following function into .bash_profile or .bashrc to evaluate this file | |
# function go { `awk -v val=^$1$ '$1!~/^[:space:]*#/ && $1~val { print "cd "$2 }' ~/.go_shortcuts`; } | |
sample /some/deep/directory/to/link/to |
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 Tapper | |
attr_reader :eavesdroppers | |
def initialize(source, *eavesdroppers) | |
@source = source | |
@eavesdroppers = eavesdroppers | |
end | |
def method_missing(method, *args) | |
if @source.respond_to?(method) |
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
require 'spec_helper' | |
describe 'Random numbers' do | |
it 'fails every time' do | |
numbers = 10.times.map { rand(100) } | |
numbers.join(', ').should eq 'the Tardis' | |
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
require 'spec_helper' | |
describe 'unintended sequence' do | |
before(:all) do | |
@x = {a: 1, b: 2} | |
end | |
it 'modifies the array' do | |
@x[:a] = 2 | |
@x[:a].should eq 2 |
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
# settings {{{ | |
config defaultToCurrentScreen true | |
config nudgePercentOf screenSize | |
config resizePercentOf screenSize | |
alias gridSize 8,8 | |
alias c (screenSizeX/8) | |
alias r (screenSizeY/8) | |
#}}} |
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
STATUS_TYPES = Hash.new {|this_hash,missing_key| | |
found_key = this_hash.keys.find {|this_key| this_key.class == Range && this_key.include?(missing_key) } | |
found_key ? this_hash[missing_key] = this_hash[found_key] : :undefined | |
}.merge({ | |
200..208 => :success, | |
500..511 => :server_error | |
}) | |
STATUS_TYPES.keys # => [200..208, 500..511] | |
STATUS_TYPES[200] # => :success |
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
STATUS_TYPES = { | |
200..208 => :success, | |
500..511 => :server_error | |
} | |
STATUS_TYPES[200] # => nil |
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
STATUS_MESSAGES = Hash.new(:undefined).merge({ | |
200 => :ok, | |
201 => :created, | |
202 => :accepted | |
} | |
STATUS_MESSAGES[200] # => :ok | |
STATUS_MESSAGES[999] # => :undefined |
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
STATUS_MESSAGES = { | |
200 => :ok, | |
201 => :created, | |
202 => :accepted | |
} | |
STATUS_MESSAGES[200] # => :ok | |
STATUS_MESSAGES[999] # => nil |