Skip to content

Instantly share code, notes, and snippets.

View shanegao's full-sized avatar

Shane Gao shanegao

View GitHub Profile
@shanegao
shanegao / xcode-project-code-counter
Created December 3, 2013 07:36
代码行数统计
find . -name "*.m" -or -name "*.h" |xargs grep -v "^$"|wc -l
@shanegao
shanegao / remote-notification-devicetoken-to-nsstring
Last active December 17, 2015 00:49
Apple Push Remote Notification device token (NSData) to NSString
const unsigned *tokenBytes = [deviceToken bytes];
NSString *hexToken = [NSString stringWithFormat:@"%08x%08x%08x%08x%08x%08x%08x%08x", ntohl(tokenBytes[0]), ntohl(tokenBytes[1]), ntohl(tokenBytes[2]), ntohl(tokenBytes[3]), ntohl(tokenBytes[4]), ntohl(tokenBytes[5]), ntohl(tokenBytes[6]), ntohl(tokenBytes[7])];
@shanegao
shanegao / useful-shell-scripts
Last active December 10, 2015 16:08
some useful shell scripts
#将当前目录下所有的文件以树形列出
alias lt='ls -R | grep ":$" | sed -e '"'"'s/:$//'"'"' -e '"'"'s/[^-][^\/]*\//--/g'"'"' -e '"'"'s/^/ /'"'"' -e '"'"'s/-/| /'"'"''
@shanegao
shanegao / remove-open-with-duplicate-items
Created November 8, 2012 08:28
删除OS X打开方式中的重复项
/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill -r -domain local -domain system-domainuser
@shanegao
shanegao / uinavigationbar-custom-background-image.m
Created June 7, 2012 07:42
uinavigationbar custom background image
//1.
[self.navigationController.navigationBar addSubview:[[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"navbarbg.png"]] autorelease]];
//2.
self.navigationController.navigationBar.tintColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"navbarbg.png"]];
//3.
@implementation UINavigationBar (UINavigationBarCategory)
- (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx
{
if([self isMemberOfClass:[UINavigationBar class]]) {
UIImage *image = [UIImage imageNamed:@"navbarbg.png"];