Skip to content

Instantly share code, notes, and snippets.

View GuanshanLiu's full-sized avatar

Guanshan Liu GuanshanLiu

View GitHub Profile
@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;
@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 / 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 / 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/"
#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.

Keybase proof

I hereby claim:

  • I am guanshanliu on github.
  • I am guanshanliu (https://keybase.io/guanshanliu) on keybase.
  • I have a public key whose fingerprint is 4D2A 8562 7939 E41E 6A32 EFE8 D823 7440 5617 4DC7

To claim this, I am signing this object:

@GuanshanLiu
GuanshanLiu / test-create-playlist.js
Last active August 29, 2015 14:14
As I learn UI Automation with TTPod, the project I work on at Alibaba Inc.
try {
UIALogger.logStart("Testing creating a new playlist")
var target = UIATarget.localTarget()
var app = target.frontMostApp()
var window = app.mainWindow()
UIALogger.logMessage("Ensure we are at Mine section by ...")
@GuanshanLiu
GuanshanLiu / 1.swift
Created May 10, 2016 05:59
Project Euler in Swift #1 for Medium
let filtered = (1..<1000).filter {
$0 % 3 == 0 || $0 % 5 == 0
}
filtered.reduce(0, combine: +)
@GuanshanLiu
GuanshanLiu / gist:de4c4c92db031a3b765ccf10186ceb36
Last active August 26, 2016 02:29 — forked from casademora/gist:c4b19d8503767479c0e05a836de4aa4c
Animation behaviors demo from Shanghai Cocoaheads
//
// ViewController.swift
// BehaviorsDemo
//
// Created by Saul Mora on 8/25/16.
// Copyright © 2016 Magical Panda. All rights reserved.
//
import UIKit
import Cocoa
//typealias Parser<Token, A> = (Tokens) -> (A, Tokens)?
struct Parser<Tokens, A> {
let parse: (Tokens) -> (A, Tokens)?
}
typealias Stream<A> = Parser<String.CharacterView, A>