Skip to content

Instantly share code, notes, and snippets.

View carlosmcevilly's full-sized avatar

Carlos McEvilly carlosmcevilly

View GitHub Profile
@carlosmcevilly
carlosmcevilly / gist:2641563
Created May 9, 2012 03:28 — forked from ferostabio/gist:1431192
Avoid iCloud syncing
- (BOOL) addSkipBackupAttributeToItemAtURL:(NSURL *)URL
{
const char* filePath = [[URL path] fileSystemRepresentation];
const char* attrName = "com.apple.MobileBackup";
u_int8_t attrValue = 1;
int result = setxattr(filePath, attrName, &attrValue, sizeof(attrValue), 0, 0);
return result == 0;
}
@carlosmcevilly
carlosmcevilly / gist:2515834
Created April 28, 2012 04:24
bring up a wifi interface from the command line
ifdown eth0
ifup eth0
iwconfig eth0 essid networkname key [hex key, all caps]
ifconfig
# so if your network name is 'startrekenterprise' and your key is 'ABCDEFGHI' the command is
# iwconfig eth0 essid startrekenterprise ABCDEFGHI
@carlosmcevilly
carlosmcevilly / fetch-google-hourly-trends.pl
Created April 28, 2012 04:18
fetch the google hourly trends atom feed
@carlosmcevilly
carlosmcevilly / test.xml
Created April 28, 2012 04:11
test file for use with xpath-eval.pl
<?xml version="1.0"?>
<BusinessCard>
<firstName>Joe</firstName>
<lastName>Smith</lastName>
<phone class="work">408-555-5555</phone>
<phone class="home">408-555-8888</phone>
<phone class="cell">408-555-2222</phone>
<phone class="fax">408-555-1111</phone>
</BusinessCard>
@carlosmcevilly
carlosmcevilly / xpath-eval.pl
Created April 28, 2012 04:10
XPath debugging tool.
#!/usr/bin/perl
use XML::XPath;
use strict;
use warnings;
my $file = shift;
my $path = shift;
unless (defined($path) && -e $file) {
My notes on using watir. This is from 2007 so it's a bit out of date.
The part starting with "Cheat Sheet" is cribbed from some long-forgotten web site.
Watir can be used with other browsers but this is Firefox-specific.
1. install Firefox 1.5 or higher
2. install jssh extension
3. close firefox
@carlosmcevilly
carlosmcevilly / gist:2381617
Created April 14, 2012 02:22
throttle bandwidth on os x for testing
# throttle bandwidth
sudo ipfw pipe 1 config bw 15KByte/s
sudo ipfw add 1 pipe 1 src-port 80
# restore
sudo ipfw delete 1
# add 'source .gitprompt' to .bashrc to use this
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
function proml {
local BLUE="\[\033[0;34m\]"
local RED="\[\033[0;31m\]"
local LIGHT_RED="\[\033[1;31m\]"
@carlosmcevilly
carlosmcevilly / gist:2295872
Created April 3, 2012 22:18
bash function to view man pages using Preview.app
# put in .bashrc
pman () {
if [ "${2}" == '' ]; then
man -t "${1}" | open -f -a /Applications/Preview.app
else
man -t "${1}" "${2}" | open -f -a /Applications/Preview.app
fi
}
@carlosmcevilly
carlosmcevilly / bash-function-work-navigation.sh
Last active June 14, 2020 03:34
bash function to cd to work/<year>/ directory
# Navigate top-level work/year project organization directories
#
# Setup:
# Put or source function in .bashrc
# Also set WORK_ROOT to point to a container directory such as ~/work
# Make a directory under that for at least the current year, e.g. ~/work/2020
#
# Usage examples:
# $ work # cd to the current year
# $ work -- # cd two years back. Or --- for three years, etc.