Skip to content

Instantly share code, notes, and snippets.

//
// NSObject+PropertyListing.h
// PropertyFun
//
// Created by Andrew Sardone on 8/27/10.
//
#import <Foundation/Foundation.h>
@andrewgleave
andrewgleave / iOSMapKitFitAnnotations.m
Last active May 17, 2024 02:07
Zooms out a MKMapView to enclose all its annotations (inc. current location)
MKMapRect zoomRect = MKMapRectNull;
for (id <MKAnnotation> annotation in mapView.annotations) {
MKMapPoint annotationPoint = MKMapPointForCoordinate(annotation.coordinate);
MKMapRect pointRect = MKMapRectMake(annotationPoint.x, annotationPoint.y, 0, 0);
if (MKMapRectIsNull(zoomRect)) {
zoomRect = pointRect;
} else {
zoomRect = MKMapRectUnion(zoomRect, pointRect);
}
}
@jcsrb
jcsrb / gist:1081548
Created July 13, 2011 23:05
get avatar from google profiles, facebook, gravatar, twitter, tumblr
function get_avatar_from_service(service, userid, size) {
// this return the url that redirects to the according user image/avatar/profile picture
// implemented services: google profiles, facebook, gravatar, twitter, tumblr, default fallback
// for google use get_avatar_from_service('google', profile-name or user-id , size-in-px )
// for facebook use get_avatar_from_service('facebook', vanity url or user-id , size-in-px or size-as-word )
// for gravatar use get_avatar_from_service('gravatar', md5 hash email@adress, size-in-px )
// for twitter use get_avatar_from_service('twitter', username, size-in-px or size-as-word )
// for tumblr use get_avatar_from_service('tumblr', blog-url, size-in-px )
// everything else will go to the fallback
// google and gravatar scale the avatar to any site, others will guided to the next best version
@jamztang
jamztang / UIImage+JTImageDecode.h
Created October 2, 2011 05:40
Force UIImage to decompress
//
// UIImage+JTImageDecode.h
//
// Created by james on 9/28/11.
// http://ioscodesnippet.tumblr.com
//
@interface UIImage (JTImageDecode)
+ (UIImage *)decodedImageWithImage:(UIImage *)image;
@end
@jamztang
jamztang / JTInvocationManager.h
Created October 2, 2011 17:37
Easily perform list of operations on specific NSOperationQueue through NSProxy
//
// JTInvocationManager.h
//
// Created by James Tang on 02/10/2011.
//
#import <Foundation/Foundation.h>
@interface JTInvocationManager : NSProxy {
id _proxiedTarget;
@jamztang
jamztang / JTMainQueueProxy.h
Created October 2, 2011 17:37
Using NSProxy to perform operation on main thread easily
//
// JTMainQueueProxy.h
//
// Created by James Tang on 02/10/2011.
//
#import <Foundation/Foundation.h>
@interface JTMainQueueProxy : NSProxy {
id _proxiedTarget;
@jamztang
jamztang / UIView+JTRemoveAnimated.h
Created October 3, 2011 18:35
Adding fade out effect on -[UIView removeFromSuperview]
//
// UIView+JTRemoveAnimated.h
//
// Created by james on 9/1/11.
// http://ioscodesnippet.tumblr.com/
//
@interface UIView (JTRemoveAnimated)
- (void)removeFromSuperviewAnimated;
@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
@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"]
},
@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