Skip to content

Instantly share code, notes, and snippets.

View davidmfoley's full-sized avatar

Dave Foley davidmfoley

View GitHub Profile
@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 / 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 / octopress_heroku_publish.sh
Created May 18, 2012 16:20
Deploy octopress to heroku without crufting your repo with generated files
#! /bin/sh
# For octopress/heroku: generate site, deploy, and tag as "deploy-yyyy-mm-dd"
# This allows you to keep your public/ assets out of git,
# and only add them just before deploying
BRANCH=`git symbolic-ref -q HEAD | sed 's/refs\/heads\///'`
SHA=`git rev-parse --short HEAD`
@davidmfoley
davidmfoley / gist:2931107
Created June 14, 2012 15:50
summarize git commits and lines changed by author
git log --shortstat -C | awk '/Author:/ {author = $NF; if (!(author in lines)) {authors[length(authors)] = author; lines[author] = 0; commits[author] = 0} } /files changed/ {lines[author] += ($4 + $6); commits[author]++} END {for (i =0; i < length(authors); i++) {printf "%s lines in %s commits - %s\n", lines[authors[i]],commits[authors[i]], authors[i]}}' |sort -n -r
@davidmfoley
davidmfoley / gist:2955240
Created June 19, 2012 16:53
macys.com customer support chat
I received an email from macys.com to an email address that I never use (an email address provided by my ISP),
regarding my macys.com account. After changing the passwords on both the email account and the macys.com account,
I attempted to find a way to alert their credit card department of at worst, potential fraud, and at best, an
incorrect email address in one of their customer records. Unable to submit a "contact us" because I didn't have
the account number (which is masked on the site), and not wanting to sit on hold on the telephone, I figured,
what the hell, I'll give the chat support a go...
Chat Transcript
Please wait while we find an agent to assist you...
@davidmfoley
davidmfoley / gist:3041435
Created July 3, 2012 18:04 — forked from re5et/gist:3036720
JavaScript Window global var differ.
var Differ = function(thing){
this.thing = thing;
};
Differ.prototype.cacheVars = function(){
this.cache = {};
for(var prop in this.thing){
this.cache[prop] = this.thing[prop];
}
};
@davidmfoley
davidmfoley / gist:3260110
Created August 4, 2012 21:38
rake spec on RubyMotion Hello World app
$ rake spec
Build ./build/iPhoneSimulator-5.1-Development
Simulate ./build/iPhoneSimulator-5.1-Development/Hello_spec.app
Application 'Hello'
- has one window [FAILED]
Bacon::Error: 0.==(1) failed
spec.rb:553:in `satisfy:': Application 'Hello' - has one window
spec.rb:567:in `method_missing:'
spec.rb:183:in `block in run_spec_block'
@davidmfoley
davidmfoley / mocha-lint.rb
Created August 8, 2012 19:20
Detect indentation errors in mocha coffeescript specs
#! /usr/bin/env ruby
current_filename = ''
allowed_indent = 0
def indent_of line
line.index /[a-z]/
end
ARGF.lines do |line|
@davidmfoley
davidmfoley / fetch.sh
Created September 6, 2012 14:59
update git repos in all subdirectories
DIR=$( cd "$( dirname "$0" )" && pwd )
pushd $DIR
for d in `ls -d */`
do
echo "$d"
pushd "$d" > /dev/null
git remote update --prune
popd > /dev/null
done
popd > /dev/null
@davidmfoley
davidmfoley / test.coffee
Created March 5, 2013 17:59
Coffeescript 1.6.1 bug
class Foo
'bar:baz' : =>
new Foo