Skip to content

Instantly share code, notes, and snippets.

Writing Commit Messages

One line summary (< 50c)

Longer description (wrap at 72c)

Summary

@nwjsmith
nwjsmith / proc_composition.rb
Created September 22, 2010 18:12 — forked from headius/proc_composition.rb
Composable procs
class Proc
def <<(other)
case other
when Proc
Proc.new do |*args|
call(other.call(*args))
end
else
call(other)
end
" 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
- 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|
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
vim_plugin_task "gundo", "git://github.com/sjl/gundo.vim.git"
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}') )"
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
#!/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
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