Raspberry Pi MagicMirror on a Touchscreen with Alexa and fauxmo

Warning: what follows is a cascade of issues and lessons learned… but just plain fun!

The goal

This project is designed to provide a reliable MagicMirror2 on a Raspberry Pi fitted with a 5 inch touchscreen that doubles to provide browsing if needed. This comes from a desire to have a quick aide in the kitchen that reports standard information when needed or a browser for looking up and displaying recipes etc.

»

Geoff McNamara

Sorting IPs

I scan my home network frequently. There are a good number of smarthome devices, raspberry pies, phones, laptops, PCs etc. Using nmap to quickly scan a network is too slow for me - and it is a challenge to parse the output for easy reading (of course I would use awk to do that). So I use arp-scan (available in most repositories). So output might look like this:

»

Geoff McNamara

Quick N Dirty Python Debug Function

Pdb is a great debugger for python but I like to use my own simple debug functions. Here is a simple debug function for python which could definitely be improved:

»

Geoff McNamara

Raspberry Pi and Xrdp

I decided to have some remote desktop fun with one of my raspberry pies. Remote desktop for the raspberry pi (or any linux machine) can be done so many different ways - but the easiest from my perspective is xrdp. It is available really on any linux distro and works with Windows remote desktop protocol (kinda). It requires that you install xrdp and tightvncserver (under the covers it uses a vnc server - thightvncserver is probably the best choice here). Then as a client on my laptop I use the very good remote desktop client called remmina; again it is availalbe on almost any linux distro.

»

Sometimes It Is The Obvious

This was one of those “problems” that nagged me for many hours until the obvious dawned on me. I wrote a python script to grab the temperature and humidiy from a DHT22 sensor and then write the output with the proper syntax to send to my monitoring program [xymon]. The wrapper bash script ran every 5 minutes and used a redirection to write out a file ie:

*/5 * * * * /usr/local/bin/temphum.sh >/tmp/temphum.dat

The wrapper script grabs output and sends it to the server. Having this wrapper script lets me run the python script independantly for testing or for curiousity.

»

Always Use Visudo

“Familiarity breeds contempt”

I get very comfortable with using the vim editor (take cover… flame way ensuing) so comfortable that using any other editor leaves me just a bit unnerved. I constantly use it to update sudoers. The best way to modify sudoers is to add a supplimental inclusion file under /etc/sudoers.d/whatevername - so the other day I needed to add an entry to allow the user for my simple monitoring program (xymon) to be able to run “sudo ufw status” without a password and report back to the monitor server.

»

Geoff McNamara on #sudo,

Recursively Replace Text

Recently I had to do a find and replace text on multiple files recursively. I had to look up how to do it to remind myself of the exact syntax. If I had to look it up, you have to suffer seeing it in my blog post…

find ./ -name \*.md -print0 | xargs -0 sed -i 's/header-img/img/'

Be careful here. I used the -0 option to deal with any filename that have spaces in the name BUT it really requires that the find command contain the -print0 option otherwise things will not operate in the manner expected.

»

Switched to Hugo

I am swtiching from jekyll to hugo for flat file for a Content Managment System (CMS). alt text

Here is why:

  • It comes as a binary file that runs on pretty much any platform. A single file… without a list of dependencies
  • I could stop with the last reason and it would be enough… but I have to say that the file tree used in hugo is simple, and simple is beautiful. As Einstein once said: >“Make things as simple as possible, but not simpler.”
  • It is written in googles go language… so it is fast and portable.
  • It is closely tied to git so it can easily be used on github and for version maintence.
  • it builds a clean directory [./public/] for the full site deploy and this can be rsync’d to where ever you like. or … just git push it to hithub and use something like netlify.com to host from your github!
  • No frustrating version incompatiblities (or at least very minimal) - unlike jekyll which seemed to break on me every few months.
  • hugo is relatively mature and has a huge developer backing.
  • configurable and changed without challenges
  • lots of themes to choose from
  • as the Hugo websites states - it makes the web fun again…
  • Did I mention that it is a single executable file?

Reference: gohugo.io

»

Converting Images

I have fought with trying to remember the syntax for Imagemagik’s convert command for years. I finaly caved in [from my normal position of “if you can’t do it from the commandline, then you are a wimp” and sought out a gui to help me quickly convert images to use on a website. Or to just roll a picture 90 or 180 degrees. The easy solution and a standard ubuntu repository file is “converseen”. »

Geoff McNamara on #convert,

shell/bash uppercase arguments

To make a long story short…

#!/bin/bash
PATTERN=$(echo $1 | tr [:lower:] [:upper:])
# or
PATTERN=$(echo $1 | tr [a-z] [A-Z])
# or
PATTERN=$(echo $1 | awk '{print toupper($0)}')

echo "Your \$1 argument is now uppercase: $1"

To make a short story long…

Just to let you know a little more about me and reveal a few more shells tricks along the way.

»