Skip to content

Instantly share code, notes, and snippets.

View seanbehan's full-sized avatar

Sean Behan seanbehan

View GitHub Profile
@seanbehan
seanbehan / test.watchr
Created June 28, 2011 18:10
Watchr Script for Test Unit
require 'ruby-debug'
require 'rainbow'
require 'colorize'
def result(message)
msg = message.to_a.map(&:strip)
stats = msg.last.split(",")
errors = stats[-1].split(" ").first.to_i
failures = stats[-2].split(" ").first.to_i
color = (failures >= 1||errors>=1) ? :"yellow" : :"green"
@seanbehan
seanbehan / mysql_backups.sh
Created June 28, 2011 18:16
Nightly Mysql Backups
#!/bin/bash
# installed as root in /root/backups/mysql
# needs to be installed via cron
# will run at 3:10 am every morning
#
# crontab -e
# 10 3 * * * /root/mysql_backups.sh > /backups/status.log
# change DB_USER and DB_PASSWD as per configuration
@seanbehan
seanbehan / pow
Created July 1, 2011 01:42 — forked from ches/pow
A quick script to switch between running Pow and Apache on OS X
#!/bin/sh -e
#/ Usage: pow [on|off]
#/ Toggle between running Pow (http://pow.cx) and Apache on Mac OS X.
# Show Usage
function usage {
grep '^#/' "$0" | cut -c4-
exit 2
}
[ -z "$1" -o "$1" = "--help" ] && usage
@seanbehan
seanbehan / Gemfile
Created October 19, 2011 00:47
Example Multi Stage Capistrano Deploy
# Gemfile
# Relevant Capistrano gems
gem 'capistrano'
gem 'capistrano-ext'
gem 'capistrano_colors'
@seanbehan
seanbehan / app.rb
Created November 19, 2011 00:12
Sinatra Reloaded
require 'sinatra'
get "/" do
@person = Person.new
"Hello #{@person.name}. You are #{@person.born_at} years old!"
end
require 'yaml'
# Nested YAML structure from something-nested.yml
#
# nested:
# key: value
# key_two: value_two
# Procedural Approach to building a single Hash from nested YAML data structure.
@yaml = YAML.load_file("something-nested.yml")
@seanbehan
seanbehan / example.rb
Created January 7, 2012 17:05
Test Unit Colorized Output with Test:Unit and Ruby 1.9
#test/test_helper.rb
require 'test/unit/ui/console/testrunner'
class Test::Unit::UI::Console::TestRunner
def guess_color_availability
true
end
end
#Gemfile
@seanbehan
seanbehan / project_edit.html
Created January 10, 2012 19:26
How To Content Editable
<script>
// coffeescript
$ ->
$("#project_fields .project").live "blur", (event)->
// alert($(this).text())
$field = $(this)
$project_id = $(this).data("project-id")
$data = $(this).text()
@seanbehan
seanbehan / gsub.rb
Created January 10, 2012 21:17
Gsub Block
"Scs Epc Score".gsub (/scs|epc/i) { |i| i.upcase }
# => SCS EPC Score
@seanbehan
seanbehan / remove_orig_files.sh
Created January 12, 2012 16:42
Recursively Delete .Orig Files After Failed Git Merge
# recursively delete original files after a git merge failure
find . -name *.orig -delete