HTTP health check endpoint using socat

What do you do when you need to expose an HTTP health check endpoint but the thing you’re health checking isn’t a web server? You socat it! Here’s a complete example:

nohup socat TCP-LISTEN:8080,reuseaddr,fork,crnl SYSTEM:"
  supervisorctl status celery | grep -q RUNNING &&
    echo HTTP/1.0 200 OK ||
    echo HTTP/1.0 500 Down
  echo
" &>/dev/null &

In short, the above will run a web server on port 8080 which will respond with HTTP status code of 200 if celery is running, or 500 otherwise. You can replace supervisorctl status celery | grep -q RUNNING with any other command. The exit code of that command determines the web server’s response. Pretty neat ha!

Non-permanent Actions

We make mistakes. In most part of life, mistakes tend to incur cost, from money, harm to simply time, and due to interaction with the physical world. In world of software however, where state of things can be cheaply changed back and forth, with some clever design, mistakes can be made free of cost. I’ve increasingly noticed more of such design in products I use and I thought I make a list here:

Mute notifications for next 4 hours. Notifications can sometimes frustrate the user who is under stress and if the notification settings stick indefinitely, a temporary annoyance can turn to ignored messages/emails for days. Google Hangouts, Slack and most messaging apps have timed mute feature. One place where this is very much needed is on browsers. Given that browser is a platform, it relieves all the individual sites from having to implement this functionality. Android is a good example where this is implemented across the entire OS. It even goes further and allows marking notifications from certain apps as being of higher priority which bypass the mute period.

read the rest …

Jump

You called it an adventure
Showed me a pretty picture
with a wide aperture
You commanded that I follow closely
after your vertically descending departure

I leaped after a bunny
when it was no longer sunny
Now I think of it as funny
how I landed in a jar of honey

read the rest …

Midnight Groove

Your wall mirror was dressed
in midnight summer breeze
I slowly walked in front of it
with an attitude and a tease

She offered her hand for a dance
You were deftly asleep that night
So She and I fell into a deep groove
And moved as one till the morning light

I’ll see her again with your permission
I’ll kiss her on the lips, that’ll be my mission
Someday we’ll profess to each other
I’ll keep seeing you until that admission

Visual Beep

The quieter you become, the more you hear.
Rumi

I was hanging in the local IKEA store when I came across this $5 multifunction digital clock. The interesting thing about it is that you switch between the functions, not by pressing a button, but by turning the clock on its various sides. It has four sides and hence four functions: thermometer, alarm, clock and countdown timer. The countdown timer in particular is awesome. You set the timer and every time you turn the clock on the timer side, it automatically starts counting down.

IKEA desktop clock/thermometer/alarm/timer

It comes under two names: LÖTTORP and KLOCKIS

read the rest …

Three way

Twelve stories tall
Waiting for a call
Watching city porn
Groping the glass wall

Seismic handshake by the lake
Bear hug soothing the hand ache
Fresh lime with a slice of cake
Conversing for hours without a break

Turning down the volume
Leaning in to consume
the air of your perfume
Feelings to exhume

systemd-nspawn based dev environment

Over the last week, I decided to move my dev environment from OSX to my own Archlinux box. Now I didn’t want to pollute my machine with various libraries/tools needed for work so I decided to run things in a container. I had played with systemd-nspawn in the past so it was the clear first choice (and last in this case). Overall I am very happy with it as it was a piece of cake to setup and only one or two hiccups along the way.

I followed the excellent guide on Archlinux Wiki and that took me 95% of the way. Firefox tweaks page took me 99% there. What follows are some tips for the last mile.

read the rest …

Split PDF files

Another ghostscript trick to split a single PDF to multiple PDFs one for each page:

gs -sDEVICE=pdfwrite -dSAFER -o outname.%d.pdf input.pdf

GPS Nav Wishlist

I drive once in awhile and even though I’d much prefer to rely on someone/something else to tell me where to go, I’ve decided to memorize directions rather than use a GPS navigation software. Instead of the why, I’ve listed my wishlist for GPS navigation software. If these are taken care of, I probably no longer have to look at street view for every turn and use pen and paper like it’s the 90s.

Top Priority

Lane navigation. A passenger familiar with an area giving you directions tends to mention which lane you should stay in well before the next turn so you won’t have to force your way onto the neighboring lanes at the last second and potentially cause an accident. This can be extended to take into account streets with lots of cross streets where people queue to turn to or streets where a lane is occupied by parked cars (both further dependent on the time of day). A lot of drivers, especially inexperienced ones, find changing lanes under pressure (ie upcoming turn) very stressful and are more likely to make mistakes doing it.

read the rest …

Convert multiple images to PDF

This command takes a bunch of images and makes a multi-page PDF out of them:

convert *.jpg -units PixelsPerInch -quality 100 \
  -density 300x300 > out.pdf