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 homebrew....

November 21, 2022 · John

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 escaping routines. An empty string will no longer cause a failure....

August 28, 2022 · John

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 working on a project where I needed to enumerate USB devices on macOS....

December 6, 2020 · John

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 was failing too in the same way as my application....

November 8, 2020 · John

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 code. While how if statements evaluate segments to most programmers....

October 20, 2020 · John

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 the ability to search....

June 10, 2020 · John

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 that I just didn’t have time for or didn’t like....

May 12, 2020 · John

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 list to have some string specific functionality....

April 22, 2020 · John

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 reallocs and memmoves but that’s going to get old really fast. It’s also error prone and not obvious when growth is needed....

April 9, 2020 · John

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 would be really bad if you passed the wrong type to a hashtable meant for another....

March 28, 2020 · John