28 Sep 2014

Teach your neighbours' noisy dogs to stop barking

As long as there are neighbours, there are neighbours with noisy dogs. While my opinions on people who make no effort to control their pets' noise are probably best not discussed here, there is a humane way to take this matter into your own hands...

I had been woken by incessant barking at 3am one too many times, did some research and came across several products designed to help manage noisy dogs. While some of them are designed for your own pets - like collars that emit high frequency sound or sprays of water triggered by barking (neighbours take note!); Others are designed to help control other dogs in the immediate neighbourhood. There is a siren that is camouflaged as a bird house that emits high frequency noise, triggered by barking that you can mount alongside your noisy neighbours' garden. I was not about to spend ZAR1000 (~$100) on a gimmick that I wasn't sure was going to solve the problem though.

Based on these existing products I came up with a cheap, make shift solution, using an old Nokia cell phone...

All you need to do is  set a high pitched frequency as the tone for incoming messages and set the volume to maximum. The idea is that now when your neighbours' dogs get into a barking frenzy, you simply send an SMS message to your old Nokia cellphone (a 'please call me' works great) and it  triggers the high pitched ring tone, discouraging your neighbours' dogs from barking. It's simple but it actually works.

I use a 2 second long, 8000 hz ring tone on a Nokia 5000D and this seems to be quite effective in training my neighbours' border collies to stop barking incessantly (different frequencies may work better for other breeds of dog?). I popped the phone into a tupperware to keep it protected from sun and rain and I need to charge it about once a week but it works great!

I don't trigger the tone every time I hear my neighbours' dogs bark - I save it for those times when they enter a torturous trance of looped barking. Sometimes I do need to trigger the tone two or three times, but it always works to break the barking cycle and certainly beats getting out of bed at 3am. It has also helped to make the barking episodes far less frequent which I think suggests an element of learning on the dogs' side.

Some peace and quiet at last :)

7 May 2014

Sony XPERIA V rebooting problem solved

I was battling with frequent reboots of my Sony XPERIA V. Particularly under high load when playing a 3D game or making heavy use of the camera my phone would get really hot and simply switch off.

My first (and it turns out guilty) suspect was the battery, but the annoying thing was that this behaviour just happened to co-incide with a recent upgrade to Android 4.3. I wanted to be sure It was the battery before I forked out the cash for a replacement so I diligently downgraded back to Android 4.1.2 and experienced the same stability problems.

I am now running Android 4.3 on my Sony XPERIA V with a new Sony BA800 battery and just completed 5 levels of Real Racing 3 without any trouble - I couldn't even complete one level with the old battery. So Problem solved!

P.S. Walk-in retail stores in South Africa don't carry a lot of Sony XPERIA accessories but I was able to find the battery online at xperiastore.co.za for about as much as I was expecting to pay.

18 Feb 2014

Custom MWEB ADSL Usage Report / Notification by email

A lot of people are on uncapped ADSL packages these days, including myself. But I still like to keep an eye on my account to watch that I don't get throttled. MWEB is my ADSL supplier of choice and the only way to monitor an MWEB account is to login to their website every time you want to see what's going on which can get tedious.

So I put a very quick php / curl script together that can login to my MWEB account for me and then email me a report. I set the script to run at 6 am, so I have an MWEB ADSL usage report waiting in my mailbox every morning - nice and convenient...

I'm not entirely proud about the quality of the code, it could be improved a lot, but as I said, I did put this together very quickly and it works. I would love to host this as a service for other people to make use of, but I think that MWEB would probably take exception to me 'colleting' other people's ADSL login information and block the ability for anyone to login to mweb.co.za with a script.

Anyway, I've included the code below and I'm sure that most people who have their own hosting to run it from will be able to make sense of it. But all you need to do is supply your own details between lines 3 and 21, setup a cron job at the time that you would like it to run and you should be sorted. You may just need to make a few more tweaks depending on how different your MWEB ADSL package is to mine and the exact output you get on your ADSL usage page on the MWEB My Account Service...

<?php
//Fill in your details between these lines=====================================================
//Your MWEB username / email address
$mwebUsername = 'username@mweb.co.za';

//Your MWEB email / ADSL password
$mwebPassword = 'password';

//The URL that displays in your browser when you click on your ADSL usage in My Account at mweb.co.za
$mwebAdslPage = 'https://myaccount.mweb.co.za/mwebcore/myaccount/modules/services/mwebadsl/uncappedview.jsp';

//The email address that you would like to send the usage report to
$sendMailto = 'your.name@domain.com';

//The Start string of the block of text (on the MWEB ADSL usage page) that you would like to include in your usage email
$startText = 'You have used';

//The end string of the block of text (on the MWEB ADSL usage page) that you would like to include in your usage email
$endText = 'Check Usage';
//Fill in your details between these lines===========================================================

//Edit code below this line at your own 'risk' :) ===================================================

//Parse text block for value near search defined by offset and length / end tag
function parse($block,$search,$Offset,$length,$endtag='')
{

$start = strpos($block,$search) + $Offset;
$end = $start + $length;
$value = substr($block, $start, $end - $start );
if ($endtag != '') {
$value = substr($value,0,strpos($value,$endtag)-(strlen($endtag)));
}
return $value;
}


//setup cUrl
$cookiefile = 'cookie.txt';
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (Windows; MSIE 6.0; U; Windows NT 5.1)');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiefile);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiefile);

//login to My account at mweb.co.za
curl_setopt($ch, CURLOPT_POSTFIELDS, 'userIdentifier='.urlencode ($mwebUsername).'&password='.$mwebPassword.'&LoginUser=Sign+In');
curl_setopt($ch, CURLOPT_URL, 'https://myaccount.mweb.co.za/mwebcore/myaccount/login/login.jsp');
curl_exec ($ch);

//load the ADSL usage page
curl_setopt($ch, CURLOPT_URL, $mwebAdslPage);
$result = curl_exec ($ch);
curl_close($ch);

//delete temporary cookiefile data (logout)
if (file_exists($cookiefile))
{
unlink($cookiefile);
}

//Prepare the usage area of the page at $mwebAdslPage for mailing...
$usage = parse ($result, $startText, 0, 10000, $endText);
$usage = preg_replace('/\s+/', ' ', $usage);
$usage = str_replace('</p>', '<br>', $usage);
$usage = str_replace('<p>', '<br>', $usage);
$usage = str_replace('<br> <br>', '<br>', $usage);
$usage = strip_tags($usage, '<br>');
$usage = str_replace('<br>', "\n\r", $usage);

//This displays the resulting usage output if you load the script in your browser
echo $usage;

//email the resulting usage output to $sendMailto address with subject 'ADSL usage report'
mail ($sendMailto, 'ADSL usage report', $usage);
?>