Skip to content

Instantly share code, notes, and snippets.

@tonycn
tonycn / build_for_iphoneos.sh
Created July 31, 2012 10:28 — forked from fbettag/build_for_iphoneos.sh
libsox compile script for iPhoneOS/iOS
#!/bin/bash
################################################################################
#
# Copyright (c) 2008-2009 Christopher J. Stawarz
#
# 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,
@tonycn
tonycn / objc_runtime_util
Created September 21, 2012 07:26
objc runtime used to create dynamic attribute
- (NSString *)viewFrame1 {
return objc_getAssociatedObject(self, kUIViewAdditionsFrame1);
}
- (void)setViewFrame1:(NSString *)frameStr {
@tonycn
tonycn / reachability_3g_wifi
Last active December 14, 2015 18:59
Reachablility to detect 3g or wifi
self.internetReachability = [Reachability reachabilityForInternetConnection];
[self.internetReachability startNotifier];
self.wifiReachability = [Reachability reachabilityForLocalWiFi];
[self.wifiReachability startNotifier];
[AppInfo setCurrentNetworkStatus:[self statusByWifiAndInternetReachability]];
@tonycn
tonycn / iOS_OTA.plist.tmpl
Created July 16, 2013 05:50
iOS OTA plist
'<div>',
'<img src="' + ((retina && item.icon2x) ? item.icon2x : item.icon) + '" />',
'<h3>' + item.name + "&nbsp;&nbsp;&nbsp;&nbsp;" + item.version + '</h3>',
'<p>' + item.created_at + '</p>',
'<a href="itms-services://?action=download-manifest&url=' + item.install_plist_url + '">下载App</a> &nbsp; &nbsp; &nbsp; &nbsp;',
'<a href="' + item.provisioning + '">下载证书</a>',
'</div>'
@tonycn
tonycn / create_universal_lib
Created August 6, 2013 04:12
bash script to create universal static library
git clean -df
set -x
# do not exit immediately on non-zero return values
set +e
set -o verbose
export DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer/
XCODEBUILD_PATH=/Applications/Xcode.app/Contents/Developer/usr/bin
XCODEBUILD=$XCODEBUILD_PATH/xcodebuild
@tonycn
tonycn / gist:7409356
Last active December 27, 2015 23:49
Git commands
View diversed commits between branches : git log --left-right --graph --cherry-pick --oneline devel...next
@tonycn
tonycn / gist:7478979
Created November 15, 2013 04:16
unix commands
1) nc & curl to view http request
$ nc -l localhost 8000 &
$ curl --proxy localhost:8000 --silent --max-time 1 http://baidu.com
@tonycn
tonycn / OSStatus.m
Last active December 28, 2015 21:39 — forked from zoul/OSStatus.m
#import <CoreFoundation/CoreFoundation.h>
#import <Foundation/Foundation.h>
NSString *NSStringFromOSStatus(OSStatus errCode)
{
if (errCode == noErr)
return @"noErr";
char message[5] = {0};
*(UInt32*) message = CFSwapInt32HostToBig(errCode);
return [NSString stringWithCString:message encoding:NSASCIIStringEncoding];
@tonycn
tonycn / TopBarViewController
Created January 7, 2014 10:09
Customise top bar with base controller
@interface TopBarViewController ()
@property (nonatomic, strong) UIView *statusbarBgView;
@end
@implementation TopBarViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
@tonycn
tonycn / jsonmodel_generator
Created April 12, 2014 06:48
sublime plugin to generate ObjC property code
# -*- coding: utf-8 -*-
import sublime, sublime_plugin
import json
class JsonpropCommand(sublime_plugin.TextCommand):
"""
Test 1:
{"a" : "abc", "b" : 1}
Test 2: