常用的gdb命令

backtrace 显示程序中的当前位置和表示如何到达当前位置的栈跟踪(同义词:where)
breakpoint 在程序中设置一个断点
cd 改变当前工作目录
clear 删除刚才停止处的断点
commands 命中断点时,列出将要执行的命令
continue 从断点开始继续执行
delete 删除一个断点或监测点;也可与其他命令一起使用
display 程序停止时显示变量和表达时
down 下移栈帧,使得另一个函数成为当前函数
frame 选择下一条continue命令的帧
info 显示与该程序有关的各种信息
jump 在源程序中的另一点开始运行
kill 异常终止在gdb 控制下运行的程序
list 列出相应于正在执行的程序的原文件内容
next 执行下一个源程序行,从而执行其整体中的一个函数
print 显示变量或表达式的值
pwd 显示当前工作目录
pype 显示一个数据结构(如一个结构或C++类)的内容
quit 退出gdb
reverse-search 在源文件中反向搜索正规表达式
run 执行该程序
search 在源文件中搜索正规表达式
set variable 给变量赋值
signal 将一个信号发送到正在运行的进程
step 执行下一个源程序行,必要时进入下一个函数
undisplay display命令的反命令,不要显示表达式
until 结束当前循环
up 上移栈帧,使另一函数成为当前函数
watch 在程序中设置一个监测点(即数据断点)
whatis 显示变量或函数类型

Mac自定义锁屏

发现mac没有control-alt-delete的锁屏功能,在公司人离开了非常不方便。于是自己用automator搞了个
  1. 打开automator
  2. 新建service
  3. 左侧选择No Input和any application
  4. 将start screen saver拖入后,保存,推出
  5. 打开system preference的keyboard shortcuts
  6. 选择service,拖到最下面有general
  7. 点击这行右侧,分配一个快捷键。
  8. 搞定!

解决Xcode模拟器attaching卡死问题

现象:xcode debug的时候run模拟器,卡死在attaching to (app name)上。模拟器按home按钮也没有用

处理方法:进入Organizer,进入Project tab。将没有用的都删除。进入出问题的project,然后删除Derived data。重启xcode(这步很重要)

MacOS半自动切换鼠标direction

用mac的时候,发现用鼠标和trackpad的时候切换非常麻烦。用鼠标的时候滚轮需要保持传统,而trackpad的时候则是natural.网上搜了一圈,发现没有可行的方法,于是用applescript写了一个,结合sh则可以较快搞定

 

首先enable device api:

在terminal中执行以下命令

sudo touch /private/var/db/.AccessibilityAPIEnabled

sudo chown 0 /private/var/db/.AccessibilityAPIEnabled

sudo chgrp 0 /private/var/db/.AccessibilityAPIEnabledsudo chmod 0444 /private/var/db/.AccessibilityAPIEnabled

 

完成后,将applescript(附)复制到一个目录,我这里用的是~/AppleScripts/ReverseScrollDirection.scpt

然后,将sh的脚本复制到(附)~/Desktop下,并另存为.command的格式。

 

每次sh runReverse.sh即可啦!

 

 

applescript

tell application "System Preferences"

activate

set current pane to pane "com.apple.preference.trackpad"

end tell

tell application "System Events"

tell application process "System Preferences"

tell tab groupof window "Trackpad"

click radio button "Scroll & Zoom"

click checkbox 1

end tell

end tell

end tell

tell application "System Preferences"

quit

end tell

 

bash

#!/bin/bash
osascript ~/AppleScripts/ReverseScrollDirection.scpt
osascript -e 'tell application "Terminal" to close window 1'

 

 

Brain and heart

最近和一位很有智慧的人吃饭,听了他的人生观,其中有一点:trust more of your heart.

 

什么是brain,指的是Logic。人生的一切烦恼,源自于logic,同样的人工资比我高,为什么比我高?我做了什么导致我那么悲惨?为什么一点点小事我的下属都做不好?为什么我的boss那么蠢?我怎么样才能找到我的career path等等。这都是brain

 

什么是heart,这一点比较模糊,某人用她的brain无法理解,在此说明一下,你理解的时候是不能用你得brain,你得logic去证明你是有heart,反之,你也无法证明你得heart的重要性。heart,是一种源自感觉的,基于过去经历和个人梦想的所产生的对于是非的判断。例如,我的内心告诉我我要做完美的产品,我深深地知道对TA好我很开心。你不能用逻辑去证明它,但是你无法否认这些东西是存在的,科学无法证明的,很多情况下都是对的。

 

Jobs所谓follow your heart,我的理解就是这样:从内心深处去感受你得梦想,感受你觉得对的事情,感受你得喜怒哀乐,感受你要什么不要什么,从而决定你做什么。heart不是要所有的事情都相信直觉,也不是所有的事情都必须用heart而非brain。你不能用heart去说服别人(特别是没有共鸣的人,除非你在人群中产生共鸣,如《乌合之众》中所属的方法)。

 

什么情况下要follow the heart:

  • 我讨厌我的工作,我和我的同事没有共鸣,没有激情,老板很挫。So follow your heart and quit tomorrow
  • 我在一个地方某食,我的同学都赚钱比我多,但是我觉得我做的是对的事情。这时候,你得brain用逻辑+世俗的压力在让你去赚钱,去搞你不擅长也不喜欢的东西,但是你深吸一口气你发现你的愿景和你要做的事情是一致的,so follow your heart and kick ass

什么情况下不要follow heart:

  • 评审产品的时候
  • 和陌生人吵架的时候
  • 考数学物理的时候

 

总之,内心的直觉,是人前进的根本动力,逻辑是人达到目的的手段。而brain恰恰又是人生烦恼的根本原因,你得heart是解药。

一个淘宝深度用户的出走

某C是淘宝深度用户,由于退休在家,长期泡淘宝,淘宝成了她网购的唯一途径和很大一部分生活乐趣。

她几乎从淘宝上购买任何个人兴趣用品,如十字绣、各种小家电、家居用品,衣服鞋子等等,期待着有一天可能自己也开个店。

就这样,她拿到了皇冠买家。但是,总是对快递,付款,以及货品的质量有这样那样的不满。

突然有一天,某人告诉她,有个叫amazon的网站,中文名叫亚马逊。她拿出信用卡,尝试了一次,送来一个包装完美(坚固的盒子,好几个气囊防震)。这个价格比淘宝商城的都要便宜。她尝到了甜头,大赞不已。她于是当天又买了巧克力送给别人,买了床单被套。

 

从此,她不看淘宝,泡卓越。而amazon也没有让她失望过。

 

呜呼!仁义不施而攻守之势异也。

 

NB的iOS阅读效果

获取ios http请求的方法

I recently had a problem. I was seeing intermittent issues with an iPhone app, Tapatalk, not working properly with a web forum hosted by a friend of mine. I knew there was a much better chance of getting the bug fixed if I could a) prove it was a bug and b) show the devs exactly where the problem was, but I was hampered by the usual problem: iOS apps are a bit of a black box, and I couldn’t see what it was doing internally.

However, like almost all network-aware iOS apps, this one was clearly using a web service to get data from the backend. So, all I needed to do was figure out a way to see the traffic on the web service. This is the sort of thing I used to do all the time when my day job was writing load testing scripts for big ecommerce sites, but the first time I’d had to do it on the Mac or from an iOS client. I managed to get it working after doing a little research. If you find yourself in need of a similar solution — perhaps for iOS app development, reporting a bug or some other reason (or just plain hacker interest!) — then click through for step-by-step instructions on how to intercept and view your iOS web traffic from any Mac running on the same network.

The first thing you need is an HTTP sniffer program. The grandaddy of all network traffic sniffers is Wireshark, but it’s rather low-level and overpowered for quickly looking through HTTP traces. It’s a bit like using an electron microscope when what you wanted was a magnifying glass. I came across several glowing references to Tuffcode’s MacScoop HTTP Scoop during my research, but didn’t really want to spend $15 on an app I was only going to use once. I settled on PortSwigger’s Burp Suite, a comprehensive HTTP security analysis tool. The free version has the HTTP Proxy feature, which is the only bit we need; grab that. (Windows users: you can use the excellent and free Fiddler Web Debugger, but I won’t be walking you through that today, sorry. The steps are very similar though.)

Burp Suite is a Java program, so when it downloads, you’ll see a directory with a JAR file in it. If you double click that, it should start up after a warning about an untested JVM version. Be thankful we still get JVMs with our OS X for now or this would be more complex.

Burp is written by and for security experts, so the UI is a bit … Spartan, … but it’s easy to configure it for the simple feature we want to do. First, click the Proxy tab at the top, then click the “intercept is on” button to make it say “intercept is off,” like so:

Next, select the Options tab. It’ll show you a single “proxy listener” running in a list. Click on it, then click the Edit button. Untick the “Listen on loopback interfaces only” checkbox, then click “Update.” You’ll get a warning you can ignore, and when you’re done, the app window should look like this:

When you’re done, click on the History tab. If you’re one of the many Mac users who find Java UIs give you hives, you can rejoice, because you’re done with that for now!

Next, open Apple > System Preferences > Network. Select your current active network connection and make a note of the IP address your Mac is using. For me, this is 192.168.2.32.

Now, turn to your iOS device — I’ll be using my iPhone, but this works the same way on an iPad or an iPod touch. Go into Settings > Wi-Fi > your Wi-Fi network, and then click the blue “more details” arrow. Scroll down and at the bottom there’s a set of three buttons under “HTTP Proxy.” Select “Manual” and fill in your Mac’s IP address (found in the last step) and the Burp Suite port number (8080 unless you changed it earlier), like so:

 

And that’s it. If you flick back to the Burp Suite window on the Mac now and start browsing the Web or using apps on your iPhone, you’ll see all the traffic show up in a neat little list. You can click on each individual request to see the full text sent and received as part of the request. Note that you might see some security warnings on the iPhone for any app that uses an encrypted link; this is because the app thinks that Burp Suite might be aman-in-the-middle attack. It’s not, though, and it’s safe to ignore that warning.

And there you have it — with one free download and a few minutes of configuration work, you can snoop all of iOS’s web traffic for fun and/or profit.

 

来源:http://www.tuaw.com/2011/02/21/how-to-inspect-ioss-http-traffic-without-spending-a-dime/

 

Jobs演讲技巧精要

纪念老乔,原创两张壁纸

点击可显示大图

 

 

大图地址:

白色:http://iflonely-wordpress.stor.sinaapp.com/uploads/2011/10/Steve_Jobs_hungry.png

黑色:http://iflonely-wordpress.stor.sinaapp.com/uploads/2011/10/Steve_Jobs_crazy.png