fpx: easy USB‑C power for all your devices

TL;DR new easier to use USB-C module to power everything; buy it and configure it

My first attempt in using USB-C adapters as a power source was met with great enthusiasm. It was just a breakout board for STUSB4500 autonomous USB-PD sink controller. It has since been picked up by Sparkfun with a much better design (as you would expect).

Although sufficient, I wasn’t very happy with how much effort was needed to program the chip. It required talking I2C which for me meant an Arduino had to be available, connected to a computer with USB and a whole bunch of jumper wires. I have since used Adafruit’s MCP2221A breakout board and a Raspberry Pi but the process still has a lot of friction. So, I set out to simplify the programming aspect of STUSB4500 and this post will take you through to what became fpx, a smaller and easily configurable version of fabpide2.

3D render of fpx board

This is a tiny module, measuring 21 mm × 12 mm

read the rest …

How to cut PDF pages into tiles

This post is about a command line tool called pdftilecut which I wrote a while ago that allows you to cut PDF pages into tiles in order to print a large page on small form printers for instance.

A little background: for my wedding, we decided to make an art piece we called “the portal”. It was basically a steam punk spaceship door with an iris window.

Art piece in shape of steam-punk spaceship door

This thing took many weekends to get done and it was so much fun. Too bad we didn’t have the space to keep it so we threw it away. It sat on the background and every now and then would slowly open and show a planet pass-by.

read the rest …

Pragmalist Electronics Kit

TL;DR My personal set of essential electronics tools that I use on regular basis. This is the first post in a series.

I’ve been dabbling in electronics for 10 years. Naturally, my approach to electronics has been influenced by my approach to life in general. And my approach to life is that of a pragmalist (pragmatist minimalist). In short, I thrive in striking a balance between practicality and fewer possessions. This has led to a carefully selected set of tools, over years of use and through many iterative refinements. The aim of this post is to presgruide (half prescribe, half guide) a set of tools to newcomers in the wonderful world of electronics, so they can get rock ‘n rollin’. More experienced folks can also benefit by multigrading their existing tools.


No such thing as a safe hobby exists. Even reading books can be hazardous over time (think neck and eye strain). Therefore safety equipment come first in order to maximize the longevity of your enjoyment.

read the rest …

Detecting Health Conditions in Visual Content

I don’t watch mainstream news but once in a while I come across some and last piece I encountered was actually thought-provoking. Some viewers of a talk show hosting Denise Richards noticed she had enlarged thyroid gland and let her know that she should see a Dr. In this case, she had ignored the symptoms and looking at the photos, it’s quite obvious. But what about more subtle visual presentations of health conditions? Attentive doctors and specificalists may suspect or detect them watching a talk show, but that’s too few eyeballs. What if computers did the honors?

Google AI research has had years of history developing machine learning systems to detect various health conditions from medical imagery. I believe they started with retina scans looking for early signs of diabetes and more recently, they can detect skin conditions. Microsoft sports a similar history of research and publications. There is other research around detecting genetic conditions from portrait photos in combination with other data. I also remember some app which could detect cataract in photos with flash on. I’m sure much more has been explored in this area.

With the promise of ever improving machine learning in detecting patterns in imagery, specifically relating to health conditions, there are some interesting end-user product and service ideas that can potentially be game changing.

For instance, Google Photos or iCloud can run a bunch of more ML on user photos and videos and notify the user of neurological conditions, eye and skin conditions, strokes, mental health conditions, etc. Similarly, face unlock hardware such as those in iPhones and iPads could detect such conditions everytime the user looks at their phone (which is much more often than taking photos). And let’s not forget about the immense amount of public imagery content such as YouTube. Google already does copyright checks, transcription, thumbnail generation and a whole bunch of other processing. Disease detection will take it to a whole new level.

Apple has already invested quite a bit in health features of Apple Watch. It makes a lot of sense to expand that further.

Of course there are social aspects that I’ve not mentioned. Privacy, fake content, etc.

USB PD Stand-alone Sink Controller (USB-C power module)

See the newer fpx module which supercedes fabpide2

TL;DR a USB-C module to power everything — buy it and program it

Since USB-C’s introduction, I’ve been consistently interested in leveraging it for powering everything under 100 watt (or rather under 90 watt, since it’s hard to come by a full 100 watt USB-C power brick). I finally found time to make the first move and this is the subject of the post.

I wanted to keep it simple at the start. Chips like the popular FUSB302 which only provide the wire level handling of the USB-PD protocol, require a lot of software work to make them reliably operational. And that software will need to run on a µC which adds to BOM. So I went to search and found a gem called STUSB4500 from STMicroelectronics. In short, you program some registers to chip’s NVM via I2C once which define what voltage range/current you require and the chip will negotiate those requirements with a charger connected to it.

Fully populated PCB of the second version of the board

Second version. The black cable goes to the laptop connector. You can buy a pre-assembled & ready to use module from my tindie store.

read the rest …

splapr: Modular, Customizable and Affordable Split-flap Displays for Everyone

I have always been fascinated by split-flap displays and for years I have wanted to make some myself. Today, I’m releasing my most recent effort to make split flap displays accessible to everyone.

To find out more, visit https://splapr.com

module front face

makes me grin everytime

WireGuard VPN on Android

My recent experience with Telstra mobile’s DNS resolver constantly pooping itself, leaving me without working 4G connection on my Pixel 2 Android phone, prompted me to look for solutions. How do I know it was the DNS resolver issue? Well I got myself a ping tool and found that I could ping various servers just fine. I did try the Private DNS feature of Android to no avail. Most of the time it doesn’t do anything!

Unfortunately, Android doesn’t allow manually setting DNS on mobile connection (only on WiFi and VPN). So the only option I had left was to look at VPN tunnels. Forget about OpenVPN and IPSEC. For my use case, they were mind numbingly difficult to setup and I gave up on both very quickly. Then I remembered WireGuard, a tiny feature of Linux kernel brewing at the moment, which lets you define an encrypted network interface with public key cryptography. There is also an app available for Android. This thing is so simple to setup and so reliable that I was hooked right off the bat.

read the rest …

An Incident Post-mortem

I was involved in an incident post-mortem today without realizing it! But first, a little background.

I lead the Incident Response team at Mathspace and we follow a blameless post-mortem culture as popularized by SREs. It boils down to not blaming specific person(s) seemingly responsible for an incident, but instead acknowledging that incidents are product of failure at team/org level. We then focus our efforts to pinpoint root cause and ways of preventing it from happening in the future.

Today’s post-mortem was outside of work! I had just met up with my partner at a cafe and we were walking home when she told me about her experience riding her usual bus back from work. The bus doors had barely finished closing behind her, when the driver stepped on the accelerator like it was race car. As she had not yet tightened her grip on the rails, she almost fell to the floor had it not been for assistance from another passenger on the first row. She was quite upset while telling the story. In fact, it was such a distressing event for her, that she took the time to report this driver to the authorities. That marked the end of her story.

read the rest …

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
" &>/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 …