QOS on VPN Client Tunnel in Tomato

From this page, I was able to have QOS functioning on an OpenVPN tunnel in Tomato.

Essentially, I had to add the following snippet to the ADMIN->SCRIPTS->FIREWALL field (note the different device names used):

cp /etc/qos /tmp/qos-tun11
sed -i 's/vlan2/tun11/g' /tmp/qos-tun11
sed -i 's/imq0/imq1/g' /tmp/qos-tun11
chmod +x /tmp/qos-tun11
iptables -t mangle -A FORWARD -o tun11 -j QOSO
iptables -t mangle -A OUTPUT -o tun11 -j QOSO
iptables -t mangle -A PREROUTING -i tun11 -j CONNMARK --restore-mark --mask 0xff
iptables -t mangle -A PREROUTING -i tun11 -j IMQ --todev 1
ifconfig imq1 up

Reset Audio on OSX

To reset CoreAudio on Mac OS X without rebooting the machine, use the following command:

# sudo kill -9 `ps ax|grep 'coreaudio[a-z]' |awk '{print $1}'`

Alternatively, open up activity monitor, and manually search for CoreAudio

Update to Latest FreeBSD Release (9.2)

For my records, here is an outline of the steps I took to upgrade FreeBSD from 9.1 to 9.2.

# freebsd-update fetch
# freebsd-update install

(and reboot if any changes were made)

Now, fetch the upgrades that are included in the 9.2-RELEASE. The differences in configuration files will need to be merged manually.

# freebsd-update upgrade -r 9.2-RELEASE
# freebsd-update install

Reboot with the new kernel before the non-kernel components receive updates:

# shutdown -r now

After rebooting, install the new user-land components, and upgrade 3rd party packages:

# freebsd-update install
# pkg upgrade

To delete the old (no longer used) system libraries:

# freebsd-update install

Finally, reboot into 9.2-RELEASE

# shutdown -r now

Root and Flash Samsung Galaxy S2 From Within OSX

Android logo

This post outlines the steps I’d taken to root and flash my Galaxy S2 (GT-i9100T) with a custom rom.

I was running the latest SGS2 firmware from Vodafone,AU – DVLS3. I decided to obtain a backup of the modem’s firmware found here. I extracted modem.bin to ~/Desktop

Rooting my GT-i9100T phone was a piece of cake thanks to Framaroot. Essentially, it is a:

… one-click application to install Superuser and su binary on phone.

You can manually download the .apk file to your phone’s storage for installation from within any file manager. It is compatible with many phones, and in particular, Exynos devices (eg Samsung Galaxy S2 GT-i9100T) work with the Aragorn exploit. At the time of this writing, I used version 1.6.0 of Framaroot successfully. Read the FAQ on the linked page for further information.

Optional: Next, I installed BusyBox and DroidWall from within the PlayStore.

Next, I downloaded codeworkx’s ClockworkMod Recovery found here. I extracted its contents (zImage) to my Desktop.

Next, I downloaded my preferred custom rom (Omega Jelly Bean) to the phone’s storage at /sdcard.

Next, I visited this page and downloaded heimdall-suite-1.3.2-mac.dmg — Heimdall Suite 1.3.2 - OS X binaries (universal). At the time of this writing, version 1.4.0 only works with OSX 10.8+ (Mountain Lion) in 64bit mode – 1.3.2 works fine with other OSX versions, though. After installation of the package, I had to reboot the machine.

Finally, I followed the instructions found here to install CWM-recovery. Essentially I had to do the following:

  • Boot the Galaxy S II into download mode by holding down Volume Down, Home & Power.
  • Insert the USB cable into the device.
  • Run heimdall flash --kernel ~/Desktop/zImage --no-reboot from Terminal.app
  • Also, run heimdall flash --modem ~/modem.bin --no-reboot
  • Turn off the phone.
  • Boot the phone into ClockworkMod Recovery mode by holding Volume Up, Home, & Power.

I then proceeded with the rest of the guide to flash the custom rom.

The end result is shown below:

Copy and Paste in Tmux with Mouse

I have my iTerm2 emulate xterm-256colors, and found that it was possible to use the mouse to copy a selection in tmux.

You’d need to hold down the option key whilst left-clicking and dragging across the target text selection. If you want to now paste the selected text back in to the terminal (in say, another window), you must also hold down the option key and middle-click to paste.

Share OSX Clipboard With Emacs

Add the following to your .el init files:

;; Use M-w to copy Emacs buffer selection; and Cmd-V to paste outside of Emacs.
;; Use Cmd-C to copy selection from OSX; and C-y to paste in Emacs

(defun copy-from-osx ()
  (shell-command-to-string "pbpaste"))

(defun paste-to-osx (text &optional push)
  (let ((process-connection-type nil))
    (let ((proc (start-process "pbcopy" "*Messages*" "pbcopy")))
      (process-send-string proc text)
      (process-send-eof proc))))

(setq interprogram-cut-function 'paste-to-osx)
(setq interprogram-paste-function 'copy-from-osx)

Control iTunes with Shell Script at Command-line

Use the following script to control iTunes from the shell:

# iTunes Command Line Control v1.0.0.1
# written by David Schlosnagle
# created 2001.11.08
# modified 2007.01.28 by David West
# modified 2013.08.02 by ootput
# filename=itunes

showHelp () {
    echo "-----------------------------";
    echo "iTunes Command Line Interface";
    echo "-----------------------------";
    echo "Usage: `basename $0` ";
    echo "Options:";
    echo " status = Shows iTunes' status, current artist and track.";
    echo " play = Start playing iTunes.";
    echo " pause = Pause iTunes.";
    echo " next = Go to the next track.";
    echo " prev = Go to the previous track.";
    echo " mute = Mute iTunes' volume.";
    echo " unmute = Unmute iTunes' volume.";
    echo " vol up = Increase iTunes' volume by 10%";
    echo " vol down = Increase iTunes' volume by 10%";
    echo " vol # = Set iTunes' volume to # [0-100]";
    echo " stop = Stop iTunes.";
    echo " search = Run query, populate playlist named foo and play. "
    echo " playlist = Show playlists saved in iTunes.";
    echo " clear = clear playlist foo. ";
    echo " quit = Quit iTunes.";

if [ $# = 0 ]; then

while [ $# -gt 0 ]; do
    echo $songname;
    case $arg in
        "status" ) state=`osascript -e 'tell application "iTunes" to player state as string'`;
            echo "iTunes is currently $state.";
            if [ $state = "playing" ]; then
                artist=`osascript -e 'tell application "iTunes" to artist of current track as string'`;
                track=`osascript -e 'tell application "iTunes" to name of current track as string'`;
                echo "Current track $artist: $track";
            break ;;

        "play" ) echo "Playing iTunes.";
            osascript -e 'tell application "iTunes" to play';
            break ;;

        "pause" ) echo "Pausing iTunes.";
            osascript -e 'tell application "iTunes" to pause';
            break ;;

        "next" ) echo "Going to next track." ;
            osascript -e 'tell application "iTunes" to next track';
            break ;;

        "prev" ) echo "Going to previous track.";
            osascript -e 'tell application "iTunes" to previous track';
            break ;;

        "mute" ) echo "Muting iTunes volume level.";
            osascript -e 'tell application "iTunes" to set mute to true';
            break ;;

        "unmute" ) echo "Unmuting iTunes volume level.";
            osascript -e 'tell application "iTunes" to set mute to false';
            break ;;

        "vol" ) echo "Changing iTunes volume level.";
            vol=`osascript -e 'tell application "iTunes" to sound volume as integer'`;
            if [ $2 = "up" ]; then
                newvol=$(( vol+10 ));

            if [ $2 = "down" ]; then
                newvol=$(( vol-10 ));

            if [ $2 -gt 0 ]; then
            osascript -e "tell application "iTunes" to set sound volume to $newvol";
            break ;;

        "stop" ) echo "Stopping iTunes.";
            osascript -e 'tell application "iTunes" to stop';
            break ;;

        "quit" ) echo "Quitting iTunes.";
            osascript -e 'tell application "iTunes" to quit';
            exit 1 ;;

        "search" ) echo "Searching Library.";
            osascript -e "tell application "iTunes"" -e "set searchResults to search playlist "Library" for "$songname"" -e "repeat with aTrack in searchResults" -e "copy aTrack to playlist "foo"" -e "end repeat" -e "play playlist "foo"" -e "end tell";
            break ;;

        "playlist" )
            if [ -n "$2" ]; then
                echo "Changing iTunes playlists to '$2'.";
                osascript -e 'tell application "iTunes"' -e "set new_playlist to \"$2\" as string" -e "play playlist new_playlist" -e "end tell";
                break ;
                # Show available iTunes playlists.
                echo "Playlists:";
                osascript -e 'tell application "iTunes"' -e "set allPlaylists to (get name of every playlist)" -e "end tell";

        "clear" ) echo "Clearing Query.";
            osascript -e "tell application "iTunes" to delete tracks of playlist "foo"";
            break ;;

        "help" | * ) echo "help:";
            break ;;

Embedding IFrames in WordPress.com

I recently came across a workaround for embedding iframes in WordPress.com blogs. According to WordPress.com’s support page on the matter:

Flash and all other embeds are not allowed in WordPress.com posts, pages, or text widgets. For security reasons, we remove the tags needed for these to work. Your intentions may be innocent, but someone somewhere might try to use such embeds to damage the site, affecting all of our users.

As this guide suggests, the workaround made use of a perfectly legitimate and supported shortcode API. In essence, the workaround involved converting an iframe to Flash, which in turn was sourced by [gigya].

I was able to illustrate the concept below:

For my dearest nephew, and any other chess enthusiasts that are perusing this blog, I have embedded a chess game that I recently played. Click the link below, and try to figure out the positional/tactical errors that my opponent (and close friend) committed, and any variations that may have redeemed his play.

If, for some reason, the embed doesn’t show, here’s a link to how it should look.

Partition OSX Mounted User Directory As Root Using iPartition


Following an Apple support article entitled: Enabling and using the “root” user in Mac OS X, and with the aid of iPartition, I was able to re-partition my User partition (located on x220’s internal 300GB drive). The use of diskutil was out of the question as I had chosen an MBR scheme during Lion’s installation.

My original partition layout (MBR) was as follows:

root# diskutil list
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *30.0 GB    disk0
   1:                  Apple_HFS Mac OSX Lion            30.0 GB    disk0s1
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *320.1 GB   disk1
   1:                  Apple_HFS User                    260.0 GB   disk1s1
   2:                  Apple_HFS Backup                   30.0 GB   disk1s2

As you can see, disk1 has available unused space amounting to 30GB. I had planned to expand my User partition (/User is a symlink to /Volumes/User) to 290GB using iPartition as an administrative user, but was unable to do so as disk1 was still in use and couldn’t be mounted. Booting the system in single-user mode was not an option for me as I wanted to use iPartition’s support of non-destructive resize of HFS+.

Fortunately, I was able to enable the root account, whereby I would then kill all processes owned by my user or that had open files on disk1 – using # lsof +D /Volumes/User for the latter. iPartition would then be able to operate unimpeded.

Moving data (upon resizing) takes a while – particularly on a 300GB drive, so it is imperative to use an external power source and to disable any power saving features such as suspend.

OSX Lion on Thinkpad X220


In all my years of computing, I’d never imagined the day where I would find myself working with an Apple OS. I’d always assumed – wrongly – that Mac systems were specifically targeted to cashed-up yuppies who didn’t know any better. I assumed that Windows was the only platform of choice to get things done, and that accumulating quality software designed for Windows was the primary goal of my technosexual existence. Of course, back then, in the days of raging hormones and teenage angst, I had made many incorrect assumptions.

As I eventually found out, both Linux and BSD proved to be rock solid workhorses and viable alternatives to the Windows that I had so admired – and now, it seems I have also taken a strong liking to Apple’s OSX. Of course, any Apple evangelism on my part will be premature, as I have yet to grasp the inner workings of OSX. For now, let’s just say that I have OSX Lion successfully running on my Lenovo X220 (alongside CrunchBang Linux) courtesy of my wife’s Snow Leopard Disk, and this guide, and that I enjoy every minute of using it. It is a very capable system, and a most welcome addition to my heterogeneous network. There were a few hiccups along the way (to be discussed later), but for the most part, the installation ran smoothly.

Thus far, I’ve made many changes to the system to arrive at a more familiar desktop (again, to be discussed later). This is not to say that I have been spending most of my time tinkering with the defaults – in fact, like Crunchbang, OSX proves to be quite operational OOTB. I suppose that I have been spoiled somewhat with Crunchbang’s easy maintenance, that proceeding to use an even simpler system seemed to be a most natural step.

My workflow has not been altered considerably, owing to the many ported software from Unix systems, and for this I am thankful. Running OSX – as opposed to any Linux distribution – does also have its perks: I am able to access a wider pool of quality commercial software for my media creation/management. As much as I admire the tenets of the Free Software movement, I’m not bound to it – nor am I vehemently opposed to commercial offerings. I have not compromised my integrity, and I like to think that I choose software on the basis of what’s right for the proverbial job.

I will try to make as many posts regarding the transition as I can – both for X220 owners considering running a Hackintosh, or for other geeks who have risen above the stigma of Macintosh use and are willing to try.