Skip to content

Instantly share code, notes, and snippets.

View puppybits's full-sized avatar

Bobby puppybits

View GitHub Profile
@puppybits
puppybits / cheeky.sh
Created August 12, 2011 19:28
convert point-and-shoot camera videos (MJPEG w/PCM_U8) to "HD" format (H264 w/ACC MP4)
#!/bin/bash
# @Puppybits circa(2011-05-23)
#FIRST install ffmpeg with the proper plugins then add ffmpeg to profile then convert videos
# sudo port install ffmpeg +gpl +lame +x264 +xvid +faac
# cat ~/.profile echo export #FFMPEG_DATADIR=/opt/local/var/macports/software/ffmpeg/0.6.2_0/opt/local/share/ffmpeg
#usage: ./cheeky.sh ./ ./convertions *.mov
#dir to start search from
@puppybits
puppybits / .profile.sh
Created August 12, 2011 19:36
OSX terminal commands
PS1="\[\033[1;31m\]\u\[\033[1;31m\]$ \[\033[0m\]"
UIARESULTSPATH="/var/log/iphone"
############## MACROS ##############
function imagefilehash(){ (sips -g make -g model -g pixelHeight -g pixelWidth $1 | tail -n 4; GetFileInfo -d $1;) | openssl sha1 | sed 's/^(.*)..//g'; }
function imagehash(){ openssl sha1 | sed 's/^(.*)..//g'; }
alias updateproflie= "pushd ~ && curl -O https://gist.github.com/raw/1142810/a7680ba07bacf8f4a6b2cef262a99312307a76da/.profile.sh"
@puppybits
puppybits / CrossDomainImageDownloader.as
Created September 8, 2011 22:01
Hack for Flash's security policy for cross-domain editable images
package lib
{
/**
* Note: This is not optimized just sample code
*/
public Class CrossDomainImageDownloader
{
public static function getImage(url:String, callback:Function):void
{
//download cross-domain image
@puppybits
puppybits / ApplicationStyles.h
Created September 17, 2011 15:22
iOS custom style categories for fonts and colors
// ARC supported. iOS 4.0+
//
// ApplicationStyles.h
//
// Created by Bobby Schultz on 8/11/11.
// Updated 8/23/12 - include fonts, new syntax.
// Copyright 2011 PB. All rights reserved.
// Based on @drawnonward idea from StackOverflow
// http://stackoverflow.com/questions/2824187/objective-c-defining-uicolor-constants
//
@puppybits
puppybits / itest.sh
Created December 21, 2011 16:52
iOS automation CLI
#Example: itest /Volumes/MyApp/src/tests/automation.js MyAppName
function itest(){
MOBILE_SAFARI="/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/Applications/MobileSafari.app";
JS_AUTOMATION_SCRIPT=$1;
APP_NAME=$2;
TEMPLATE_DIR="/Developer/Platforms/iPhoneOS.platform/Developer/Library/Instruments/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate";
APP_DIR=$(find ~/Library/Application\ Support/iPhone\ Simulator -iname $APP_NAME.app)
if [ !$APP_DIR ]
then
APP_DIR=$MOBILE_SAFARI;
@puppybits
puppybits / iOS_API+Blocks.h
Created December 27, 2011 13:38
Replace common iOS delegate APIs with blocks
//
// iOS_API+Blocks.h
//
// Created by Bobby Schultz on 12/1/11.
@interface UIAlertView (PBBlocks)
+ (id) alertWithTitle:(NSString*)title
message:(NSString*)message
clickedBlock:(void(^)(NSInteger))buttonIndexClickedBlock
@puppybits
puppybits / halfPNGs.sh
Created January 2, 2012 13:47
resize @2x pngs to @1x iphone images for an entire folder
function halfPNGs(){
dir=$1
n=0
while read f
do
# Image name
i=$(basename "$f")
if [[ $i == *\@2x\.png ]]; then
# Height of image
h=$(sips -g pixelHeight $f)
@puppybits
puppybits / image64.sh
Created January 5, 2012 14:18
Create data URI image from Terminal command
#!/bin/sh
# Examples:
# ./image64.sh myImage.png
# outputs: data:image/png;base64,xxxxx
# ./image64.sh myImage.png -img
# outputs: <img src="data:image/png;base64,xxxxx">
filename=$(basename $1)
xtype=${filename##*.}
append=""
@puppybits
puppybits / ls-uuid.sh
Created May 18, 2012 16:23
find if any dSYMs match a UUID
#!/bin/bash
# search for dSYMs for a full or partial UUID from a crash log.
# examples:
# ls-uuid.sh B533
# ls-uuid.sh B533 /Volumes/ProjectDrive/savedbuilds
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
@puppybits
puppybits / .profile
Last active October 11, 2015 22:48
Profile
_LGREY='\033[01;32m'
_RED='\e[1;31m'
_USER='\u'
_DIR='\W'
_B_RED='\033[1;31m'
_DEFAULT_COLOR='\033[0m'
function parse_git_branch {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo "("${ref#refs/heads/}")"
}