Sunday, March 22, 2015

Green Slips

Also known as Comprehensive Third Party (CTP) insurance. In NSW, there are currently seven Green Slip insurers. Instead of getting quotes from each of them, Motor Accidents Authority (MAA) provides a green slip calculator that asks you a series of basic questions, and gives a fairly accurate estimate of how much each insurer will charge you. Prices include Medical Care and Injury Services (MCIS) and GST. You can find the calculator here: http://prices.maa.nsw.gov.au/

Thing is, I can't remember who's my current CTP insurer. And I didn't get a renewal notice or email. I was hoping to get a better deal through a renewal of policy.

Turns out Roads & Maritime Services (RMS) offers a free greenslip and registration check service at https://myrta.com/regcheck/ Simply enter the plate/registration number, and you'll get a free report with basic vehicle info, registration and CTP insurance details. Anything more, you'll need to pony up $21 for a vehicle history report.

For everything related to green slips, visit www.greenslips.com.au. Heck, then even have their own calculator.

Thursday, March 12, 2015

For When rm Is Not Good Enough

So one day I find myself with a directory with more that a million files that need to be cleaned out. A simple rm * is not going to work because of the number of files (argument list too long). First thing I tried is:
find <directory> -name "alarm.*" -mtime +360 -exec rm {} \;
This worked, but takes too long because you have find, xntpd, and rm working sequentially. I also noticed that xntpd is just hogging all the CPU.

Then I tried removing mtime, but it still takes too long. If I try some other filename patterns, find just quits - maybe because there are just too many matches.

Instead of using -exec rm, someone suggested using the -delete argument to make it safer, faster, and more efficient:
find <directory> -type f -delete
Unfortunately, my find doesn't support this argument.

Another suggestion is to do a loop via bash:
bash# for i in *; do
> rm -f $i;
> done
While this works, you're still deleting files one at a time, so very slooooow.

Another trick is to create an empty directory, then rsync it with the directory to be nuked:
rsync -a --delete empty_dir/ full_dir/
Again, unfortunately, my locked-down system doesn't even have rsync, and I'm too lazy to copy it in.

The other way of doing it is to remove the directory totally, then recreate it. One downside is that the new directory might not be exactly the same as the one you deleted, so some applications might not work anymore.

What ultimately worked for me is:
ls -f| xargs rm
By disabling sort, you don't have to load the entire directory listing to memory. The unsorted ls simply streams its output. xargs then passes on as many filename as possible to rm for deletion.