String art rendering of a face

BASIC Programming With No Strings Attached

Today in programming language hacks we have string art rendered in BASIC. String art — also known as pin and thread art, or filography — is an art form where images are invoked by thread woven between pins on the border of an image. In this case the thread and the pins are virtual and there is a simple 67 line BASIC program which generates and renders them.

Of course BASIC, the Beginner’s All-purpose Symbolic Instruction Code, isn’t just one thing and was a bit of a moving target over the years. Invented in 1964 at Dartmouth College by John Kemeny and Thomas Kurtz it turned into a family of languages as a dynamic array of implementations added, removed, and changed implementation details as the future unrolled.

We remember GW-BASIC and QuickBASIC, but the landscape was much broader than that. Implementations of QuickBASIC came with a “compiler”, qb45.exe, which worked by bundling the BASIC script as p-code into an executable along with the runtime binary, which we used back in the day to make “real applications”, not mere scripts.

Thanks to [Keith Olson] for writing in to let us know about this one. If you’re interested in seeing what the state of the art in string art is, be sure to check out String Art Build Uses CNC To Make Stringy Art and CNC Router Frame Repurposed For Colorful String Art Bot. The best string art is in the real world, not software!

Detail of Horus's face, from a statue of Horus and Set placing the crown of Upper Egypt on the head of Ramesses III. Twentieth Dynasty, early 12th century BC.

HORUS Framework: A Rust Robotics Library

[neos-builder] wrote in to let us know about their innovation: the HORUS Framework — Hybrid Optimized Robotics Unified System — a production-grade robotics framework built in Rust for real-time performance and memory safety.

This is a batteries included system which aims to have everything you might need available out of the box. [neos-builder] said their vision is to create a robotics framework that is “thick” as a whole (we can’t avoid this as the tools, drivers, etc. make it impossible to be slim and fit everyone’s needs), but modular by choice.

[neos-builder] goes on to say that HORUS aims to provide developers an interface where they can focus on writing algorithms and logic, not on setting up their environments and solving configuration issues and resolving DLL hell. With HORUS instead of writing one monolithic program, you build independent nodes, connected by topics, which are run by a scheduler. If you’d like to know more the documentation is extensive.

The list of features is far too long for us to repeat here, but one cool feature in addition to the real-time performance and modular design that jumped out at us was this system’s ability to process six million messages per second, sustained. That’s a lot of messages! Another neat feature is the system’s ability to “freeze” the environment, thereby assuring everyone on the team is using the same version of included components, no more “but it works on my machine!” And we should probably let you know that Python integration is a feature, connected by shared-memory inter-process communication (IPC).

If you’re interested in robotics and/or real-time systems you should definitely be aware of HORUS. Thanks to [neos-builder] for writing in about it. If you’re interested in real-time systems you might like to read Real-Time BART In A Box Smaller Than Your Coffee Mug and Real-Time Beamforming With Software-Defined Radio.

Two threads running concurrently

The Staggering Complexity And Subtlety Of Concurrency

If you’re gonna be a hacker eventually you’re gonna have to write code. And if you write code eventually you’re gonna have to deal with concurrency. Concurrency is what we call it when parts of our program run at the same time. That could be because of something fairly straightforward, like multiple threads, or multiple processes; or something a little more complicated such as event loops, asynchronous or non-blocking I/O, interrupts and signal handlers, re-entrancy, co-routines / fibers / green threads, job queues, DMA and hardware level concurrency, speculative or out-of-order execution at CPU-level, time-sharing on single-core systems, or parallel execution on multi-core systems. There are just so many ways to get tied up with concurrency.

In this video from [Core Dumped] we learn about The ’80s Algorithm to Avoid Race Conditions (and Why It Failed). This video explains what a race condition looks like and talks through what the critical section is and approaches to protecting it. This video introduces an old approach to protect the critical section first invented in 1981 known as Peterson’s solution, but then goes on to explain how Peterson’s solution is no longer reliable as much has changed since the 1980s, particularly compilers will reorganize instructions and CPUs may run code out of order. So there is no free lunch and if you have to deal with concurrency you’re going to want some kind of support for a mutex of some type. Your programming language and its standard library probably have various types of locks available and if not you can use something like flock (also available as a syscall, to complement the POSIX fcntl), which may be available on your platform.

If you’re interested in contemporary takes on concurrency you might like to read Amiga, Interrupted: A Fresh Take On Amiga OS or The Linux Scheduler And How It Handles More Cores.

Continue reading “The Staggering Complexity And Subtlety Of Concurrency”

Messing With JPEGs In A Text Editor Is Fun And Glitchy

If you’re looking to edit an image, you might open it in Photoshop, GIMP, or even Paint Shop Pro if you’re stuck in 2005. But who needs it — [Patrick Gillespie] explores what can be done when editing a JPEG on a raw, textual level instead.

As the video explains, you generally can’t simply throw a JPEG into Notepad and start making changes all willy nilly. That’s because it’s very easy to wreck key pieces of the image format that are required to render it as an image. Particularly because Notepad likes to sanitize things like line endings which completely mess up the structure of the file. Instead, you’re best off using a binary editor that will only change specific bytes in the image when you tell it to. Do this, and you can glitch out an image in all kinds of fun digital ways… or ruin it completely. Your choice!

If you’d like to tinker around with this practice, [Patrick] has made a tool for just that purpose. Jump over to the website, load the image of your choice, and play with it to your heart’s content.

This practice is often referred to as “datamoshing,” which is a very cool word, or “databending,” which isn’t nearly as good. We’ve explored other file-format hacks before, too, like a single file that can be opened six different ways. Video after the break.

Continue reading “Messing With JPEGs In A Text Editor Is Fun And Glitchy”

Modifying A QingPing Air Quality Monitor For Local MQTT Access

The QingPing Air Quality Monitor 2 is an Android-based device that not only features a touch screen with the current air quality statistics of the room, but also includes an MQTT interface that normally is used in combination with the QingPing mobile app and the Xiaomi IoT ecosystem. Changing it to report to a local MQTT server instead for integration with e.g. Home Assistant can be done in an official way that still requires creating a cloud account, or you can just do it yourself via an ADB shell and some file modifications as [ea] has done.

By default these devices do not enumerate when you connect a computer to their USB-C port, but that’s easily resolved by enabling Android’s developer mode. This involves seven taps on the Device Name line in the About section of settings. After this you can enter Developer Options to toggle on Debug Mode and Adbd Debugging, which creates the option to connect to the device via USB with ADB and open up a shell with adb shell.

From there you can shoot off the QingSnow2 app and the watchdog.sh that’s running in the background, disable IPv6 and edit /etc/host to redirect all the standard cloud server calls to a local server. Apparently there is even SSH access at this point, with root access and password rockchip. The MQTT configuration is found under /data/etc/ in settings.ini, which is used by the QingPing app, so editing redirects all that.

Of course, the device also queries a remote server for weather data for your location, so if you modify this you have to provide a proxy, which [ea] did with a simple MQTT server that’s found along with other files on the GitHub project page.

Ray Marching In Excel

3D graphics are made up of little more than very complicated math. With enough time, you could probably compute a ray marching by hand. Or, you could set up Excel to do it for you!

Ray marching is a form of ray tracing, where a ray is stepped along based on how close it is to the nearest surface. By taking advantage of signed distance functions, such an algorithm can be quite effective, and in some instances much more efficient than traditional ray marching algorithms. But the fact that ray marching is so mathematically well-defined is probably why [ExcelTABLE] used it to make a ray traced game in Excel.

Under the hood, the ray marching works by casting a ray out from the camera and measuring its distance from a set of three-dimensional functions. If that distance is below a certain value, this is considered a surface hit. On surface hits, a simple normal shader computes pixel brightness. This is then rendered out by variable formatting in the cells of the spreadsheet.

For those of you following along at home, the tutorial should work just fine in any modern spreadsheet software, including Google Sheets and LibreOffice Calc. It also provides a great explanation of the math and concepts of ray marching, so is worth a read regardless your opinions on Excel’s status as a so-called “programming language.”

This is not the first time we have come across a ray tracing tutorial. If computer graphics are your thing, make sure to check out this ray tracing in a weekend tutorial next!

Thanks [Niklas] for the tip!

A tab-based terminal window is shown, with the label “brow6l – Hackaday.” The Hackaday website is visible in the upper part of the terminal screen, and in the lower part is a text display containing information about the website and interface information.

Terminal-Based Web Browsing With Modern Conveniences

Programmers hold to a wide spectrum of positions on software complexity, from the rare command-line purists to the much more common web app developers, and the two extremes rarely meet. One point of contact, though, might be [Jan Antos]’s Brow6el, which uses sixel graphics to display a fully graphical web browser within a terminal.

Behind the scenes, the Chromium Embedded Framework renders webpages headless, then Brow6el uses libsixel to convert the rendered output image to sixels, a simple kind of console-based graphics representation, which it then outputs to the terminal. It regularly re-renders the page to catch page updates and display them in real time, and it can send mouse or keyboard input back to the webpage. For more advanced work, it also has a JavaScript development console, and it’s possibly to manually inject scripts into rendered webpages, or inject them automatically using URL match patterns. Continue reading “Terminal-Based Web Browsing With Modern Conveniences”