Skip to content

Instantly share code, notes, and snippets.

# show log tree (one-line per commit)
git config --global alias.logtree "log --graph --pretty=oneline --abbrev-commit"
# show log tree (detailed)
git config --global alias.logtreelong "log --graph"
@jamztang
jamztang / UIApplicationAddition.h
Last active October 5, 2015 18:29
Handy marco to return supported UIInterfaceOrientation for your View Controllers
// Created by Jamz Tang 2012-06-02
// http://ioscodesnippet.com/post/24203288551/quickly-switch-supported-uiinterfaceorientation-for
// Convert UIInterfaceOrientation to NSString, so we can compare it
static inline NSString *NSStringFromUIInterfaceOrientation(UIInterfaceOrientation orientation) {
switch (orientation) {
case UIInterfaceOrientationPortrait: return @"UIInterfaceOrientationPortrait";
case UIInterfaceOrientationPortraitUpsideDown: return @"UIInterfaceOrientationPortraitUpsideDown";
case UIInterfaceOrientationLandscapeLeft: return @"UIInterfaceOrientationLandscapeLeft";
case UIInterfaceOrientationLandscapeRight: return @"UIInterfaceOrientationLandscapeRight";
@jamztang
jamztang / UIBlocksView.h
Created June 13, 2012 09:52
UIBlocksView - Adding blocks to UIViews
// ARC based
#import <UIKit/UIKit.h>
typedef void(^UIDrawRectBlock)(CGRect rect);
typedef void(^UILayoutSubviewBlock)(void);
@interface UIBlocksView : UIView
- (void)onDrawRectHandler:(UIDrawRectBlock)block;
@jamztang
jamztang / UITableViewDeleteActionResponder.m
Created June 28, 2012 08:08
Fixing the "delete" menu for UITableView shouldShowMenuForRowAtIndexPath
//
// Quick Hack to enable delete menu item
// Original blog post at http://mystcolor.me/post/26114988122/show-delete-menu-item-in-tableview
//
// Updated: 30 June 2012
// I realized there should really be a more elegant way to
// send actions to responder chain, without manually looping
// through the responder chain. Here we implement the
// delete: method in both UITableViewCell and UITableView, so
// that they know the right thing to do in their own delete:
@jamztang
jamztang / YourViewController.m
Created August 3, 2012 04:48
Properly handle custom rotation animations in both iOS 4 and iOS 5
@interface YourViewController ()
@property (unsafe_unretained, nonatomic) UIInterfaceOrientation fromInterfaceOrientation;
@end
@implementation YourViewController
@synthesize fromInterfaceOrientation;
#pragma mark Rotations for iOS 5
- (void)viewWillLayoutSubviews {
@jamztang
jamztang / UIImage+Retina4.h
Created September 14, 2012 16:05 — forked from bstahlhood/UIImage+Retina4.h
Swizzled UIImage imageNamed for iPhone 5
//
// UIImage+Retina4.h
// StunOMatic
//
// Created by Benjamin Stahlhood on 9/12/12.
// Copyright (c) 2012 DS Media Labs. All rights reserved.
//
#import <UIKit/UIKit.h>
@jamztang
jamztang / LICENSE
Last active November 2, 2019 22:33
UINibDecoderProxy - Use NSProxy to observe what's encoded when views and controllers are created in Interface Builder.
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
Last active December 13, 2015 20:28
objective-C method swizzling helper
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 / JTKeyValueObserver.h
Last active December 19, 2015 19:49
The simplest KVO+Block wrapper. http://ioscodesnippet.com
/*
* This file is part of the http://ioscodesnippet.com
* (c) Jamz Tang <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*
* Usage:
@jamztang
jamztang / JTDropShadowFixNavigationViewController.h
Last active December 23, 2015 06:09
JTDropShadowFixNavigationViewController - Using custom drop shadows in UINavigationBar (fix for iOS 6.1)
/*
* This file is part of the http://ioscodesnippet.com
* (c) Jamz Tang <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
#import <UIKit/UIKit.h>