Skip to content

Instantly share code, notes, and snippets.

View cddr's full-sized avatar

Andy Chambers cddr

View GitHub Profile
@cddr
cddr / git-fu.sh
Created July 11, 2013 19:09
Find the first few branches that contain the specified commit
# Find the pull request that introduced a given commit
COMMIT=c78f9ef # just an example commit id
# This will list the first few branches that contain this commit (including only "pull request" branches)
git branch -r --contains $COMMIT |grep "origin/pr" |sort |head
@cddr
cddr / fixup-whitespace.sh
Created September 13, 2013 20:03
Fixes whitespace only on the lines I've changed
# Really dumb script to fix up whitespace but only on the lines changed in the current
# commit. Run this script from your $PROJECT/.git/hooks/pre-commit
#
git diff HEAD --no-color > /tmp/stage.diff
git apply -R /tmp/stage.diff
git apply --whitespace=fix /tmp/stage.diff
@cddr
cddr / fixup-whitespace.sh
Created September 13, 2013 20:03
Fixes whitespace only on the lines I've changed
# Really dumb script to fix up whitespace but only on the lines changed in the current
# commit. Run this script from your $PROJECT/.git/hooks/pre-commit
#
git diff HEAD --no-color > /tmp/stage.diff
git apply -R /tmp/stage.diff
git apply --whitespace=fix /tmp/stage.diff
@cddr
cddr / gist:8237666
Created January 3, 2014 13:12
ad_details question
So if we have the following line item...
line_item
ad_distribution{:price_per_unit = 20}
buy_item{:id = 1}
buy_item{:id = 2,
:price_per_unit = 40}
I think the first case is simple. Seems we should return....
@cddr
cddr / gist:8237667
Created January 3, 2014 13:12
ad_details question

So if we have the following line item...

line_item
  ad_distribution{:price_per_unit = 20}
  buy_item{:id = 1}
  buy_item{:id = 2,
           :price_per_unit = 40}
@cddr
cddr / pre-commit
Created April 1, 2014 02:14
Git precommit hook for keeping Changelog up-to-date
#!/bin/sh
# MVP precommit hook that keeps the Changelog up-to-date.
#
# Assumes that `pwd` is the project root
./scripts/gitlog-to-changelog >Changelog
git add Changelog
@cddr
cddr / pre-commit
Created April 1, 2014 02:14
Git precommit hook for keeping Changelog up-to-date
#!/bin/sh
# MVP precommit hook that keeps the Changelog up-to-date.
#
# Assumes that `pwd` is the project root
./scripts/gitlog-to-changelog >Changelog
git add Changelog
@cddr
cddr / fixup-whitespace
Created April 1, 2014 19:43
Fix whitespace before commit
git diff HEAD --no-color > /tmp/stage.diff
git apply -R /tmp/stage.diff
git apply --whitespace=fix /tmp/stage.diff

Keybase proof

I hereby claim:

  • I am cddr on github.
  • I am cddr (https://keybase.io/cddr) on keybase.
  • I have a public key whose fingerprint is 64E1 19C6 8F72 F2C4 E650 F321 4093 000D 8C99 8B18

To claim this, I am signing this object:

@cddr
cddr / selfied
Created April 7, 2014 17:08
Infinite selfie power
# Lets thank Arnold for the headphones!
#
# Next time you're doing coding hours, get your headphones on and
# run this script in a terminal.
#
# Usage:
#
# 1. Download imagesnap from here: https://github.com/rharder/imagesnap
# 2. Update the global variables below according to where you put imagesnap
# and where you'd like the images to show up