Skip to content

Instantly share code, notes, and snippets.

@jamztang
jamztang / LICENSE
Created March 26, 2012 14:40
JTTargetActionBlock - Adding blocks support for UIControl target/action mechanism
Copyright (c) 2013 Jamz Tang <[email protected]>
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
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
@jarsen
jarsen / pinhack.m
Created March 21, 2012 07:01
A snippet showing how to pin something to pinterest from your iOS app
NSURL *url = [NSURL URLWithString:@"pinit12://pin/create/bookmarklet/?media=http%3A%2F%2Fimages.apple.com%2Fhome%2Fimages%2Fipad_hero.jpg&url=http%3A%2F%2Fwww.apple.com%2F&title=Apple&is_video=false&description=Test"];
[[UIApplication sharedApplication] openURL:url];
@chriseidhof
chriseidhof / nsincrementalstore.markdown
Created February 18, 2012 16:39
Accessing an API using CoreData's NSIncrementalStore

Accessing an API using CoreData's NSIncrementalStore

Note: the original location of this article is on my blog, however, it is posted here too for better readability.

In this article, we will see how to use Core Data for accessing your API. We will use the Bandcamp API as our running example. I've only been experimenting with this code for a few days, so there might be mistakes in there.

@atomicbird
atomicbird / NSObject+setValuesForKeysWithJSONDictionary.h
Created January 11, 2012 02:35
NSObject category for handling JSON dictionaries. Described in detail at http://www.cimgf.com/2012/01/11/handling-incoming-json-redux/
//
// NSObject+setValuesForKeysWithJSONDictionary.h
// SafeSetDemo
//
// Created by Tom Harrington on 12/29/11.
// Copyright (c) 2011 Atomic Bird, LLC. All rights reserved.
//
#import <Foundation/Foundation.h>
@chriseidhof
chriseidhof / TilingView.h
Created December 8, 2011 17:50
TilingView
#import <UIKit/UIKit.h>
typedef UIImage*(^getTile)(CGFloat scale, int row, int col);
@interface TilingView : UIView {
getTile getTile;
}
- (id)initWithSize:(CGSize)size levelsOfDetail:(NSInteger)levelsOfDetail tileSize:(CGSize)tileSize;
@property (nonatomic,copy) getTile getTile;
@steipete
steipete / iOSDocumentMigrator.m
Created December 6, 2011 15:21
Helps migrating documents between iOS <= 5.0 and >= 5.0.1 to comply with Apple's iCloud guidelines. Follow @steipete on Twitter for updates.
#include <sys/xattr.h>
/// Set a flag that the files shouldn't be backuped to iCloud.
+ (void)addSkipBackupAttributeToFile:(NSString *)filePath {
u_int8_t b = 1;
setxattr([filePath fileSystemRepresentation], "com.apple.MobileBackup", &b, 1, 0, 0);
}
/// Returns the legacy storage path, used when the com.apple.MobileBackup file attribute is not available.
+ (NSString *)legacyStoragePath {
@pinglamb
pinglamb / pretty_print.css
Created November 5, 2011 18:22
JSON Pretty Print JS
body { font-family: monospace; font-size: 1.1em; }
ul { margin: 0 0 0 .2em; list-style: none; }
li { padding: 0; margin: 0;}
li:after { content: ','; }
li:last-child:after { content: ''; }
span.object { font-weight: bold; }
span.string, span.string a { color: green; }
@yachi
yachi / siteisup.sh
Created November 4, 2011 06:57
有貨未
while sleep 15; do if [ `curl -s "http://store.apple.com/hk" |md5` != 3627b1dac6a928cfc587d5ac3be0654c ]; then open http://store.apple.com; fi done
@pinglamb
pinglamb / api_spec.json
Created November 2, 2011 15:31
damn-api sample spec
{
"host": ["api.example.com", "api-staging.example.com"],
"headers": { // By default, optional: false
"X-EXAMPLE-DEVICE-TYPE": ["iphone", "android"],
"X-EXAMPLE-DEVICE-UUID": {
"value": "mock",
"optional": true
},
"X-EXAMPLE-APP-ID": ["com.example.iphone.app1", "com.example.iphone.app2", "com.example.android.app1"]
},
@jamztang
jamztang / NSArray+JTArraySection.h
Created October 18, 2011 08:02
Handy NSArray category method for splitting an NSArray
// ARC
@interface NSArray (JTArraySection)
- (NSDictionary *)dictionaryBySectionKeyPath:(NSString *)keyPath;
- (NSArray *)arrayBySectionKeyPath:(NSString *)keyPath;
@end