### Experiences with new Mac Mini

Earlier this month I bought a Core i5 Mac Mini. It was quite an impulsive decision, partly influenced by the fact that it was a bit annoying frequently rebooting my office Dell desktop to switch back and forth between Windows and Linux. I have been using Linux for everything (like browsing, programming, creating Tex documents as well as for music and movies) since the last 4+ years. However, when I joined as a Grad student in CQT, earlier this year, my requirements changed a bit, which made be quite a bit dependent on Windows. I got involved in some device driver development in Windows, creating/maintaining several VIs in Labview and working in AutoDesk occasionally to coordinate with workshop technicians. Moreover the lab-notebooks were traditionally being maintained in MS OneNote. Since I am heavily reluctant to completely move away from *nix for my computing needs, I tried dual-booting my Core i7 desktop with Windows 7 and Ubuntu 11.10. Primarily I was using Ubuntu, but had to frequently reboot into Windows for either Labview/Autodesk/Onenote. At this point wanted to give OS X a try and ordered the base version of the new Core i5 Mac Mini online. It came with a 500GB HDD and 2GB DDR3 RAM. It was pointless giving \$ to Apple for memory upgrade, when 4GB Kingston DDR3 modules are available in the market at a fraction of Apple's price. Even before my Mac Mini arrived, I headed off to Sim Lim Square to get a pair of 4GB, 1333MHz DDR3 Kingston modules for 78 SGD.
When the Mini arrived in my office, before switching it on, I took off the back cover and replaced the 2GB modules with the 8GB ones. I had a Dell 23" display and Microsoft wireless keyboard/mouse, so without wasting anymore time, hooked them and booted the Mini. First time startup configuration was highly "Idiot Friendly". All I had  to do, was enter my Apple ID, everything else was done automagically.
Ofcourse, having used a Hackintosh for sometime, the OS X experience was nothing new. But I was pissed off a bit by the fact that the new computer didn't come with any inbuilt system recovery option. Even though I didn't have any urgent need to do a system recovery, I tried the much famed "Lion Internet Recovery", where the Mac downloads a recovery image of Lion directly off Apple's server. But  I was heavily disappointed to find that it doesn't work reliably. A little bit of Googling revealed that, I am not the only one, it fails to work reliably for most Earthlings.
Anyway, I used SuperDuper to create a full disk image and stored it away in a external USB drive safely, in case I manage to bork the system in the future.

### Force an application to use VPN, using iptables in Linux

Enforcing an application, for example a torrent client like Transmission , to always use the VPN interface or any particular network interface for that matter, is trivially simple using iptables on Debian, Ubuntu or any other GNU/Linux distro. Personally, I am running Debian Sid on the Raspberry Pi . Occasionally I use it for downloading files ( legal stuff, seriously, believe me :D  ) using Transmission Bittorrent client over a VPN connection. Sometimes it happens that the VPN connection fails and doesn't reconnect for whatever reason and Transmission continues pulling stuff directly over my internet connection, which I would like to avoid. Fortunately it is very straightforward to enforce rules based on application owner UID. Transmission runs under the owner debian-transmission in Debian (use htop to check this) and the following two lines of iptables ensures that any process with owner having UID, debian-transmission , will not use any other network interface apart from the

### Rendering LaTeX in Blogger.

Rendering LaTeX in Blogger is pretty easy thanks to the JavaScript LaTeX equation render engine from http://www.yourequations.com . To enable LaTeX rendering go to the Blogger Dashboard --> Layout --> Edit HTML . Then add the line <script> type="text/javascript" src="http://tex.yourequations.com/"></script> <script type="text/javascript" src="http://tex.yourequations.com/"></script> just before <body/> . Half the job is now done. Then, for example to render: \int_{0}^{\pi}\frac{x^{4}\left(1-x\right)^{4}}{1+x^{2}}dx =\frac{22}{7}-\pi Use the code: <pre lang="eq.latex"> \int_{0}^{1}\frac{x^{4}\left(1-x\right)^{4}}{1+x^{2}}dx =\frac{22}{7}-\pi </pre> The LaTeX code will now be displayed as: \int_{0}^{1}\frac{x^{4}\left(1-x\right)^{4}}{1+x^{2}}dx=\frac{22}{7}-\pi Ofcourse Javascript needs to be enabled in the Browser for the renderer to work.

### Making inactve USB Hard Disk spin down automatically in Linux.

I have a 400GB Seagate IDE HDD connected to Mars, our hostel's file-server using an USB enclosure. The USB enclosure is a cheap "Made in China" product. Consequently it has some special "features". One such notable "feature" is that the disk is kept spinning by the controller even if there has been no disk I/O for a long time. I have three other USB disks connected to the same machine, a 1TB Seagate FreeAgent Desk External Drive, a 500GB Maxtor Basics External Drive and a 2.5" 60GB Fujitsu SATA Disk inside a Transcend USB enclosure. All of these spin down themselves if there has been no I/O for sometime. Keeping the hard disk spinning unnecessarily for ever, not only wastes power but also overheats the drive, thereby reducing its life. I tried noflushd, which is supposed to force idle hard disks to spin down, but found it to be of no help. USB enclosure generally work by performing an SCSI emulation over USB. sdparm is an utility which can be use