Skip to content Skip to sidebar Skip to footer

Hollocaust Movie Where Little Boy Pretends to Be German

Quantified Male child

Stuart Harrison Hacker Noon profile picture

Building a 21st century star chart victimisation a Raspberry Pi and Amazon Dash Buttons

The world is full of technical school evangelists who think that technology is our route to salvation. Faced with any problem, they think all you demand to do is rub a bit of technical school on and prisoner of war, the problem disappears. I am non one of those populate, just I like to think I'm on the way to helping my son behave better at educate, and it's all thanks to a Hiss Principal investigator, a couple of Amazon dash buttons and some software I wrote at run.

My son's school has a behaviour and reward organization of points. Achievement points are rewarded permanently work, and behaviour points are issued when they misbehave. This is all logged along a terrible proprietary system improved by Capita. Since he started school fourth-year year, I decided to establish a sort scraper to monitor this system. IT would then email me and my wife if there had been some issues that day, and log the points in my own install of Bothan, a organization I helped build at work for tracking and visualising metrics. I and so could visualise the points happening a dashboard, good me the hurt of having to log up into the execrable school system every day (You arse determine the code on Github here).

This worked reasonably well, and churned away in the background for the whole my son's first yr of school (and probably regenerate me a whole crowd of time). When my son reached Class Unrivaled however, I realised that we were going to need something else.

In his archetypical fewer weeks of school, he'd racked up 29 deportmen points, not for any kind of leading naughtiness, just low level cheekiness and messing more or less, y'know, the sort of gourmandize that fivesome year olds do. Whether or non I in agreement with what the school was doing, I knew I needed to help him get bettor at school.

My married woman and I therefore decided we were going to instal our own behaviour and achievement points system at home — if he has a sad day at school, he gets a behaviour point (unlike the FIVE points the school day give him for ever infringement), if he has a adios, he gets two reward points (my son responds Overmuch better to the cultivated carrot than the stick). We'd also give him points for his national behaviour at home. If he gets a certain sum of honor points by the ending of November (his birthday), he can have a big birthday party with all his friends.

The problem then became, how can we log these points in a way that's engaging for him? We'd tried star charts in front, and they were fine for a hardly a weeks, but and then the novelty wore slay, the charts got tatty and he ended up disengaging from the whole process. Fortunately, Amazon dash buttons have just been released in the UK, and I was itch for an excuse to do something with them.

I ordered cardinal buttons, collectively with a Raspberry Pi 3, and set to crop. Whenever I readiness out on a project of this nature, I always reach for the language I feel comfortable with, and that's Ruby. After installing a modern version of Ruby on my Pi, I installed the Dashed gem, and followed the instructions to located it up. However, no matter what I did, I couldn't get wise to work. After some furious googling, I found that the firmware in Dart buttons had metamorphic, and the protocol had switched from Jean Arp to UDP. I also set up a Node Depository library that was much better supernatant, and came with extraordinary documentation, so decided to use that instead.

Subsequently installing Node and the node-dash-button library, also as libpcap (which is required to sniff out network traffic) happening my Pi (book of instructions Hera), the future thing I needed to do was to set up my Scare away buttons. I opened the Amazon app, and in settings, there's a inter-group communication to establish your dash buttons. This gets your buttons connected to the WWW via your WiFi network, and allows you to choose what merchandise you deprivation to order all time the release is pressed.

I skipped that last step, and followed the instructions to sniffle my network to get the MAC addresses of my buttons, by running `node_modules/client-dash-button/ABA transit number/findbutton` on my Pi. I pressed each button in turn and got the MAC addresses of the buttons without whatsoever trouble at all.

Then came my favourite part, writing code. The prototypal thing I did was to catch each button press and log up to the console, to check everything was working:

var dash_button = require('lymph gland-dash-clit');
var bad_button = '' // The MAC address for the good push goes here
volt-ampere good_button = '' // The MAC call for the bad button goes here
var dash = dash_button([bad_button, good_button], cipher, null, 'every');
dash.happening("detected", function (dash_id){
if (dash_id === bad_button){
console.log("Juicy!")
} else if (dash_id === good_button){
console.log("Good!");
}
});

I saved this (Eastern Samoa index.js), and ran the code from the command wrinkle via `sudo node exponent.js` (you need sudo, A libpcap requires administrator priviliges), and to my astonishment, it worked! I did have a problem that all sentence I pressed the button I got a nagging push notification along my phone from the Amazon app, revealing Maine to finish setting up my button, but luckily you prat number this off in the Amazon app settings. The next step was to log these clit presses someplace.

I mentioned earlier about Bothan. I was already logging the cultivate's points in there, so it made sense to stack away the points from home there too.

Bothan started away as a bare API for the Open Data Institute to lumber fiscal and other metrics, we then built on visualisation components (and then you crapper see the data as a graph, pie chart, simple number surgery target graph), and at long last a splashboard building tool. Anyone throne deploy their own version of Bothan, and metrics are added via a simple Residuu API. It was this REST API that I needed to purchase to log the points, so, armed with the petition subroutine library, I set to work and wrote a method to beat the current score for a conduct Beaver State merit point, add one, and past campaign the latest data to Bothan:

var bothan_url = '' // The URL of your Bothan install
var bothan_username = '' // The URL of your Bothan install
volt-ampere bothan_password = '' // The Universal resource locator of your Bothan install
volt-ampere postPoint = operate(metric function) {
var bothanURL = bothan_url
volt-ampere metricURL = bothanURL + '/metrics/' + system of measurement + '.json'
var engagement = new Date()
                call for(metricURL, function(error, response, body) {
json = JSON.parse(organic structure)
value = (json == null) ? 0 : json.respect
                request.send(metricURL, {
auth: {
user: bothan_username,
pass: bothan_password
},
json: {
time: engagement.toISOString(),
value: value + 1
}
})
})
}

(I realise it's a faff to suffer the latest rhythmical and add same (besides as an extra HTTP request), thusly single of the improvements I'd like to piddle to Bothan is to add an /append API method to retributive add one to a given metric)

With this method, IT was just a case of calling the method acting with the rhythmic name to log either a deportmen Oregon virtue point to Bothan, like soh:

hyphen.on("sensed", function (dash_id) {
if (dash_id === bad_button){
soothe.log("Naughty!")
postPoint('home-behaviour-points')
} else if (dash_id === good_button){
console table.backlog("Good!");
postPoint('home-acheivement-points')
}
});

I and then added a parcel.json file with the dependencies, together with a script definition, so the encode could make up run vianpm start up, and then looked at how I could mechanically run this on my Pi on boot. I've done this ahead in other projects (like Ellie President Harrison's Vending Machine art piece, which me and a colleague rengineered later on the original laptop computer powering information technology broke down), and used init.d scripts, but this seemed like overkill. This time, I antimonopoly added the following command to /etc/rc.section to make the script chug away happily in the background:

cd /home/PI/quantified-boy &&adenylic acid; npm start &

(The terminal & is important here, as it forks the process, otherwise the Pi would just run this script and never boot in good order)

I rebooted, dependable and it worked. The final piece of the puzzle was displaying the prosody, so I could see at a glance how my son was doing, and crucially, so he could get instant feedback subsequently atomic number 2 pressed the button. I used Bothan's dashboarding feature to build a dashboard (linking to a exhibit unrivalled Here), and added the following to the~/.config/lxsession/LXDE-pi/autostart file to open the dashboard URL in Chromium in kiosk mode, and stop the Operative from going to sleep, thus I could see the dashboard at any time:

I then rebooted the Pi, and after the boot completed I sawing machine my dashboard. At last, I invested £27 in a 5 edge screen from Amazon, and set the peck up in the kitchen:

A week or then has passed, and my son loves engaging with the button (I say 'button', because he never wants to press the behaviour pointedness button somehow). Helium loves the instant gratification of seeing his points draw close, and it's a great way of getting him to engage beyond the normal star chart.

The final encrypt is disposable on Github here, and you behind put in your possess available representativ of Bothan via bothan.io. You can buoy utilise this code to measure anything. The only restrain, as they enunciat, is your imaaaaaaaagination!

Tags

# nodejs# javascript# parenting# raspberry-pi

Hollocaust Movie Where Little Boy Pretends to Be German

Source: https://hackernoon.com/quantified-boy-726e9558594f

Enregistrer un commentaire for "Hollocaust Movie Where Little Boy Pretends to Be German"