One line summary (< 50c)
Longer description (wrap at 72c)
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
class Proc | |
def <<(other) | |
case other | |
when Proc | |
Proc.new do |*args| | |
call(other.call(*args)) | |
end | |
else | |
call(other) | |
end |
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
" I'm so over vi | |
set nocompatible | |
" The one true encoding | |
set encoding=utf-8 | |
" We have a fast connection | |
set ttyfast | |
" I back up other ways |
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
- form_for interviewer do |f| | |
= f.error_messages | |
= f.label :name, "What is their name?" | |
= f.text_field :name | |
#languages | |
= f.label :languages, "What languages do they speak?" | |
- f.fields_for :speaks_language do |language_fields| |
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 'spec_helper' | |
require 'stringio' | |
describe BloomFilter, '#collision?' do | |
subject { object.collision?(word) } | |
let(:dictionary) { Dictionary.new } | |
let(:object) { described_class.new(dictionary) } | |
context 'checked with a filtered word' do |
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
vim_plugin_task "gundo", "git://github.com/sjl/gundo.vim.git" |
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 'nokogiri' | |
require 'yaml' | |
kml_path = File.join(File.dirname(__FILE__), 'FloodLine_x5.kml') | |
File.open(kml_path) do |f| | |
kml = Nokogiri::XML(f) | |
kml.xpath('//ns:MultiGeometry', {'ns' => "http://www.opengis.net/kml/2.2"}).each do |polygon| | |
escaped_geometry = con.escape_string(polygon.to_s) | |
con.exec "INSERT INTO flood_zones VALUES( ST_GEOMFROMKML('#{escaped_geometry}') )" |
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
pyths :: Int -> [(Int, Int, Int)] | |
pyths n = [(x, y, z) | x <- [1..n], y <- [1..n], z <- [1..n], arePyths x y z] | |
where arePyths x y z = x ^ 2 + y ^ 2 == z ^ 2 |
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
#!/bin/sh | |
set -e | |
last_commit_time="$(git log --pretty=format:'%at' -1)" | |
current_time="$(date +%s)" | |
((minutes_since_last_commit=($current_time - $last_commit_time) / 60)) | |
# Color Green/Yellow/Red depending on the amount of time since the last commit |
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
describe '#chunk' do | |
def chunk(arr) | |
arr.inject([]) do |chunks, elem| | |
current_sequence = chunks.last || [] | |
if elem == current_sequence.last | |
current_sequence << elem | |
else | |
chunks << [elem] | |
end | |
chunks |