Skip to content

Instantly share code, notes, and snippets.

@TonnyXu
TonnyXu / .bashrc
Created September 10, 2011 04:44
Colorful Prompt PS1 with Error
export PS1="\e[35;40m\u\e[0m@\e[36;40m\h\e[0m[\e[37;40m\A\e[0m] [\e[36;40m\W\e[0m]: "
@TonnyXu
TonnyXu / .bashrc
Created September 10, 2011 04:46
Colorful Prompt with Correct Setting
export PS1="\[\e[35;40m\]\u\[\e[0m\]@\[\e[36;40m\]\h\[\e[0m\][\[\e[37;40m\]\A\[\e[0m\]] [\[\e[36;40m\]\W\[\e[0m\]]: "
@TonnyXu
TonnyXu / IAPVerification.m
Created September 10, 2011 05:36
IAP Verification server definication
// APPSTORE is a macro defined in AppStore build configuration.
// You need to do it yourself. Xcode won't help
#ifdef APPSTORE
NSString * const verificationURL = @"http://www.yourserver.com/verify?usingSandbox=1";
#else
NSString * const verificationURL = @"http://www.yourserver.com/verify?usingSandbox=0";
#endif
@TonnyXu
TonnyXu / IAPVerification2.m
Created September 10, 2011 05:48
IAP Verification server definition with version parameter
// APPSTORE is a macro defined in AppStore build configuration.
// You need to do it yourself. Xcode won't help
#ifdef APPSTORE
NSString * const verificationURL = @"http://www.yourserver.com/verify?usingSandbox=1&version=1.1";
#else
NSString * const verificationURL = @"http://www.yourserver.com/verify?usingSandbox=0%version=1.1";
#endif
@TonnyXu
TonnyXu / include.h
Created September 18, 2011 06:22
the #include directive
// Refer to http://msdn.microsoft.com/en-us/library/36k2cdd4(v=vs.80).aspx
/* Tonny's NOTE
* ------------
* Sep 18, 2011
*
* 1. このファイルが存在しているフォルダ ->
* 2. "header.h"をインクルードしたその他のファイルが存在しているフォルダ ->
* 3. コンパイラの /I に指定したフォルダ ->
* 4. 環境関数のINCLUDEに指定したフォルダ
@TonnyXu
TonnyXu / generateUnicodeCharacters.vim
Created December 26, 2011 06:08
generate Unicode characters as you want
function! GenerateUnicode(first, last)
let i = a:first
while i <= a:last
" you can change the format, here \'%04X\' => \' is used to output the value and make it avaiable for php.
let c = printf("\'%04X\' => \'", i)
for j in range(16)
let c = c . nr2char(i)
let i += 1
endfor
" also, append \', to the end of line, to make it php compatable.
@TonnyXu
TonnyXu / iOSUnitTestBundlePath.m
Created January 29, 2012 08:49
Use bundleForClass to get the unit test bundle's path
/*
This tips is extremely useful when you test your CoreData app in Unit Test.
*/
// iOS app is an executable bundle, means the `main` method is
// included inside app bundle, so `mainBundle` returns the app bundle
//
// See doc at https://developer.apple.com/library/ios/#documentation/Cocoa/Reference/Foundation/Classes/NSBundle_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40003624
NSBundle *appBundle = [NSBundle mainBundle];
@TonnyXu
TonnyXu / InsertSort.m
Created January 29, 2012 12:23
InsertionSort
//
// CLRS_InsertionSort.c
// algorithms-iOS
//
// Created by Tonny Xu on 2/1/12.
// Copyright (c) 2012 Tonny Xu. All rights reserved.
//
#include <stdio.h>
#include <sys/time.h>
@TonnyXu
TonnyXu / MergeSort.m
Created January 29, 2012 12:26
Merge Sort
// TBD
@TonnyXu
TonnyXu / xPowerToN.m
Created January 29, 2012 12:29
X power to n
// TBD