Skip to content

Instantly share code, notes, and snippets.

View yalestar's full-sized avatar

Hank Radstar yalestar

View GitHub Profile
@yalestar
yalestar / consecu_dates.rb
Created February 6, 2012 22:46
Find the longest streak of consecutive dates
dates = thing.order("created_at DESC").map(&:created_at)
longest = 1
streaks = []
return 0 if dates.nil? || dates.empty?
dates.each_with_index do |d, idx|
unless (idx == dates.size - 1)
d1 = dates[idx]
@yalestar
yalestar / gist:1054190
Created June 29, 2011 16:08 — forked from watsoncj/gist:1005449
pre-commit hook to prevent me from accidentally checking in debug code
#!/bin/sh
#
# This hook prevents you from committing any file containing "debugger".
#
# To enable this hook, rename this file to ".git/hooks/pre-commit".
DIFF_FILES=`git diff-index HEAD --cached --name-only`
if [ $? -ne 0 ]
then