Skip to content

Instantly share code, notes, and snippets.

View bkeepers's full-sized avatar

Brandon Keepers bkeepers

View GitHub Profile
@bkeepers
bkeepers / .profile
Created May 27, 2009 13:43
Bash completion for Rake
complete -C ~/.rake_completion -o default rake
@bkeepers
bkeepers / .git-completion.sh
Created May 27, 2009 13:35
Bash completion for Git
#
# bash completion support for core Git.
#
# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
# Distributed under the GNU General Public License, version 2.0.
#
# The contained completion routines provide support for completing:
#
# *) local and remote branch names
@bkeepers
bkeepers / gist:126457
Created June 9, 2009 12:36
Installing Git and gitjour
# Mac
1. Install MacPorts
2. $ port install git-core
3. $ gem install gitjour
# Windows:
1. Install git: http://code.google.com/p/msysgit/
2. $ gem sources --add http://gems.github.com
@bkeepers
bkeepers / application.html.erb
Created June 9, 2009 19:11
Initial layout and stylesheets for Idea Foundry example app
<!DOCTYPE html>
<html lang="en">
<head>
<title>eHarbor</title>
<%= stylesheet_link_tag 'boilerplate', 'main' %>
</head>
<body>
<div id="main">
<header>
<h1>
@bkeepers
bkeepers / .autotest
Created June 13, 2009 13:42
.autotest
require 'redgreen/autotest'
require 'autotest/growl'
require 'autotest/fsevent'
Autotest.add_hook :initialize do |autotest|
%w{.git .svn .hg .DS_Store ._* vendor}.each {|exception| autotest.add_exception(exception) }
false
end
@bkeepers
bkeepers / gist:132611
Created June 19, 2009 13:24 — forked from defunkt/gist:132456
open new shells in the most recently visited directory
# Bash snippet to open new shells in most recently visited dir.
# Useful if you want to open a new terminal tab at the present
# tab's location.
#
# Put this in your .bashrc or whatever.
pathed_cd () {
if [ "$1" == "" ]; then
cd
else
@bkeepers
bkeepers / snippet.rb
Created July 3, 2009 13:46
Command to keep cloned TextMate bundles up to date
#!/usr/bin/env ruby
home = File.expand_path('~')
Dir["#{home}/Library/Application Support/TextMate{,/Pristine Copy}/Bundles/*/.git"].each do |bundle|
dir = bundle.gsub(/\.git/, '')
puts "Updating #{File.basename(dir)}"
Dir.chdir(dir) { `git pull` }
end
class Position < ActiveRecord::Base
attr_protected :account_id, :created_at, :updated_at
belongs_to :account
#### Option 1 ####
attr_restricted :job_id
# assigns attribute if this method returns true
def allow_job_id_assignment?(id)
(function($) {
$.fn.delayedObserver = function(delay, callback) {
return this.keyup(function() {
var element = this, $element = $(this);
if(!$element.data('delayedObserver')) {
$element.data('delayedObserver', setTimeout(function() {
callback.apply(element);
$element.removeData('delayedObserver');
}, delay * 1000));
// easy refresh-css keybinding to alt-w
// alt-r was taken in IE, so consider this a CSS Weefresh
// original code from http://paulirish.com/2008/how-to-iterate-quickly-when-debugging-css/
$(document).keyup(function(e){
if (e.which == 87 && e.altKey) {
$('link').each(function() {
if((/stylesheet/i).test(this.rel) && this.href) {
var href = this.href.replace(/(&|\?)forceReload=\d+/,'');
this.href = href + ((/\?/).test(href) ? '&' : '?' ) + 'forceReload=' + new Date;