Skip to content

Instantly share code, notes, and snippets.

View dstnbrkr's full-sized avatar

Dustin Barker dstnbrkr

View GitHub Profile
target :'MyApplicationTestsHost', :exclusive => true do
end
@dstnbrkr
dstnbrkr / gist:ac579f689f1275eed71c
Created March 18, 2015 20:53
find files matching multiple name patterns
find $DIR -type f \( -name '*.h' -o -name '*.mm' \)
@dstnbrkr
dstnbrkr / gist:5f9a3c91d43eca89afce
Created March 18, 2015 05:19
Loop through filenames with spaces
# example: renaming files named {0, 0, 0, 0} to 0-0-0-0
find $DIR -type f | while read f
do
NEW=`echo $f | sed 's/[{}]*//g' | sed 's/, /-/g'`
git mv "$f" $NEW
done
@dstnbrkr
dstnbrkr / Makefile
Last active September 25, 2017 00:22
The Makefile we use for continuous integration and distribution at Artsy.net
PROJECT = Artsy
BUNDLE_ID = net.artsy.artsy.beta
CONFIGURATION = Beta
WORKSPACE = $(PROJECT).xcworkspace
SCHEME = $(PROJECT)
APP_PLIST = $(PROJECT)/App/$(PROJECT)-Info.plist
IPA = $(PROJECT).ipa
DSYM = $(PROJECT).app.dSYM.zip
@dstnbrkr
dstnbrkr / gist:2770652
Created May 22, 2012 18:10
predicate templates
// the query:
// foo amount:15
// first becomes an array of predicate templates
[ "${column} like '%foo%'", "${column} >= 14 and ${column} <= 16" ]
// next, we inspect the model to find which columns to search on
// and repeat each query for each property
@dstnbrkr
dstnbrkr / git-merge-combine
Created January 13, 2012 21:15
git-merge-combine
#!/bin/sh
# Combines two versions of a file by removing all conflict markers
# Usage: git-merge-combine MyProject.xcodeproj/project.pbxproj
FILE=$1
TMPFILE=$1.tmp
sed -e 's/<<<<<<< HEAD//; s/=======//g; s/>>>>>>> .*$//' $FILE > $TMPFILE
if [ $? -ne 0 ]; then
@dstnbrkr
dstnbrkr / xcode-usages
Created December 6, 2011 23:50
Find references to a resource
grep -Rl "$1" * | grep -v build | grep -v BankSimple.xcodeproj | grep -v Icon*.png | grep -v Assets
filename=$1
extension=${filename##*.}
filename=${filename%.*}
grep -Rl $filename * | grep -v build | grep -v BankSimple.xcodeproj | grep -v Icon*.png | grep -v Assets
@dstnbrkr
dstnbrkr / xcode-remove-unused
Created December 6, 2011 23:47
Remove unused resources from xcode project.
#!/bin/sh
for f in `find Resources/Images -type f ! -name '*@2x.png' ! -name 'Default*.png'`; do
FILENAME=`basename $f`;
NUSAGES=`usages $FILENAME | wc -l | awk '{print $1}'`;
if [ $NUSAGES = 0 ]; then
echo $f;
fi;
done;
@dstnbrkr
dstnbrkr / UIColorFromRGB
Created March 28, 2011 19:32
Convert hex value to UIColor
UIColor* UIColorFromRGB(NSInteger rgb) {
return [UIColor colorWithRed:((float) ((rgb & 0xFF0000) >> 16)) / 0xFF
green:((float) ((rgb & 0xFF00) >> 8)) / 0xFF
blue:((float) (rgb & 0xFF)) / 0xFF
alpha:1.0];
}
@dstnbrkr
dstnbrkr / fermat.rkt
Created March 4, 2011 21:38
fermat test for primality
(define (is-fermat-prime? n iterations)
(or (<= iterations 0)
(if (= (modulo (expt (+ (random (- n 1)) 1) (- n 1)) n) 1)
(is-fermat-prime? n (- iterations 1))
#f)))