Planet Linux Australia

Syndicate content
Planet Linux Australia -
Updated: 22 min 47 sec ago

Andrew Pollock: [geek] Lifehacking with NFC, Tasker and HabitRPG

Wed, 2014-08-06 09:25

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();"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:

Similarly, to query HabitRPG, I'm using:

function query_task() { var http = new XMLHttpRequest();"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.

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.

Andrew Pollock: [life] Day 188: Sickness, Thermomix consultancy, some tennis

Tue, 2014-08-05 21:25

Today derailed a bit. Sarah sent me a message saying that she thought Zoe was too sick to go to Kindergarten, so I picked her up and brought her home.

I had a 9am coffee lined up with the Thermomix Group Leader for my area to talk about becoming a Thermomix consultant, so Anshu offered to stay and keep an eye on Zoe for me, which made going to that still a possibility.

The chat ended up going a lot longer than I expected, so Anshu hung around for lunch with us after I got back, and then left. I decided to just do the house cleaning today instead of tomorrow, and Zoe mostly just followed me around and helped and generally entertained herself.

She indicated to me that she'd still like to go to her tennis class, so we were getting ready for that when I got a text message from Megan's Mum about picking up Megan. We'd miscommunicated, and I hadn't realised I was picking her up, so it worked out well that we were still going to go for tennis.

So we drove to Kindergarten, collected Megan, and both girls went to tennis class. I used the time to give my accountant a call, and about half way through the class Zoe seemed to have had enough and sat it out.

After Megan finished, we drove home again and the girls played dress ups and generally entertained themselves, which was good, because I think I've contracted whatever illness Zoe currently has and am not feeling particularly perky.

Jason arrived to pick up Megan, and Sarah arrived shortly after, and I pretty much collapsed on the couch. I've decided that as much as I'd like to go to yoga class tonight, I'm going to give it a miss and go to bed early instead.

Colin Charles: Percona Live London Call for Presentations

Tue, 2014-08-05 19:25

Europe traditionally doesn’t have many MySQL-dedicated conferences, which is why I personally enjoy Percona Live London, now in its 2014 Edition. This year it happens November 3-4, and the call for presentations is still open — till August 17th.

The topic list is growing as the MySQL ecosystem matures: DevOps, cloud, security, case studies and what’s new are things you don’t often see. Tutorials are also welcome, of course.

Location-wise, London can’t be beat. And happening at Gloucester Road, you’re on the District/Circle/Picadilly lines to go to many fun places.

If you don’t want to present, do attend – registration is open. Early-bird (ending August 31st) conference & tutorials will set you back £425.00 and if you just want to attend the conference only, its £235.00 (VAT and fees excluded). A steal if you ask me!

See you there!

Related posts:

  1. Percona Live London 2011
  2. Percona Live Santa Clara 2013 tutorial schedule out
  3. MariaDB at Percona Live Santa Clara

Ian Wienand: Finding out if you're a Rackspace instance

Tue, 2014-08-05 16:25

Different hosting providers do things slightly differently, so it's sometimes handy to be able to figure out where you are. Rackspace is based on Xen and their provided images should include the xenstore-ls command available. xenstore-ls vm-data will give you a handy provider and even region fields to let you know where you are.

function is_rackspace { if [ ! -f /usr/bin/xenstore-ls ]; then return 1 fi /usr/bin/xenstore-ls vm-data | grep -q "Rackspace" } if is_rackspace; then echo "I am on Rackspace" fi

Other reading about how this works:

Glen Turner: Ancient word processor files

Tue, 2014-08-05 14:19

One of the issues with writing document filters is the lack of a corpus of real documents in the various ancient formats.

If you have files you have written in the past in Wordstar, PC-Write, XyWrite, DisplayWrite and other pre-Windows word processors then I would be interested in contributions.

My hope would be that such files have little content of value, and thus the corpus could be licensed CC BY-ND 4.0.

David Rowe: Embedded FreeDV

Tue, 2014-08-05 07:29

For the SM1000 development I need a way to embed the core functionality of a FreeDV “mode” in a simple library. A FreeDV “mode” is defined by the Codec 2 rate, the FEC, the frame structure, and the FDMDV modem waveform. Several modes have evolved over the past 18 months, and more are likely in the future. The current widely used mode (e.g. in the FreeDV GUI application) is known as “1600″ due to the bit rate.

Here is the simple C API I came up with:

struct freedv *freedv_open(int mode);

void freedv_close(struct freedv *freedv);

void freedv_tx(struct freedv *f, short mod_out[], short speech_in[]);

int freedv_nin(struct freedv *f);

int freedv_rx(struct freedv *f, short speech_out[], short demod_in[]);

Here is the header file freedv_api.h , C implementation freedv_api.c, and example transmitter and receiver programs.

It’s really easy to use from the command line:

$ ./freedv_tx ../../raw/hts1.raw - | ./freedv_rx - - | play -t raw -r 8000 -s -2 -

More examples are in the Codec 2 README.

The receive side is little tricky, as the number of input samples to the demodulator (and output samples from the codec) is time varying. You can see how that’s handled in this while loop:

    nin = freedv_nin(freedv);

    while(fread(demod_in, sizeof(short), nin, fin) == nin) {

        nout = freedv_rx(freedv, speech_out, demod_in);

        fwrite(speech_out, sizeof(short), nout, fout);

        nin = freedv_nin(freedv);


The demodulator works out how many samples it needs, to adjust for differences in the transmit and receive sample clocks (e.g. a few hundred ppm).

Transmit and receive of text characters is handled through call-back functions.

This API will be useful for “embedding” FreeDV into general purpose digital comms applications like fldigi, SDR radios, Android applications, custom embedded devices like the SM1000, or “headless” implementations of FreeDV on platforms like the Raspberry Pi. It needs hardware floating point and at least a 168MHz ARM4 (the SM1000 CPU).

SM1000 Update

OK, back to the SM1000 integration. Over the last week I have optimised the FDMDV modem by re-arranging the rx filtering. The modulator now takes 5ms and the demodulator 15ms (20ms total) for 40ms worth of data (200% real time). The modem optimisation work has also accelerated the code on x86 machines significantly.

Right now I’m working on drivers for the UI (switches and LEDs) so I can put it all together. Key tests include (i) everything operates OK in real time (ii) test the modem performance is OK through the SM1000 analog interfaces and (iii) test coverage of all of the hardware so we can kick off a Qty 100 beta run.

Andrew Pollock: [life] Day 187: Kindergarten, tinkering, a spot of break and entry and some baking

Mon, 2014-08-04 20:25

Today was busy. I didn't end up getting a chance to do any Debian work, but I did do some satisfying hacking, which I'll write about separately once I've got it slightly less... hackish.

Zoe slept solidly for about 12 hours. I was a bit slow getting going this morning, and that made us a bit late getting to Kindergarten. Drop off was nice and quick and easy though.

I was supposed to have a coffee with my downstairs neighbour, Michelle, who was in the process of moving out. She had asked if she could borrow an Allen key to dismantle her bed, so I popped down with that when I got home. She'd also managed to misplace her wallet, and thought it might be at her boyfriend's house. Long story short, we ended up over there with a ladder to get into his house and (fortunately) retrieve her wallet before we ended up having our coffee.

After that, I did some hacking on my phone to try and integrate NFC with HabitRPG, which ended up being successful, but not ideally so. I managed to get that going before just before Anshu arrived to come with me to Kindergarten to pick up Zoe and Megan.

I'd asked the girls if they wanted to help bake some carrot and kale muffins when we got home, but they quickly got distracted doing some craft, so they did that while Anshu and I started on the muffins. Part way through, they decided they wanted to help after all, so they took turns throwing ingredients into the Thermomix. They then proceeded to lick the bowl clean while watching them rise in the oven.

Zoe wanted to watch an episode of Spiderman on her tablet, and so did Megan, so I put it on the TV with the Chromecast and they happily watched it while the muffins finished baking.

After that, Zoe and Megan went for a scooter around the block with us while I put a letter in the mail and picked up some mushrooms from the Hawthorne Garage. By that stage Sarah was on her way to pick up Zoe, so we got home and got Zoe organised to get picked up.

Sarah picked up Zoe, but Jason was held up in traffic, so Megan came back upstairs and watched some more TV until Jason arrived.

It was a nice, busy afternoon, which went quite quickly.