Skip to content

Instantly share code, notes, and snippets.

View carlosmcevilly's full-sized avatar

Carlos McEvilly carlosmcevilly

View GitHub Profile
@carlosmcevilly
carlosmcevilly / install-boot-muter.sh
Created September 28, 2012 05:06
eliminate the Mac power-on sound
#!/bin/bash
cd
export myhomepath=`pwd`
sudo defaults write com.apple.loginwindow LoginHook $myhomepath/Library/Scripts/mute-off.sh
sudo defaults write com.apple.loginwindow LogoutHook $myhomepath/Library/Scripts/mute-on.sh
@carlosmcevilly
carlosmcevilly / spaces-to-tabs.sh
Last active October 11, 2015 03:48
replace runs of four leading spaces with tabs in .m files
#!/bin/bash
# Bah. I prefer spaces. So why this script? I was on a project that required tabs.
export isconfirmed=$1
if [[ ! "$isconfirmed" == 'confirmed' ]]; then
echo 'run with a "confirmed" command line argument to confirm you want to run this destructive operation'
exit -1
fi
@carlosmcevilly
carlosmcevilly / symbolicate-crash.sh
Created September 20, 2012 21:42
symbolicate a crash for an iOS app
#!/bin/bash
export log=$1
export dsym=$2
export app=$3
if [[ "$app" == '' ]]; then
echo usage: $0 '<logfile> <dSYM folder> <.app folder>'
echo
exit -1
@carlosmcevilly
carlosmcevilly / add
Last active October 10, 2015 20:38
get the best matching value from an encrypted store keyed by one or more tags, and put it in the pasteboard
#!/bin/bash
export key=$1
export data=$2
export __KEYSTORE__=$3
if [[ "$data" == '' ]]; then
echo usage: $0 '<"key text"> <"data text"> [keystore_name]'
echo
echo " for multi-line data, put in file and do:"
@carlosmcevilly
carlosmcevilly / gist:3738912
Created September 17, 2012 18:26
how to revert the iOS optimization of a png file
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/pngcrush -revert-iphone-optimizations -q otimized.png reverted.png
# or if Xcode is in a non-standard path:
"`xcode-select -print-path`"/Platforms/iPhoneOS.platform/Developer/usr/bin/pngcrush -revert-iphone-optimizations -q otimized.png reverted.png
@carlosmcevilly
carlosmcevilly / gist:3738897
Created September 17, 2012 18:23
how to print the path of the currently selected Xcode
xcode-select -print-path
@carlosmcevilly
carlosmcevilly / simple-rename.sh
Created June 6, 2012 19:45
Do a simple rename of some strings in some files stored under 'Source/'
#!/bin/bash
# requires ack: http://betterthangrep.com/
# is there a better way to pass in the arguments to this perl one-liner other than using the environment? pretty hacky. could just rewrite the whole thing as a Perl script using File::Find
# todo: redo this to use find, xargs, and grep in case ack isn't available
# todo: this looks only for files in a "Source" directory; generalize it
export old=$1
export new=$2
@carlosmcevilly
carlosmcevilly / make-blank.pl
Created May 15, 2012 19:36
quickly create a blank (white) image of the same size as a reference image passed in on the command line
#!/usr/bin/perl
# requires imagemagick to be installed on the system for 'identify' and 'convert'
use strict;
use warnings;
my $infile = shift;
my $color = shift;
@carlosmcevilly
carlosmcevilly / gist:2656980
Created May 11, 2012 01:42
git stash current changes to a new branch
git stash save
git branch xxx HEAD
git checkout xxx
git stash pop
or do:
git checkout -b xxx
@carlosmcevilly
carlosmcevilly / gist:2641614
Created May 9, 2012 03:35 — forked from luikore/gist:149493
chinese string
# regexps to check if a string is pure chinese
class String
# 20k chars
CHINESE_UCS2 = /^(?:
[\x4e-\x9e][\x00-\xff]
|\x9f[\x00-\xa5]
)+$/xn
# 20k chars
CHINESE_UTF8 = /^(?: