Skip to content

Instantly share code, notes, and snippets.

View nuthatch's full-sized avatar

Stephen Ryner Jr. nuthatch

View GitHub Profile
# xcode noise
build/*
*.pbxuser
*.mode1v3
*.perspectivev3
# old skool
.svn
# osx noise
#!/usr/bin/env ruby
#
# build AdHoc package
#
# Install:
# sudo gem install mechanize
#
# Usage:
# ruby build-adhoc.rb adhoc.yaml
- (CGImageRef)CGImageRotatedByAngle:(CGImageRef)imgRef angle:(CGFloat)angle
{
CGFloat angleInRadians = angle * (M_PI / 180);
CGFloat width = CGImageGetWidth(imgRef);
CGFloat height = CGImageGetHeight(imgRef);
CGRect imgRect = CGRectMake(0, 0, width, height);
CGAffineTransform transform = CGAffineTransformMakeRotation(angleInRadians);
CGRect rotatedRect = CGRectApplyAffineTransform(imgRect, transform);
@nuthatch
nuthatch / NSString+URIQuery
Created March 13, 2010 00:03
NSString+URIQuery
************** NSString+URIQuery.h ******************************************
// Created by Jerry Krinock
// Posted Thu, 29 Jan 2009
// http://lists.apple.com/archives/cocoa-dev/2009/Jan//msg02349.html
#import <Foundation/Foundation.h>
@interface NSString (URIQuery)
@nuthatch
nuthatch / symbolicate-damn-you
Created February 18, 2011 04:45
For whatever reason, Xcode refuses to symbolicate my crashes in the Organizer. So I wrote this script to run symbolicatecrash over tester crash reports. It's quick and very dirty.
#!/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"
@nuthatch
nuthatch / gist:983606
Created May 20, 2011 19:31
set Typeface to all TextViews in a ViewGroup for Android
// recursively apply typeface to our textviews
static final void setTypeface(ViewGroup viewGroup, Typeface typeface)
{
if (viewGroup == null) return;
int children = viewGroup.getChildCount();
Log.d(TAG, "setTypeface " + viewGroup + " : " + children);
for (int i=0; i<children; i++)
{
View view = viewGroup.getChildAt(i);
@nuthatch
nuthatch / TouchyWebView.java
Created February 5, 2012 19:29
Android: If you're going to embed a WebView that responds to touch events inside a ScrollView or other touch consumer, you need to override onTouchEvent to requestDisallowInterceptTouchEvent and prevent the parent from stealing your events. Do it!
static final class TouchyWebView extends WebView
{
public TouchyWebView(Context context) {
super(context);
}
@Override
public boolean onTouchEvent(MotionEvent event){
requestDisallowInterceptTouchEvent(true);
return super.onTouchEvent(event);
@nuthatch
nuthatch / convert-key.bash
Created February 20, 2012 21:38
Automate conversion of Apple Push Certificates into .p12 format for Urban Airship
#!/bin/bash
if [ -e aps_production.cer ]
then
echo "Converting production push certificate"
security -v create-keychain -p '' temp-production.keychain
security -v import aps_production.cer -k temp-production.keychain
security -v export -k temp-production.keychain -f pkcs12 -P '' -o push-production.p12
security -v delete-keychain temp-production.keychain
fi
@nuthatch
nuthatch / flurry curl
Created February 22, 2012 16:05
use curl to automate creation of Flurry API keys
curl -v -c ./flurry.jar \
--location-trusted \
-d "loginEmail=$USERNAME&loginPassword=$PASSWORD&rememberMe=true&__checkbox_rememberMe=true" \
-k https://dev.flurry.com/secure/loginAction.do > login.html
curl -v -b ./flurry.jar \
--location-trusted \
http://dev.flurry.com/viewProjects.do > projects.html
curl -v -b ./flurry.jar \
@nuthatch
nuthatch / NSManagedObject+Serialization.h
Last active May 8, 2019 11:25 — forked from pkclsoft/NSManagedObject+Serialization.h
Fixes for Peter Easdown's category 1. don't assume each Entity name matches the Class name. 2. strip DATE_ATTR_PREFIX when deserializing dates back into NSManagedObject 3. add support for NSOrderedSet 4. use set to keep traversal history, and allow classes to opt-out with serializationObjectsToSkip
@interface NSManagedObject (Serialization)
- (NSDictionary*) toDictionary;
- (void) populateFromDictionary:(NSDictionary*)dict;
+ (NSManagedObject*) createManagedObjectFromDictionary:(NSDictionary*)dict
inContext:(NSManagedObjectContext*)context;
@end