Skip to content

Instantly share code, notes, and snippets.

View jessearmand's full-sized avatar

Jesse Armand jessearmand

View GitHub Profile
#Newbie programmer
def factorial(x):
if x == 0:
return 1
else:
return x * factorial(x - 1)
print factorial(6)
#First year programmer, studied Pascal
@jessearmand
jessearmand / mpParse.m
Created November 23, 2010 13:59
A command line tool to parse .mobileprovision file
//
// © 2008 Eugene Solodovnykov
// http://idevblog.info/mobileprovision-files-structure-and-reading/
//
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
@jessearmand
jessearmand / PointyRoundedRect.m
Created January 23, 2011 02:47
Using CG to draw a pointy rounded rect.
//
// From http://stackoverflow.com/questions/4442126/how-to-draw-a-speech-bubble-on-an-iphone
//
void DrawPopupShapeInRect(CGRect rect, CGColorRef borderColor, CGColorRef backgroundColor, CGFloat borderRadius, CGFloat strokeWidth, CGFloat pointerWidth, CGFloat pointerHeight)
{
CGRect currentFrame = self.bounds;
CGContextSetLineJoin(context, kCGLineJoinRound);
CGContextSetLineWidth(context, strokeWidth);
#!/bin/bash
# run this in ~/Library/Logs/CrashReporter/MobileDevice
pth=${0%*/*}
cd "$pth"
#echo "$@"
if [ -z "$1" ]; then
find . -name "*.crash" | while read file;
do
echo "converting $file"
@jessearmand
jessearmand / clean_assets.rb
Created April 29, 2011 09:29 — forked from soffes/clean_assets.rb
Rake task to clean unused images in your iOS project
desc 'Remove unused images'
task :clean_assets do
require 'set'
all = Set.new
used = Set.new
unused = Set.new
# White list
used.merge %w{Icon Icon-29 Icon-50 Icon-58 Icon-72 Icon-114}
@jessearmand
jessearmand / new-github.sh
Created July 26, 2011 02:51 — forked from topfunky/new-github.sh
Shell shortcut to setup a Git repo with GitHub. Works with zsh or bash.
# Usage: new-github topfunky tidy_table
function new-github() {
git remote add origin git@github.com:$1/$2.git
git push origin master
git config branch.master.remote origin
git config branch.master.merge refs/heads/master
git config push.default current
}
@jessearmand
jessearmand / BaseViewController.m
Created October 19, 2011 09:11 — forked from boctor/BaseViewController.m
A base view controller class that when running on the simulator in debug mode, will auto simulate a memory warning every time the view controller's viewDidAppear is called
//
// BaseViewController.m
//
// Created by Peter Boctor on 5/4/11.
//
// Copyright (c) 2011 Peter Boctor
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
@jessearmand
jessearmand / config
Created February 13, 2012 15:31
This config solved my SSH connection problem with M1 fibre broadband network (on a Huawei HG256 residential gateway device) that I'm currently using
# SSH Connection pooling for faster additional connections to a machine
ControlMaster auto
ControlPath /tmp/ssh_mux_%h_%p_%r
# This makes subsequent connections go faster
ControlPersist 2h
# Make it so ssh-ing from one server to another passes keys around automagically
Host *
ForwardAgent yes
@jessearmand
jessearmand / cleanupfinder
Created September 9, 2012 14:32
To clean up the "Open With" in Finder context menu
#!/bin/sh
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user
@jessearmand
jessearmand / find_delete
Created September 25, 2012 08:07
Delete found files with "keyword" as a filename inside "dir" interactively.
#!/bin/sh
dir = "$1"
keyword = "$2"
find "$dir" -name '$keyword' -exec rm -i {} \;