Make your Mac (OSX) serve as a NTP time server

Some background to the problem

At the time of writing I work for NewsCorp and they have a corporate firewall proxy inside the office LAN which blocks almost all ports below 1000 to external services (ex: github, bitbucket, ntp servers, etc) unless you specifically request for firewall rules to be allowed.

I sometimes use my Mac to run some linux applications in virtual machines, so when the host is suspended (closing the laptop lid) or shutdown while VM state is saved and resumes it cannot resync the system clock (vm) since NTP uses Port 123 (UDP) the packets cannot get out or come back in via the corporate proxy / firewall rules. So AWS and other web services started reporting my requests are in past or not in sync with the current epoch.

So I needed a way to somehow sync the VM system clock automatically, since accessing NTP servers outside the LAN was not possible, this is what I did to make my MacBook Pro (VM host) serve time.

Step 1

Get a terminal and edit the following file, I used the following command

sudo vim /etc/ntp-restrict.conf

Step 2

There should be only 10-15 lines in the file, locate the last few lines which includes some .conf files using “includefile” command, just above that add the following line

restrict mask

“” IP and mask “” allows all IPs in the range “ to”, this is the range I am using in the Virtual Box (my vm management software, VMware and others should have a similar Virtual Network Adapters). Thats the default range Virtual Box is configured to use when one VM adapter is configured to use via NAT or Host-only adapter.

If you need a different range (such as whole LAN in the house, etc) use that instead.

So after the modification my ntp-restrict.conf file looks like this,

# Access restrictions documented in ntp.conf(5) and
# Limit network machines to time queries only

restrict default kod nomodify notrap noquery
restrict -6 default kod nomodify notrap noquery

# localhost is unrestricted
restrict -6 ::1

restrict mask

includefile /private/etc/ntp.conf
includefile /private/etc/ntp_opendirectory.conf

Step 3

Restart the ntp daemon in your OSX by running the following command (kills but gets auto-restarted)

sudo killall ntpd

Step 4

Thats it! Try running the following command from the VM to sync time. Set up a cron to resync every 5min or so if needed.

sudo ntpdate <mac ip addr>

Linux brightness control

This is more of a note to myself than a blog post, whenever I install some Linux distribution on one of my laptops the first thing to be done is fix brightness controls as it helps to conserve battery life significantly.

The changes required is trivial, start off with figuring out what drivers are in use on your system

ls -ld  /sys/class/backlight/*

should list something like below but not all three, on mine I get intel and acpi




So assume you have an intel_backlight entry in the sys filesystem, then try following command to figure out the MAX supported brightness level.

cat /sys/class/backlight/intel_backlight/max_brightness

I get 975, so that would be the maximum possible brightness value your device can produce, if we could set something in between we should be able to control the level of brightness. So try something like this and see if that works, on mine I use “intel_backlight” as I use an intel chipset and run the following command

sudo sh -c “echo 488 > /sys/class/backlight/intel_backlight/brightness”

That sets half the brightness level my laptop supports. so right now you should have an idea about how to control brightness levels using a terminal. So if you bind that command into a key combination and make a shortcut you should be able to set up with any sort of desktop environment you use.

Since you understand the underline brightness control system, here is a better trick which may prevent you from setting up key combinations in your desktop.

I also found that you can let the system know which virtual device to be used for controlling brightness levels. This is done at the boot time, so you need to edit the following file

sudo vim /etc/default/grub

locate GRUB_CMDLINE_LINUX_DEFAULT line and set it to look like the code below

GRUB_CMDLINE_LINUX_DEFAULT=”quiet splash acpi_backlight=vendor”

acpi_backlight parameter lets the acpi system know which device to be used for controlling brightness, here vendor refers to intel (in my case).

Hope this helps.

QtMultimedia: FATAL: cannot locate cpu MHz in /proc/cpuinfo

This became a problem for my Raspberry Pi (armv6h) running Archlinux (with a relatively newer kernel). Some users of my Grooveshark server reported some bufferring problems where it stopped streaming songs and reported “FATAL: cannot locate cpu MHz in /proc/cpuinfo”.

Since the Grooveshark server is based on Qt5 I thought the new Qt5.3 version had some multimedia library changes that caused the issue, but turned out the issue is /proc/cpuinfo not producing CPU frequency for the ARM based CPUs. But what program is using a proc cpuinfo to determine CPU frequency without getting the value from sys filesystem exposed by the kernel? or using a monotonic clock as per newer kernels, which would provide timing capabilities without depending on system level changes, turned out there are quite a few programs around that depends on the value specified in “cpuinfo” file in proc filesystem. Including “jack” audio server which is a dependancy for QtMultimedia framework and number of other applications.

After hours of searching I came up with the commit that broke this,, after reading the mailing list which explains why they have removed BogoMips (bogus mips rating of the CPU) from the /proc/cpuinfo, which gets set in the kernel bootup process for the purpose of setting its internal busy-loop.

How to fix QtMultimedia on ARM

Since qtmultimedia libraries depend on jack audio server for sinking audio-out and jack server being broken because of the removal of bogus mips value, I found out that there is jack2 version which seems to be working fine on ARM based computers, so here is set of steps to get JACK2 (a drop-in replacement for JACK as far as I understand) working on your Raspberry Pi,

Login in as root (if you are running Archlinux)

cd ~
git clone git://
cd jack2
./waf configure --alsa
./waf build # this takes a while
./waf install
cd ..
rm -r jack2


That’s it, you should not get “FATAL: cannot locate cpu MHz in /proc/cpuinfo” error when using QtMultimedia framwork under ARM (Raspberry Pi, etc) boards.

Interested in kernel level timers and clocks, go on to

My experiance with GI Stasis in Rabbits

Every rabbit owner should read all the articles on this page

It is a must, if you don’t and you have a bunny with you, I am sure you will regret when you lose them one day.

Okay, I am not going to get into much detail on GI Stasis (in short and as far as I understand, it is a partial or full shutdown of a rabbits gastrointestinal system) as you can find hundreds of articles about the illness if you do a google search. What I will be explaining here is what we went through when our pet rabbit was struck with the illness and what we learnt from it. Here I am referring to ‘we’ as me, Maddie and Sloppy the minilop.

Day 1

Every morning before I leave for work I give Sloppy a pile (size of his body) fresh oaten hay and a bawl of fresh water. When we get back we give him vegies, fruits (occationally) and Oxbow adult pellets (1/5 of a cup). Monday the 28th July 2014 was such a day, we left home and came back. Today Maddie went out to give him his share of vegies, and asked me to come down as she found that the he hasn’t drunk any water from his bawl or hasn’t even got into his hay pile as it was exactly the way I gave it to him.

We normally keep and good eye on his behaviour as almost two years ago he had a stomach upset and partially stopped eating for two days. Since then I would normally run my palm and fingers through his *stomach* (cecum area to be specific) and feel how hard it is. I do this every other day. So I did the same and I felt it was bit stiff was around 1-1.5 inch at least. So felt the left side of his stomach as well but it was normal (you will understand what normal is when you feel your rabbits tummy everyday for few weeks). Maddie asked me to bring him inside the house because when she gave him greens he ate abit and went out the backyard to play with her, normally he would eat at least half and beg for pellets as well. We knew that rabbits should eat and produce dropings all the time, so we brought him inside the house which he liked very much as well.

His room was upstairs where he had his hay container and water bawl, so brought him in and offered some parsley and english spanish, he had a parsley leaf or two and came to my room where he would lie down and relax next to my desk where he could see mee. Since we both were bit worried I started moving from room to room so he followed me. We knew the best thing for a rabbit with a slow moving gut is exercices. Oh as well as lot of fluids.

Hour or two went past but didn’t really eat anything but he was bright as any-other day. Around 8:30 (after two hours) or so we read online that we should force feed feed water or some enzymes such as papaya or pineapple juice. So Maddie asked me to go and buy some of that and a syringe before the shops close. I could only find papaya and two 3ml and 5ml syringes. Came back home around 9:30 and Maddie made him a papaya juice with a bit of water to make it sort of watery and I gave around 2ml-3ml and 2ml of water.

His gut was hard like I said and I also noticed that it was a bit swollen. So I thought we shouldn’t feed him any more food (which was not appropriate though, read on), Maddie suggested that we should give him more papaya juice every two hours or so and water but I rejected the proposal. We just fed another 2ml of water around 12:30am and went to bed, decided that Maddie should take him to the vet tomorrow. As we were *sort of* worried (6/10 I would say) and knew stomach upsets are bad for rabbits. After almost 6 hours he didn’t even produce a single dropping.

Day 2

When I was getting ready for work he was up already and bright as usual, following me from room to room while I was getting ready. I gave him another parsley leaf but didn’t eat, also a pellet but he rejected both. I asked Maddie to not wait for that long and take him to Dr. Alex Rosenwax at early as possible. Dr. Alex was his regular vet since we showed Sloppy to him the first day. Alex is a very experianced bird and exotics vet in Sydney.

Maddie went to the clinic around 10am and said that doctor wanted Sloppy to be admitted immediately and he might not be able to come home for two days as it very neccessary to make sure that he eats and poops. They also suggested that we need X-Rays to confirm that there is no obstruction before treating him. X-Rays were clean as no foreigh object was in his body, so Maddie left him there and called me and explained to me that they will give him probiotics, laxatives to make him poop. We were relaxed.

Maddie called up again around end of the day to see how he is doing, but doctor confirmed that he hasn’t pooped but has pee’ed, and also said 95% of such rabbits would produce droppings once they receive those laxatives. So they would treat this as a critical case and force feed him water and baby food as well as antibiotics to make sure his gut and liver can handle bacteria in the gut.

Day 3

We both went to work today and also took the pet carrier as we knew we wanted to bring him back as soon as recovers and treat him at home.

We called the hospital around the midday but they said he hasn’t really produced any droppings yet so were worried now. Maddie suggested that we should go to the hospital and see him. So we did. I saw him for the first time after two days and his stomach was swollen on both sides and hard as a brick. I was shocked to see him like that, I gave him my hand as he likes to lick my fingers but he didn’t, I also cleaned his left ear with finger as couldn’t because of his splay leg. He normally lick the finger after cleaning his ear but today he didn’t, that was enough indication that he wasn’t really at his 50%. He occasionally ground his teeth as well. We both were upset. Dr Andrew was there that day and explained that Sloppy is not really doing good but they force feed him lot of water and baby food with pain killers to help him.

We discussed what options Sloppy got at the time and doctor said we will have to give him sometime as some rabbits take more time to recover from the condition than others, and surgery would be the last option but survival rate of a gastrointestinal surgery for a rabbit is extremely low, less than 50%.

We came home with tears on our eyes. We couldn’t really sleep that night thinking about what he sort of pain he is going through, but hoped he would produce droppings at least tonight or tomorrow morning. We spent pretty much the whole night looking for another person with a similar experience, and any information regarding what we can do to ease his pain and help him with his condition, and I found this video I thought of performing that massage to Sloppy hoping it would make any difference.

Day 4

We both went to work today and also made a call early morning to find out how Sloppy did last night. He was the same. Maddie said we should go in the evening. So we thought we should bring some red towels as that was his favourite colour so he likes to mark those with his pee and droppings. We thought red towels would stimulate him, so we went to the hospital and the staff asked us to go into one of the two rooms they had and came in with Sloppy.

Maddie laid the towels on the floor and we put him on the floor. Maddie gave him lot of cuddles and kisses I was massaging two sides of his tummy with my fingers with enough pressure not to hurt him, it was gentle but I did it for at least 10-15mins. I also picked him up (with his belly up) and head between my elbow and body as shown in the above video. And massaged his tummy for 30secs to 1min. Then back to massaging both sides of tummy again for another 5min or so, I also kept my ears to his stomach area and listened weather I can hear any gut movements, I heard sort of a stomach movement for a second but nothing much. Doctors came into the room and gave us and heads up saying they need to give medication before they leave work and we have another few minutes with sloppy, that was around 5:40pm. Around 5:50pm Dr Alex came in and took Sloppy away. He also asked us weather we want to go ahead with a GI surgery tomorrow and explained that survival rate is extremely low. But we said will still do that to save him if nothing else would work by Friday morning. He agreed, Dr Alex told us that we can come and see him tomorrow morning before the surgery if we need to, we said probably not, as we were weak at the time. We went home with a heavy heart.

Day 5

We couldn’t really sleep, woke up very early got ready and went to work thinking what we should do if he hasn’t pooped by today. We knew surgery could be extremely dangerous and difficult in a sense that extreme medical care is neccessary after the surgery. Also we knew that most rabbits can’t make it through the anesthetic process as well.

I came to work, and told Maddie that I would talk to the doctors today as she didn’t really want to make decisions as of today. I received a call from Maddie just after she dropped me off at work, she was crying on the other end. She said “Sloppy pooped, but he also has passed away.”, it was a shocker, we both drove back to the hospital again. approx 10 mins from the city, where we work. Dr Alex was there and said though Sloppy pooped last night around 6:20pm, that was exactly 30mins after we left, he also admitted that he probably pooped because we massaged his tummy and did some exercises with him. But he really doesn’t know why he died even after producing droppings. He said if we don’t mind he would like to proceed with a necropsy for his and staff’s benefit to better understand Sloppy’s illness, I agreed as I wanted save another rabbit from the same disease in future. He also said the only regret he has is no one was with him last night.

Both Maddie and I have the same regret as of today, two days after his death. I still see him running around the backyard and following me from room to room, sleep next to my feet when I work. I thought of writing this post not to say how depressed we are now but to give someone a better understand the GI Stasis. So now I am gonna proceed explaining what we could have done differently to possibly save him.

Dr. Alex called me after the post-mortem and said he didn’t really have any dried hay or food in his tummy, and his organs were good as far as he could see, but bit of lumps in the stomach area. They still don’t really have a successful answer.

What could have we done differently?

The question which echoed in my head since the moment I heard that upsetting news. I am writing this in point form, based on priority as far as I understand this illness.

1. I could have checked his tummy more often (at least everyday if not twice a day) to see if it was hard or not.

2. Once we discovered that his tummy was hard on the first day, and not producing any dropings. I could have done what Maddie told me, force feed him water and enzymes (papaya juice or pineapple juice) in small amounts more frequently, every two hours or so the whole night. Also force feed lot of water since the first day.

4. We could have massaged his tummy and perform the exercise that is shown on the video ( since the first day. Massaging is the most beneficial of all for GI stasis on par with enough hydration, cannot emphasise any more about how effective this can be if you do right. So look the video number of times, back off if bunny doesn’t like it or try a different posture, pressure and try again.

5. We could have taken him back home with medication and not leave him in the hospital with other animals and no one to take care of him. And could have taken back to hospital on the following day. I would still do this if lived closeby, because stressing out a sick rabbit is not really good in any way. Right now I think I could have booked a hotel room but too late now.

Little about Sloppy

Sloppy was a three and half year old male minilop, who had E. Cuniculi and a splay leg (we think it was a birth defect). He had to go through his first surgery when he was around 8-9months, when his left eye had abscess due to E.Cuniculi, he recovered from it pretty well.

He was very playful and always run after us, he liked red towels, blankets, pretty much any soft cloth that is red. Since his early days he was on 1/4 cups of Oxbow pellets every other day or so and lots of fresh hay and greens, not much veggies but occational fruit such as strawberries or tiny bits of pear, apples, oranges. He was a happy bunny who had lot of exercises and freely roamed in the backyard when there was enough shade, also at nights till we go to bed. Few days a week he spent time with us indoors, thats when he pee’d on all the red cloths he could find :)


If your bunny has a hard tummy or if she/he doesn’t eat or poop or produces small droppings then you should consult your exotic vet immediately, in the meantime get a syringe and feed him lot of water. Again I can’t emphasize any more how effective a tummy massage can be, look at that 7 year old video (, I found it when it was too late to save him. Once you have required medication and if you can put in 8-10 hours a day during GI stasis don’t leave him in the hospital at night, bring him/her back home and do those massages gently and feed them lot of water. Once your bunny recovered from his first episode of GI stasis, make sure you check his tummy every day, keep a good eye on his droppings, shape, size, frequency, etc. That’s what good bunny parents do.


Very first picture I took of him. The day we brought him 16-04-2011
Thats where he stays if he is inside the house
Him and the herb garden we planted for him

IMG_20130901_133500 IMG_20130901_153303

Installation Guide for Linux Mint 17 / Ubuntu 14 04 on Mac mini late 2012

Installing Ubuntu 14.04 based distribution on a Mac (or any EFI based computer) has become very straightforward. If you read my previous guide on getting Ubuntu installed on Mac mini guide and thought it was long and too many things to configure, relax because you only have to run few commands with the latest Ubuntu 14.04 / Linux mint 17 distributions.

Firstly, remember that you can either split your Mac partitions using DiskUtil and have a separate partitions for your Linux or you can wipe the whole disk and have just Linux on your Mac. If you choose to go with the first, then make a partition on your Mac, of at least 10GB for Linux. And remember how much disk space you allocated for this partition as in the Ubuntu/Mint setup, you will have to point to this specific partition.

Make a bootable USB of Ubuntu 14.04 or Mint 17 (Qiana), you can easily do this by following these instructions (on your Mac).

1. Download the ISO from either Ubuntu or Linux Mint website (make sure you get the 64bit version).

2. Make sure the ISO file copied into your home directory of your Mac with the name linux.iso

3. Then run “hdiutil convert -format UDRW -o ~/linux.img ~/linux.iso” without quotes. This will take a minute or two.

4. If the output file is called “linux.img.dmg” then rename it to “linux.img”

5. Plug your USB of at least 2GB, some old USBs won’t boot so if this guide doesn’t work for your try it with a different USB.

6. Run “diskutil list” without quotes and check the output, should look like the following example. You should be able to distinguish your USB device from your hard drive because of the size, type name (it says usb_disk).


7. Now we gotta unmount the USB disk using this command before writing the image file we created in Step 3. Run “diskutil unmountDisk /dev/diskN“, where is the USB device number from the above list. As per the above example it would be 2 so command would be “diskutil unmountDisk /dev/disk2″, make sure you get yours right!

8. Making the bootable USB is easy, run “sudo dd if=~/linux.img of=/dev/rdiskN bs=1m”, again is the USB device number as per Step 6.

This step will take a while, have a coffee and come back.

9. Then you gotta eject the USB, don’t just pull it out. run “diskutil eject /dev/diskN“, again N is the USB device number you used in the above steps. Wait 5secs and then pull the USB out.

10. Reboot your Mac. Keep press “Option / alt” button when you hear the boot sound.

11. You should end up with a password screen where you need to enter your Admin password.

12. You will end up in the bootloader screen of the Mac, now plug in your bootable USB. And press Enter.

13. Continue as per normal Ubuntu / Linux mint installation except the partitions section where you should have a partition for EFI boot partition. So if you choose to have both Mac and Linux you can just split the partition you created in the first steps of this guide to two, for an example one “swap” (of at least 1 to 8GB, or whatever suits you) partition and one “/” (root) partition. And leave the boot loader installation device as as it is (bottom dropdown in partition management section).

If you choose to wipe the whole Mac, I recommend you should chose “Erase disk and install Linux Mint” / “Ubuntu” in the partition management section and leave LVM un-ticked.

14. After finishing the installation process it will ask to reboot, but DONT! get a terminal and run the following commands to make sure that GRUB is the preferred bootloader on your Mac (this overrides your Macs original bootloader sequence but your can revert it back when you want to so don’t panic).

You should also make sure the USB is still plugged into your Mac.

run “sudo apt-get install efibootmgr


sudo efibootmgr“, this will list something like the below example output

Mint is at address “Boot0000”

Ubuntu is at address “Boot0010”

Mac OS is at address “Boot0080”

above are the EFI identifiers of my mac, yours will look similar what you need to do now is alter the boot sequence.

I ran the following command, which changed my Mac boot sequence to boot Mint first then Ubuntu (which is just a phantom EFI identifier I assume), lastly the Mac’s original.

sudo efibootmgr -o 0, 10, 80

then just to confirm that above command altered the sequence run “sudo efibootmgr” again and confirm the new order.

15. Reboot using the menu in Mint/Ubuntu. Unplug the USB.

16. You should come back to Mint/Ubuntu, then you gotta fix your wireless networking if required. Make sure the USB is pugged back in then press the “Super” (Command key or Windows key) key and type “Driver manager“, press enter. You should end up in a screen like below.

Choose the Airport Extreme driver and apply.





Low colour depth in the second monitor

If you have a dual monitor setup, they you will notice that sometimes one of the monitors display less colours than the other one. I read somewhere that this issue happens in EFI based machines with Intel HD xxxx video cards, but I am not exactly sure the reason behind it.

The permanent fix for this would be to alter a configuration register for the Intel HD video card. The way I prefer for this is through the /etc/profile file.

sudo gedit /etc/profile

Add the following line

intel_reg_write 0x70008 0xC4002000

Save the file and exit. In the next boot colours will be normal on both monitors.



Installing LPCXpresso on Ubuntu 14.04 based distribution

I had to spend a lifetime trying to install LPCXpresso IDE built by NXP on Ubuntu 14.04, always came up with the following error message.

[14:52:45] purinda@purinda-ws[~/Downloads]+ ./Installer_LPCXpresso_7.1.1_125_Linux-x86
invalid command name "bind"
 while executing
"::unknown bind Text <Tab>"
 ("uplevel" body line 1)
 invoked from within
"uplevel 1 $next $args"
 (procedure "::obj::Unknown" line 3)
 invoked from within
"bind Text <Tab>"
 (procedure "::InstallJammer::InitializeGui" line 19)
 invoked from within
"::InstallJammer::InitializeGui "
 (procedure "::InstallJammer::InitInstall" line 68)
 invoked from within
 (file "/installkitvfs/main.tcl" line 38437)


The issue was that with multiarch built binaries shipped with Ubuntu, 32bit libraries cannot be installed via old library which I used in the past (ia32libs). As of Ubuntu 14.04 the 32bit packages can be installed by typing the same old “apt-get install <package>”, but with an extra suffix “:i386”.

So for getting LPC Xpresso (Java based IDE / Installer) installed you need 32bit variants of the following libraries.

sudo apt-get install libgtk2.0-0:i386 libpangox-1.0-0:i386 libpangoxft-1.0-0:i386 libidn11:i386 libglu1-mesa:i386 libxtst6:i386 libncurses5:i386

Weekend Project:

One of my friends is working on a project which she spends most of her time integrating data from Xero, MyOB and other sources with their product at her work place, pretty much everyday.

Normally this data exports come as CSV and Excel spreadsheets, last week she asked me whether we can build something to help her with this repetitive, boring task which needs lot of attention to get it right.

So I asked her what she does, and she explained that the application the company has developed, only accepts data in a certain format, so she normally open spreadsheets coming from multiple sources and transform them by hand using a spreadsheet software to fit the template that developers have provided to her to get the data into the system. So this is what she does,

  1. Remove unnecessary fields from the import file.
  2. Merge multiple fields to a single field (ex: First name and Surname becomes Name, etc)
  3. Trim certain characters from Address fields and Phone number fields so the system doesn’t blow up trying to import them into their database.

As she claimed, this normally takes around an hour per file with 100 rows.

I thought there might be more than 1 person in the world who might need help with manipulating data in spreadsheets. So was born last weekend.

What it does is pretty much what I explained above in three points, it can Trim/Remove characters or words from Columns that get imported, merge and map multiple columns into single column, convert file types while doing all the above and get the output in a clean, compatible Excel file. Oh it also supports previewing data before taking an export, so proof-read before really export stuff.

I also implemented user accounts in the applications as well, which let users to save their Mappings as templates in the cloud, so ones they have build whatever templates they want to use against multiple different types of files, all they gotta do is upload the file and apply the template and rest gets done automatically, producing a clean, precise spreadsheet which fits the template user wants. Front Page


Supports Excel AutoFilter like searching.


Adding custom fields to the export and mapping source columns from the imported spreadsheet.
Previewing data before exporting.
Look here for the application
Like everything else I do, find the code here  :)