SQLite On The Web: Absurd-sql

Love it or hate it, the capabilities of your modern web browser continuously grow in strange and wild ways. The ability for web apps to work offline requires a persistent local storage solution and for many, IndexedDB is the only choice as it works across most browsers and provides a database-like interface. However, as [James Long] found, IndexedDB is painfully slow on chrome and limited in querying ability. He set out to bring a tool he was familiar with, SQLite, and bring it to the web browser as absurd-sql.

Why absurd? Partially because most browsers (not chrome) implement IndexedDB on top of SQLite. So for many browsers, it is just SQLite on top of IndexedDB on top of SQLite. Luckily for [James] there already was a project known as sql.js that uses emscripten to compile the C-based SQLite into WebAssembly. However, sql.js uses an in-memory storage backing and all data is lost when refreshing the page. [James] tweaked SQLite’s method of reading and writing blocks. Instead of being memory backed, he added a layer to read and write blocks from IndexedDB. This means that only sections of the database need to be read in, bringing in huge performance gains.

a graph showing absurd-sql beating IndexDB on every benchmarkThat brings us to the other reason why it’s absurd. On chrome (as well as Firefox), absurd-sql beats IndexedDB on almost every benchmark. A query like SELECT SUM(*) FROM kv led to stunning results.

So what’s the downside? Other than a somewhat large WebAssembly file that needs to get downloaded (409KB) and cached, there really isn’t. Of course, it’s not all roses when it comes to web development. Native SQLite runs 2-3 times faster than absurd-sql, which demonstrates how slow IndexedDB really is.

There are other storage standards on the horizon for web browsers, but locking becomes an issue. SQLite expects synchronous reads and writes because it’s just simple C. IndexedDB and other storage solutions are asynchronous as the event loop of Javascript lends itself well to that model. Absurd-sql gets around that by creating a SharedArrayBuffer that is shared with a worker process. The atomics API is used to communicate with the buffer. In particular, atomics.wait() allows the worker to block main thread execution until the read or write has finished. From the perspective of SQLite, the operations are synchronous. IndexedDB provides transactions so multiple connections can happen (for example multiple tabs open). Multiple readonly transactions can occur in parallel but only one readwrite transaction can be in flight.

Why not pull up your browser and start playing around with it? You’re already doomed to learn WebAssembly anyway.

mRNA badge next to an image of the actual Moderna vaccine nanoparticle.

Celebrate MRNA Vaccine With This Badge That Blinks The Nucleotide Code

To celebrate getting his second vaccine dose [Paul Klinger] combined two of our favorite things — blinking lights and wearable tech — to create an awesome mRNA vaccine badge.

The badge, which is designed to be worn like a pendant, will slowly blink through all 4,000 nucleotides of the Moderna vaccine over the course of 10 minutes. Watch the video after the break to see it in action. Don’t worry if you got the Pfizer vaccine, you can use the interface button on the back of the badge to change over to Pfizer’s mRNA sequence instead. There’s even a handy legend on the badge, identifying the lipids in case your microbiology skills are a bit rusty.

On the reverse side of the board, you will find a handful of current limiting resistors, a CR2032 battery holder, and the ATtiny1617 microcontroller that runs everything. To assist in converting the mRNA sequence into LED pulses, [Paul] wrote a Python script that will automatically import the nucleotide string from the standard .fasta file and store each nucleotide in just 2 bits, allowing the entire sequence to fit in the program memory of the microcontroller.

This isn’t [Paul’s] first RNA-related project; he originally developed the aforementioned Python script to compress the entirety of the COVID-19 sequence, containing over 30,000 nucleotides, into program memory for his Virus Blinky project, that we featured last year.

Continue reading “Celebrate MRNA Vaccine With This Badge That Blinks The Nucleotide Code”

The interior of a failed boiler.

Fail Of The Week: Learning How Not To Silver Solder

Sure, there are subtleties, but by and large it’s pretty easy to pick up soldering skills with a little practice. But wait! Not all soldering is created equal, and as [Quinn Dunki] learned, silver soldering is far harder to get right.

Granted, the job [Quinn] is working on is much more demanding than tacking some components to a PCB. She has been building a model steam engine, a task fit to put anyone’s machining skills to the test. And a steam engine needs a boiler, which is where the silver soldering comes in. As she explains in the video below, silver soldering, or “hard” soldering, uses solder that melts at a much higher temperature than “soft” solders like we’re used to in electronics. That’s a big advantage in the heat and pressure of a boiler, but it does pose some problems, many of which [Quinn] managed to discover as she tried to assemble her copper beast.

It turns out that heating a big hunk of copper evenly without burning off the flux actually isn’t that easy, though you can’t say she didn’t give it the old college try. In the process, she managed to share a number of tidbits that were really interesting, like the fact that drawing acetylene from a tank too fast can be dangerous, or that model steam boilers have to be certified by qualified inspectors. In the end, her boiler couldn’t be salvaged, and was put to the saw to determine the problem, which seems to be her initial choice of heating with oxyacetylene; after that initial failure, there was little she could do to save the boiler.

As [Quinn] says, “Failure is only failure if you don’t learn from it.” And so it may be a bit unfair to hang “Fail of the Week” on this one, but still — she has to go back to the beginning on the boiler. And we already know that model steam engines aren’t easy.

Continue reading “Fail Of The Week: Learning How Not To Silver Solder”

Sparkpad Sparks Joy For Streamers

The best streamers keep their audience constantly engaged. They might be making quips and doing the funny voices that everyone expects them to do, but they’re also busy reading chat messages aloud and responding, managing different scenes and transitions, and so on. Many streamers use a type of macro keyboard called a stream deck to greatly improve the experience of juggling all those broadcasting balls.

Sure, there are dedicated commercial versions, but they’re kind of expensive. And what’s the fun in that, anyway? A stream deck is a great candidate for DIY because you can highly personalize the one you make yourself. Give it clicky switches, if that’s what your ears and fingers want. Or don’t. It’s your macro keyboard, after all.

[Patrick Thomas] and [James Wood] teamed up to build the perfect stream deck for [James]’ Twitch channel. We like the way they went about it, which was to start by assessing a macro pad kit and use what they learned from building and testing it to design their ideal stream deck. The current version supports both the Arduino Pro Micro and the ESP32. It has twelve key switches, a rotary encoder, an LED bar graph, and an OLED screen for choosing between the eight different color schemes.

If you’d rather have dynamic screens instead of cool keycaps, you can do it cheaper by making non-touch screens actuate momentaries.

Know Audio: Amplifier Nuts And Bolts

As we’ve followed a trail through Hi-Fi and audio systems from the listener’s ear towards the music source, we’ve reached the amplifier. In our previous article we gave a first introduction to distortion and how some amplifier characteristics can influence it, and here we’ll continue along that path and look at the amplifier itself. What types of audio amplifier circuits will you encounter, and what are their relative merits and disadvantages?

A Few Amplifier Basics

Horowitz and Hill's Transistor Man
Horowitz and Hill’s Transistor Man

If you know anything about a transistor, it’s probably that it’s a three terminal device whose output pin forms part of a potential divider whose state is dependent on what is presented to its input pin. The Art of Electronics had it as a cartoon of a man standing inside a bipolar transistor and adjusting a variable resistor between collector and emitter while watching an ammeter on the base.

Properly biased in its conducting range, a transistor can behave as a linear device, in which the potential divider voltage moves in response to the input in a linear relationship, and thus the voltage on the output is an amplified version of the voltage on the output. This is the simplest of transistor amplifiers, and because different types of amplifier are referred to by lettered classes, it’s known as a class A amplifier. Continue reading “Know Audio: Amplifier Nuts And Bolts”

Game Boy Advance SP Case Mod Adds Battery Capacity And Modern Interfaces

While there’s nothing quite like running retro games on their original hardware, using older consoles in today’s day and age can be a hassle due to incompatibilities with modern chargers and headphones. [tito] and [kyle] worked together to update Nintendo’s Game Boy Advance SP with a whole bunch of new features, tightly packed inside a 3D-printed replacement backshell. (Video, embedded below.)

The original 600 mAh battery has been replaced with a 1600 mAh pack for several hours of additional screen time. A Qi standard wireless power module as well as a USB-C connector allows charging the battery without carrying the original mains adapter. A Bluetooth module enables the use of wireless headphones, and a 3.5 mm jack enables classic earbuds as well, a feature lost when the SP replaced the original GBA.

The new backshell fits exactly on the original console, making it about 10 mm thicker. Although this makes it slightly less portable, it is apparently more comfortable to hold for those with big hands. The new functionality is implemented using off-the-shelf circuit boards, connected together with flying wires that are soldered to the required points on the GBA’s circuit board. The original connectors and switches remain in place and functional, and the entire operation can be undone if you want to return the device to its original state.

Others have added USB charging to the original GBA, or even stretched that handheld to become twice as wide. But adding significant new functionality previously required replacing the handheld’s entire contents.

Continue reading “Game Boy Advance SP Case Mod Adds Battery Capacity And Modern Interfaces”

As ISS Enters Its Final Years, Politics Take Center Stage

There was a time when the idea of an international space station would have been seen as little more than fantasy. After all, the human spaceflight programs of the United States and the Soviet Union were started largely as a Cold War race to see which country would be the first to weaponize low Earth orbit and secure what military strategists believed would be the ultimate high ground. Those early rockets, not so far removed from intercontinental ballistic missiles (ICBMs), were fueled as much by competition as they were kerosene and liquid oxygen.

Space Shuttle docked to Mir space station in 1995.
Atlantis docked to Mir in 1995.

Luckily, cooler heads prevailed. The Soviet Almaz space stations might have carried a 23 mm cannon adapted from tail-gun of the Tu-22 bomber to ward off any American vehicles that got too close, but the weapon was never fired in anger. Eventually, the two countries even saw the advantage of working together. In 1975, a joint mission saw the final Apollo capsule dock with a Soyuz by way of a special adapter designed to make up for the dissimilar docking hardware used on the two spacecraft.

Relations further improved following the dissolution of the Soviet Union in 1991, with America’s Space Shuttle making nine trips to the Russian Mir space station between 1995 and 1997. A new era of cooperation had begun between the world’s preeminent space-fairing countries, and with the engineering lessons learned during the Shuttle-Mir program, engineers from both space agencies began laying the groundwork for what would eventually become the International Space Station.

Unfortunately after more than twenty years of continuous US and Russian occupation of the ISS, it seems like the cracks are finally starting to form in this tentative scientific alliance. With accusations flying over who should take the blame for a series of serious mishaps aboard the orbiting laboratory, the outlook for future international collaboration in Earth orbit and beyond hasn’t been this poor since the height of the Cold War.

Continue reading “As ISS Enters Its Final Years, Politics Take Center Stage”