Newest Post

December 13th, 2019

A non-professional critique of the Weather Underground app

I’m not a UX expert, but I have opinions.

Weather Underground is one of my most-used apps. It gathers data from thousands of neighborhood weather stations run by individuals. Here’s the new front page:

Weather Underground front page, above the fold

The first thing you might notice is the large circular dial. That’s taking up a LOT of real estate here, and it doesn’t add a lot given that the temperature is already listed. (It took me a bit to realize this was temp, and not a compass direction). The app used to show relative weather (“Today will be cooler than yesterday”) which I really miss. Likewise with hourly specifics, like (‘Rain will begin around 2:00’) rather than just a percentage spread out over some unspecified amount of time. I just want to know if I need to grab an umbrella or not, and so on.

And what’s going on with the little wind dial? Is it pointing northwest or southeast? And I have no idea what that — underneath “Winds” is supposed to show.

The Wundermap is nice, but I wish I had more control over what appears above the fold…

Let’s scroll past the huge tracts of ads. (not faulting anyone for this–gotta pay the bills)

Are my eyes playing a trick on me, or are the “daylight” sections of this top readout darker than the nighttime ones? Nights are the dark times, right?

The other thing that keeps tripping me up on this page is that there is no indication of where “now” is. It looks like it will start raining in the evening, but I can’t get a sense of how imminent that might be.

The red line looks like temperature, but what those unevenly-spaced hollow dots represent, I haven’t the slightest idea.

The hourly section came up exactly like this on a fresh launch of the app. Admittedly, forecasting the past is easier, but still I with it was scrolled to the point where I could see what’s upcoming. Maybe some indication of “now” here would also help orient viewers, and link the hourly forecast to the daily one above.

Anyway, the devs are always tweaking things, so I hope they’ll run across this and take it into account in their designs.

Signed, a fan -m

August 16th, 2019

Time Management for Senior Engineers

I recently joined LinkedIn as a Senior Staff engineer–an individual contributor role more senior than any of my previous roles. As such, I’ve been inundated with every manner of request for my time. Part of my journey toward handling this situation is writing up my thoughts. Let’s go.

Does time work differently for “senior” engineers? Yeah, pretty much. The way you need to manage your time changes dramatically throughout the course of a career. Take an intern, for example. They’ll have their 6-to-18-week project that they work on, with a manager checking in maybe once a week, give or take. They’re expected to attend customary project planning meetings including daily standups or similar.

Junior engineers have it much the same, though their assignment shifts over time. Gradually, they might start jugging multiple projects, and having to make their own prioritization decisions. In this mode of work, it’s helpful to block out chunks of time on your calendar for focused work. Bonus points for pushing back on excessive meetings.

At some rung of the engineering ladder, part of your job is figuring out what to work on, rather than just getting handed assignments. This complicates time management, in much the same way that Star Trek-style 3D chess is more complicated than ordinary chess. But with great responsibility, comes great power…

Time Domain Mastery Part 1: Delegation. One of my most productive working relationships was with a now-retired Principal Engineer. This guy had achieved a high rank–across thousands of engineers, there were a only a dozen or so PEs at the company. He made a point of never insisting on his way. In fact, he encouraged disagreement. But in those cases where you disagreed, you had better come equipped with data to make your point. That made collaborating with him invigorating as well as productive.

Now, as I look back at those days and see myself inching toward playing the part of the mentor, I also see valuable that must have been for him. He never viewed spending time with up-and-coming engineers as a chore, but rather as a force-multiplier for the team. It will always be the case that the set of things you’d like to do is bigger than the time available to get stuff done. Working with teams, you don’t have to do it all yourself. The more you raise up those around you, the greater the effect.

Time Domain Mastery Part 2: What have you accomplished today? Calendar blocks don’t seem to work any more at these higher rungs. At least in the role as I’ve experienced it, there’s a lot of temporal noise you have to deal with. Keeping afloat requires constant and intense skepticism to avoid the folly of the urgent. (And there’s always something urgent going on.)

One of the main ways that engineering leaders add value to an organization is by providing steady-handed distinction between the urgent and the important. It’s too easy to get caught on the treadmill of the urgent, rushing from one firefight to the next. The solution, of course, is to instead focus on important things, like making sure those fires don’t start in the first place!

To this end, every day you need to strive to have one notable accomplishment. And putting out fires isn’t an “accomplishment”. Concrete improvements to culture, process, architecture, or documentation, are. More than before, your success will hinge on your capability to set aside time at the start of the day, start of the week, and the start of the quarter to think and strategize. Bill Gates famously set aside “think weeks.” That’s not a bad start.

But what we really need to talk about is meetings. Thought experiment time. If you were an Apple engineer in the 90s, and Woz happened to pop in for one of your meetings, how would that have affected the dynamic of the meeting? I picked Wozniak for this example because he was (and is!) widely considered a strong technical player. Most engineers would look forward to the honor of working with him in a technical context. If it was Steve Jobs stopping by to scream at people, then there’d be all kinds of blame and accusation flying around. Yuck.

Politics aside, the higher up the engineering ladder, the bigger of a deal it is for you to be in a meeting. As you climb the ladder, it’s your imperative to make an impact at any meeting that’s worth your time to be in. This could mean asking the obvious questions that others are afraid to ask or to say what everyone is thinking. It might be using your technical capital to insist on sticking to the planned agenda and avoid rathole-ing on unimportant details. Based on your higher level of context, experience, and vision, you can reshape a meeting from a waste-of-everyone’s-time to a sharp-edged tool for your organization.

But not if you keep your nose in your laptop, working on one of your other urgent projects while only half-listening to what’s going on around you.

The most valuable contribution to a meeting might even mean taking notes when nobody else is willing (or able) to. A succinct summary of a complicated discussion can be worth its weight in gold. So is knocking the legs out from a corrosive culture that considers writing stuff down too mundane for senior folk.

The key takeaway–as a senior engineer, every action you take matters. Your actions have second-order effects–for example if junior engineers see you enduring through a useless meeting, they’ll start to think “that’s how things work around here.” Thus, for senior engineers, even second-order effects need to be carefully crafted due to their outsized impact.

You’ve spent a career becoming a leader. Act like it and you’ll be rewarded.

Production note: Version 1.2 Special thanks to Charles Greer, Jason Hunter, Tomomi Imura, and Evan Goer, for helpful feedback. This essay is a work in progress. Please comment below with suggestions for improvement.

June 30th, 2019

Xanadu in 2019

If you haven’t been following Ted Nelson on YouTube, you’re missing out. Recently, he’s been posting a series of informational videos on the Xanadu architecture and concepts. Even more recently, he hosted a live Q&A session, taking questions from Twitter.

Ted Nelson’s Channel

What’s Xanadu, you ask? It’s the original concept for a hypertext system, designed well before the web was a gleam in Tim BL’s eye. Nelson himself coined the term ‘hypertext’. It can be hard to wrap your head around a hypertext system not based on markup or HTML. For a brief technical overview, check out this article, now nearly a decade old.

One of the biggest points of contention between the “current web” and Xanadu is the de-facto security restrictions (such that they are) on browsers with the Same Origin policy. With several loopholes, once your browser loads a page from, other content, excluding images and other things, have to be loaded from the same site. [Yes, it’s possible, via preflights, to get around this, but the kind of per-site configuration needed flies against the notion of a global “docuverse”.] In contrast, the central construct of Xanadu is that documents consist of a central list of chunks of content and links to load.

Because we’ve lived in a web-wide-world for so long, it’s hard to think clearly about this alternate reality. What role would something like JavaScript play in a Xanadu-docuverse? I haven’t been able to find any detailed studies about how security design on a web-scale Xanadu deployment. What would be the nearest equivalents to cookies or webapps? To web forms (or dare I say, XForms)? To untrusted content surreptitiously leaking personal information? To CSRF attacks? To the OWASP security checklist?

It seems like Xanadu wants to consist of purely documents, and is less friendly toward other media types, and outright hostile to what we today call webapp technology. This makes for a clean and elegant design, but I can’t help wonder whether it’s also a factor in the takeover of one-ended “jumplinks” as seen in HTML, and the mountain of web architecture that came along with it.

My gut says that not all hope is lost. Large chunks of web technology, including HTTP, could be hugely useful in a global docuverse. One way or another, the browser ship has sailed, so it would have to work with modern web browsers. So what can we do about the Same-origin problem? How can we design a docuverse on top of today’s web? -m

P.S. I still have the same question from the earlier article:

“Our enfilade data structures and methods effectively refute Donald Knuth’s list of desirable features that he says you can’t have all at once (in his book Fundamental Algorithms: Sorting and Searching)”. I’m curious if anyone knows more about this, or if Knuth ever got to know enough details to verify that claim, or revise his.

Maybe Ted will comment about this on YouTube.

P.S.2. Xanadu is a registered trademark, here used for specific identifying purpose.

February 26th, 2019

New maker project — retro name badge

If you played pinball in the 80s, you know about 16-segment LED displays. They existed in the narrow technology window after mechanical switches and alarm-clock-style 7-segment displays, but before full dot-matrix displays or full video were feasible with off-the-shelf computer hardware. There’s something geekily charming about these old displays.

16 segments allow all alphabetic characters to be rendered…for the most part.

So naturally, I wanted to have a name badge made from these for FOGcon, which was 8 weeks away when I started this project. I would, in 8 weeks, conceive, design, construct, and debug a name badge based on this technology. With a professional printed circuit board. And a custom-programmed 32-bit microcontroller. All powered by a USB power bank.

You can find all kinds of electronic gadgets on Indiegogo and Tindie, but these pitches are always shown in the rosiest light. Seldom do you get a real-time view into a project, including all the little missteps and backtracks that are part of any maker project. Well, watch on.

Check out these videos for progress, starting with the schematic, revising it, creating a printed circuit board in KiCad, and revising it, then sending it off to get created, writing the code, and final assembly and debugging. Fun!

Part 1:
Part 2:
Part 3:
Part 4:
Part 5:

All the parts in a playlist

Since I ordered the PCB in a 10-pack, there are going to be extras to give away to Patreon and YouTube subscribers.

Please subscribe to my channel for the latest progress! -m

October 29th, 2018

Think Like Tesla

I’ve avoided publicizing this until there was significant content out there. Announcing a new YouTube channel: Think LIke Tesla.

This channel exists to celebrate a certain Serbian inventor/pop-culture figure and help YOU become a clearer thinker.

In time, it will include everyday descriptions of Nikola Tesla’s patents and experiments, as well as fundamental ideas that underlie all modern technology. All explained clearly, for a non-necessarily-technical audience.

Even if you’ve never worked with electronics–especially if you haven’t–this channel will inspire you to explore new avenues that many folks have written off as something that only a Tesla-sized brain can handle.

I’m proof that’s not true. If I can do it, so can you.

Please stop by and binge watch. In these early days, more subscribers will help, so point your friends this way too. Give a big thumbs-up to videos that you find helpful.

Thanks! -m

Any advice on how to improve the channel is welcome too.

Think LIke Tesla


June 11th, 2018

Measuring high voltage the easy and fun way

I picked this up from The Plasma Channel on YouTube (which is worth more than a look)

How to Measure High Voltage with Spheres

A (somewhat) standardized way to measure high voltages is to see how big an arc can be established between two one-inch conductive spheres. The roundness of the spheres normalizes against surface effects that are present in pointier objects.

I grabbed some 1-inch chrome steel bearing balls. Perfect.

Now, how to connect them? It turns out, it is possible to solder copper and stainless steel. Here’s how.

I had some beefy 4 ga. copper ring terminals around from another project. And I had just picked up a Bernzomatic plumbing torch that comes with silver-bearing solder and flux.

  1. Don’t use the sliver-bearing solder. Nobody’s going to eat off this, so go ahead and use regular leaded solder, which is much easier to work with.
  2. Coat at least half the bearing ball with blue-tack. This will help keep it in place, as well as preserve the metal finish.
  3. Using a regular soldering iron, melt a good amount of solder on to the copper terminal. Arrange for it to be upside down, so the bulk of the solder collects on the part that will be in contact with the ball.
  4. Using gritty sandpaper, sand a rough patch on the steel ball. This will remove the invisible outer layer of oxidation.
  5. Immediately apply a dollop of plumbing flux on the sanded steel. For good measure, I used a few drops of really strong acid flux, but this might not be necessary.
  6. Holding the copper terminal in a long-nose pliers and pressing it against the fluxed steel, fire up the torch and gently go over the contact area until the solder melts and adheres.
  7. Let it air cool for some time, then run it under water to wash away any remaining flux or acid.

Voila. Make a second one of these, then stand them up near a plastic ruler, and let the arcs fly.


December 28th, 2017

About the iPhone slowdown issue

When their hand was forced by hard evidence, Apple admitted what many people had suspected: they deliberately slow down older phones, in as little as a year.

Their apology letter is a masterpiece of copywriting. But let’s have a closer look, shall we?

A chemically aged battery also becomes less capable of delivering peak energy loads, especially in a low state of charge, which may result in a device unexpectedly shutting itself down in some situations.

It’s true that batteries lose capacity over time and use. But it doesn’t so easily follow unexpected shutdowns are the result of this fact of physics. In particular, competing phones seem to avoid this problem.

They glibly follow this two paragraphs later with:

It should go without saying that we think sudden, unexpected shutdowns are unacceptable.

Cute. Apple doesn’t get off the hook so easily. Know what else goes without saying?

They have full, unrelenting, absolute control over every detailed aspect of the design of their products. They alone are responsible for the bizarre obsession with making phones thinner at the expense of everything else. They alone chose the size, composition, and performance parameters of the batteries they use by the millions. They designed the power handling circuitry, specifying its behavior under load. They alone control every scrap of power handling circuitry on the mainboard all the way down to the CPU. They alone tested their designs in as many varied circumstances as their imaginations could provide.

It goes without saying that lithium batteries are consumable components—ones they’ve deliberately made non-user-serviceable, in some cases gluing them into the inner chassis so thoroughly that they’re nearly impossible to remove. Speaking from experience here.

So in that context, no, I don’t buy the polished arguments about how this was done for my benefit. They’re definitely optimizing for something, but long-term customer experience ain’t it. -m

December 25th, 2017

Call me AJ6BD

CQ, CQ, CQ. This is AJ6BD.

I officially have a callsign. I can now legally broadcast on the amateur radio bands.

I’ve been building radios since I was ten (really). I had plenty of help from my mentor, who taught me more than I realized there was to know about electronics, AC theory, signals, modulation, ionospheric propagation, phasors, oscilloscopes, and calculus. It was with his help I built that infamous Tesla Coil for my 6th grade science project.

Despite all that, I never got into the transmit side of radio. There used to be a formidable requirement to send and receive Morse Code at a particular rate, but the FCC dropped that requirement around 2007.

Recently, I’ve experienced an uptick in interest in electronics, and a little nudge from W6RQ at work I brushed up on the materials and went in for my test. Actually three tests, which I somehow managed to pass.

So as I write this, I’m in the unusual position of having an “Amateur Extra” license, but never having had a QSO (over the air contact).

If you’re into Ham radio, leave your callsign in a comment below. Maybe you’ll be the first I make contact with. :)

73, (best regards)



December 10th, 2017

Power Supply build: part 2: component selection

In the previous posting, I went over requirements for a DIY power supply build. Now on to the fun part–shopping!


I wanted something fairly compact, but still nice looking. I ended up going with Jameco ABS Heavy-Duty Instrument Case. It’s a good quality build. In metric, it’s 200mm across, and 64mm tall, which is just about right. I wasn’t looking forward to hand drilling, and worse, cutting rectangular holes in those end-plates though. We’ll come back to that.

This case has a really unusual pattern of mounting holes in the bottom surface. I’m sure there’s ready-made circuit boards that would fit that spacing, but I wasn’t planning on wiring this whole thing up at the component level. So we’ll have to stick a pin in this part too, and revisit later.

AC to DC

I originally sought to get a single board that took 120volts AC in, and came with dual, indepenent outputs. Without reading too closely, I picked up from Jameco a Mean Well “dual” output board. It looks like it was designed to provide both a DC output, as well as a battery charger output. After it arrived, a bit of inspection showed that the two outputs were not independent at all. Trying to (for example) connect them in series would create a short. So for my purposes, I had a high-quality single-ended supply only.

One down, one to go.

It would have been natural to pick up a second identical Mean Well board. But thinking about the requirements, I saw an opportunity to try out something else. The maximum current on the Mean Well was around 3 amps. Perhaps I could do better, at least on one channel? Who knows when I’ll be trying some crazy electroplating experiment and need it. So after more shopping, I settled on the GEREE AC to DC Converter 85 ~ 265v AC to DC 12V 8A Adapter/Industrial Module Switching Power Supply by way of Amazon. This baby can put out up to 8 amps.


These things come from many different overseas manufactuers, under a variety of names, but they all look like this: 5A Constant Adjustable LED Dual Display Amp/Volt. They are actually two boards stacked togetehr with conductive risers. The bottom board is a constant current/constant voltage buck regulator, so it can produce an output anywhere from a bit less than the input, down to a few hundred millivolts. Great. Allegedly, they can handle up to 5 amps. I have my doubts, but we’ll see. (And if I blow one up, it’s easy to replace. Hooray for DIY!)

The top board is a voltage and current display. I started out with grand ideas of replacing the LED displays with larger seven-segment modules, but that quickly got complicated. At least I got a chance to learn how to lay out circuit boards in KiCAD.


OK, spoiler alert. I ended up using separate voltmeter/ammeter modules, like these:DROK Digital Current Tester Multimeter DC 100V Volt 2A Ampere Battery Monitor Gauge 2in1 Red/Blue 2-color LED Display Car Automotive 12V 24V Built-in Shunt. So much for the larger LED display. These are only 0.28 inches, but it’ll have to do. And I like that the LEDs are different colors for voltage vs. current.

So there’s the major pieces. But there remains the significant job of hooking everything together professionally, safely, and upgradibly (if that’s a word). How things connect together is make-or-break on projects like this. Let’s spend some time going over connectors in the next installment.

November 13th, 2017

Power Supply build Part 1: requirements

Building a power supply is a rite of passage for electronics experimenters. I grew up in an age where all power supplies, even “wall warts,” had heavy iron transformers. In the last decade or two, better power transistors have become available, making possible switching power supplies, which are much lighter. (Think of your laptop power converter, or one of those tiny USB power adapters.)

So, there’s more than a bit of nostalgia in play here. I can build something better than what I’ve gazed at longingly during my school years. It’s also a good example of an end-to-end design process, and a time to reflect on how far along technology–and my life–have progressed.

Every project starts with requirements:

1) I want dual, independent supplies. I like to play around with op-amp circuits, many of which require separate positive and negative power lines.

2) A reasonable maximum current, but with adjustable current limiting and short-circuit protection.

3) Fine adjustment. I want to dial in exact voltages and currents, down to the hundredth of a volt or amp.

4) Digital display. Analog meters look cool, but I want the precision of digital.

5) Prominent earth ground connectors up front. When building radio circuits, you often need an earth ground connection handy. And many components are static-sensitive and require protective equipment, which includes a path to ground to dissipate any charges.

6) Repairability: My prior supply was a (single-ended) cheapo box from Fry’s. One day, it started spewing smoke every time I powered it on. I didn’t get very far in troubleshooting what went wrong. I want something made out of cleanly-separated components, which I’ve hand-picked. I want to be able to upgrade or repair anything, as I wish.

Just satisfying 1-5 would put things in the $4-to-$500 range. And the last requirement can only be met by building something yourself. Add to that the satisfaction of using a tool you designed and built with your own hands. The answer is clear. We’re going to build this thing.

Up next: component selection.

August 17th, 2017

Electricity Neutrality

A recent survey showed that 72% of consumers don’t understand what Net Neutrality is. Here’s a simple explanation. It starts with a comparison…

Electricity Neutrality

It’s 2023 and you’re just moved into your new home. Spared no expense. You unbox the new iToaster you ordered online. It’s got all the latest features, including Bluetooth. You plug it into the outlet, drop in two slices of multigrain, and hit the brightly-colored Start button on the LCD display.

Instead of warming up, it displays an error message.

‘Sorry, this appliance has not been approved by your Electric Power Provider. Please tap your credit card to the sensor to pay $0.25 per use to continue.’

That’s when you notice the sleek plastic face of the iToaster actually contains a smart-card reader. Only certain brands of toasters—those whose companies made sweetheart deals with the electric company—work without additional hassle and expense.

Is this a world you’d want to live in? “Electric Power Providers” sure would, if they could get away with it. There’s great business potential in double-billing: they could continue to charge by the kilowatt-hour as they already do, AND on top of that exact huge sums from every appliance and device maker on the planet. And the manufactures would be desperate to avoid having their product crippled.

So great for the Electric Power Providers. But how would you feel as a consumer? How much would appliance makers have to raise prices just to break even? And do you think innovation and experimentation would flourish in such an environment?

Electricity Neutrality isn’t a topic of discussion (yet) because the electric grid isn’t “smart” enough to make it possible. But the internet grid, pretty much by definition, is. New business models become possible with new technology. But just because a business model becomes available, it isn’t necessarily a good idea to adopt it.

Change a few words in this story, and it describes Net Neutrality, which can often be difficult to get across. Net Neutrality means that—like how electricity works today—all usage is metered at a consistent price, no matter what devices or services are involved. Providers don’t get to pick-and-choose the end-user experience by making side deals.

Hopefully this analogy helps make it clearer. So with what you understand now, what do you think? Should your electric company get this kind of control over devices attached to it? Should your internet service provider? -m

P.S. If you’re a fan of geeky writing, I’d be honored if you checked out my fiction. Sign up for a free anthology and a behind-the-scenes look. Unsubscribe anytime.

May 13th, 2017

Items appearing in an Amazon search for Bench Grinder

Shall we speak for a moment about Amazon’s epic metadata problem?

On, search for “Bench Grinder”–a query with clear intent if there ever was one. Search by price low to high. Here are some items that appear in the results before a single piece of hardware you’d reasonably call a bench grinder…

  • Water & Wood 13mm Thickness Resin Polishing Grinding Pad Wheel for Concrete Marble
  • 1/4″ HSS cutting tool blank
  • MAXGOODS 2PCS Fix It Pro Clear Car Coat Scratch Cover Remove Repair Painting Pen Clear Coat Applicator,with 10…
  • 4 Parts Chromium Crusher Herb Grinder (35mm)
  • Vitrex Sanding & Loft Insulation Standard Moulded Mask FFP1
  • Black & Decker 284422-00 Restl.H.Tool
  • Razor Sharp Edgemaking Rouge
  • ZFE® 1/4″,3/8″,1/2″,5/8″ Shank Roundwood Tenon Drill Steel for Bench/pist Drill
  • Integrated Flex Splash Block – 1 Each
  • Bees Wax for Lubricating & Cooling Gritted Paper Wheel – Pro Sharpening Supplies
  • Ryobi BGH616 Bench Grinder (2 Pack) Replacement Switch # 602101-2pk
  • THANYA Salt Spice Pepper Mills Grinder Black Electric
  • BORA 560019 Marking Gauge; Beechwood
  • Mini Hand Drill
  • NOVA 47000 Comet II Versaturn Coupler Lathe Accessory

At this point, on page 20 of the results, I still have not encountered a single bench grinder.

Cory Doctorow’s Metacrap is more relevant than ever. C’mon Amazon, get your act together. You’re more search engine than anything now. You can do better.

March 25th, 2017

Build an electronics lab for under $200

Modern technology has exceeded my wildest dreams as a teenager struggling to build an electronics lab. With an order, one can have an entire electronics lab for next to nothing.

As a teen, I paid a guy $100 for a used oscilloscope that took two adults to lift. These days, you can get a solid state one for under forty bucks. And the component tester listed below is cooler than anything I could have conceived.

So if you want to get started in electronics from scratch, here’s what I’d recommend to get started. I’m not saying this is the best way to go. A single Fluke meter would cost more than $200 but provide a lifetime of quality service. This is aimed at folks getting started on a shoestring budget.

Prices are rounded off and subject to change.

Workbench $0. You’ve already got a desk, kitchen table or something. Start there.

Lighting $8. I grabbed these LED strips and plugged them into a 12 volt power brick I had laying around. 16.4 foot LED flexible strip

Multimeter $18. This isn’t the greatest, but it gets the job done. Even includes a frequency meter! Tacklife DM02A

Soldering station $22. This is the model I’ve used for years. Works great. Stahl SSVT Soldering Station

Solder ($5). 63/37

Flux ($8). It took me far too long to realize how useful flux is in getting solder to flow onto a connection. If you shop around, be sure NOT to get anything acidic. Flux pen

Component tester $12. This completely blows my mind. Plug in nearly any component, push the button, and get a read of the pinout and operating specs. A good project might be mounting this in a nice case. Mega328 component tester

Oscilloscope $23. Not the greatest bandwidth, but for poking around in Arduino circuits and leaning it’s great. DSO 138 TFT scope

Signal generator $17. Once you start testing circuits, you’ll need to inject signals. This little generator is a good start. XR2206 Signal Generator

Power Supply $31. It’s a rite of passage for electronic experimenters to build their own power supply. A good start might be with an ATX computer supply ($21) which you can hook up to an external current limiting regulator ($7). Another good project is to replace the tiny trimmer controls on this unit with multi-turn potentiometers (2 for $3).

Grab bag of parts $20. Go to Jameco for this one. Sorting through the grab bag is a different experience every time, and an educational experience in itself. Component grab bag (but collecting and dismantling old devices will be your primary source)

Wire strippers $5. Over time you’ll want to try several and see what works for you. But this is a good start. CP-301G

Diagonal cutter $6. CHP-170

Screwdrivers $12. This kit works with lots of unusual screws that you’ll encounter in iPhones and so on. And it includes tweezers and spudger tools to get into modern devices. Pro bit driver kit

Breadboard & wires $18. This set includes lots of components that will be helpful to get you started, including a bare-bones USB power supply. Electronics Fun Kit

So this adds up to a bit over $200, but this (plus a few trips to the library) would be a great start for someone getting started in electronics. Check out the EEVblog which has a huge wealth of informational videos.

Let me know what you think!


March 16th, 2017

Overcoming Anxiety

I’ve got a new book coming out. Check out some of the details in this short article.

Overcoming Anxiety

Join my mailing list for a free mini-course and be the first to hear about publication!

January 12th, 2017

LED cube: The Ultimate Assembly Guide

Here’s the manual I wish had been included with the 8x8x8 LED cube kit I picked up on Amazon. Technically there’s already a manual available if you know where to look, but it’s poorly translated and difficult to follow in places. There’s several very similar kits out there, but the LED assembly process is the same, as far as I can tell.


I will skip over the details of soldering the board itself. There’s nothing new or particularly difficult about getting all the components on the board. (email me if you’d like to see more in this section.)

The LED grid, though is another matter.

How everything connects

We’re talking about LEDs. The D stands for diode, which means that they only conduct electricity (and hence light up) in one direction. If you look at a factory fresh LED, one lead will be a bit longer than the other. This is the positive (+) or anode lead. The other is the negative (-) or cathode lead. The anode needs to be connected to a more positive voltage than the cathode, by about 3 volts, in order to light up. (How do you remember which one is the longer lead? Easy. A + sign, if taken apart and put back together end-to-end would be a bit longer than just a – sign. So the longer lead is the + lead.)

Imagine a grid of LEDs, say 4×4. You could address any individual LED with only 8 wires, 4 rows and 4 columns. (Schemes with even fewer wires are possible, but this is as dead simple as it gets.) For example, each row could have all 4 cathode leads connected, and each column all 4 anodes. It’s a little more complicated in three dimensions, effectively a 8×64 grid, but the basic principle is the same.

Assembling the grid

We’re definitely going to need a jig to hold each layer in place while we solder the LEDs. The instructions recommend using cardboard or possibly punchboard for this. There might even be some exactly fitting the needed dimensions, which for my kit were an exact 1cm spacing with 3mm holes for the LED. Imagining the horror that would ensue if I tried to hand-drill 64 accurate holes, I ended up 3D printing a jig, based on this design from Thingiverse. Since I don’t have a 3D printer, I used 3Dhubs to find someone nearby print it for me. It worked great, and it’s very precise.

With your jig ready, the next (and possibly most important) part is at hand: the bend. You need to bend evach LED’s leads in just the right way, so that once situated in the jig, the leads will be overlapping their neighbors. Take this part slow and get it exactly right.

Bending. So much bending.

The bend is one of the most critical parts of a quality assembly. You’re going to do this 512 times, so take your time and get things exactly right. In short, you need to do this:

Click to zoom. In all three cases, the longer anode lead is on the right.

In the middle LED, the anode lead is bent at a crisp 90 degree angle, pointing right into the camera. The bend is close to the LED body, only the width of the needle node pliers seen at the bottom. (I don’t like to make the bend flush against the plastic case, because that makes it too easy to damage the LED.)

On the right, the cathode is bent 90 degrees pointing left, but the bend is farther up the wire. There’s a little crimp mark on the lead that I use as a guideline. If you looked at it from a top down view, it would make a perfect L shape. Since the bends are at different distances from the LED body, this will allow the anode and cathode grids to cross over without touching. (Which would short out the display.)

Make sure all the bends are crisp and exactly right angles, including from the top-down view. This will make the next step easier.

Soldering. So much soldering.

Starting from the bottom-right of your jig, place the first LED so that the leads are sticking out post both sides of the corner. Continue placing LEDs up the entire column. The anode wires should loosely overlap. If you haven’t already checked your LEDs, right now would be an excellent time to do so. (In my kit, if found one dead LED, and one shorted one, which would have caused havoc for the whole display.)

Here’s the trick to soldering quickly. In normal situations, making a good solder joint would involve heating the entire connector, while feeding in a bit of fresh rosin core solder. This is how it’s normally done, but in this case, you’re probably going to need one extra hand free to hold the wires in place. And we need to work extra quickly to not fry our LEDs.

So solder this way: with the wires snug up against each other for the entire length of their overlap (tweezer-assisted as needed) use a toothpick to apply a very small amount of flux to the junction between the two wires. We’re talking less than the volume of a sesame seed here.

Look at the image above. The layer of flux is there, but so thin you might’ve missed it without looking closely.

Wipe off the tip of your soldering iron so it’s clean and shiny. Melt a small blob of solder on the tip, and briefly press it to the fluxed, overlapping wires. The flux will make the solder wick between the wires, nearly instantaneously. PROTIP: you should be able to do this so quickly that even if you’re steadying the wire with your bare finger, a few centimeters away, you don’t get burned.

Remove heat and make sure everything stays absolutely still until the solder hardens. It should look like this, with the first column soldered, and the second column placed but not yet soldered:

Continue on with the rest of the columns. Once you’ve finished all eight, congratulations. You’ve finished the first layer. Now do seven more layers.

Final assembly

Recall that electrically, the 8x8x8 grid is really more like a 64×8 array. On the board you’ll see the 8×8 grid, plus 8 more connectors close by. These extra eight are the return wires. We’ll call that side of the cube the front.

Carefully position one of your layers with anodes facing downward, and cathodes facing the front. Use your needle-nose pliers to slide all eight wires all the way into the connector. This will be frustrating. You’ll get all the way to the end and find one wire that didn’t go in. When you try to back things out a bit, several more wires will pop out, etc. Keep working on it until you have one layer fully connected on the bottom. Now–and this is important–test to make sure everything’s connected properly.

If you apply power without the return wires, nothing should light up. (After all, all those LEDs are so far only connected on one end.) If something does light up, that means you have a defective LED in that layer, and it’s leaking current in the reverse direction. If this happens to you, pull that layer off and replace the bad LED–generally the one that didn’t light up.

Connect a wire from one of the return terminals into any one of the front connectors, and power up your unit. Depending on the exact sequences it’s running through, at some point you should see some LED action.

Photo: It’s alive! Click to zoom.

Be on the lookout for any LEDs that don’t seem to ever light up, and replace them as needed.

Bit in all 8 layers this ways so that all 64 wires on the bottom are fully seated. Nearly there!

You’ll still have 64 wires sticking out the front. What do we do with these? Each horizontal row of 8 wires needs to be connected together. Maybe you could bend the LED leads to do this, but it would be hard to make it look good. I ended up using some tinned uninsulated bus wire. The conventional soldering method works here. Once you have 8 horizontal wires (each connecting to one side of 64 separate LEDs), hook up the return wires. Each layer goes to one of remaining 8 return wire sockets. It’s a good idea to do this in a temporary fashion, with jumper wires, to make sure everything’s fine. When it is, solder away.

Congratulations, you’ve finished your LED cube, and constructed a project more complicated than 99.99% of people in the world. Enjoy!

January 2nd, 2017

Signal generator

Another blast from the past, from the same era. This was a general-purpose gadget: a 5V power supply, plus bouncelsss switch, plus a variable frequency TTL square wave generator. This was one of my experiments with making my own circuit boards, starting with copper cladded boards, drawing on the circuit paths with an inert ink, then etching the rest away in acid. Oh, and hand drilling tiny holes. Lots of tiny holes.

Look at all those scrounged parts! -m

January 1st, 2017

Frequency Counter

A blast from the past! While going through old stuff, I found this device, which I designed and assembled maybe 25 years ago. I never used it. I think it didn’t work on the first try, and I got distracted by other shiny things. Story of my life. I thoughtfully left my future self a schematic diagram.

Click to embiggen.

I don’t recall getting this out of a magazine. I came up with the design on my own, though I wouldn’t be surprised if either of these specialized ICs have a usage note with a similar circuit. It’s a pretty straightforward design. There’s a simple power supply, a JFET op amp input stage, a seven decade LED driver, a timebase, and a good old 555 timer driving the multiplexing.

The construction of the circuit is nothing to be proud of. (notice no pictures here!) It nicely fits on one of those pre-made circuit boards the same size and shape as a wireless breadboard.

Any electronics folks care to comment on this design? I’m more than tempted to fire it up and see if I can get it working. -m

Update: the more I look, more more odd the 555 section seems. There are two pin 3s marked on the 7208. I’m pretty sure that’s not how MUX is supposed to work. Time to pore over some old data sheets…

Update2: I removed the 555 circuit, and instead fed the existing MUX signal from pin 12 of the 7207a to pin 19 (MUX1) of the 7208. And wouldn’t you know, the thing works. I now have a fully functioning frequency counter.


December 23rd, 2016

Two free courses that improved my life

Check out this post at its new home on Writing Through The Fog.

September 28th, 2016

Quantified bronchitis

Lots of people are using Fitbit to get into better shape. But I haven’t heard of anyone using trackers to better measure what happens when you get sick.

As it turns out, I’ve had a nasty case of bronchitis over the last week. This is the sickest I’ve been in a while, and I find it fascinating to look at the data. I hope folks from Fitbit corporate, and other interested individuals will be able to make use of the data.

First off, here’s what shortness of breath and fever do to you: they raise your heart rate.


My normal resting heart rate is in the low 60s. But as you can see here, it hardly dropped below 90, even while I was asleep. Fitbit considers a rate of 89 or above to be the “fat burn” zone, and I had an incredible 20 hours less two minutes in that zone. Interestingly, Fitbit considered my resting heart rate to be only 76 bpm. I think it uses some kind of rolling average over many days.


Here’s what the resting heart rate looked like:


And here’s the overall time in various zones.



The highest spike is the day we were just talking about. But days leading up to that had significantly raised heart rate too. After that, it dropped off fast, but the scale can be deceptive. That data point 3rd from the end is still more than four hours in the “fat burn” zone, which is a lot for lying in bed.

Next up, step counts:


I muddled through Wednesday not feeling well, but activity crashed the way you’d expect, spending entire days in bed.

Lastly calories:


The leftmost column is the Wednesday I muddled through, with a burn of 3004 calories, which is pretty typical. But the next day, despite my step count dropping by 90%, Fitbit recorded a burn of almost 3,500 calories. True, this was with 14-and-a-half hours in the “fat burn” zone, but I don’t think it could make that much of a difference. This has to be a bug. Someone, my set of physiological conditions triggered some defect in the algorithms that made it badly overestimate my burn.

[From what research I could find, running a fever of 102 indeed increases your basal metabolic rate. But not that much. It probably less-than-compensates for the decreased physical activity while sick.]

Friday, the day I had 20 hours in the “fat burn” zone, I recorded a more realistic 2438 calorie burn.

What do you think? If you have fitness tracker data from when you’re sick, I’d love to see it.

Thanks, -m

June 16th, 2016

Antennas and photons

In the previous article I described how antennae work in terms of EM waves. But EM isn’t exactly a wave. Quantum aspects require modeling as particles. Photons. But I can’t really figure out how a photon traveling through space gets converted into an electron current in a wire. There are some cases where treating EM as waves really seems simpler.

But there are probably places where considering it as particles matters too. Like, maybe, the EM drive. Multiple independent tests have confirmed that this device, simply by bouncing microwaves around inside a specially-shaped resonator, produces thrust. Huh?

A new paper suggests a theoretical model where this doesn’t violate Newton’s 3rd law. But the explanation involves paired up out-of-phase photons. Are there existing technologies or experiments where this phenomonon takes place?

I wonder if it’s analogous in any way to how electrons pair up to manifest superconductivity… Would love to hear from the Physics crowd. Add your comment below.


May 8th, 2016

The antenna project

A layman’s description of how antennas work, plus some related experiments. Physics is strange when you think about it.

I’ve been working with electronics since I was about five. (Not an exaggeration. I “fixed” one of my two-battery-requiring cars with one good battery and some wire.) I sailed through high school electronics, and went on to get professional training in the field. But I’m still pretty mystified by radio waves.

So here’s my set of experiments and a written journal of my learning process. I’m going to figure out Radio, RF, antennas, wave propagation, and be able to explain it to a beginner. My goal is to create a device that harvests ambient RF from the air and illuminates (possibly intermittently) an LED.

First off, DC circuits. Most people have seen something like this, or can figure it out just by looking. (Schematic diagrams courtesy of the iCircuit simulator on OS X)


Due to a chemical reaction, the nine volt battery produces a constant potential of 9 volts. The longer side in the diagram is the + terminal. The squiggly line is a resistor, a device that slows the flow of electricity. The arrow is a LED, a light emitting diode. In this configuration, it would light up, though not terribly brightly. In a circuit like this, the wires can be treated as if they have no resistance at all, because compared to anything else in the circuit, they effectively are zero resistance. So measuring the voltage, say at the top of the battery terminal, is within a rounding error of the measurement on the left-hand side of the resistor.

This circuit is static and simple. In particular, there’s no energy storage anywhere. Current is always proportional to voltage divided by resistance (Ohm’s Law). Compare with this circuit:


Same 9 volt supply and a limiting 1k resistor. But also two more branches on the right. The rightmost one is a capacitor. As the diagram indicates, it is essentially two metal plates separated by an insulator. This has the ability to store energy in the form an electric field. Notice that the voltmeter still reads the full 9 volts, even though the switch in the lower-left is open. The battery has been disconnected from the circuit, but it’s still live. (This, by the way, is why old CRT-style TV sets can be dangerous to poke around inside, even after they’re unplugged.)

As further evidence that energy is being stored, when the circuit is first turned on, the voltmeter doesn’t instantly snap up to 9 volts. It gradually builds up, because the capacitor is charging.

The other branch in the circuit is an inductor, or a a coil. This can store energy in the form of a magnetic field. (The 10 ohm resistor is to model the inevitable resistance in the windings of the coil. Without it, this simulator assumes a perfect conductor which throw things off a bit.)

What would happen if we closed the switch on the inductor circuit? Well, the energy from the capacitor would suddenly gush through the inductor, which stretch out a magnetic field around the coil, like a rubber band. Then the magnetic field would collapse, sending a new burst of energy into the capacitor, and so forth. Current will slosh back and forth in the circuit until the losses through the resistor diminish the impulse. The circuit would ring like a tuning fork, though with the values here, the frequency is only around 5 cycles per second.

Within the coils of the inductor, we can no longer assume that all voltages and currents will be equal, because it is interacting with the outside world through a magnetic field. Because there is more going on than simple DC, the simplifying assumption from the first circuit no longer holds. Voltage and current may not be directly proportional, because we have to account for stored energy.

So what in the world is a radio wave then? How is visible light, or an X-Ray, the same as an AM radio broadcast? We need more theory to get there.

Every wire that conducts electricity produces a magnetic field (and every moving magnetic field produces current in a conductor) like this:


(image: Wikimedia Commons)

If you put iron filings on paper, ran a wire through perpendicularly as shown here, and put a strong current through the wire, you’d get a nested donut pattern. (Incidentally, this is why inductors are coils. That shape makes all the magnetic donuts on every turn of the wire point the same way and sum together.) My electric toothbrush uses magnetic induction to charge. But this still isn’t a radio wave.

A closely related concept is an electric field. While the magnetic field is caused by current (flow), an electric field is caused by voltage (potential). Every charged particle exhibits a field like this:


(image: Wikimedia Commons)

When you combine an electric field with a magnetic field, amazing things can happen. Like in the circuit above where energy sloshed back and forth, electric and magnetic fields can support each other and propagate, that is, travel through space at the speed of light.

Probably the most straightforward math comes from a “dipole” antenna, which we can make by taking twin-lead wire and separating out the ends. This is most efficient when each end of the T is half a wavelength of the signal. (For example, the speed of light ~= 300M m/sec. So your 2.4Ghz wifi signal has a wavelength of ~ 300M / 2400M = 0.125 m, or a hair under 5 inches.)

If you drive this antenna at its resonant frequency, you could measure the current along various points of either side of the dipole, and you’d measure different values. This isn’t a simple DC circuit! It took me a while to figure out how to visualize this, but you need to start with the current. At the extreme end of the wires, the current will always be zero. Think of a long, arterial one-way street. At the very end, there will always be no traffic, but the farther you get toward the main road, the more traffic there will be coming and going. You can visualize it like this. The black represents the physical wires of the antenna, and blue is a graph of the current at a given point along the wire.

Remember that current flow means there’s a magnetic donut circling the wire, proportional in strength to the amount of current flow.

This flow means that electric charge will accumulate, being strongest at the very ends of the wires. Which in turn means there will be an electric field that looks very much like our diagram above.


The applied signal, being a sine wave, drops to zero a quarter of a cycle later, and these electric fields, supported by the donut magnetic fields, slosh back and detach from the wire to become closed loops in space, and then proceed to propagate. The cycle repeats, switching polarity each time.


The wikipedia page for dipole antenna has some animated gifs which may or  may not help you visualize this.

I welcome your feedback. Coming up next: some experiments. If you have suggestions, I’d love to hear them. -m

May 5th, 2016

Unsafe Java

Pop quiz. Why is the following Java 8 code unsafe? UPDATE: this code is fine, see comments. Still good to think about, though.

Entity e = new Entity();
e.setName("my new entity");

To provide some context, Entity is a POJO representing something we want to store in a database. And persistanceLayer is an instance of a Data Access Object responsible for storing the object in the database. Don’t see it yet?

Here’s the function signature of that put method

<E extends AbstractEntity> CompletableFuture<E> put(E newEntity);

Ah, yes, Spring, which because of the @Async annotation will proxy this method and cause it to execute in a different thread. The object getting passed in is clearly mutable, and by my reading of the Java Memory Model, there’s no guarantee that the other thread’s view of the update that happened in the setName method will be visible. In other words, there’s no guarantee the two threads idea of “before-ness” will be the same; who knows what might have been reordered or cached?

I’m having trouble coming to terms with what seems like a gaping hole. Do you agree with this analysis? If so, how do you deal with it? Immutable object classes seem like an obvious choice, but will introduce lots of overhead in other parts of the code that need to manipulate the entities. A builder pattern gets awkward and verbose quickly, as it hoists all that complexity on to the caller.

How do you handle situations like this? I’d love to hear it.

If you produce libraries, please include documentation on what is and isn’t guaranteed w.r.t. async calls. -m

April 24th, 2016

The physics of the impossibly tiny

According to Newtonian gravitation, the attraction between two bodies is proportional to the product of their masses and inversely proportional to the square of the distance between them. Einstein refined this somewhat, but as long as there aren’t crazy speeds or non-flattish spacetime involved, Newton’s formulation is accurate. As far as we know.

I read this interesting article, which spun off the thought experiment below. The EM Drive mechanism keeps confounding some Really Smart people who would genuinely like to discredit it. What’s going on here? I’m probably butchering the explanation, but the article posits that very small accelerations don’t behave in a completely smooth manner. In other words, they’re subject to quantum effects.

Here’s a thought experiment. What is the Newtonian gravitational attraction between this hydrogen atom in my little finger, and one in, say, the Andromeda galaxy? (Pedantically, one that was in the Andromeda galaxy 2.5 million years ago, from the Earth’s frame of reference)

I put this into Wolfram Alpha (which helpfully supplied an value for the big-G constant) and came up with an answer of:

1.419 * 10-109 N (newtons)

That’s not a typo. There’s 109 places to the right of the decimal.

I don’t even have a good analogy for how slight that force is. A trillionth trillionth of the seismic energy of a dandelion seed landing, measured from a trillion km away?? Still too much, by a lot. It’s a reasonable question whether the universe even goes to that level of detail. Could such a slight force even be said to exist in a meaningful sense? In other words, could it be measured, even in principle? I’m no expert, but I doubt it. So maybe physics isn’t completely smooth down to that level.

Is there a limit to how small a force can be and still act like a force?

To accurately compute the complete gravitational affect on this hydrogen atom in my little finger, I’d have to take into account the 1080 particles in the observable universe, the vast majority of which make unmeasurably tiny contributions to the overall sum. That’s for a single instant. For a continuous number, I’d need to repeat this enormous calculation something like 1043 times per second. So all you universe simulator writers out there, take note. Some simplification is probably warranted. :)

(A realistic simulator would only need to take into account the mass of the Earth, Moon, Sun, and for a few decimal places more, Jupiter. But I’m talking about laws running the universe, not engineering hacks.)

It seems there are still some quite interesting things left to discover in the universe. I keep going back to the chapter Surprises from the Real World in Lee Smolin’s Trouble With Physics. Exciting times ahead! -m

January 11th, 2016

Re-creating the Semantics Demo

(From the archives: I wrote this over 2 years ago, but never hit publish. At last, the tale can be told!)

If you haven’t seen it, the keynote at MarkLogic World 2013 is worth a look. I was on stage demonstrating new Semantics features built into MarkLogic server. Two of the three demos were based on MarkMail, a database of some 60 million messages, with enhanced search capabilities driven by semantics. (The third demo was a built-from-the-ground-up semantic application).

Since then, several folks have asked about the code behind the demo. What I showed was a fully operational MarkMail instance, including millions of email messages. This was understandably quite expensive to keep up on AWS, and it went away shortly after the keynote. A huge part of the demo was showing operation at scale, but reading between the lines, what folks are more interested in is something more portable–a way to see the code in operation and play with it without having to stand up an entire cluster or go through a lengthy setup procedure.

Space won’t allow for a full semantics tutorial here. For that, a good resource is this free tutorial from MarkLogic University.

So, in this posting, let’s recreate something on a similar level using built-in features. We’ll use the Oscars sample application that ships with the product. To get started, create an Application Builder sample project and deploy it. We’ll call the relevant database names ‘oscar’ and ‘oscar-modules’ throughout. Since Application Builder ships with only a small amount of data, you may also want to run the sample Information Studio collector that will fetch the rest of the dataset.

Before we can query, we need to actually turn on the semantics index. The easiest place to do this is on the page at http://localhost:8000/appservices/. Select the oscar database and hit configure. On the page that comes up, tick the box for Semantics and wait for the yellow flash.

Semantic Data

This wouldn’t be much of a semantic application without triple data. Entire books have been written on this kind of data modeling, but one huge advantage of semantics is that there’s lots of data already set up and ready to go. We’ll use dbpedia. The most reecent release as of this writing is version 3.9.

From there we’ll grab data that looks relevant to the Oscar application: anything about people and/or movies, picking and choosing from things most likely to have relevant facts:

In all, a bit less over 38 million triples–not even enough to make MarkLogic break a sweat, but still a large enough chunk to be inconvenient to download. Since the oscar data and dbpedia ultimately derive from the same source–Wikipedia itself. Since the oscar data preserved URLs it was straightforward to extract all triples that had a matching subject, once prefixed with “”.

I extracted all these triples: Grab them from here and put it somewhere on your local system.

Then simply load these triples via query console. Point the target database to ‘oscar’ and run this:

import module namespace sem=""
  at "MarkLogic/semantics.xqy";

Infopanel widget

So an ‘infopanel’ is what in the MLW demo showed the Hadoop logo, committers, downloads, and other facts about the current query. The default oscar app already has something like this: widgets. Let’s create a new widget type that looks up and displays facts about the current query. To start, if you haven’t already, build the example application in App Builder. There’s some excellent documentation that walks through this process.

Put on your Front End Dev hat and let’s build a widget. All the code we will use and modify is in the oscar-modules database, so either hook up a WebDav server or copy the files out to your filesystem to work on them. Back in AppBuilder on the Assemble page, click the small X at the upper-right corner of the pie chart widget. This will clear space for the widget we’re about to create, specifically in the div <div id=”widget-2″ class=”widget widget-slot”>.

The way to do this is to modify the file application/custom/app-config.js All changes to files in the custom/ directory will survive a redeployment in AppBuilder, which means your changes will be safe, even if you need to go back and change things in Application Builder.

function infocb(dat) {
 $("#widget-2").html("<h2>Infopanel</h2><p>The query is " +
    JSON.stringify(dat.query) + "</p>");
var infopanel = ML.createWidget($("#widget-2"), infocb, null, null);

This gives us the bare minimum possible widget. Now all that’s left is to add semantics.

Hooking up the Infopanel query

We need a semantic query, the shape of which is: “starting with a string, find the matching concept, and from that concept return lots of facts to sift through later”.

And we have everything we need at hand with MarkLogic 7. The REST endpoint, already part of the deployed app, includes a SPARQL endpoint. So we need to make the new widget fire off a semantic query in the SPARQL language, then render the results into the widget. One nice thing about the triples in use here is that they consistently use the foaf:name property to map between a concept and its string label. So pulling all the triples based on a string-named topic works like this. Again, we’ll use Query Console to experiment:

import module namespace sem = ""
    at "/MarkLogic/semantics.xqy";
let $str := "Zorba the Greek"
let $sparql := "
prefix foaf: <>
construct { ?topic ?p ?o }
{ ?topic foaf:name $str .
?topic ?p ?o . }
return sem:sparql($sparql, map:entry("str", $str))

Here, of course, to make this Query Console runnable we are passing in a hard-coded string (“Zorba the Greek”) but in the infopanel this will come from the query.

Of course, deciding what parts of the query to use could be quite an involved process. For example, if the query included [decade:1980s] you can imaging all kinds of interesting semantic queries that might produce useful and interesting results. But to keep things simple, we will look for only a s single word query, which includes quoted phrases like “Orson Welles”. Also in the name of simplicity, the code sample will only use a few possible predicates. Choosing which predicates to use, and in what order to display them, is a big part of making an infopanel useful.

Here’s the code. Put this in config/app-config.js:

function infocb(dat) {
  var qtxt = dat.query && dat.query["word-query"] &&
        dat.query["word-query"][0] && dat.query["word-query"][0].text &&
  if (qtxt) {
      url: "/v1/graphs/sparql",
      accepts: { json:"application/rdf+json" },
      dataType: "json",
      data: {query:
        'prefix foaf: <> ' +
        'construct { ?topic ?p ?o } ' +
        'where ' +
        '{ ?topic foaf:name "' + qtxt + '"@en . ' +
        '?topic ?p ?o . }'
      success: function(data) {
        var subj = Object.keys(data); // ECMAscript 5th ed, IE9+
        var ptitle = "";
        var pdesc = "";
        var pthumb = "";
        var title = "-";
        var desc = "";
        var thumb = "";
        if (data[subj]) {
          if (data[subj][ptitle]) {
            title = data[subj][ptitle][0].value;
          if (data[subj][pdesc]) {
            desc = "<p>" + data[subj][pdesc][0].value + "</p>";
          if (data[subj][pthumb]) {
            thumb = "<img style='width:150px; height:150px' src='" +
                data[subj][pthumb][0].value + "'/>";
        $("#widget-2").html("<h2>" + title + "</h2>" + desc + thumb );
  } else { $("#widget-2").html("no data")} 

var infopanel = ML.createWidget($("#widget-2"), infocb, null, null);

This works by crafting a SPARQL query and sending it off to the server. The response comes back in RDF/JSON format, with the subject as a root object in the JSON, and each predicate against that subject as a sub-object. The code looks through the predicates and picks out interesting information for the infopanel, formatting it as HTML.

I noted in working on this that many of the images referenced in the dbpedia image dataset actually return 404 on the web. If you are not seeing thumbnail images for some queries, this may be why. An infopanel implementation can only be as helpful as the data underneath. If anyone knows of more recent data than the official dpbedia 3.9 data, do let me know.

Where to go from here

I hope this provides a base upon which many developers can play and experiment. Any kind of app, but especially a semantic app, comes about through an iterative process. There’s a lot of room for expansion in these techniques. Algorithms to select and present semantic data can get quite involved; this only scratches the surface.

The other gem in here is the widget framework, which has actually been part of all Application Builder apps since MarkLogic 6. Having that technology as a backdrop made it far easier to zoom in and focus on the semantic technology. Try it out, and let me know in the comments how it works for you.

January 11th, 2016

Geektastic Things

I am trying something new with the GeekThoughts domain. Instead of pointing to my blog, it’s pointing at some cool geeky things on a CMS that’s easier to update. Won’t you check it out?

January 2nd, 2016

Pixel editor

I did a thing.

I am experimenting with machine learning and neural networks. To do so, I need a real-world dataset to play with. For starters, I am using a 5×7 pixel array, as common in many DIY projects, representing digits 0-9. Please help me my drawing a picture of the randomly-selected digit below. All data will be released to the public domain.

Can you help me? Take a few seconds and draw a picture of a number by clicking on pixels to toggle their value.

Email me with any questions or suggestions.


Data collection by Google Custom Forms.

Machine learning datasets FTW! Stay tuned for code & results.

October 12th, 2015

The Vector Sum theory of leadership

I’ve talked about this before, but I don’t think I’ve ever written it down. As more of my day-to-day involves leadership, I think about this stuff. To run an effective team, you need to think in vector sums.

As the great poet A. Yankovic once said, “Do vector calculus just for fun.” But this isn’t even calculus, just trig. :) Let’s see if we can avoid flashbacks to high school math. You can think of a vector as a value that has both a magnitude and a direction, like the wind blowing 10 mph to the NW.

Every team member is a vector. The magnitude is how much stuff that person can get done, and the direction is what they see as the end-point of their work. The goal. Unlike a wind report, the direction might consist of many different dimensions, but the basic principles still hold.

What happens when your team grows to two people?

Vectors can add. Geometrically, you can think a vector as an arrow with a particular length and orientation. Adding is stacking two (or more) arrows tail-to-head. So two vectors opposed by 180 degrees will tend to cancel each other out. Two vectors pointing exactly the same direction reinforce.

But here’s the great thing: two vectors that mostly point in the same direction give almost as much benefit as if they were exactly aligned.

Example: Team member A is pulling NW at 10 mph. Team member B is pulling NE at 10 mph. If you treat this as a right triangle, you get approximately:

Team member A contributions: 7 mph N, 7 mph W

Team member B contributions: 7 mph N, 7 mph E

The E and W components fight against each other, and you end up with 14 mph due north. Even though the team members are pointing in very different directions, they are still around 70% effective in combination. Of course, the job of a manager is to establish and communicate goals effectively to better align team members and prevent rework. Herein lies efficiency.

For example, if my math is right, in the case where team member A is pulling NNW and B is pulling NNE, the efficiency jumps from 70% to 92%.

Many managers fall into the trap of micro-managing, which is missing the point. Hire smart people, make sure they’re pointed in the right direction and let them run ahead as fast as they can. Stay just enough ahead of them to remove obstacles before they encounter them. That’s a great leader.

Bonus epiphany

I recently realized that this principle also applies to the thoughts in your head. No, I’m not talking about an after-school-special  multiple-personality situation. But thousand of thoughts rattle through your mind every day, and each one has a magnitude and a direction. You need to get them all pointing in the same direction, more-or-less, to be effective as a human being.

This is a restatement of a common concept that goes under many names such as “Personal brand.” Is everything you think about (and subsequently do) helping make you into who you want to be?

May 2nd, 2015

Before your standup, sit down

I’m running a Scrum project, and doing things a little differently than the classic method. I’ve done this at two different companies now, and it seems to work out well.

Before a traditional standup meeting with The Three Questions, I schedule 15 minutes of intentional downtime. Since this happens at the start of the day, it’s a chance to quietly plan out your day, and start on a thoughtful note.

I’ve often found myself “preparing” for a standup meeting by quickly scribbling down what I’ve done on a sticky note, so that when called upon, I can know what to say without having to think too hard. So why not formalize this? Work life is hectic enough. A few minutes of quiet reflection can make a big difference. Knowing what you need to work on is the first step to avoiding thrashing. Since we use a software tool to track sprint work, capturing the day’s list in this app is a fine thing to do during this time.

One caution: it’s easy for this to slip into extra-minutes-for-commute time, or just a regular standup meeting that starts 15 minutes later. To get the benefit, the team needs to be present (but not necessarily in the meeting room).

Has anyone else tried something like this? -m

March 18th, 2015

Fiction update

Quick update here: if you are reading this, you’d probably like this short story, named in honor of Dennis Ritchie, FREE and currently burning up the charts for 30 minute reads in Mystery, Thriller, & Suspense. Doing pretty well in Science Fiction and Cyberpunk as well. (link fixed)

Do a solid for readers everywhere and leave a review.

Coming soon is the prequel to this story. It will be free only to folks who jump on the author mailing list.

We now return to your regularly-scheduled nonfictional geekery.


February 5th, 2015

DIY fizzy yerba mate drink

Filed under need-to-try this: A homebrew version of a popular hacker drink called Club Mate.

I already have a carbonator cap and CO2 setup, as part of my beer brewing hardware.

One variation I would experiment with is cutting down on the sugar. Even though Club Mate isn’t very sweet, it still has a fair amount of sugar in it. Stevia could be a good alternative. -m