Category Archives: OS



brew install python

brew安装的命令会在/usr/local/bin里面,如果系统自带了一些工具在/usr/bin里,那么brew安装的可能无法被使用到。所以需要将/usr/local/bin放到 /usr/bin前面去

brew doctor会提供修复的命令:

Consider setting your PATH so that /usr/local/bin
occurs before /usr/bin. Here is a one-liner:
    echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.zshrc

修改之后source ~/.zshrc就可以使用最新版的python了

➜  python --version
Python 2.7.11
➜  which python



enable xtrafinder to work under OS X 10.11 El Capitan

据说是OSX 10.11开启了一个System Integrity Protection的功能,所以Xtrafinder就无法正常工作了。


How to modify System Integrity Protection

You must boot into the Recovery OS. You do this by restarting your machine, and holding COMMAND + R until the Apple logo appears.

Then select Terminal from the Utilities menu. It looks like this:

In the window that opens, type csrutil enable --without debug and press return.

This turns off the part of SIP that XtraFinder needs to run, and OS X complains that it is an unsupported configuration.

Now type reboot and press return to restart your machine.






It always has been a missing feature: disabling the sleep mode on a Apple Laptop. Who does not want to use it as a big juke-box or go warwalking. The best looking server ever, especially at about one inch height. This small utility is what you will want, this small utility acts as a wrapper to the Insomnia kernel extension.


Close your MacBook without putting it to sleep

Projects consists of kext and userspace tools that help to manage sleep behavior.

NoSleep makes closing of your MacBook lid possible without going to a sleep mode. Now you shouldn’t have to plug your mouse and monitor to stay computer awake – just activate it by clicking a menu bar icon or check a tick in the System Preferences and continue downloading huge files and watching favorite movies over the network with lid closed.


Caffeine is a small, free app for Mac users by lighthead software. You can download it from their site or from the Mac App Store. Once installed, Caffeine sticks a small coffee cup icon in your menu bar, and presents you with its preference screen.




据说是可以媲美windows下beyond compare的工具,不过够贵,69.99$


据说也不错,Mac app store有,才4.99$, 便宜多了

Beyond Compare





ClipMenu represents the best combination of simplicity and power that I’ve found in a clipboard manager. It has all the features I need: a completely customizable history, support for text and image clips and a keyboard activated pop up window. It even has some really powerful options that I now couldn’t live without such as a snippets manager and a robust actions system that allows you to manipulate strings of text (change the case, wrap with tags, etc.).

The thing that really makes me love ClipMenu is that it doesn’t even really feel like an app. Instead it feels like a natural extension of OS X. I’ve tried some really expensive and fancy options that I didn’t like half as much. If you’re in the market for a clipboard manager, start here.




1、按 delete 键,实现 Windows 键盘上退格键(Backspace)的功能,也就是删除光标之前的一个字符;
2、按 fn+delete 键,删除光标之后的一个字符,相当于传统Windows的delete键;
3、按 option+delete 键,删除光标之前的一个单词(英文有效);
4、按 command+delete 键,删除光标之前整行内容;
5、选中文件后按 command+delete,删除掉该文件.



Mac下面窗口大小的调整、窗口的最大化等操作,跟Windows比起来有点麻烦。尤其是多个显示器的时候,Windows 7以后有快捷键 Shift + Win + ->,可以很方便的将当前窗口移动到下一个显示器。这样做演示的时候尤其方便,不需要用鼠标慢腾腾的将窗口拖过去。Mac本身是没有这种快速切换显示器的功能的。



cinch,sizeUP, divvy,moom 等

1. SizeUP


2. divvy


3. Moom






4. slate


A window management application (replacement for Divvy/SizeUp/ShiftIt)



Slate is a keyboard-driven window management program for Mac OSX. It is highly configurable and has tons of features. It has permanently changed the way I use my Mac. Not only is it better than other popular programs like Divvy, SizeUp and Moom, it beats their prices at being free. Slate is the VIM/Emacs of window managers: it is less of a window manager than a workflow changing tool you will never give up.

Slate has so much functionality that I think of it more as a shortcut-based productivity tool than a window manager. Here is a sample of what it can do:

  • Move/Resize/Shift windows: this can be done based on different screen size fractions and even mathematical formulae. There are commands for practically every window operation you can think of. It also supports the Divvy style sizing grid.
  • Switch Windows: Slate can act as a complete replacement for command+tab in many ways. I will talk about this more in the “Window Switching” section.
  • Manage multiple monitors: Slate can move windows between monitors as well as detecting your monitor configuration and automatically moving windows around when you plug in an external monitor.
  • Save window layouts: Slate has a feature called “snapshots” that allows you to save your current window layout and restore it at any time. This is handy for having different layouts for different projects/tasks.

5. ShiftIt



都说Mac的神器是Alfred, 可以极大的提高工作效率。使用了一下,确实如此。

收费版中才有的功能 workflow,相当于给自己经常做的事情加上快捷键,所以能节省很多时间。


建议安装一个workflow search, 然后就可以直接找自己需要的workflow了,比较方便


另外一个免费的launcher, QuickSilver据说也很不错,如果不想花钱的话,也是一个不错的选择:



一句话: odex文件是为了加速程序的运行,但是制作custom rom的时候,会麻烦一点;所以就有了deodex的机制出来,把odex文件重新塞回到APK里面去。


What do “Odex” and “Deodex” mean? The All Inclusive Explanation

by Jim Farmer on 

Show of hands, how many of you reading this have been browsing forums looking for ROMs only to come across a term completely foreign. Hey, it’s OK, I’ve been there too. In particular, the terms Odex and Deodex notoriously cause budding Android modders’ eyes to glaze over. So, what are they talking about?

To better understand deodex, you first need to know about odex.

Stock Android implements an odex file structure, with odex meaning “optimized” dalvik executable file. As your likely aware, Android apps on your device are packaged as .apkfiles. That all being said, what this means is that for pretty much all of your apks there is a corresponding odex file. This goes for the framework files in .jar format as well.

For instance, on this non-rooted Galaxy Nexus you’ll find


as well as


But what exactly are these odex files?
Well, when the Android OS needs to run your apps or utilize framework components, it has to parse (read/interpret) the compressed data stored in the .apk and/or .jar files. Having an odex file structure expedites this process by utilizing another file, the .odex file, which includes only the most critical data in an uncompressed format so the Android OS can quickly interpret that important information before parsing through the rest of the data held within the compressed .apks and .jars. Therefore, not all of the components of an app or framework are present in one file in an odexed sile system. I’ll elaborate on why I stress that in a moment. The goal of this scheme is to boot up faster,  and generally load applications more quickly and smoother.

Ok so what is deodex?
The odexed file structure works well as an optimization tool, except for in the case of theming. Odexed apps and frameworks present a unique problem to those wanting to theme because the aspect they want to theme is broken up into two files. Typically theming involves swapping out images for home made ones, however this is simply impossible in an Odexed environment. The solution is to DeOdex the file system and reunite all of the uncompressed critical data of an app or framework back into the compressed .apk or .jar file

On this rooted Galaxy Nexus running a custom ROM we see


but no longer the corresponding .odex file. The reassembled files become classes.dex

So which should you run?
The fact of the matter is DeOdexing is really only useful for theming. It won’t speed up your phone any.Technically it should slow it down, but in reality the difference is unnoticeable. In my experience, all custom ROMs come pre-DeOdexed, and they also zipalign your apps at boot. Zipaliging is the process of reorganizing the manner in which the .apk is packaged to optimize it for being parsed faster by the Android OS. The funny thing is, it is comparable if not better than the odex file structure, so you get the best of both worlds; a themed ROM and the speed of an optimized file structure. So really the only considerable difference lies in theming capability, and that’s where the choice is yours.

Find and kill a process in one line using bash and regex


In bash, you should be able to do:

/bin/ps aux | grep "/usr/local/bin/[p]ython2.7 /home/miniui/fw_dinners/" | awk '{print $2}' | xargs kill -9

Details on its workings are as follows:

  • The ps gives you the list of all the processes.
  • The grep filters that based on your search string, [p] is a trick to stop you picking up the actual grepprocess itself.
  • The awk just gives you the second field of each line, which is the PID.
  • The $(x) construct means to execute x then take its output and put it on the command line. The output of that ps pipeline inside that construct above is the list of process IDs so you end up with a command likekill 1234 1122 7654.

Here’s a transcript showing it in action:

pax> sleep 3600 &
[1] 2225
pax> sleep 3600 &
[2] 2226
pax> sleep 3600 &
[3] 2227
pax> sleep 3600 &
[4] 2228
pax> sleep 3600 &
[5] 2229
pax> kill $(ps aux | grep '[s]leep' | awk '{print $2}')
[5]+  Terminated              sleep 3600
[1]   Terminated              sleep 3600
[2]   Terminated              sleep 3600
[3]-  Terminated              sleep 3600
[4]+  Terminated              sleep 3600
pax> _

and you can see it terminating all the sleepers.

Explaining the grep '[p]ython' bit in a bit more detail:

When you do sleep 3600 & followed by ps -ef | grep sleep, you tend to get two processes with sleepin it, the sleep 3600 and the grep sleep (because they both have sleep in them, that’s not rocket science).

However, ps -ef | grep '[s]leep' won’t create a process with sleep in it, it instead creates grep '[s]leep' and here’s the tricky bit: the grep doesn’t find it because it’s looking for the regular expression “any character from the character class [s] (which is s) followed by leep.

In other words, it’s looking for sleep but the grep process is grep '[s]leep' which doesn’t have sleep in it.

When I was shown this (by someone here on SO), I immediately started using it because

  • it’s one less process than adding | grep -v grep; and
  • it’s elegant and sneaky, a rare combination 🙂