Skip to content

Instantly share code, notes, and snippets.

@mckeed
mckeed / dark_sky_growler.rb
Created April 21, 2013 20:07
My script to use the DarkSky API to tell me when it's going to start raining in the next hour. When I bike to work, I run this on a launchd job every 10 minutes from 4:00-6:00.
#! /usr/bin/env ruby
# encoding: UTF-8
require 'rubygems'
require 'active_support/core_ext'
require 'rest_client'
require 'json' unless defined?(JSON)
require 'growl'
API_KEY = ENV["DARKSKY_API_KEY"]
@mckeed
mckeed / post-merge
Created June 8, 2012 20:05
A useful post-merge git hook for Rails projects. Automatically runs bundle install and rake db:migrate. Put it in .git/hooks
#!/bin/bash
if [ ! -z `git diff --name-only HEAD@{1}..HEAD Gemfile` ]
then
echo -e "\033[0;31m*** Gemfile change detected, running bundle install ***\033[0m"
bundle install
fi
if [ ! -z `git diff --name-only HEAD@{1}..HEAD db/migrate` ]
then
@mckeed
mckeed / strong_parameters.rb
Created June 5, 2012 22:24
Before filters to make rails/strong_parameters work with CanCan's load_resource or load_and_authorize_resource.
require 'strong_parameters'
class ActiveRecord::Base
include ActiveModel::ForbiddenAttributesProtection
end
class ActionController::Base
# Use this with CanCan's load_resource to permit a set of params before
# it tries to build or update a resource with them.
javascript:document.getElementsByTagName("tbody")[0].deleteRow(-1);document.getElementsByTagName("tbody")[0].deleteRow(0)