Diary of a geek

December 2017
Mon Tue Wed Thu Fri Sat Sun
       
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31

Andrew Pollock

Categories

Other people's blogs

Subscribe

RSS feed

Contact me

JavaScript required


Tuesday, 05 August 2014

Lifehacking with NFC, Tasker and HabitRPG

Oh man, I'm such a geek...

Being a single parent has required a considerable amount of self-discipline on my behalf. I find I do best in an environment with routine to make sure stuff gets done. One of the things I did to try and make sure stuff got done was to form positive habits. To help and make this a bit more "fun", I started using HabitRPG, an online role-playing game based on habits.

I've only ever used it in a half-arsed manner, and as a result, I die a lot. Often I'll do my dailies, but then forget to mark them off. Sometimes I just fall off the habit wagon altogether. And die.

One of my dailies is to scoop my cat's litterboxes. For whatever reason, I find this a tad onerous, and had found myself falling out of the habit of doing it on a daily basis. My cat deserves better than this, so I wanted to get back on the habit wagon, but make it a bit more "fun" as well.

I love NFC, I've been a big NFC weenie for a long time. It's a solution looking for a problem. I have a huge collection of NFC tags, and I've finally found a problem I could use them with. I wanted to make it more frictionless to mark a task as completed in HabitRPG. I didn't want to have to take out my phone, unlock it, open the HabitRPG app and check off the daily task. I just wanted to wave my phone at an NFC tag. Here's how I did it.

The inimitable Paul Fenwick, who first inspired me to use HabitRPG, has a way more complicated set up to achieve something similar. The Site Reliability Engineer in me wanted the least number of moving parts and third-parties to have to get from my phone to HabitRPG.

After some hunting around, I found this wiki page on integrating Tasker with HabitRPG's API, so based on that breadcrumb, I got hacking.

I'd not used Tasker before. I was already using AutomateIt to do some other, reasonably dumb automation on my phone, though. Tasker is a little bit obtuse, and it took me a couple of days of casual fiddling with it to wrap my head around it's usage model. The fact that it can run arbitrary JavaScript, and that NFC Tools integrates with it is where the real awesome lies.

So based off the wiki, I crafted a couple of bits of JavaScript, one to mark daily tasks as complete on HabitRPG, and one to query HabitRPG to see if they have been marked as complete.

For the former, it was trivial, using NFC Tools, to write an NFC tag that then runs the Tasker task to call the HabitRPG API to mark a daily task as complete. That goal was now complete.

The equally satisfying part was also having Tasker do a time-based conditional nag based on the state of the daily task in HabitRPG. So now if it gets to 4:45pm and I haven't scooped the litterboxes, my phone literally tells me I'd better go do it.

I've also done the same thing with putting the dishwasher on. I've stuck an NFC tag on the dishwashing powder bottle lid, and I get a conditional reminder before bed time. It used to be an unconditional reminder with AutomateIt, and it was dumb, because I rarely forget to put the dishwasher on. Now, I can use HabitRPG to keep state on it instead.

The hunk of JavaScript to update HabitRPG is very simple:

function mark_completed() { 
  var http = new XMLHttpRequest();
  http.open("POST", http_post_url, false);
  http.setRequestHeader("x-api-user", global('HabitrpgUserid'));
  http.setRequestHeader("x-api-key", global('HabitrpgApiToken'));
  http.send();
  return(http.responseText); 
}

try { 
  var result = mark_completed(); 
} catch(e) { 
  var error = e.message; 
}

All of the interesting stuff is defined in variables preceding the JavaScript in the task definition. Here's a screenshot of the Task in Tasker that tells a thousand words:

Screenshot of Tasker task that uses HabitRPG API to mark a
task complete

Similarly, to query HabitRPG, I'm using:

function query_task() { 
  var http = new XMLHttpRequest();
  http.open("GET",http_get_url,false);
  http.setRequestHeader("x-api-user", global('HabitrpgUserid'));
  http.setRequestHeader("x-api-key", global('HabitrpgApiToken'));
  http.send();
  var p = JSON.parse(http.responseText);
  return p['completed'];
}

try { 
  var task_completed = query_task(); 
} catch(e) { 
  var error = e.message; 
}

It's only slightly trickier because you have to parse the JSON blob that comes back.

Again, a screenshot.

Screenshot of Tasker task that
uses HabitRPG API to query task state

Now maybe I'll stop dying so much in HabitRPG, my cat will have the clean toilet she deserves, and I'll stop getting reminded about putting the dishwasher on when I already have. Better living through automation, that's my motto.

[14:39] [geek] [permalink]

Monday, 03 February 2014

Yep, I'm still a geek

I did some soldering tonight, and it felt good.

I haven't really done much soldering since I built my cat water bowl monitor, and that's going back to the last decade.

My apartment building has an intercom-triggered release to the common front door, and the latch has been sticking a bit lately. It stuck today when Megan's Dad came to pick her up, and it stuck when Sarah came to pick up Zoe. It's annoying to have to trek all the way downstairs to let them in and then walk back up again. I decided I'd try and look into what the problem was today after everyone left.

A visual inspection of the latch showed nothing obvious, and no one else was home to push the door unlock button for me while I was at the front door, so I decided to have a look at how it worked from within my apartment.

I pulled the intercom phone off the wall and identified the two wires that got shorted when you pressed the unlock button, and shorted them by hand with a wire, and sure enough, I could hear the door solenoid releasing.

I was thinking to myself, "if only there was a way to trigger this with my phone". I have a RaspberryPi and an Arduino board at my disposal, but I didn't really want to risk frying either of them. Then I remembered that I had a BoArduino that I'd bought at the Maker Faire years ago, but never assembled. I figured it'd make a good sacrificial lamb.

So I rummaged around and found it, and busted out the 240v soldering iron I bought recently, but haven't used yet, and set about slapping it together. Man, it was fun. I had it half built before yoga, and finished it off when I got home. It even worked first go. I felt such a sense of accomplishment.

The problem is, my general electronics fu is so weak, I'm not sure where to go from here, and my multimeter needs a new battery. I think the voltage on the wire for the intercom is higher than the BoArduino likes. I'd naively thought I could just connect the two wires of interest, one to ground and the other to one of the digital I/O pins, and have the BoArduino act as a switch, but that's not working. If I wire it one way, it unlocks the door instantly, even with the board powered off, and if I wire it the other way, it seems to half power up the board just using the power of the intercom system. So I'm obviously doing something wrong.

My plan is to just have the BoArduino simulate pressing the button for 5 seconds at a time, every 10 seconds or so. Then I can be downstairs wiggling the latch to see what's up with it.

Or I could just place a maintenance request with the Body Corporate.

At least I had fun assembling the BoArduino, and now I have a spare one. It was nice to be able to go from problem to idea to execution in one night, even if the execution failed.

[05:46] [geek] [permalink]

Saturday, 24 July 2010

Cleaning up from 20 years ago

I'm a terrible hoarder. I hang onto old stuff because I think it might be fun to have a look at again later, when I've got nothing to do. The problem is, I never have nothing to do, or when I do, I never think to go through the stuff I've hoarded. As time goes by, the technology becomes more and more obsolete to the point where it becomes impractical to look at it.

Today's example: the 3.5" floppy disk. I've got a disk holder thingy with floppies in it dating back to the mid-nineties and earlier. Stuff from high school, which I thought might be a good for a giggle to look at again some time.

In the spirit of recording stuff before I throw it out, I present the floppy disks I'm immediately tossing out.

MS-DOS 6.2 and 6.22
Ah the DOS days. I remember excitedly looking forward to new versions of MS-DOS to see what new features they brought. I remember DOS 5.0 being the revolutionary one. The dir command grew a ton of options.
XTreeGold
More from the DOS days, when file management was such a pain in the arse that there was a business model to do it better. ytree seems like a fairly good looking clone of it for Linux.
WinZip for Windows 95, Windows NT and Windows 3.1
Ha. I actually paid money for an official WinZip floppy disk.
Nissan Maxima Electronic Brochure
I'm amazed this fit on a floppy disk
Turbo Pascal 6.0
Excluding GW-BASIC, this was the first "real" language I dabbled in. I learned it in Information Processing & Technology in grades 11 and 12. I never got into the OO stuff that version 6.0 was particularly geared towards.
Where in the World is Carmen Sandiego?
Awesome educational game. I was first introduced to this on the Apple ][, and loved it. This deserves being resurrected for a console.
Captain Comic II
Good sequel to the original, but I never found a version that worked properly (I could never convince it to let me finish it)
HDM IV
Ah, Hard Disk Menu. A necessity from the DOS days when booting up to a C:\> prompt just really didn't cut it. I used to love customising this thing.
ARJ, LHA, PK-ZIP
Of course, you needed a bazillion different decompression programs back in the days of file trading. I guess things haven't changed much with Linux. There's gzip, bzip2, 7zip, etc.
Zeliard
I wasted so many hours playing this. The ending was so hard.
MicroSQL
This was some locally produced software from Brisbane, written in Turbo Pascal (I think). It was a good introduction to SQL, I used it in high school and my first stab at University.
DOOM and DOOM II
Classics. I don't seem to have media for it any more, but I also enjoyed playing Heretic and Hexen. Oooh, Hexen has been ported to Linux? Must check that out...
SimCity 2000
I wasn't a big fan of this game, but I liked the isometric view that 2000 had, compared to the previous version.

[14:41] [geek] [permalink]

Wednesday, 03 February 2010

On trying to buy a 19 inch rack

The first time we looked at this condo that we ended up buying, I looked at the cupboard under the stairs, and could visualise a small 19 inch rack in the lower part of it, with all of my computer gear in it.

When we got structured cabling installed, I had the CAT-6 cabling terminated onto a basic 19 inch patch panel, with the intent of mounting this in a rack.

Then it became a case of trying to find a rack.

My favourite junk shop, Weird Stuff, didn't have anything that wasn't full height, so I started looking around online.

There's certainly a lot of variance in price. I settled on a 26U Intellinet rack from New Tech, because based on the dimensions on the website, it would fit in the space I had in mind.

When we assembled it, it became obvious that the dimensions quoted were the inside dimensions and not the outside dimensions, and it was about 4 centimetres too tall. In hindsight, I should have figured that out. 26 x 1.75 is 45.5.

This is where I must give a shout out to New Tech. Sarah called them up, explained the situation, and they agreed to take the rack back, and sent us some shipping labels to ship it back.

We managed to find a more simple rack, a 20U Middle Atlantic, which arrived today, and was significantly easier to put together. The only downside: no rear mounting holes. I don't think it'll be a huge problem, though. All I'm planning on mounting in the immediate future are the patch panel, some sort of cable management, a Catalyst switch, and a power strip. At some point in the future, once we stop spending money hand over fist, I'll look at getting a rack mountable server to replace the hodge podge of computers I'm currently running.

What I wish we'd discovered about two days ago, was the Lack Rack. This would have been perfect (and so much cheaper).

[22:44] [geek] [permalink]

Thursday, 09 July 2009

Facebook seems to render RSS feeds incorrectly (when newlines are involved)

I've been sufficiently annoyed by this to try and file a bug against Facebook (we'll see how well that works) and to go to the trouble of documenting the problem as I see it...

I have my blog importing into Facebook as what they call a "note". I figured, I could, so why not? It also gives me spam-free comment support for free (not that I particularly care about comments, people seem to be able to figure out how to email me if they really want to say something to me about a post).

I have a very rudimentary blogging setup. I'm using Blosxom (an old version at that). I hand-write my posts, and the HTML, in Vim. It works for me, and I can't be bothered changing it. Vim is set to wrap lines at 76 characters. I'm writing raw HTML, so sometimes it wraps sooner than it might if I was writing raw text.

The fact that I've got newlines in my HTML source doesn't seem to affect the way my blog is displayed, nor does it seem to mess up in anything else that consumes the RSS feed. Consider this recent post:

HTML source of a recent blog post

There's a newline after "in", there's a newline after "ask".

Here's how it gets mangled by Facebook:

The same blog post rendered in Facebook

It seems to have correctly ignored the newline characters, except everything else seems to treat the newline as whitespace. Facebook seems to just eat it completely, which mangles the words together.

This phenomenon is not observed in Planet:

The same blog post rendered in Planet

Nor in Google Reader:

The same blog post rendered in Google Reader

and of course it looks fine in its native environment:

The blog post as it appears on my blog

So I'm really inclined to say that Facebook is doing it wrong. I haven't read an HTML specification yet to try and figure out if how this should be done is specifically codified, but it seems to make the most sense to treat a newline as whitespace - it's being used to break words.

[00:01] [geek] [permalink]

Saturday, 10 January 2009

Out with the old, in with the new

My old hackergotchiMy new hackergotchi

It's a new year, so why not a new hackergotchi I say?

Brandon and Robin came around on Thursday night, and where there's Brandon, there's his camera, so he got a decent enough mugshot to convert into a less crap hackergotchi (after I spent a few hours fighting with the GIMP today)

[15:05] [geek] [permalink]

Thursday, 01 January 2009

Connect-a-desk

OMG OMG OMG!!!

I just discovered the connect-a-desk

I had a crazy idea for something exactly like this a couple of years ago, when I was in Las Vegas for Christmas, in a line for a buffet on Christmas Day, and on call. I was trying to juggle a laptop and deal with something I'd been paged about whilst still standing in line.

I'm so buying one. I could work on a treadmill!

[17:47] [geek] [permalink]

Sunday, 27 July 2008

This almost makes me wish I had a lawn that needed mowing. Almost.

I just became aware of this electric lawn mower via Woot!

I never minded mowing the lawn, when it was a decent kind of yard (i.e. level). This mower looks like it'd take the fun to a whole new level: hardly any noise, and no smoke.

I just need a yard now...

[22:39] [geek] [permalink]

Monday, 03 March 2008

Living the dream

I first heard about Jon Oxer's home automation setup when he visited Google last year to give a tech talk (heh, that's right, I introduced him).

After reading this latest article on his house, I've come to realise that he's implementing pretty much every cool thing I wanted to do when I get around to building the "dream house" (except I'm not too keen to go microchipping myself).

The main difference is Jon's actually electronically inclined, whereas I have all the ideas, but lack the ability to go hack them together myself.

So many things I'd like to learn, so little time to learn them...

[21:18] [geek] [permalink]

Thursday, 09 August 2007

Woot!

Got my Linux Fund credit card today. I've been wanting one ever since I moved to the US, but they haven't been accepting applications for a long time.

I don't know how the various credit card companies decide what limit they're going to offer people (beyond credit score). Some companies have given me thousands, others only a few hundred.

I'd sworn off applying for any more cards just for the heck of it, but hey, this one's got Tux on it!

[21:56] [geek] [permalink]

Monday, 22 January 2007

Psst! In Sydney for Australia Day?

[12:19] [geek] [permalink]

Wednesday, 18 October 2006

Who would have thought...

You can pipe figlet through cowsay?

That is all.

[18:05] [geek] [permalink]

Wednesday, 16 August 2006

I love MythTV

Many, many years ago, I dreamed of making a VCR that had either a serial interface, or an Ethernet interface with a Telnet server. It would have been so useful for those times that I was out and about, and either knew I wouldn't make it home in time to watch a TV show I wasn't already recording, or heard about something on TV during the day that I'd like to record.

Many, many years later, with the installation of the MythTV web interface, I've now achieved that dream. Ah, the feeling of accomplishment!

Oh, and while I'm being geeky, I should mention how I can run a MythTV front end on my laptop, and watch TV in bed with no extra hardware required.

I've reached the pinnacle...

[22:20] [geek] [permalink]

Sunday, 23 July 2006

I love technology

Although Windows' Bluetooth support is a bit weird.

I'm sitting in a hotel room in Canberra, with my old Sony Ericsson HBH-35 Bluetooth headset paired with my laptop, talking to Sarah on her mobile phone, using X-Lite on my laptop, talking to my Asterisk server at home. The call quality is quite acceptable without any QoS.

I should do some maths to work out if the obscene rate the Telstra wireless hot-spot is charging me is less than what it would cost me to use my Australian mobile phone or the hotel phone for the same call.

The next step is to do all of this, but with the iPaq, and on Google Wifi anywhere in Mountain View. Then I'll just have a ridiculously expensive mobile phone.

[12:40] [geek] [permalink]

Sunday, 26 February 2006

Best. Picture. Ever.

[20:22] [geek] [permalink]

Sunday, 08 January 2006

Hell yeah

We are so doing this. Blows away these guys on cost.

[23:41] [geek] [permalink]

Saturday, 19 November 2005

Debian saves the day again

I'm already over punching in over thirty numbers to call people back home with the prepaid phone card I've bought, so I did a quick apt-cache search dtmf, happened upon dtmfdial, and in five minutes had a quick and dirty shell script making my laptop do all the button pushing for me. So as to not drive anyone in earshot insane, I just hold the cordless phone's microphone to my headphones.

Of course, if the phone had a speed dial, all this would be unnecessary.

[23:46] [geek] [permalink]

Tuesday, 27 September 2005

But I don't want to be patent encumbered!

[00:20] [geek] [permalink]

Tuesday, 23 August 2005

Yeah baby!

A.N.D.R.E.W.: Artificial
Networked Destruction and Rational Exploration Worker

[23:08] [geek] [permalink]

Monday, 15 August 2005

Sheesh

My
computer geek score is greater than 83% of all people in the world! How do
you compare? Click here to find out!

Not as geeky as some...

[16:20] [geek] [permalink]

Monday, 04 July 2005

Spiffy

The new look Planet Linux Australia is the most spesh looking Planet I've seen to date (not that I've seen that many)

[02:42] [geek] [permalink]

Friday, 13 May 2005

Damn

apollock@debian:~$ date -d '13 dec 1976 + 10000 days'
Fri Apr 30 00:00:00 EST 2004

No 10K days party for me :-(

[05:18] [geek] [permalink]

Saturday, 27 November 2004

Everyone needs a Planet

I finally got around to setting up planet.andrew.net.au so I can aggregate all the feeds I read (and ones I haven't been reading) into one place. I have to give big fat kudos to Scott and Jeff for making it so easy to set up.

Now I just need to make it look sexy...

[19:48] [geek] [permalink]

Tuesday, 09 November 2004

Happy 1.1 billion seconds since 1970

Tragic, but I happened to be running pbuilder about five minutes prior, and noticed all the 9's. As I managed to miss when the epoch ticked over to 1 billion, I had to sit back and watch it roll over to 1100000000.

[03:37] [geek] [permalink]

Friday, 22 October 2004

On IRC clients

When I first discovered the Internet, I was a windoze user, and so when I discovered IRC, mIRC was it. So I grew up on mIRC, and never quite managed to adapt to command-line IRC clients like ircII. Well, I could single-task in them fine, but that wasn't how I was used to using IRC.

Whenever I was on a machine with a GUI, I'd generally use XChat, and didn't feel too much like a fish out of water. Problem is, I rarely use a GUI. I usually SSH into the box that is my gateway, reattach screen, in which I have a screen for Mutt, a screen for micq, and a screen for bashing away at a shell prompt.

So the net result of all this is I don't IRC much any more. People who know me know that I tend to flit in and out, depending on if I'm after someone, or some information. I wouldn't mind changing that, and having an idle IRC session in another screen, but till now, I haven't found the IRC client to make it worth my while.

Today, I discovered irssi, and it might just be that IRC client. At least for a start, it didn't bugger up my terminal, the way ircII invariably seems to. The main issue I have is I feel totally uncoordinated in it at the moment. I can split the screen into windows, which is half the battle, I'd like to be able follow a couple of channels at once. It's totally bizarre trying to get my head around what happens when you split the screen, join a channel and then part. It seems to close the "window" resulting in your splits going to hell. The other issue is colours. I haven't mastered how to customise that yet, and the doco is, well, light on in places. So if you run into me on IRC in the next little while, please be patient, while I figure out how the heck to drive my IRC client.

[16:52] [geek] [permalink]

Thursday, 02 September 2004

Holy crap!!!

AJ said he had good Google Juice, but jeez, he only added my blog to his blogroll on the weekend, and now my blog is the first hit when you Google for my name...

Boggle.

[04:46] [geek] [permalink]