Repairing a Broken Multimeter

In December 2017 my multimeter broke. It no longer measured resistance correctly. For low resistances, the numbers looked alright, but with bigger resistances, the value didn’t go higher than about 40kΩ. I only had one multimeter, so I didn’t have anything to compare against, so how did I determine that it’s broken for sure?

It seemed to measure 1kΩ accurately, so I used Ohm’s Law and connected 10 of the 1kΩ resistors in series. It read about 7kΩ. Uh, oh.

I ordered a new one, same model. I complained to my friends on Facebook and got some pity likes. I didn’t know much about electronics, so I accepted that the old one is broken and only trusted the new one. Until it broke as well. In a similar way.

How did I break it? To be honest, I don’t know. I assume it was a user error. If I had to guess I either tried to measure the resistance on a powered circuit or tried to measure current with the red lead still in the Voltage/Resistance socket.

Last year I asked Santa for a different multimeter as I was tired of buying them myself. After learning some more electronics theory I decided to take a look and try to fix it.

Read more...

Why did no one tell me about gdb-add-index?

I’ve been exploring TensorFlow internals in the past couple of weeks.

Doing that required me to run some python scripts with a debug version of TensorFlow, set some breakpoints, examine some values, modify the script, repeat. You know, general sleuthing.

TensorFlow core functionality is written in C++. The python package is a wrapper around C++ code + libraries at the python layer. The way that python interacts with TensorFlow core is by loading a shared object.

Read more...

Debugging a Safe Module

TL;DR: change -XSafe to -XTrustworthy.

I’ve found myself needing to add some trace statements to System/Environment.hs. The module is marked Safe, so when you try to:

import Debug.Trace (trace)

you get the following error:

Debug.Trace: Can't be safely imported!
The module itself isn't safe.

I don’t know anything about Safe Haskell and I didn’t want to learn at the time. Removing {-# LANGUAGE Safe #-} made the Safe modules depending on System.Environment (the module I was trying to debug) fail to compile, so that wasn’t an option. Turns out you can just bypass this by marking your module as Trustworthy:

Read more...

A Hacky Way to Send Notifications From a Development Machine on iTerm2

When hacking on something in a language that’s compiled, some compiles take a long time. So long that it doesn’t make sense to wait and watch it. You can do some lightweight tasks in the meantime - respond to emails, review diffs… The problem is, unless you leave your terminal visible, you won’t know it’s done the moment it is done.

The solution is to send a notification once it’s compiled. This is not a new idea, iTerm2 has support for notifications from within a terminal via a special escape code. Problem solved? Kind of. If you only use iTerm2, then it works like a charm. But if you use a combination of iTerm2

Read more...