Skip to content

Instantly share code, notes, and snippets.

@siqin
siqin / gist:4201667
Created December 4, 2012 07:57
Remove Emoji in NSString
// XCode 4.2.1
@implementation NSString(EmojiExtension)
- (NSString*)removeEmoji {
__block NSMutableString* temp = [NSMutableString string];
[self enumerateSubstringsInRange: NSMakeRange(0, [self length]) options:NSStringEnumerationByComposedCharacterSequences usingBlock:
^(NSString *substring, NSRange substringRange, NSRange enclosingRange, BOOL *stop){
@siqin
siqin / RunLoopObserver.m
Created August 14, 2012 13:10
RunLoop Observer
#pragma mark - RunLoop Observer
- (void)onNewThread:(id)info
{
NSRunLoop *runloop = [NSRunLoop currentRunLoop];
if (!runloop) {
return ;
}
if (runloop == [NSRunLoop mainRunLoop]) {
@siqin
siqin / quicksort.py
Created August 8, 2012 09:41
Python QuickSort
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import random
global compareCount
def swap(arr, l, r):
temp = arr[l]
arr[l] = arr[r]
@siqin
siqin / routeOnMap.m
Created July 25, 2012 08:17
Draw route on MKMapView
#pragma mark -
- (void)drawTestLine
{
// test code : draw line between Beijing and Hangzhou
CLLocation *location0 = [[CLLocation alloc] initWithLatitude:39.954245 longitude:116.312455];
CLLocation *location1 = [[CLLocation alloc] initWithLatitude:30.247871 longitude:120.127683];
NSArray *array = [NSArray arrayWithObjects:location0, location1, nil];
[self drawLineWithLocationArray:array];
}
@siqin
siqin / SwipeNavigationController.h
Created November 21, 2013 11:10
SwipeNavigationController
//
// SwipeNavigationController.h
// cdNBA
//
// Created by Jason Lee on 13-9-17.
// Copyright (c) 2013年 Jason Lee. All rights reserved.
//
#import <UIKit/UIKit.h>
// Taken from the commercial iOS PDF framework http://pspdfkit.com.
// Copyright (c) 2013 Peter Steinberger. All rights reserved.
// Licensed under MIT (http://opensource.org/licenses/MIT)
//
// You should only use this in debug builds. It doesn't use private API, but I wouldn't ship it.
#import <objc/runtime.h>
#import <objc/message.h>
// Compile-time selector checks.
@siqin
siqin / observeKeyboardChange_iOS
Created April 25, 2013 10:04
Perfectly following keyboard height change.
#pragma mark - reg & unreg notification
- (void)regNotification
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillChangeFrame:) name:UIKeyboardWillChangeFrameNotification object:nil];
}
- (void)unregNotification
{
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillChangeFrameNotification object:nil];
@siqin
siqin / Path-Style-Menu.m
Created October 9, 2012 08:46
Path-Style Menu
//
// ViewController.m
// PathStyleMenu
//
// Created by Jason Lee on 12-10-9.
// Copyright (c) 2012年 Jason Lee. All rights reserved.
//
#import "ViewController.h"
@siqin
siqin / fade.m
Created September 28, 2012 08:33
Fade In and Fade Out
CATransform3D transform = CATransform3DMakeScale(0.001, 0.001, 1.0);
hintView.layer.transform = transform;
hintView.alpha = 0;
transform = CATransform3DMakeScale(1.0, 1.0, 1.0);
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
hintView.layer.transform = transform;
hintView.alpha = 1;
[UIView commitAnimations];
@siqin
siqin / gist:3798664
Created September 28, 2012 08:35
iOS-App-Launch-Animation
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] autorelease];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
UIImageView *splashScreen = [[[UIImageView alloc] initWithFrame:self.window.bounds] autorelease];
splashScreen.image = [UIImage imageNamed:@"Default"];