Skip to content

Instantly share code, notes, and snippets.

View simonbaird's full-sized avatar
💭
🤔

Simon Baird simonbaird

💭
🤔
View GitHub Profile
@simonbaird
simonbaird / gist:663503
Created November 5, 2010 01:16
Little bash script to nuke a branch in git
#
# https://gist.github.com/663503
#
# Use this to clean your repo by removing old branches.
# It will remove the branch on local and on origin.
#
# Usage:
# $ nuke_branch some_old_branch_you_dont_need
#
# Note we use -d not -D for teh safety.
[Development]>> puts Time.now; (-5..5).each { |w| t = Time.now + w.weeks; puts "now and #{'%2d'%w} weeks: #{t.beginning_of_fortnight} - #{t.end_of_fortnight}" }; nil
Wed Oct 06 16:29:52 +1000 2010
now and -5 weeks: Mon Aug 30 00:00:00 +1000 2010 - Sun Sep 12 23:59:59 +1000 2010
now and -4 weeks: Mon Aug 30 00:00:00 +1000 2010 - Sun Sep 12 23:59:59 +1000 2010
now and -3 weeks: Mon Sep 13 00:00:00 +1000 2010 - Sun Sep 26 23:59:59 +1000 2010
now and -2 weeks: Mon Sep 13 00:00:00 +1000 2010 - Sun Sep 26 23:59:59 +1000 2010
now and -1 weeks: Mon Sep 27 00:00:00 +1000 2010 - Sun Oct 10 23:59:59 +1000 2010
now and 0 weeks: Mon Sep 27 00:00:00 +1000 2010 - Sun Oct 10 23:59:59 +1000 2010
now and 1 weeks: Mon Oct 11 00:00:00 +1000 2010 - Sun Oct 24 23:59:59 +1000 2010
now and 2 weeks: Mon Oct 11 00:00:00 +1000 2010 - Sun Oct 24 23:59:59 +1000 2010
#
# Use this in models for status codes etc. Will dynamically create a class constant
# for each row in the table. The name of the constant will be based on the field specified.
# Typically it would be code, though name might be useful in some cases.
#
# This will build the constants once on rails startup. It only hits the database once, the find(:all),
# so should be reasonably efficient as long as it's used for small tables only.
#
# Put this in lib/create_id_constants.rb
#
@simonbaird
simonbaird / phpa.php
Created February 12, 2010 02:25
Nicer handling of exceptions. See http://david.acz.org/phpa/
#!/usr/local/bin/php -qC
<?
/*
$Id: phpa.php 2008/04/28 $
David Phillips <[email protected]>
*/
__phpa__setup();
__phpa__print_info();