PiFi: The poorman's Ethernet-to-WiFi adapter

Recently I had a need to perform some reasonably in depth traffic shaping and monitoring for one of my desktop systems under a variety of software configurations. Ordinarily I would have broadened my knowledge of iptables/nftables a little and done the processing under my usual Linux setup. However in this case I needed to analysis traffic from my Windows installation as well. Fortuitously I had a ‘spare’ Raspberry Pi 3 laying about which I could draft into service as an overly complicated, though intelligent, wireless adapter.

Edict.20170915

This fortnight saw a lot of Vulkan experimentation and further work towards consistent vertex buffer handling in asset loading and dynamic geometry generators. Vulkan Delving into Vulkan for a week was interesting, but very intimidating. There are an amazing number of concepts that need to be chained together to accomplish even a simple “Hello World”. While I can understand the rationale it was a shock to discover that swapchains, a feature I take for granted in OpenGL, aren’t even a core API.

Functional Style Preprocessor Macros

The C preprocessor has a deservedly poor reputation as a means to define function-like code. However there aren’t many guaranteed alternatives for trivial code generation without resorting to external tools. I’ve been making use of it for some time to iterate over lists of types when manually instantiating templates, defining enum-to-string conversions, and some trivial (but tedious) free functions. Implementing a map function over lists of tokens using only the preprocessor is a neat way to simplify this whole process.

Edict.20170904

The bulk of this weeks work focused on integration of game logic with the render libraries, chasing up toolchain issues, and investigating an OpenGL state management bug. I’m still well and truely focussed on fairly dry technical and internal development details here. Simluation reintegration We’re now back to the point where we can perform terrain picking and basic zone management, but with the newer and more performant render infrastructure (as opposed to the original OpenGL 1.

Linux swap over loopback devices

Some Linux filesystems do not natively support swapfiles as they do not implement the required kernel calls or are unable to do so. Notable amongst this list of filesystem is btrfs, whose snapshot functionality I use to streamline my backup system. Unfortunately, some systems I maintain have a chronic lack of RAM and require a swapfile to complete some long running operations. As a workaround it is possible to create a loopback device from a file, which one can then pass to the kernel as a swap device.

Gentoo pkg-config and cross-compilation

A note to myself (given that I’ve solved this issue a few times now). If you’re attempting to cross-compile under Gentoo, and are using pkg-config, certain functionality will be silently disabled. Of particular note for my purposes is PKG_CONFIG_PATH, which I use as part of my autotools sub-package strategy. There is no point filing bugs for this issue as the maintainers have made it explicit that this is deliberate and no patches will be accepted.

Debugging with Library Interposition

At some point when debugging one will encounter a scenario where it is desirable to modify or observe an application’s interaction with an external library (or the system). Various techniques are available, but few are quite as straightforward as `library interposition’: the practice of overriding references to symbols from one library with another library at executable load-time. To dramatically simplify the relevant process: when an application is being prepared to execute, the executable loader will extract from the target executable an ordered list of required symbols and an ordered list of requested libraries.

KVM and WiFi

When developing cross-platform code, testing is critical. Access to various families of operating systems will allow rapid identification of (some) inadvertent platform specific assumptions. While there are some public testing services, like Travis CI, you will inevitably need to test locally at some point. I use a set of small virtual machines on my development machine for this. I could use Xen or VirtualBox, but I am happier with KVM/QEMU in my particular environment.

Cross platform unit testing with Wine and Autotools

My current project targets the Windows and Linux operating systems. Development is primarily under Linux and uses the Autotools build system. Windows binaries are generated with the mingw cross compilers. This setup isn’t for everyone, but it suits me quite well. For my testing needs I use Automake’s simple builtin test harness and the simple TAP driver. Automake will add Makefile targets for each executable listed in TESTS. The LOG_DRIVER command will be used to generate test logs and test statuses using any LOG_COMPILER wrapper provided.

Coherent Noise Generation: First Principles

Randomness plays a key roll in many graphics and simulation techniques. Variations in behaviour can make simulations feel more alive. Randomised worlds can keep exploration alive in games. Often a simple call to your language’s equivalent to rand for will suffice; perhaps modified by a non-uniform distribution. But what if we wanted a smooth transition between generated values? A function of position? Infinite and tilable but non-repeating patterns? These properties can be satisfied by a ‘coherent noise’ function which maps an n-dimensional vector to a single value.

Bitcoin Exchange API Observations

A new project has prompted me to investigate the trading APIs belonging to a number of Bitcoin exchanges. It’s been a fun few weeks and I’ve learned a lot about an area I’ve never really watched in the past. Credit has to be given to Vault of Satoshi and justcoin for having particularly well behaved APIs (though justcoin does have to be reverse engineered from their trading platform’s source). However, as expected it’s not all been rainbows and unicorns.

Imaging Misconceptions: Resolution

Every few weeks I come across questions on my regular photography forums which indicate a deep misunderstanding of what is actually occuring under the hood of some popular piece of imaging software. The most common misconception I see is that a photographic image has an inate physical size, or DPI. The graphical part of a photographic image is comprised of a grid of pixels; samples of light taken regularly across the dimensions of the image sensor.

Comparing Photographic Lens Weights

As part of a current project I have access to (mostly complete) metadata on over 200 lenses across a range of consumer vendors. As part of a test to visualise discrepencies in the collected data I managed to construct a few plots of basic metadata over focal length. As a quick preview to a future longer analysis I’ve thrown in the initial plot of lens weight vs. minimum focal length below.

Improving Linux Font Rendering

After spending the better part of a day reinstalling my operating system (protip: don’t uninstall your system compiler if you’re running a source based distro), I finally got my system back to the point where I had a browser and email. Immediately the text rendering in Chromium stood out as particularly poor. I’ve seen similar issues before where poorly spaced, uneven strokes, or changing line spaces have indicated errors from misconfigured modelines with ye olde CRT, or mismatched sub-pixel rendering on modern LCDs.

Ideal Daemon Configuration Files

If you’re thinking of writing a daemon that has anything in the way of configuration files I implore you to consider a small amount of implementation effort for an ‘include’ directive. This simple addition may not seem like a great deal for yourself, but it will undoubtedly go a long way to easing some poor sysop’s life. An annoying example from the postfix documentation: Is there some kind of ‘include’ directive for main.

Serving XHTML5 with Rails and HAML

After spending a few hours wrestling with the latest web-software I inflicted upon myself, it occured to me I’d best write instructions to my future self for reconfiguring this mess. For reasons that are irrelevant to this article I need to generate XHTML, and would prefer to generate an HTML5 variant (yes, I know this doesn’t officially exist). Rails appears to conflate the HTML and XHTML content-types. So we remove the existing HTML content-type and re-register those for HTML and XHTML.