Posts tagged #Go

3 posts

PostedAugust 15th, 2015#Go

The other day, while playing around with some Alfred workflows, I had the need to store small bits of data between workflows in a key/value fashion. In the past, I've used either environment variables to do so or something like boom by Zach Holman. I don't really like defining tons of environment variables for stuff like this, so boom was a natural fit.

After creating the workflow and adding boom to it, I ran into some issues related to running Ruby via an embedded Alfred script. The way Alfred runs scripts can cause some weirdness and usually involves the user having to source their .zshrc (or .bashrc) in order to configure their terminal to work the way they expect. After doing so, I still had some issues with Ruby and being that I'm not a Ruby guy in the slightest I did what any programmer would do... over-engineer!

I decided to create a clone of boom written in Go. It doesn't help that I've been looking for Go projects to work on lately and this was simple enough to bang out in a few days.

It's called goboom. Yeah yeah, the name isn't as snappy as boom, but we can't all be perfect can we? Many of the commands are the same and, assuming you've used boom in the past, it uses your existing .boom file as its data source.

A bit of warning though... I just "finished" this and I'm still working out the kinks, not to mention adding better test coverage. That being said... make a backup of your .boom file if you choose to use goboom. I have no reason to believe any data loss is occurring, just better to be safe than sorry.


PostedMarch 25th, 2017#Raspberry Pi#MQTT#GPIO#Go

I've wanted to formalize this project for a while and just recently got some free time to do so. gpio-to-mqtt is a Go application that monitors state changes to GPIO pins on a Raspberry Pi and relays those changes as JSON messages to an MQTT broker.

That's a mouthful. Hear me out though.

Say you have an old alarm system in your house that you aren't using. You have the little magnetic reed switches on your windows and maybe some door jamb switches that all run back to a central security system box somewhere in a laundry room, garage, basement, or wherever. With this application, you can repurpose those devices and make them smart. gpio-to-mqtt will notify anyone listening when the those switches are tripped.

All it requires is a Raspberry Pi, a network connection, and Go + gpio-to-mqtt to get running.

Once you have this up and running, you can write any number of utility applications to listen to the broker on your network and perform other actions. Maybe you get a notification every time your front door opens or when someone opens a window unexpectedly. You could even just connect physical buttons to the GPIO pins and use them as network attached buttons.

There is still some development work to be done at this point, a lot of which surrounds additional MQTT options (like the ability to connect using certificates). I'm going to follow this post up with my set up for people to reference if needed. For the time being, here's what my install looks like.

Have fun!

Wired Raspberry Pi


PostedJuly 31st, 2015#Go#IFTTT

The other day, I noticed that IFTTT has added a new channel called the IFTTT Maker Channel. The premise being that you can send a POST or GET request to IFTTT to trigger a recipe. This opens up IFTTT quite a lot if you want to do some really custom work without trying to shoehorn a combination of workflows into producing some desired result. A few days later I also noticed they released a Spotify Channel, something else I'd been hoping for.

For a while I'd wanted to create a dynamic playlist that grows as people recommend music from various locations around the web like r/music and r/listentothis. With the addition of those two channels, it becomes fairly easy.

That being said, I put together a small library named Go-IFTTT-Maker for posting to the IFTTT Maker Channel and threw it up on Github. All it does is provide an object that accepts the three arguments you can pass to the Maker Channel and a Send method that accepts your API key and the event you're posting to. That's it. Here's a simple code snippet.

I've already made a few applications from this library that I might throw up on Github soon. One for calling the IFTTT Maker Channel from the command line and another that transfers music recommendations to a Spotify playlist. The former is nice if you want to create some really custom recipes from your machine.

If you're at all interested in that Spotify playlist, it's also available here.

    James Miller