Apple OS X

I'm one of the folks who bought MacUpdate Spring 2012 Bundle, which includes Drive Genius 3. I've just upgraded my Mac with 750Gb Seagate Momentus XT2 (ST750LX003) and wanted to try defragging a hard-drive on OS X (just because).

So here's the result and a picture worth a thousand words:

Drive Genius 3 - Defrag Failed


Thank goodness it was still an empty drive with no data. Continue Reading
 Read More

There was an unused Apple desktop machine running OS X 10.4 sitting around, so I decided to use it as a storage for our company's firewall log. The current log is then rotated and saved in /private/var/log/archived. Here's the script:

#!/bin/bash
echo Stopping Syslog...
sudo launchctl unload /System/Library/LaunchDaemons/com.apple.syslogd.plist
sleep 1

echo ""
printf %s "Rotating log files:"
cd /var/log
for i in edmonton.log; do
    if [ -f "${i}" ]; then
        printf %s " ${i}"
        if [ -x /usr/bin/gzip ]; then gzext=".gz"; else gzext=""; fi
        if [ -f "${i}.6${gzext}" ]; then mv -f "${i}.6${gzext}" "${i}.7${gzext}"; fi
        if [ -f "${i}.5${gzext}" ]; then mv -f "${i}.5${gzext}" "${i}.6${gzext}"; fi
        if [ -f "${i}.4${gzext}" ]; then mv -f "${i}.4${gzext}" "${i}.5${gzext}"; fi
        if [ -f "${i}.3${gzext}" ]; then mv -f "${i}.3${gzext}" "${i}.4${gzext}"; fi
        if [ -f "${i}.2${gzext}" ]; then mv -f "${i}.2${gzext}" "${i}.3${gzext}"; fi
        if [ -f "${i}.1${gzext}" ]; then mv -f "${i}.1${gzext}" "${i}.2${gzext}"; fi
        if [ -f "${i}.0${gzext}" ]; then mv -f "${i}.0${gzext}" "${i}.1${gzext}"; fi
        if [ -f "${i}" ]; then
              touch "${i}.$$" && chmod 640 "${i}.$$" && chown root:admin "${i}.$$"
              mv -f "${i}" "${i}.0" && mv "${i}.$$" "${i}" && if [ -x /usr/bin/gzip ]; then
                gzip -9 "${i}.0"; fi
        fi
    fi
done
if [ -f /var/run/syslog.pid ]; then kill -HUP $(cat /var/run/syslog.pid | head -1); fi
echo ""

cp -f /var/log/edmonton.log.1.gz /var/log/archived/edmonton_log-`/bin/date +%Y-%m-%d`.gz

sudo rm -f /var/log/edmonton.log
sudo touch /var/log/edmonton.log
sudo chgrp -v admin /var/log/edmonton.log
sudo chmod -v go+w /var/log/edmonton.log


for i in toronto.log; do
    if [ -f "${i}" ]; then
        printf %s " ${i}"
        if [ -x /usr/bin/gzip ]; then gzext=".gz"; else gzext=""; fi
        if [ -f "${i}.6${gzext}" ]; then mv -f "${i}.6${gzext}" "${i}.7${gzext}"; fi
        if [ -f "${i}.5${gzext}" ]; then mv -f "${i}.5${gzext}" "${i}.6${gzext}"; fi
        if [ -f "${i}.4${gzext}" ]; then mv -f "${i}.4${gzext}" "${i}.5${gzext}"; fi
        if [ -f "${i}.3${gzext}" ]; then mv -f "${i}.3${gzext}" "${i}.4${gzext}"; fi
        if [ -f "${i}.2${gzext}" ]; then mv -f "${i}.2${gzext}" "${i}.3${gzext}"; fi
        if [ -f "${i}.1${gzext}" ]; then mv -f "${i}.1${gzext}" "${i}.2${gzext}"; fi
        if [ -f "${i}.0${gzext}" ]; then mv -f "${i}.0${gzext}" "${i}.1${gzext}"; fi
        if [ -f "${i}" ]; then
              touch "${i}.$$" && chmod 640 "${i}.$$" && chown root:admin "${i}.$$"
              mv -f "${i}" "${i}.0" && mv "${i}.$$" "${i}" && if [ -x /usr/bin/gzip ]; then
                gzip -9 "${i}.0"; fi
        fi
    fi
done
if [ -f /var/run/syslog.pid ]; then kill -HUP $(cat /var/run/syslog.pid | head -1); fi
echo ""

cp -f /var/log/toronto.log.1.gz /var/log/archived/toronto_log-`/bin/date +%Y-%m-%d`.gz

sudo rm -f /var/log/toronto.log
sudo touch /var/log/toronto.log
sudo chgrp -v admin /var/log/toronto.log
sudo chmod -v go+w /var/log/toronto.log

for i in montreal.log; do
    if [ -f "${i}" ]; then
        printf %s " ${i}"
        if [ -x /usr/bin/gzip ]; then gzext=".gz"; else gzext=""; fi
        if [ -f "${i}.6${gzext}" ]; then mv -f "${i}.6${gzext}" "${i}.7${gzext}"; fi
        if [ -f "${i}.5${gzext}" ]; then mv -f "${i}.5${gzext}" "${i}.6${gzext}"; fi
        if [ -f "${i}.4${gzext}" ]; then mv -f "${i}.4${gzext}" "${i}.5${gzext}"; fi
        if [ -f "${i}.3${gzext}" ]; then mv -f "${i}.3${gzext}" "${i}.4${gzext}"; fi
        if [ -f "${i}.2${gzext}" ]; then mv -f "${i}.2${gzext}" "${i}.3${gzext}"; fi
        if [ -f "${i}.1${gzext}" ]; then mv -f "${i}.1${gzext}" "${i}.2${gzext}"; fi
        if [ -f "${i}.0${gzext}" ]; then mv -f "${i}.0${gzext}" "${i}.1${gzext}"; fi
        if [ -f "${i}" ]; then
              touch "${i}.$$" && chmod 640 "${i}.$$" && chown root:admin "${i}.$$"
              mv -f "${i}" "${i}.0" && mv "${i}.$$" "${i}" && if [ -x /usr/bin/gzip ]; then
                gzip -9 "${i}.0"; fi
        fi
    fi
done
if [ -f /var/run/syslog.pid ]; then kill -HUP $(cat /var/run/syslog.pid | head -1); fi
echo ""

cp -f /var/log/montreal.log.1.gz /var/log/archived/montreal_log-`/bin/date +%Y-%m-%d`.gz

sudo rm -f /var/log/montreal.log
sudo touch /var/log/montreal.log
sudo chgrp -v admin /var/log/montreal.log
sudo chmod -v go+w /var/log/montreal.log


sudo launchctl load /System/Library/LaunchDaemons/com.apple.syslogd.plist

Then, I also added the following to /etc/syslog.conf

local4.*                        /var/log/montreal.log
local6.*                        /var/log/edmonton.log
local0.*                        /var/log/toronto.log

That's it!

Continue Reading
 Read More

I can finally watch Bloomberg on OS X with only Quicktime & Flip4Mac installed, and the audio is working!. No need to run the old Windows Media Player 9 anymore.

Bloomberg TV

Just open this link with Quicktime:

Bloomberg TV for Mac OS X

What's the catch? This is the stream from Hong Kong (Bloomberg Asia) :) The content is exactly the same, but you'll get different advertisements every now and then. At least you don't need to run a 6-years old WMP9 with Rosetta.

Continue Reading
 Read More
I've just downloaded Firefox 3 Beta 4 on my Mac and Windows machines and tried it out. First impression is fantastic but not without a caveat. First of all, all of the Firefox add-ons from version 2.0.0.x don't work at all.

Firefox 3 Beta 4 Add-ons incompatibility

Secondly, Firefox 3 Beta 4 in OS X does some strange rendering. It doesn't render one of my clients' website correctly in OS X but it looks normal in Windows. If you take a look at the screenshot below, the Contact Us text is rendered just below the cyan box. This doesn't happen on Firefox 2.0.0.x in OS X. Firefox 3 Beta 4 OS X rendering bug Compare this with the Windows rendering, which is identical to v2.0.0.x rendering.Firefox 3 Beta 4 Windows rendering Other than that, general browsing does feel faster. It uses OS X form controls - which is a bit disadvantage for me because everytime I want to check what it looks like on Windows I'll have to go back to Windows again. Continue Reading
 Read More
I'm the kind of guy who prefers typing with a keyboard than clicking and moving a mouse to do things. Another minor annoyances is OS X disables the Tab button by default for selecting buttons (OK, Cancel) in a dialog. If you're a typer and not a clicker, you may find that enabling All Controls option in System Preferences => Keyboard & Mouse makes your keyboard operation more efficient. Continue Reading
 Read More
If you find yourself confused with distinguishing directory & file listing in UNIX, you're not alone. I remember when I first installed of Redhat 5.2 in 1998, I got confused with distinguishing file and directory after ls command. It took me a while to find out that the good news is: it is configurable with color-coded directory listing for easier reading and usability if you're a heavy command line user. The second thing is finding where exactly I am located in the current directory without typing pwd all the time. OS X Terminal with a cool BASH promptSo here's a little step that you can to do to improve your working efficiency in UNIX command line:
  1. Edit /etc/bashrc and add alias ls="ls -laFG" to make directory listing colored
  2. For the command prompt, add the following command: if [ -n "$PS1" ]; then PS1='nu@e[31;1m[w]33[0mn$ '; fi
Continue Reading
 Read More
I've finally purchased OS X Leopard 10.5 and I believe the improvement increases my efficiency working with files than in OS X Tiger 10.4. The first improvement that I'm particularly impressed with is the Columns view in Finder. Even with Tiger, I've always liked Finder's ability to navigate my folders in one click and see the content of the upper directories on the left column. The only quirk is that there is no way I could arrange the sort order by Kind so I can easily see folders sorted on top. I am also surprised, however, that Finder sorts the filename kind by its alphabetical definition of the filetype without placing folder on top. For example: a folder called Library (File type: Folder) will still be placed below com.apple.IntlDataCache.le.sbdl (File type: Document) as you can see above. I find it easier to navigate with KDE File Manager or Windows Explorer where folder is always sorted on top. I am disappointed, however, that, the Open Dialog still has no configurable options to sort by Kind. I'm used to seeing folders on top in Windows, KDE, or GNOME environment. This lack of option in OS X oftentimes slows down my day-to-day operation with files. I hope that the next release of OS X address this issue. OS X Open File Dialog Another improvement over Tiger is the Path Bar (breadcrumb) as you can see below. I've always find it difficult to see folders within folders before Leopard comes out, there has never been a path bar (only shown during Spotlight search result) except the Path button on top, which was really quirky. Although the placement of the Path Bar (inconsistent to where address bar should be) is at the bottom of the window, this is still a very much welcomed improvement. I found it difficult working with nested folders in Tiger as I couldn't see which directory I'm located then. OS X Finder Column View Continue Reading
 Read More