Skip to content

Instantly share code, notes, and snippets.

View davidmfoley's full-sized avatar

Dave Foley davidmfoley

View GitHub Profile
@davidmfoley
davidmfoley / restore_db_from_heroku_backup.sh
Created May 2, 2012 16:09
Heroku/Rails: restore local development db from heroku
#! /bin/bash
# First you need to have the "pgbackups" addon in your heroku app, for example:
# $ heroku addons:add pgbackups:auto-week
# your database name here
DB_NAME='foobar_development'
# grab the data directory for postgres from the running process
DATA_DIR=`ps ax |grep [/]post | sed "s/^.*\-D //" | sed "s/ .*$//"`
@davidmfoley
davidmfoley / coffeelint.vim
Created April 2, 2012 14:07
coffeelint/vim quickfix integration
" Get coffeelint errors in the vim quickfix menu
" requires coffeelint to be installed and in the path
" http://www.coffeelint.org/
" lint the current file
function! CoffeeLintFile()
let current = fnamemodify(expand("%"), ':p')
call CoffeeLintAnalyze(current)
endfunction
@davidmfoley
davidmfoley / gist:1340336
Created November 4, 2011 20:02
BASH Prompt
export PS1='\[\e[35;40m\]\h:\[\e[36;40m\]\W\[\e[32;40m\]$(__git_ps1 "(%s)") \[\e[33;40m\]\$\[\e[0m\] '
@davidmfoley
davidmfoley / gist:1126260
Created August 4, 2011 20:57
update and prune all remotes except heroku
alias gru='git remote show | sed '\''/heroku/d'\'' | xargs -I {} git remote update {} --prune'
@davidmfoley
davidmfoley / gist:1107331
Created July 26, 2011 17:44
VIM: flip between test and production files (rails/rspec)
function! FindOrCreateAlternate()
let buflist = []
let bufcount = bufnr("$")
let currbufnr = 1
let altname = AlternateFileName()
while currbufnr <= bufcount
if(buflisted(currbufnr))
let currbufname = bufname(currbufnr)
let curmatch = tolower(currbufname)
@davidmfoley
davidmfoley / gist:1038439
Created June 21, 2011 17:50
Good idea or bad idea?
#
# rspec shared examples for standard resource post to /create handling
#
# usage:
# it_should_behave_like "handles POST create"
#
# good idea or bad?
#
shared_examples_for 'handles POST create' do
before :all do
@davidmfoley
davidmfoley / gist:978761
Created May 18, 2011 15:06
Drop all mongodb tmp collections
names = db.getCollectionNames(); for (var i = 0; i < names.length; i++) { if (names[i].substring(0,4) =='tmp.') { print(names[i]); db.getCollection(names[i]).drop(); }}
@davidmfoley
davidmfoley / analdiffist-git-log.txt
Created May 4, 2011 02:35
Best set of commits I've done in a while
|
* commit aa1e16dfb818f2e7b5c27883aad5ccfa14eea4da
| Author: Dave Foley <[email protected]>
| Date: Sun Mar 27 07:07:42 2011 -0400
|
| fixing stupid 6AM bug
|
* commit 46f5a2bff1199ec7004589550c33410548c65647
| Author: Dave Foley <[email protected]>
| Date: Sun Mar 27 07:06:49 2011 -0400
@davidmfoley
davidmfoley / gist:923364
Created April 16, 2011 18:12
Example javascript namespace declaration helper
// Replace App with your root namespace name.
//
// use like:
// App.declare('foo.bar.baz', function(){});
// App.foo.bar.baz();
// or
// App.declare('some.namespaceName', {foo : function(){}, bar:function(){}});
// App.some.namespaceName.foo();
var App = {};
@davidmfoley
davidmfoley / gist:859064
Created March 7, 2011 19:38
VIM: populate quickfixes with any methods that flog >= 10.0
" flog wrappers
function! FlogFile()
let current = fnamemodify(expand("%"), ':p')
call FlogAnalyze(current)
endfunction
function! FlogAll()
call FlogAnalyze('app lib -g')
endfunction