RSSAmplifier

Blog

John's Blog

Recent content on John's Blog

nachtimwald.comRSS feed ↗300 posts

Latest posts

Using AI with erings

Introduction As I’ve been working on my Sega Saturn emulator erings , I started thinking about how exactly I’m using AI to help with development. Especially with wanting to keep it as close to a clean room implementation as I can. I’m making sure everything is either documentation based or from tracing I’ve done and never letting it autonomously read source code from other…

Chip-8 Dev Challenge: Sound Revisited

Introduction Last year I wrote about generating XO-Chip sound and the challenges it creates. Specifically, taking a 128 bit pattern of 1’s and 0’s and turning that into a sound wave. However, that post only went into detail of the audio pattern. Recently I was updating Chipped-8 and optimizing sound was one of my areas of focus. In addition to optimization I wanted to fix a few bugs and annoyances…

Chipped 8 Now With a Cached Interpreter

Introduction I decided to pick up Chipped 8 again so I could learn more about interpreter design. Specifically, cached interpreters. Since I already have a Chip-8 emulator, it was the perfect way to get into the subject. When I first made Chipped 8, the interpreter for the CPU instructions was written as a pure interpreter: the standard read, analyze, execute loop. I knew that pure interpreters…

Packaging with PyInstaller

Introduction Not to long ago I needed to deploy a simple Python app I had written on a Linux server. It was a single file and my first thought was to drop the file on the server, but it needed some dependencies. Not a big deal, or so I thought. Putting a single file Python app on a server is typically fine. Just install the deps from the requirements.txt either through the distro package manager…

Zsh Disable History

Introduction There are a number of times when I’m working on something and need to set an API key as an environment variable. I don’t want this recorded in my terminal history because it’s never a good idea to have an API key stored that way. What I end up doing is making a run.zsh file, put the export and then what ever command I plan to run that uses the environment variable.…

Listing Files in Docker Image

Introduction A common problem I run into when containerizing apps is checking the files included in the image. More often than I’d like to admit, the first attempt I end up with files in the wrong location. For example, when I containerized “is it Easter”, I needed to verify all the files were getting added to the correct location. Normally, I’d create an image, then start…

Split Hugo Config

Introduction Recently, I was looking into converting my blog to use hugo modules and saw that hugo supports splitting the configuration file into multiple components. I really liked this idea and decided to give it a try. Splitting the configuration allows setting different options for development and production. This is really handy because while writing new posts I use hugo server and I have to…

KDocker 6.1 Released

KDocker 6.1 has been released! Yet more work has been put into reading the application icon. The latest issue was the icon being completely blank. I tweaked reading the icon and reworked the fallback. Additionally, I put a check in place to ensure an icon is only used when 10% or more is opaque. That way the fallback icon will be tried or the default icon not found icon will be used. This should…

KDocker Reflections and What's After 6.0

Introduction KDocker 6 is now out and I want to take some time to reflect and think about what the future has in store for it. Random reflections KDocker was started 20 years ago in 2004. I took over in 2009 and have been running the project for the past 15 years and I never thought I’d be part of it for so long. At that time I was heavily using the application and when the original author…

KDocker 6.0 Released

Introduction It’s finally here, KDocker 6.0 . It’s the biggest since release ever and packs in every one of my wishlist features. While there are a lot of changes, I want to talk about a few of the more important and interesting ones. Updates First and foremost, it’s been updated for Qt 6. KDocker’s major versioning since 4.0 has followed the major Qt version it uses. With…

KDocker 5.5 Released

It’s been quite a while since the last KDocker release but, here we are with a new release! In this release reading the window icon has been changed to make those pesky ‘?’ icons less likely. The source code for this release can be found here . This is the last planned 5 series release before 6.0 is out. More on this in the future.

Using Hugo Modules

Introduction A little less than a year ago I switched to hugo for my blog and I’m still liking it. Since hugo did everything I wanted out of the box, I didn’t look into how third party components work. Aside from themes. Recently, I wanted to update the robots.txt file to disallow known AI scrappers. Why is for another post. I started by looking at adding known user agents to the file…

Packaging Flask App as a Wheel

Introduction Deployment is an issue I’m having with “is it Easter”. I was deploying by getting a zip of the project from GitHub, extracting and copying the folder to the server. I’d then have to copy files into the app directory as well as create the instance folder for the config file. This is a very cumbersome process and error prone. While I do have a Dockerfile and can…

Making "is it Easter" Multilingual

Introduction In the world of software, no project is ever truly complete and “ is it Easter ” is no exception. After having the site live for a few weeks, I thought about what more I could do with it. There is still more I want to learn about web development and I decided to make the app support multiple languages. Which turned out to be straightforward and relatively easy. Exactly why…

Is it Easter?

Introduction Easter passed by not to long ago and I found out that Easter day is determined by the phase of the moon. I think this is really interesting and the Wikipedia page has a lot of information. It also has an algorithm that lets you calculate the day of Easter. I wanted to do something with this and I ended up making a web app that will tell you if it’s Easter. I was planning to…

Chip-8 Dev Challenge: Frame Rate

Introduction Chip-8 runs at 60 fps (frames per second) and it’s very important to maintain this frame rate. Unlike modern systems, the sound and delay timers are tied to the frame rate. If the frame rate is too fast or too slow, the timing within apps will be off. Also, some apps will time off of the VSync (vertical synchronization). Making the frame rate even more important. I tried…

Chip-8 Dev Challenge: Sound

Introduction Sound in Chip-8 is very easy. If the sound timer isn’t 0, play a tone. While this isn’t difficult, XO-chip adds another level of complexity. It uses a 16 byte pattern buffer with an associated pitch in order to create unique tones which can change per frame. Thus, XO-Chip can create basic music with it’s expanded audio . XO-Chip Audio This was by far the hardest…

I Made a Chip-8 Emulator

Introduction I’ve been following game console emulation for a long time and I decided I wanted to learn more. Specifically, the hardware aspect because I have no experience with how chips work. In order to learn more, I decided to write an emulator for a simple system. I originally thought NES but that is more complex than was realistic for me. Next, I thought of the Atari 2600 but even that…

Optimizing Docker Container Image Size

Introduction When I was containerizing my blog search service , I went through multiple iterations of the Dockerfile as I was learning how to create an image. Containerizing was easy but I wanted to create a small and efficient image and that process was a bit more involved than I expected. I want to go into a little detail about what I learned about writing a Dockerfile that puts importance on…

Updating Blog Full Text Search

Introduction A few years ago I switched from WordPress to Jekyll and I lost full text search. But then I remembered I’m hosting my blog on my own server! So I wrote a Full Text Search service to restore the only feature I lost in the transition. This was working great until I moved from Jekyll to Hugo . The search Javascript needed a slight tweak but otherwise search was still working.…

A Better Vaultwarden Deployment

Introduction Earlier this year I looked at switching from Bitwarden (online service) to self hosting Vaultwarden . The post I wrote was fairly high level and focused on different container options. It was a fairly generic deployment that didn’t go into much detail. Configuration and security considerations were woefully neglected in that post. It also didn’t go into detail about how…

Switching from NGINX to Caddy

Introduction My go to web server has always been NGINX and it’s been my default choice since I started this blog. Any time I need a web server it’s without question NGINX. That is until recently. I’ve been playing around with containerization and specifically making my vaultwarden deployment better. But that’s for another post. As I was looking into this, the Caddy web…

Moving from Jekyll to Hugo

Introduction I needed to update some pages on my blog and while looking at it, it feels a bit stale. The site design hasn’t really changed in nearly 15 years. The only real update was in 2019, when I switched from WordPress to Jekyll . They were minor changes and made to accommodate moving to Jekyll. Otherwise, this blog has looked and acted essentially the same for all these years. Wanting…

Automating DNS Adblocking

Introduction A few months ago I setup a private DNS resolver with ad blocking . At that time I decided to manually update the block file whenever I installed server updates. This works, but it very quickly became tedious. I’m not sure why I initially thought it wouldn’t. I’ve since decided to automate the process. Block File Script The previous script I wrote would download a…

Linode vs DigitalOcean

Introduction For about the past 14 years I’ve been using Linode as my preferred personal VPS provider. I started using them at the beginning of November 2008 when I first setup my blog . Other than a short and painful mistake of hosting my blog elsewhere, it has lived on Linode. Recently I had to setup a VPS with DigitalOcean. This was due to needing the VPS in a data center located in a…

Vaultwarden a Self Hosted Password Vault

Introduction When Lastpass first came on the scene I jumped on it because of how easy it makes syncing passwords between devices. Previously, I was using a local password manager that was only on my computer. Thankfully, mobile logins weren’t nearly as necessary for daily life back then. However, I still needed my computer to log into anything on my phone. Over the years, Lastpass started…

Setting up a Private DNS with adblocking

Introduction Recently I setup a VPN to so I could get around geo-restrictions for for a specific streaming service I’m using. So far it’s been working well. Now that I have the server, I started thinking about what else I could do with it. One thing that jumped out at me is DNS. I configured my WireGuard client connections to use CloudFlare and fallback to Google’s DNS servers.…

My VPN Experience

Introduction I was recommended some videos and I’ve been very interested to watch them. However they’re not available outside of a specific country due to geographic restrictions. This is a common problem and pretty much every commercial VPN service advertises this as a major reason to use their VPN. So I embarked on what should have been a simple journey. Sign up for a VPN, choose an…

Restic Backup

Introduction Since 2017 I was using SpiderOak for backups of my laptop. While the service has gotten better since I first tried them, they still have some issues which kept me looking for alternative . I was using SpiderOak because they are one of the only all in one solutions that allow local encryption and specifying what directories to backup. This is a must for me because I don’t want my…

CSO Compression and Decompression Tool

Introduction I have a number of backed up ISO files that were taking up quite a bit of space. I wanted to save some space and I decided to compress them. Instead of putting them into something like a ZIP archive, I decided that compressing into CSO would be the most usable option. Sadly, there is a lack of CSO compression and decompression tools that can be easily installed using something like…

Lua Template Engine Yet Again

Introduction After writing a template engine in Lua, I found some deficiencies and wrote a few more iterations . After having used the template engine for quite a while, I’ve made a few enhancements and some fixes. This is hopefully the final version of the template engine. Newest Engine This engine is an iteration of the previous template_engine3.lua . The differences are: Bug fixes for…

macOS USB Enumeration in C

Introduction Apple provides documentation for using IOKit, but it’s not very clear how to do a number of things. Descriptions and relationships of functions often isn’t clear. While there are examples, they tend to be lacking. The generic types IOKit uses doesn’t help either because you could have multiple different types of hardware sharing the same device object type. I was…

macOS IOHIDManager Permission Issue

Introduction The other day I was working with a USB-HID device and I thought my machine was starting to act funny. I could use the device no problem in a Windows VM but whenever my application tried to use the device, it was unable to open it. At this point I know the device is good and my machine should be fine but the device was unusable. I tried other software to just inspect the device and it…

C if Statement Evaluation

Introduction One of the bad things that the C language allows is setting variables and calling functions directly in an if statement. This should be avoided due to how the statement can exit early stopping some of the logic from happening. That said, this can also be abused to write more compact code. Not that you should do this because it’s better to have maintainable, rather than clever…

Full Text Search with Jekyll

Introduction When I switched from WordPress to Jekyll I gave up searching posts. I knew this was a limitation of running a static site and I didn’t think it would be too big a deal. After a year I’ve found I actually look up some old reference posts just enough that search to be useful. Trying to remember which tags given posts use became a bit of an annoyance. I really started to miss…

Making and Using C plugins

Introduction No app is ever complete and you’ll never get to the point where users stop asking for new features. Sometimes those feature are low priorities so you’ll never get to them or they’re inane and you’ll never touch the idea with a 10 foot pole. This happened to me when I was working on an ebook editor a number of years ago. There were so many features people wanted…

String List in C

Introduction Currently we have a generic list container which uses void pointers to allow anything to be stored. Previously, we created a type safe string hashtable wrapping the generic hashtable . We want to do the same thing for our list and so now we’re going to create a type safe string list wrapping our generic list. Design Unlike the string hashtable we want to extend the our string…

Generic List in C

Introduction Lists (dynamic arrays) are yet another super useful data structure that C just doesn’t have. C arrays are great for when you can get away with a fixed size but not so fun if you need to dynamically expand because you don’t know quite how many elements you’ll need. You could use a series of realloc s and memmove s but that’s going to get old really fast.…

String Hashtable in C

Introduction We have this amazing generic hashtable and we can put pretty much anything we want into it, but it has a few flaws. It uses void pointers and has a pretty verbose setup with that callback struct . If you’re using the same types over and over again you’ll have a lot of redundant code. There is also a much more pressing issue of void pointers. They remove type safely. It…

Generic Hashtable in C

Introduction So, C doesn’t have a native hashtable object but that’s not a problem because we can use one one someone else wrote. Lack of a robust standard library is probably the biggest impoundments of working with C. It’s a real shame C doesn’t natively support hashtables because they are so versatile. You should keep this saying in mind, “when in doubt hash it…

Formatting Strings for Logging

Introduction I’ve been working on a project, and I needed to add logging to the app. I wanted a log formatting function that can take a prefix and a format string (think a sprintf -type format string but safer). This function needs to be more than just an sprintf knockoff; it also needs to prefix the date and time to the message. Oh, the messages are passed in without a new line, so we need…

Validating Constant Time String Comparison In C

Introduction Awhile back I wrote a constant time string comparison function . I briefly mentioned how the compiler can optimize away some of what makes the function constant time. Specifically, the k++ counter used to balance the increment when the forward scan of s2 stops. The volatile keyword was used in the code to prevent key operations from being removed. What I neglected to go into was…

Python Http Server

Introduction Quite often I find that I need to serve some files for viewing in a web browser. Most recently, I needed to do this with an in progress OpenAPI document as rendered by ReDoc . All I needed was something that can serve static files. I really didn’t want to take the time to setup and configure something like Apache or Nginx. These are overkill for static files on a developer…

Python Self Signed Cert Gen

Introduction Sometimes I need to write a simple network server to emulate an application I’m integrating with. Typically, this is ends up being a throw away Python script that allows me to easily inspect at a request and returns a basic response. It’s handy to verify what I’m sending isn’t malformed. Also, it helps to ensure my response parser is at least somewhat sane. The…

Python Binary to C Header

Introduction Once again I needed to embed some text files into a C application. The right way to do this is turn the data into a byte array and compile it in. At least it’s the most portable way because some compilers have string length limitations. xxd -i is the easiest way to format the data so it can be compiled in. However, just like the last time, I don’t have access to xxd -i .…

Making MiniZip Easier to Use

Introduction Zip files are one of the most popular archive formats out there, and there are a lot of things you can do with them. While working with the ePub ebook format I spent a lot of time working with zip files. Thankfully, the standards committee for ePub used zip as the container format instead of designing their own. If you’ve ever done anything with Android you’ve dealt with…

Read Write File C Helpers

Introduction Reading and writing files in C isn’t as difficult as it sounds. A few simple loops are all you really need. That said, it’s nice to have a few helper functions ready to drop into a project. Before we write anything we need to think about the choice between fopen and open . The major differences are fopen is portable, part of the C standard, and unbuffered. While open is…

Recursive Create Directory in C Revisited

Awhile back I wrote a function to recursively create directories in C. It used a string builder to split the parts and rebuild the path. The way mkdir works is by taking a single directory that does not exist and creates it. If there are multiple path parts that don’t exit it will error. Hence needing to split the string into parts and create each part of the path separately. Earlier parts…

Unsigned Count Down

Introduction Something that comes up surprisingly often is traversing an array backwards. Maybe you’re emptying a queue. How about my personal favorite, reversing the order of elements. Counting in a for loop is so common you just don’t think about it. But counting backwards can lead to issues if you don’t do it right. The Wrong Way When you count down to and include 0 with an…

Lua For Loop Scope

Introduction One odd thing about Lua when compared to other programming languages is, everything is global by default. Take this for example: function func_a () q_var = 7 end func_a() print(q_var) Once func_a is called q_var is available and set to 7 . Even outside of func_a . You can mark a variable or function as local so it’s not global and pretty much anything written in Lua that’s…