Skip to content

Instantly share code, notes, and snippets.

View calebhaye's full-sized avatar

Caleb Adam Haye calebhaye

View GitHub Profile
@calebhaye
calebhaye / create_slugified_branch
Last active December 14, 2017 18:58
Ruby bash script to create a git branch from string STDIN
#!/usr/bin/env ruby -w
name = ARGV[0]
slug = name.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '')
system("git checkout -b #{slug}")
@calebhaye
calebhaye / active_record_bash_cli.rb
Created January 22, 2016 22:54
Rails from Bash / Shell
#!/usr/bin/env ruby
begin
puts "Loading Rails..."
require File.join('.', 'config', 'application')
require File.join('.', 'config', 'boot')
Rails.application.require_environment!
rescue
$stderr.puts "Please run #{$0} in your Rails root."
exit 1
#!/bin/sh
#
# This hook does two things:
#
# 1. update the "info" files that allow the list of references to be
# queries over dumb transports such as http
#
# 2. if this repository looks like it is a non-bare repository, and
# the checked-out branch is pushed to, then update the working copy.
# This makes "push" function somewhat similarly to darcs and bzr.
@calebhaye
calebhaye / Garden.ino
Last active August 29, 2015 13:59
Arduino Garden
/* Pin Locations */
const int pinLightSensor = A1; // light sensor (analog 1)
const int pinThermistor = A2; // thermistor (analog 2)
const int pinRelayLED = 2; // relay LED (digital 2)
const int pinRelay = 3; // relay (digital 3)
const int pinMotionSensor = 5; // motion sensor (digital 5)
const int pinRangeSensor = 7; // range sensor (digital 7)
const int pinLED = 13; // LED (digital 13)
/* Globally scoped variables */
@calebhaye
calebhaye / pre-push
Created February 27, 2014 19:55
Run tests before git push
#!/bin/sh
branch=`git rev-parse --abbrev-ref HEAD`
echo "Running tests before pushing ...."
if [ $branch == 'master' ]; then
exit_code=$(bundle exec rake > /dev/null 2>/dev/null )$?
if [ $exit_code -gt 0 ]
then echo "Did not push because of failing tests"
fi
exit $exit_code
@calebhaye
calebhaye / gist:7830604
Created December 6, 2013 19:20
Create Pow! app from current directory
POWAPP=`pwd`; cd ~/.pow/; ln -s $POWAPP; cd -

Twitter Bootstrap Components Helper

Provides an accordion helper and a tabs helper

In your Gemfile:

gem 'bootstrap-components-helpers', :git => 'git://gist.github.com/5105757.git'

Accordion helper:

Resque.workers.each {|w| w.unregister_worker }
CURRENT_FEATURE=$(git symbolic-ref -q HEAD)
CURRENT_FEATURE=${CURRENT_FEATURE##refs/heads/}
CURRENT_FEATURE=${CURRENT_FEATURE:-HEAD}
# see - http://reinh.com/blog/2009/03/02/a-git-workflow-for-agile-teams.html
# get latest from master
git pull origin master
# set "current feature" variable and create feature branch
export CURRENT_FEATURE=1234567-feature-name
git checkout -b $CURRENT_FEATURE
# or use the following to get the current branch name