Skip to content

Instantly share code, notes, and snippets.

View edenwaith's full-sized avatar

Chad Armstrong edenwaith

View GitHub Profile
@edenwaith
edenwaith / git branch-delete clean
Last active August 29, 2015 14:05
Clean up old git repositories
git branch | grep "some_string_or_pattern" | xargs -n 1 git branch-delete
@edenwaith
edenwaith / Compact JSON.py
Created October 14, 2014 15:49
TextWrangler Text Filter to Compact JSON (remove whitespace)
#!/usr/bin/python
import fileinput
import json
if __name__ == "__main__":
text = ''
for line in fileinput.input():
text = text + ' ' + line.strip()
jsonObj = json.loads(text)
print json.dumps(jsonObj, sort_keys=False, separators=(',',':'))
@edenwaith
edenwaith / Remove .svn
Created November 8, 2014 22:32
Removing .svn files from a git repository
find . -name '.svn' | xargs git rm -rf --ignore-unmatch
@edenwaith
edenwaith / batch_resize_images
Created June 18, 2015 20:36
Batch resize images from the OS X command line
find . -name *3x.png | xargs sips -Z 168
@edenwaith
edenwaith / crush_em.sh
Created August 7, 2015 21:42
Use pngcrush to batch reduce the size of a collection of PNG images
#!/bin/sh
# Reference:
# http://www.mactricksandtips.com/2012/02/installing-and-using-pngcrush-on-your-mac.html
for png in `find $1 -name "*.png"`;
do
echo "crushing $png"
pngcrush -rem allb -brute -reduce "$png" temp.png
mv -f temp.png $png
@edenwaith
edenwaith / PSPDFModernizer.c
Last active August 29, 2015 14:27 — forked from steipete/PSPDFModernizer.c
Retrofitting containsString: on iOS 7
#import <Foundation/Foundation.h>
#if __IPHONE_OS_VERSION_MIN_REQUIRED < 80000
@interface NSString (PSPDFModernizer)
// Added in iOS 8, retrofitted for iOS 7
- (BOOL)containsString:(NSString *)aString;
@end
@edenwaith
edenwaith / check64bit.c
Created December 25, 2013 18:49
Check if OS X is running in 32 or 64-bit mode.
/* File: check64bit.c
* Description: Check if the running version of Mac OS X is 64-bit
* To Compile: gcc -Wall -o check64bit check64bit.c
* To run: ./check64bit
*/
#include <stdio.h>
#include <string.h>
#include <sys/utsname.h>
@edenwaith
edenwaith / quick batch file rename
Created January 5, 2014 02:12
Quick batch file rename from the command line
ls foo*.jpg | awk '{print("mv "$1" "$1)}' | sed 's/foo/bar/2' | /bin/sh
@edenwaith
edenwaith / Format JSON.py
Created October 14, 2014 15:48
TextWrangler Text Filter to Format JSON
#!/usr/bin/python
import fileinput
import json
if __name__ == "__main__":
text = ''
for line in fileinput.input():
text = text + ' ' + line.strip()
jsonObj = json.loads(text)
print json.dumps(jsonObj, sort_keys=False, indent=2)
#!/bin/sh
VER1=2.6.33.2
VER2=2.6.38
OSVERSION=`sw_vers -productVersion`
echo "Current OS Version: $OSVERSION"
echo "Arg 2 : $# $0 $1 $2"
if [[ $VER1 > $VER2 ]]; then