The default key bindings for the home and end keys in Mac OS X are different to any other operating system I’ve ever used. By default, they seem to be bound to the viewport, rather than the line of text you are editing. In a multi-line document, the Home key scrolls up to the top of the document, and the End key scrolls down to the bottom. In each case the caret stays where it was.
As a programmer I find this behaviour to be just plain wrong— I want Home and End to move to the start and end of the current line.
I have found a way to “fix” this problem by editing the default keybindings file, ~/Library/KeyBindings/DefaultKeyBinding.dict. Create the directory and / or the file if they’re not already there, and make it look like this:
{
/* Remap Home / End to be correct
*/
"\UF729" = "moveToBeginningOfLine:"; /* Home */
"\UF72B" = "moveToEndOfLine:"; /* End */
"$\UF729" = "moveToBeginningOfLineAndModifySelection:"; /* Shift + Home */
"$\UF72B" = "moveToEndOfLineAndModifySelection:"; /* Shift + End */
}
If there are already entries in DefaultKeyBinding.dict, just add the 4 new mappings above to the main section of your file.
Add the following line to get a “recent applictions/documents folder” on the dock.
defaults write com.apple.dock persistent-others -array-add '{"tile-data" = {"list-type" = 1;}; "tile-type" = "recents-tile"; }'
I have my MATLAB installed in Parallel Desktops for Mac. Since I do majority of my work in Mac now, I hate to open Parallel Desktops very often. So I’m thinking about porting some important packages to use in Mac OS natively.
CrossOver is a good package, I managed to port my BaKoMa TeX into Mac OS, it works fine. MATLAB turned out to be hard. When I install it within CrossOver, it gives an error:”Can not install OLE server”. It is related to Database, so I cleaned up all the extra toolboxes, and only install MATLAB itself. The error message still comes up.
Then I zipped the MATLAB from Parallel Desktop and unzipped the files to the “Drive_C” in CrossOver. Running MATLAB gives an error “License Manager Error -9.”. Checking MATLAB website, it seems that even if I have the serial number, I still need to reinstall, but in CrossOver, I simply can not install.
Here is the solution. Just open %CrossOver_Drive_C/MATLAB7/bin/win32/license.dat, and look for something like this: “HOSTID=DISK_SERIAL_NUM=d8682dc9 PLATFORMS=i86_n SN=0″.
Go to %CrossOver_Drive_C and create a file “.windows-serial” and “echo d8682dc9 > .windows-serial”.
Everything will be fine.
As soon as I can port SAS into CrossOver, I can delete Parallel Desktops and save me 30G hard drive space.
UPDATE: I forgot to mention that I installed the latest JRE in CrossOver before I copy MATLAB.
Full version of MATLAB 2006 for Windows. Java GUI included (_without_ -nojvm).
The new Java Runtime Environment Version 5.0 Update 6 for windows (jre-1_5_0_06-windows-i586-p.exe) must be downloaded from: http://www.java.com/en/download/windows_manual.jsp.
JRE must be installed either in windows or through wine.
Then the jre folder in matlab (../Program Files/MATLAB/R2006a/sys/java/jre/win32/jre) directory must replaced by the newly generated jre1.5.0_06 in ../Program Files/Java/.
After that the ../Program Files/MATLAB/R2006a/sys/java/jre/win32/jre.cfg file must be edited to contain a single line withe: 1.5.0_06
After that, MATLAB 2006a will be fully functional (as far as know). You can either use the windows installed version or copy the whole MATLAB folder to ~/.wine/drive_c/Program Files/ (that way you won’t need the windows partition anymore).
Note the beautiful title bars you see in this blog.



They are on top of the blog, each time you reload the page, you get a different title bar.
I may write a post about these title bars and the stories behind them later, but today, I’d like to record how I can copy them quickly to the title bar directory from my Mac.
There are a few steps:
#!/bin/sh
#
infile=`echo $1|tr '"' '\"'`;
filename=`basename "$infile"`;
`/usr/bin/scp "$infile" username@mikezhang.com:/home/username/mikezhang.com/wp-content/themes/aura/headerimg/`;
base="http://mikezhang.com/wp-content/themes/aura/headerimg/";
echo "$base$filename" | perl -ne 's/ /%20/g; print';
To use the shortcut, select the newly created title bars, invoke QS, type “Current Selection..”, then “TAB”, then “Copy to”, the option called “Copy to Server” will show up, press Enter. It’s done.
Here is the newest addition:

To prevent the creation of these files, open the Terminal and type:
defaults write com.apple.desktopservices DSDontWriteNetworkStores true
I sometimes use MIT’s VPN to download obscure papers from the MIT library. To do it, you have to have an MIT IP address. The MIT VPN software allows me to obtain one.
I sometimes also download files through BitTorrent (for legitimate files of course), and HKUST blocks this kind of traffic. So the VPN proved also useful.
This trick can be used in mainland China, too. Last time when I visited Shanghai, I tried to access a Wikipedia article (in fact, I was writing a wikipedia paper, and needed to check the page). Due to the block in China, I could not access Wikipedia directly, so the MIT VPN was used again. Alternatively, I can set up a quick proxy connection in my Mac. Here is how:
open Terminal, and type:
ssh -ND 9999 zxq@mikezhang.com
where “ssh” is the command to connect to the server “mikezhang.com”, which is hosted in California. “zxq” is my login name on that server. The “-ND 9999″ part tells the machine to keep the connection and use it as a proxy server.
That’s all, then I just need to go to Firefox to set up the proxy. Below is how, just choose “Manual” and change the port for “SOCKS Host” to 9999.

I need to copy some songs from my iPod Classic 80GB to the Mac. Many programs fail to work here, for example, ipoddisk, isynctunes, etc (since the iPod is very new).
One software works greatly is called Senuti, I don’t know the meaning of this word, but it does what it was meant to do. One tiny thing to note is that since I have many songs with Chinese titles, they became unrecognizable in iTunes. The solution is simple, in the “preferences” menu, select “Always add songs to iTunes Library” and “Add Songs to Playlist” under “iTunes”.
I guess Apple’s concern about allowing people to copy songs from ipod to itunes is to prevent piracy. It really doesn’t make sense. Suppose my friend has an iPod, and would like to share the songs for me, it is easy to use the iPod itself as a hard drive and copy everything to my machine. The only reason I wanted to copy songs from iPod to iTunes would be
In both cases, Apple’s decision makes it very difficult for the consumers to perform legitimate actions with their own songs.
I always wondered why we need bloated software packages just to do simple word processing. There is something called easter egg in software programs. For example, I learned many years ago that when you type certain things in Excel, you get a 3-D flying simulator. No wonder Office became so large even when I was using 16MB memory. (Time flies, I’m ordering a machine with 16GB memory, Yee! Moore’s Law!)
Just learned that Google Earth has that too. It’s a flight simulator, simply press Command-Option-A (Caps Lock on to get capital A). It’s not bad, I crashed my plane twice in two minutes. While I always get amazed by how innovative Google has been, I really don’t like this idea. They are wasting (1) some best programmers’ time, (2) millions of people’s computer resources.
If they like to do a flight simulator, why not just make one and release it?
When the battery is fully charged, do this in the terminal:
ioreg -l | grep -i LegacyBatteryInfo
If the number following capacity is below 2000, then the battery is quite wasted. Normally, it should be more than 4000.
If you don’t know what the title means, just ignore this post. :-p
I found that on a Mac, I can’t really “su root” as I often do on Linux. Whenever I change the root password, I can “su root”, but the next time when I start “Terminal”, the root password is not recognized. The trick lies in creating a super user account, then “sudo” each time.
For example, to move some files to a directory that the current user does not have right to write. I can do:
sudo mv somefiles* /home/root/dir
Good thing is that the only difference is to add sudo in the beginning.
This cartoon from xkcd says it all.

Copyright Xiaoquan (Michael) Zhang, 2004-2007. All rights reserved.
All trademarks property of their owners.