Skip to content

Instantly share code, notes, and snippets.

View GuanshanLiu's full-sized avatar

Guanshan Liu GuanshanLiu

View GitHub Profile
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <sys/stat.h>
static const char *gameName = "GameName";
/* Gets the ideal save directory for the target platform.
* @param output A character array, ideally PATH_MAX characters long.
@GuanshanLiu
GuanshanLiu / run_script
Created December 28, 2012 07:12
armv6 support for XCode 4.5 and above
# Modified from http://stackoverflow.com/questions/12619124/how-to-support-both-armv6-and-armv7s-for-release-build-in-xcode-4-5/12678077#12678077
# Thanks Mike, Jerome, Max_B for their contributions
#################
# Configuration #
#################
# Find the common base directory for both build
XCODE_BUILD=${BUILD_ROOT%%/Build*}
# Change this to the full path where Xcode 4.4 (or below) puts your armv6 output
export ARMV6_OUTPUT_PATH="$XCODE_BUILD/Build/Products/Release-armv6-iphoneos/"
@GuanshanLiu
GuanshanLiu / applesource.sh
Created July 22, 2012 07:49
Downloads Mac OS X, iOS released source code from http://www.opensource.apple.com/
#!/bin/sh
# applesource.sh
# Downloads Mac OS X, iOS released source code from http://www.opensource.apple.com/
#
# Created by Guanshan Liu on 22/07/2012.
#
if [ $# != 2 ]
then
@GuanshanLiu
GuanshanLiu / test.m
Created July 10, 2012 07:18 — forked from mikeash/test.m
Cocoa array slicing
#import <Foundation/Foundation.h>
@interface Slice : NSObject
@property NSInteger from;
@property NSInteger to;
@property NSInteger step;
@end
@implementation Slice
@end
@GuanshanLiu
GuanshanLiu / gist:3080963
Created July 10, 2012 04:17 — forked from drunknbass/gist:3074015
Swizzletastic
#include <objc/runtime.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "SwizzleMyNizzleProtocol.h"
BOOL SwizzleMethod(Class _class, SEL origSel, IMP altImp, char *prefix) {
if (_class == NULL || origSel == NULL || altImp == NULL) {
fprintf(stderr, "[Error] Class, SEL or IMP is NULL");
return NO;