Showing posts with label mac. Show all posts
Showing posts with label mac. Show all posts

Sunday, March 09, 2008

Emptying a File in the Terminal

Here is a handy trick that I find useful from time to time:

$ echo "here is some jibberish" > somefile.txt
$ cat somefile.txt
here is some jibberish
$ cat /dev/null > somefile.txt
$ cat somefile.txt
$

Essentially by calling "cat /dev/null > somefile.txt" we redirect nothing (/dev/null) to the file 'somefile.txt', which in effect empties it. I like to use this for emptying log files as it saves time recreating files and possibly resetting the right permissions.

If interested, you can read more on I/O redirection.

Monday, February 25, 2008

Quick Mac and Windows Keyboard Switching

Since Mac OS X doesn't save profiles for multiple keyboards (which I hope will change in subsequent versions), I had to find a solution for quickly changing between a Windows style keyboard and a Mac style keyboard. After spending some time with Google, I found some AppleScript that seems to provide an adequate solution. For convenience, I made two scripts: one called keyboard_win.scpt that switches the modifier keys on a Windows style keyboard to behave Mac-like, and one called keyboard_mac.scpt that restores the default keyboard behavior for a Mac style keyboard.

(1) keyboard_win.scpt:
(2) keyboard_mac.scpt:
Hopefully, this will save you some time.