Sunday, January 31, 2016

Mac: Change the default application for a file type

On OS X, I wanted to change the default application for opening .txt file. I tried selecting a different app through Open With > Other... > Always Open With. But apparently that option is specific to the file I selected, not for that file type.

To change the default application for a file type:
1. Right-click on the file > Get Info
2. Expand Open with:, and select the desired app

Saturday, January 30, 2016

Mac: Set different scroll direction for trackpad and mouse

On OS X El Capitan, I liked the default "natural" scrolling behavior when using the trackpad. However, it also inverted the scroll direction when using an external mouse. The scroll direction option can be found under System Preferences > Mouse and System Preferences > Trackpad. Unfortunately, it does not allow you to set an independent value for Mouse v.s. Trackpad. Luckily, there's an utility app called Karabiner to help us.

1. Enable System Preference > Mouse Scrolling direction: natural
2. Download and install Karabiner
3. Launch Karabiner through Spotlight
4. Enable Karabiner core settings > Exclude devices > Don't remap Apple's pointing devices
5. Enable Pointing Device > Reverse scrolling direction > Reverse Vertical Scrolling

How to separate "mouse" and "trackpad" settings? - Ask Different

Wednesday, January 27, 2016

Mac: keyboard shortcuts

Taking Screenshot
  • Capture the whole screen to clipboard:
    control + shift + command + 3

  • Capture the whole screen and save it to desktop:
    shift + command + 3

  • Capture part of the screen to clipboard:
    control + shift + command + 4

  • Capture part of the screen and save it to desktop:
    shift + command + 4

  • Lock computer
    shift + control + power

  • Sleep
    command + option + power

  • Delete a file
    command + delete

  • Open a file or directory
    command + O

  • Rename a file

  • Go to folder
    shift + command + G

  • Home
    fn + left arrow

  • End
    fn + right arrow

  • Page Up
    fn + up arrow

  • Page Down
    fn + down arrow

  • Switch between different applications
    command + tab

  • Switch between application windows
    command + `

  • Application windows
    control + down arrow

  • Mission Control
    control + up arrow

Text editing
  • Delete text after the cursor (in-place delete)
    fn + delete

  • Focus to address bar
    F6 -or- command + L

  • Go to home page
    alt + home = fn + option + left arrow

Wednesday, January 6, 2016

Windows: Redirect both stdout and stderr to a file

To redirect stdout to a file:
c:\>command_to_run > output.txt

To redirect both stdout and stderr to a file:
c:\>command_to_run > output.txt 2>&1

So what is 2>&1
Stack Overflow user Ayman Hourieh explained:

File descriptor 1 is the standard output (stdout).
File descriptor 2 is the standard error (stderr).

Here is one way to remember this construct (although it is not entirely accurate): at first, 2>1 may look like a good way to redirect stderr to stdout. However, it will actually be interpreted as "redirect stderr to a file named 1". & indicates that what follows is a file descriptor and not a filename. So the construct becomes: 2>&1.

windows - Redirect stdout and stderr to a single file - Stack Overflow
bash - In the shell, what does " 2>&1 " mean? - Stack Overflow

Monday, January 4, 2016

Firefox 43: Disable "Visit website" suggestion in address bar

Since Firefox version 43, Mozilla added some sort of "Visit website" suggestion as you type in the address bar...I did not find it useful, and I would rather get the old behavior back. Luckily, SuperUser contributor MC10 shared a way to do that.

To disable the "Visit website" suggestion:
1. goto about:config
2. set browser.urlbar.unifiedcomplete to false

search - Is it possible to get old suggestion system back in Firefox 43.0? - Super User

Tuesday, December 15, 2015

Game development: fighting game action and movement

I came across this case study on turning a simple punch animation to be more impressive and intense. It's a funny and interesting read.
【專欄】別再揮空氣了!關於遊戲中的「打擊感」三兩事 - 巴哈姆特

Monday, November 16, 2015

Toyota Prius: 12V auxiliary battery check

For 2004-2009 Toyota Prius, you can check the 12V battery's status in diagnostic mode.

To enter diagnostic mode:
1. press the Power button (without pressing the brake)
2. press and hold the Display button (on the side of the dashboard computer)
3. tap on the yellow highlighted spots, 1 -> 2 -> 1 -> 2 -> 1 -> 2. There's no visible buttons, you just need to tap on the two spots as shown below:
4. if done properly, it should enter the diagnostic mode. Alternatively, you can press and hold the Display button, and then toggle the head lights ON/OFF 3 times instead.

To check the 12V battery's status:
1. tap Menu > Display Check > Vehicle Signal Check
2. a good battery should be around the 12.x range. If you turn on the vehicle, it should start charging the battery and the value would increase to 14.x.

To exit diagnostic mode:
press and hold the Display button for 5 seconds

Owner manual:
You can download them at
(It's a shame that they are not available on, their Technical Information System (TIS) is down or no longer available)

How to see if your 12v Auxiliary Battery is going bad - YouTube
Quick test of a Prius 12v battery - YouTube
Toyota Prius: How to Check the 12v Auxiliary Battery Health -