Skip to content

Instantly share code, notes, and snippets.

View seanbehan's full-sized avatar

Sean Behan seanbehan

View GitHub Profile
@seanbehan
seanbehan / mini.rb
Created January 13, 2012 18:18 — forked from defunkt/mini.rb
test/spec/mini 5 - nested contexts, stacked setups
##
# test/spec/mini 5
# http://gist.github.com/307649
# [email protected]
#
def context(*args, &block)
return super unless (name = args.first) && block
require 'test/unit'
klass = Class.new(defined?(ActiveSupport::TestCase) ? ActiveSupport::TestCase : Test::Unit::TestCase) do
def self.test(name, &block)
@seanbehan
seanbehan / signature.py
Created January 13, 2012 20:34
Plugin for Sublime Text 2
# Tools > New Plugin
# Save as signature.py
import datetime, getpass
import sublime, sublime_plugin
class SignatureCommand(sublime_plugin.TextCommand):
def run(self, edit):
# In Preferences > Key Bindings - Default
# Add a new entry
{"keys": ["ctrl+alt+s"], "command": "signature" },
@seanbehan
seanbehan / style.css
Created January 14, 2012 22:08
gradient h3 tag
h3 {
text-align:left;
padding:8px;
border-bottom:solid 2px #333;
font-weight:400;
font-size:18px;
padding:10px 20px;
background:#f4f4f4;
background:-webkit-gradient(linear,left top,left bottom,from(#f4f4f4),to(#e8e8e8));
background:-moz-linear-gradient(top,#f4f4f4,#e8e8e8);
@seanbehan
seanbehan / Rails.sublime-build
Created January 16, 2012 15:52
Sublime Text 2
## Tools > New Plugin...
{
"cmd": ["/path/to/script/run_rails_tests.rb", "$file"]
}
@seanbehan
seanbehan / Rakefile
Created January 18, 2012 21:36
How to add an arbitrary directory to your tests/ directory
# Edit Rakefile in project root
#
# Add a new rake test task... E.g., rake test:lib, below everything else in that file...
# Alternatively, add a task in lib/tasks/ directory and plop in the same code
namespace :test do
desc "Test lib source"
Rake::TestTask.new(:lib) do |t|
t.libs << "test"
t.pattern = 'test/lib/**/*_test.rb'
t.verbose = true
@seanbehan
seanbehan / backup.sh
Created January 19, 2012 17:19
Simple Backup Script
#!/bin/bash
# crontab -e
# 10 3 * * * /root/mysql_backups.sh > ~/backups/status.log
# change DB_USER and DB_PASSWD as per configuration
export DB_BACKUP="~/domains/baks"
export DB_USER="******"
export DB_PASSWD="*****"
export DB_HOST="*****"
@seanbehan
seanbehan / .bash_profile
Created February 7, 2012 15:04
My Bash Profile
alias ll='ls -lha'
alias r='rails'
alias b='bundle'
alias reload!='rake db:drop && rake db:create && rake db:migrate && rake db:fixtures:load'
source ~/.git-completion.bash
PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ \e[0;31m$ \e[0m'
export CLICOLOR=1
@seanbehan
seanbehan / misc.rb
Created February 24, 2012 23:31
Misc Code
# ERB YAML Template
def database_configuration
require 'erb'
YAML::load(ERB.new(IO.read(paths["config/database"].first)).result)
end
# HEREDOC Syntax
TEMPLATE = <<-HTML # :nodoc:
class PostsController < ActionController::Base
def create
Post.create(post_params)
end
def update
Post.find(params[:id]).update_attributes!(post_params)
end
private