Skip to content

Instantly share code, notes, and snippets.

@jamztang
jamztang / JTStringAddition.h
Created January 8, 2012 14:19
NSStringf. Simpler printf styled +[NSString stringWithFormat:]
//
// JTStringAddition.h
//
// Created by James Tang on 27/08/2011.
//
NSString *NSStringf(NSString *format, ...);
@jamztang
jamztang / LICENSE
Created January 8, 2012 14:01
Rendering any UIViews into UIImage in one line
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
@jamztang
jamztang / LICENSE
Created January 8, 2012 13:55
Loading a Nib file programmatically using NSObject category
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
@jamztang
jamztang / LICENSE
Created January 6, 2012 18:48
Creating a placeholder UIImage dynamically with color
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
@jamztang
jamztang / LICENSE
Created January 6, 2012 18:28
Cancelable Scheduled Blocks in Objective-C
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
@jamztang
jamztang / GPlusAlbumLogic.m
Created November 18, 2011 10:43
Google+ Style Album
#define MAX_HEIGHT 100
#define MAX_WIDTH 310
#define BORDER_WIDTH 5
- (NSArray *)resultingArrayWithArray:(NSArray *)originalArray {
NSMutableArray *rootArray = [NSMutableArray array];
for (NSValue *value in originalArray) {
// Missing part
}
@jamztang
jamztang / ReferenceBookmarks.txt
Created November 17, 2011 10:04
Settings.bundle instructions
Official Link
http://developer.apple.com/library/ios/#documentation/PreferenceSettings/Conceptual/SettingsApplicationSchemaReference/Introduction/Introduction.html#//apple_ref/doc/uid/TP40007005-SW1
Adding a settings bundle
http://useyourloaf.com/blog/2010/5/18/adding-a-settings-bundle-to-an-iphone-app.html
Debug Only settings
http://mrox.net/blog/2008/11/16/adding-debug-only-preferences-in-iphone-applications/
@jamztang
jamztang / .profile
Created November 12, 2011 06:35
.profile show git branch
export PS1="[\u@\h \W\$(git branch 2> /dev/null | grep -e '\* ' | sed 's/^..\(.*\)/(\1)/')]\$ "
@jamztang
jamztang / JTImageProxy.h
Created November 11, 2011 19:12
UIImage downloader spec using proxy placeholder. Anyone in favor of this idea?
#import <UIKit/UIKit.h>
@protocol JTImageProxy <NSObject>
- (NSURL *)URL;
- (CGFloat)expectedSize;
- (CGFloat)totalDownloadedSize;
- (CGFloat)progress;
- (NSError *)error;
- (void)cancelDownload;
@jamztang
jamztang / api_spec.json
Created November 3, 2011 17:00 — forked from pinglamb/api_spec.json
damn-api sample spec
{
"host": ["api.example.com", "api-staging.example.com"],
"headers": {
"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"]
},