Skip to content

Instantly share code, notes, and snippets.

@jonbalbarin
jonbalbarin / backup2dropbox.sh
Created June 30, 2014 12:26
compress current directory and move it to a backups folder in dropbox
#!/bin/bash
BASE_PATH=/tmp/$(basename $(pwd))_$(date "+%Y-%m-%d-%H%M%S")
if [ -z "$1" ]; then
BACKUP_ARCHIVE=$BASE_PATH.tar.gz
else
BACKUP_ARCHIVE="$BASE_PATH"_\(${1// /-}\).tar.gz
fi
@jonbalbarin
jonbalbarin / backup2dropbox.sh
Created November 30, 2011 17:20
a bash script for backing up the current directory to dropbox
#!/bin/bash
if [[ $1 ]]
then
BACKUP_ARCHIVE=$(basename $(pwd))_$(date "+%Y-%m-%d-%H%M%S")_\(${1// /-}\).tar.gz
echo "backing up to "$BACKUP_ARCHIVE
tar -czf $BACKUP_ARCHIVE .
cp -pv $BACKUP_ARCHIVE ~/Dropbox/Backups
rm -v $BACKUP_ARCHIVE
echo done
else
@jonbalbarin
jonbalbarin / gist:1223571
Created September 17, 2011 02:50
making a category on a class to contain its protocol methods
////////////////////////////////////////////////////////////////////////////////
// MyProtocol.h
////////////////////////////////////////////////////////////////////////////////
@protocol MyProtocol <NSObject>
-(void) thisThingDidDoSomething:(OriginalThing*)sender;
-(void) thisThing:(OriginalThing*)sender didDoSomethingWithThing:(Thing*)thing;
@end
////////////////////////////////////////////////////////////////////////////////
@jonbalbarin
jonbalbarin / throttle.sh
Created July 14, 2011 00:06
throttling bandwidth to emulate mobile devices (when running simulators)
# stick this in your .bash_profile
alias throttle150='sudo ipfw pipe 1 config bw 150Kbps && sudo ipfw add 1 pipe 1 src-port 80'
alias throttle300='sudo ipfw pipe 1 config bw 300Kbps && sudo ipfw add 1 pipe 1 src-port 80'
alias throttleOff='sudo ipfw delete 1'
@jonbalbarin
jonbalbarin / .bash_profile
Created July 7, 2011 16:22
a tip calculator in python
alias tippy='python ~/path/to/this/thing/tip.py -s'
set number
syntax on
filetype on
filetype plugin on
set expandtab
set tabstop=4
set softtabstop=4
set shiftwidth=4
set wildmenu
@jonbalbarin
jonbalbarin / gist:972698
Created May 14, 2011 22:19
switching between ubuntu and chromeos on the cr48
#set ubuntu as default
function bootUBUNTU {
sudo cgpt add -i 6 -P 5 -S 1 /dev/sda
}
#set chromeos as default
function bootCHROMEOS {
sudo cgpt add -i 6 -P 0 -S 1 /dev/sda
}
@jonbalbarin
jonbalbarin / prettyjson.sh
Created April 20, 2011 14:35
pretty print json
#in .bash_profile...
function prettyjson
{
if [ $1 ]; then
curl -s $1 | python -mjson.tool
else
echo "specify a url";
fi
}
@jonbalbarin
jonbalbarin / .gitignore
Created April 14, 2011 16:22
my global git ignore...basically the vi, vim, and eclipse stuff from https://github.com/github/gitignore
.DS_Store
*.swp
*.swo
.*.sw[a-z]
*.un~
Session.vim
*.pydevproject
.project
.metadata
bin/**
@jonbalbarin
jonbalbarin / .gitconfig
Created April 13, 2011 13:51
my gitconfig
[diff]
tool = opendiff
[color]
ui = auto
[alias]
graph = log --graph --decorate --pretty=short
findbranch = "! git branch -a | ack $1"
[user]
name = My Name