2010-09-29 13:17





Most commonly used commands in GDB Console

load program

Load the program into the target.

b main

Set a breakpoint in function main.


Continue after a breakpoint.


View a listing of the program.


Step one line (stepping over function calls).


Step one line (stepping into function calls).

info reg

View register values.

p xyz

Print the value of xyz data.

watch gvar1

Set Watchpoint on Global Variable gvar1.

via Commonly Used GDB Console Commands

Objective-C Notes

//string1 将被自动释放

NSString* string1 = [NSString string];


NSString* string2 = [[NSString alloc] init]; [string2 release];

Typically, each class gets two files: a header file that contains the @interface for the class and a dot-m file that holds the @implementation.






一个实例变量的设置器(setter)会自动释放(autorelease)原来引用的对象,同时保留(retain)新的。你只需要保证在dealloc函数中释放 (release)了它就行了。

  • When you create an object using new, alloc, or copy, the object has a retain count of 1. You are responsible for sending the object a release or autorelease message when you’re done with it. That way, it gets cleaned up when its useful life is over.
  • When you get hold of an object via any other mechanism, assume it has a retain count of 1 and that it has already been autoreleased. You don’t need to do any further work to make sure it gets cleaned up. If you’re going to hang on to the object for any length of time, retain it and make sure to release it when you’re done.
  • If you retain an object, you need to (eventually) release or autorelease it. Balance these retains and releases.

如果过你通过alloc或者copy创建了一个对象,在函数结尾的地方给它发送一个release或者autorelease消息就行了。如果你是通过其它方式创建的对象,就什么也别做。“If I get it from new, alloc, or copy, I have to release or autorelease it.”


@property (retain) NSString* caption;

@property 是Objective-C语言的一个指令,通过它声明属性。带括号的”retain”指示设置器(setter)要保留输入值,该行后面的是指定属性的类型以及名称。

@synthesize 指令为我们主动生成了setter和getter.

@class sets up a forward reference. This is a way to tell the compiler, “Trust me; you’ll learn eventually what this class is, but for now, this is all you need to know.”

The colored boxes next to the name indicate what the symbol is: E for an enumerated symbol, f for a function, # for a #define, m for a method, C for a class, and so on.

Chose File-Make Snapshot (or its handy shortcut, Command-Control-S) and Xcode will remember the state of your project.

#!/usr/bin/env python vs #!/usr/local/bin/python

#!/usr/bin/env python

Will figure out the correct location of python and make that as the interpreter for rest of the script.


Pointing to python is located at /usr/local/bin/python.

简单说 /env python 就是查找系统环境变量中的 python 并默认选择 path 里第一个。/usr/local/bin/python 就是指定使用这个路径下的 python,可能不同机子不同环境下 python 位置稍有差别,就有可能 /usr/local/bin/python 不存在。

via Here

Cron notes

Cron is a Linux system process that will execute a program at a preset time. To use cron you must prepare a text file that describes the program that you want executed and the times that cron should execute them. Then you use the crontab program to load the text file that describes the cron jobs into cron. via Using cron

crontab -e to edit the crontab file.


[min] [hour] [day of month] [month] [day of week] [program to be run]

Some examples:

10 3 * * * /usr/bin/foo ==> Will run /usr/bin/foo at 3:10am on every day.

12 3 * * * root tar czf /usr/local/backups/daily/etc.tar.gz /etc >> /dev/null 2>&1 via Cron Help Guide

CocoaChina Devcon 2


  1. 东西方游戏差别:东方玩家讲究剧情、操作、难度、画面,更享受游戏的过程和过关后那种爽快;西方游戏玩家比较喜欢休闲、娱乐、简单的游戏,不愿意去学习游戏操作甚至秘籍。
  2. 90% 的 iOS 用户对游戏都是新手,所以不能照搬 PC、PSP、街机游戏机游戏那种设计。
  3. 大部分 iOS 上的游戏玩家的 GQ 都很低,所以 Don’t make me think.
  4. 游戏时长最好 3~5 分钟,这个时长也是大家的碎片时间,休闲娱乐来一下~
  5. App 推广,俩字:曝光!充分利用一切途径加大程序的曝光度。
  6. 上线之前的准备工作要充足细致,App ICON 设计,画面截图,文字描述要准备充分,这个是唯一的一次宣传机会。

最后一个演讲很有货,准备把 keynotes 抓下来自己好好回味一下,不仅仅是 App Store 的生存法则。

SQL LEN function in MySQL

SQL: The LEN() function returns the length of the value in a text field.

SELECT LEN(column_name) FROM table_name

BUT: in MySQL LEN() does NOT work,it’s called LENGTH().

SELECT * FROM table_name WHERE LENGTH(column_name) < 5

via 1 2

Terminal Tips and Tricks For Mac OS X

via SuperUser:Terminal Tips and Tricks For Mac OS X

  • open . #Opens the folder you’re currently browsing in Finder.URLs, images, documents.

  • open -a Preview image.png #overriding the default program set for the filetype.

  • say “Hello there.” #text-to-speech.

  • !! #Runs the last command again; sudo !! to rerun the last command using sudo.

  • mdfind fileName #-onlyin for directory specified; -name for matching file names only.

  • python -m SimpleHTTPServer 8000 #Start a quick webserver from any directory.

  • qlmanage -p 2>/dev/null #alias as ql,launch quicklook on a file from the command line



The formatting of the sig block is prescribed somewhat more firmly: it should be displayed as plain text in a fixed-width font (no HTML, images, or other rich text), and must be delimited from the body of the message by a single line consisting of exactly two hyphens, followed by a space, followed by the end of line.

via Wikipedia:E-mail and Usenet



  1. 整天津津乐道的就是那些算法、数据结构、设计模式、语言技巧、技术规范
  2. 对于普通老百姓关心的东西一概没有兴趣。
  3. 大部分人对于时尚、化妆品、小资情调嗤之以鼻
  4. 对于电影、音乐、艺术、美食一知半解,对于地产、金融、法律知识一窍不通
  5. 对于一个普通老百姓市场生活中所能遇到的困难和问题,所追求的那一点享受和乐趣不闻不问
  6. 既不愿意亲身实践,更在主观心态上予以拒斥。


  • 做出来的东西千篇一律
  • 看上去什么都有,一用起来处处不贴心。
  • 我们把太多的时间用来围着电脑转,根本上缺少对于生活和需求的深刻体察,对于人的关怀。
  • 在企业软件领域,我们把这种情况称之为“不了解业务”,现在整个企业软件领域都在寻找“懂技术,通业务”的复合型人才
  • 在大众软件和公众互联网领域,这种情况同样严重。我就经常感觉,就算是 MP3 播放器、电子书、网络论坛这样最最平常的应用,一旦加上具体应用背景, 放在具体场合下,就有很多地方显得不方便,不贴心。

via Slide success story by @stingchen.