Skip to content

Instantly share code, notes, and snippets.

View dstnbrkr's full-sized avatar

Dustin Barker dstnbrkr

View GitHub Profile
@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 / gist:ac579f689f1275eed71c
Created March 18, 2015 20:53
find files matching multiple name patterns
find $DIR -type f \( -name '*.h' -o -name '*.mm' \)
target :'MyApplicationTestsHost', :exclusive => true do
end
From 0be864d8f6eac17afb245b44020e53b932412770 Mon Sep 17 00:00:00 2001
From: Dustin Barker <dustin.barker@gmail.com>
Date: Thu, 15 Oct 2009 19:24:08 -0700
Subject: [PATCH] If a mock dir exists and is a symlink, resolve it.
Fixes specs that fail on Mac OS X due to symlink /var -> /private/var
---
core/dir/fixtures/common.rb | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
From 092ae12aec59cc8883f6f6454f111df56260338e Mon Sep 17 00:00:00 2001
From: Dustin Barker <dustin.barker@gmail.com>
Date: Thu, 15 Oct 2009 20:49:22 -0700
Subject: [PATCH] If a mock dir exists and is a symlink, resolve it
Fixes specs that fail on Mac OS X due to symlink /var -> /private/var
---
core/dir/fixtures/common.rb | 12 +++++++++++-
1 files changed, 11 insertions(+), 1 deletions(-)
@dstnbrkr
dstnbrkr / server.js
Created January 19, 2011 16:57
Simple server that writes raw HTTP post data to a file.
var http = require("http");
var fs = require("fs");
var path = require("path");
http.createServer(function(request, response) {
unique_filename(function(filename) {
upload_file(filename, request, response);
});
}).listen(8000);
@dstnbrkr
dstnbrkr / node static server anywhere
Created February 12, 2011 01:47
Launch a webserver anywhere, the current working directory will be the document root
#!/usr/local/bin/node
var
sys = require('sys'),
path = require('path'),
http = require('http'),
paperboy = require('/usr/local/lib/node/paperboy'),
PORT = 8003,
WEBROOT = process.cwd();
@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)))
@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 / 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