Sunday, June 1, 2008

Unison: An Elegant File Sync App

Ever since I got an 24" iMac at work, how to sync between this iMac and my MacBook has being a problem for me. First of all, the place I work has a very tight security policy and everything has to go through either VPN or an SSH gateway. I eventually figure out how to do SSH tunnel, but that's the topic for another day.

Once I set up the SSH connection between the iMac and the MacBook, it is easy to use rsync to sync files. However, I am not really into this whole command-line thing, otherwise I'd just get a linux box. Fortunately, I found this nice little app called Unison, which provides a GUI for Mac OS X. The setup is straightforward. There is only one catch: both machines should have Unison installed. I actually found this out by scanning through the console log. One small complain: there is practically no documentation, everything has to be found through google.

Below is quoted from Unison website
Unison runs on both Windows and many flavors of Unix (Solaris, Linux, OS X, etc.) systems. Moreover, Unison works across platforms, allowing you to synchronize a Windows laptop with a Unix server, for example.


Since I cannot find a screenshot of Unison running on OS X on its website, I figured it'll be helpful to upload one here:

Tuesday, May 27, 2008

Sold on Firefox - Zoom In Just Gets Better

Two pictures worth a thousand words.

Web pages in Firefox after zoom in



Web pages in Safari after zoom in



That's right. Firefox not only increases the font size, it increases the size of everything proportionally.

Tuesday, May 13, 2008

Plain text in Mail.app by default

I generally prefer plain text when writing emails. However, in the place where I work, a lot of people use Microsoft Outlook or its web version. By default, it sends out emails in HTML. Even worse is the fact that the font size in those emails is too small. To reformat all incoming email and display them as plain text, quit Mail.app, type
# defaults write com.apple.mail PreferPlainText -bool TRUE
Relaunch Mail.app and enjoy.

To revert back, use
# defaults delete com.apple.mail PreferPlainText

Thursday, May 1, 2008

find

One thing about sharing files between Windows and Mac via a USB is that the USB has to be formated in fat32. Then all the files copied from Windows will have the file mode x enabled. Manually removing it for each file is very cumbersome because for directories you do want to keep the x mode. This can be done easily using find
# find . ! -type d -exec chmod -x {} \;
Another example is
# find . ! -type d -exec xattr -d com.apple.quarantine {} \;

Monday, April 21, 2008

Bluetooth unavailable? Reset SMC!

I don't know when did this happen: bluetooth in my MacBook suddenly becomes unavailable. System profile shows me no bluetooth device is detected. Just last week I transfered some photos from my cell phone to my MacBook, and now this?

After some googling, I found the solution: Reset the SMC unit. OK, unplug the AC adapter, remove the battery, hold on the power button, and 5 seconds later, my bluetooth is back.

My friend il actually had another problem with his MacBook: iSight no longer works. Guess what he did...... Reset SMC!

What else CANNOT be fixed by resetting SMC?

Sunday, April 20, 2008

Play rmvb format using MPlayer

MPlayer is my favorite media player on Mac OS X. I really don't understand the great disparity in terms of user numbers between VLC and MPlayer, as shown on osx.iusethis.com. In my experience, MPlayer plays more formats than VLC does and has better subtitle support. I don't mean to diminish VLC but I think at least these two players should be similar in every aspect.

In any case, both MPlayer and VLC are way better than the bloated RealOne player. However, sometimes I need play rmvb file but it is not supported by MPlayer out of box. In this case, first download RealOne, then copy all the bundles in
RealPlayer.app/Contents/Frameworks/HXClientKit.framework/HelixPlugins/Codecs
to
/usr/local/lib/codecs
If you don't have the second folder then create it first.

Oh, don't forget to delete RealOne afterwards.

Friday, April 18, 2008

Tips on ssh

1. Use ssh-keygen to generate key pairs
# ssh-keygen -t rsa -b 2048
ssh-keygen can generate both RSA and DSA keys. While you can specify any key length for RSA keys (in the example it is set to 2048 bits), the key length for DSA is always 1024 bits as required by the government. RSA is also faster when it comes to verify the key.

After ssh-keygen generates the key pair, put id_rsa.pub to ~/.ssh/ on the remote machine and rename it to authorized_keys.

Now enjoy remote login without having to input your password. (Of course you have to make sure the physical access to your machine is secured.)

2. Use ssh_config to specify ssh setting

You can put the configuration into the file ~/.ssh/config. Below is an example
Host short
HostName long.server.name
User name
Then you only need input
# ssh short
instead of
# ssh name@long.server.name
For more options, man ssh_config.

Saturday, April 12, 2008

A 'Perfect' iTunes Equalizer Setting

I recently came across this post on MacOSXHints.com. The modified equalizer sounds amazing. Simply copy the applescript below and run it in script editor
tell application "iTunes"
tell EQ preset 1 -- the Manual setting which you can then save
set band 1 to -8
set band 2 to -5
set band 3 to -3
set band 4 to -4
set band 5 to -5
set band 6 to -6
set band 7 to -4
set band 8 to -2
set band 9 to 0
set band 10 to -3
set preamp to 6
end tell
end tell

This is how it looks.

Save the preset and enjoy!

Wednesday, April 9, 2008

Change the background of TeXShop

Sometimes I need use LaTeX to generate equations in white color for my Keynote presentation (copy/paste from TeXShop). It is then necessary to change the background of TeXShop, otherwise nothing can be seen. There is a hidden preference just for this:
# defaults write TeXShop Pdfbackground_R 0.5
# defaults write TeXShop Pdfbackground_G 0.5
# defaults write TeXShop Pdfbackground_B 0.5

Change the values back to 1 to get white background or you can change it to any value you prefer.

Monday, March 31, 2008

Single window mode in Safari

Another hidden preference...
# defaults write com.apple.Safari \
TargetedClicksCreateTabs -bool true

Friday, March 28, 2008

Right click on a mac laptop

I've been using control+click for right click for ages on my macbook and I have complained about the lack of a control key on the right side of the space bar. But now I just found out that there is an option in System Preferences under Keyboard & Mouse that allows you to right click by putting two fingers on the trackpad. See the screenshot.



This is just way better than control+click!

Wednesday, March 5, 2008

Collect all open windows to one space

I love using Space, especially after replacing an aging 15" PowerBook (more than 4 years old) with a brand new MacBook with a relatively small 13" screen.  However, sometimes I found my application windows are all over the four spaces I opened and I need a quick way to move them into one space.

Here is the trick: Enter space, press c, all windows will be collected into the first space.  Press shift+c to watch the slow motion.  Enjoy!

Monday, March 3, 2008

Several Mac OS X tips

1. Getting tired of the default background of login window? You can change it by
# sudo defaults write \
/Library/Preferences/com.apple.loginwindow \
DesktopPicture '/Path/To/Your/Picture'

2. Set default path for every application in Mac OS X:
# mkdir ~/.MacOSX
# defaults write ~/.MacOSX/environment "PATH"  $PATH

Log out then log in and you are all set. You can also use this method for other shell variables.

3. When you use spotlight to search content of PDF files, clicking on the result will bring up Preview.app, showing the highlighted text at a very large scale, effectively rendering this feature useless. To change it,
# defaults write com.apple.Preview Preview \
-dict-add PVPDFSpotlightSelectionSize 1

Sunday, March 2, 2008

Display several plots together in Mathematica

In Mathematica one can display several plots together using the following command. Let's first generate two plots, for example,
g1 = Plot[Sin[x], {x,0,2Pi}];
g2 = Plot[Cos[x], {x,0,2Pi}];

One can then choose to show these two plots in the same graph:
Show[g1,g2]

or display them in an array:
Show[GraphicsArray[{g1,g2}]]

It is generally a good idea to assign a variable to each plot so later it can be used without regenerating the plot.