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
#.gvimrc.local | |
" Cancel the current search hightlight | |
nnoremap <esc> :noh<return><esc> | |
set guifont=Mensch:h12 | |
--- | |
#.vimrc.local | |
map <Leader>nf :NERDTreeFind<CR> |
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 'rubygems' | |
require 'rspec' | |
require 'benchmark' | |
class FifoQueue | |
def push(item) | |
if (@head.nil? && @tail.nil?) | |
@head = @tail = Wrapper.new(item) | |
else |
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
mario:(git)strangeloop[master]/$ git push origin master | |
Counting objects: 9, done. | |
Delta compression using up to 2 threads. | |
Compressing objects: 100% (5/5), done. | |
Writing objects: 100% (5/5), 445 bytes, done. | |
Total 5 (delta 4), reused 0 (delta 0) | |
remote: Push worked, but post-receive failed: Connection reset by peer | |
remote: /data/github/current/vendor/gems/ruby/1.8/gems/redis-2.2.0/lib/redis/client.rb:234:in `ensure_connected' | |
remote: /data/github/current/vendor/gems/ruby/1.8/gems/redis-2.2.0/lib/redis/client.rb:114:in `process' | |
remote: /data/github/current/vendor/gems/ruby/1.8/gems/redis-2.2.0/lib/redis/client.rb:183:in `logging' |
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 'test/unit' | |
def chop(num, arr) | |
return -1 if arr.empty? | |
return -1 unless num <= arr.last | |
return -1 unless num >= arr.first | |
seek = lambda do |lower, upper| | |
next_index = (upper - lower) / 2 | |
val = arr[next_index] | |
return next_index if val == num |
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 'test/unit' | |
class List | |
def add(item) | |
new_item = Item.new(item, @tail) | |
@tail = new_item | |
end | |
def delete(item) | |
if item == @tail |
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 'test/unit' | |
TempRecord = Struct.new(:index, :high, :low) | |
class TempRecord | |
def <=>(record) | |
(high - low).<=>(record.high - record.low) | |
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
class GroupOfThingies | |
attr_accessor :thingies | |
# Use like this: | |
# | |
# group_of_thingies = GroupOfThingies.new | |
# group_of_thingies.each do |thing| | |
# puts "Check out this awesome thing: #{thing}!" | |
# 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
In the example, I can run: | |
$> rspec . --tag "2" | |
or | |
$> rspec . --tag 2 | |
and it will find the test I want. The others are unreachable via tag. |
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 Profile | |
def initialize(email) | |
self.class.send :define_method, :email, -> { email } | |
end | |
end | |
p = Profile.new '[email protected]' | |
p.email #=> '[email protected]' | |
p.email = '[email protected]' #=> <boom> | |
p.instance_variable_set :@email, '[email protected]' |
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 Profile | |
def initialize(email) | |
email_val = email.dup.freeze | |
self.class.send :define_method, :email, -> { email_val } | |
end | |
end |