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
Last active September 20, 2017 19:13
git-branch-delete Delete both a local and remote git branch with one command.Place this file in your /usr/local/bin/ directory.Usage:git branch-delete <name_of_branch>
#!/usr/bin/env ruby
#
# git-branch-delete
#
# Deletes a branch both locally and remotely in the origin.
#
###############################################################################
# Usage
###############################################################################
@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 / 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 / sorting.m
Last active January 11, 2019 13:29
Objective-C Searching and Sorting with NSPredicate
/*
* File: sorting.m
* Author: Chad Armstrong
* Date: 22 September 2014
* To compile: gcc -g -Wall -framework Foundation -o sorting sorting.m
*/
#import <Foundation/Foundation.h>
void printByAge(NSArray *people);
@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)
@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 / git-branch-batch-rename
Created February 9, 2015 17:27
Rename multiple git branches from the command line
git branch | grep defects | awk '{original=$1; sub("defects","old-defects"); print original, $1}' | xargs -n 2 git branch -m
@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