Gwilym’s blog

Hopefully someone finds something useful here

  • Git rebase like a pro

    I felt a lot like I was fumbling in the dark when using git for the first year or so. Tools like learngitbranching were great for getting me going, but I often felt like I didn’t have as much control over my commits and the history as I would like. And when working in a team, merge conflicts become quite common. The race to be the first to merge the PR so you don’t have to deal with the conflict becomes quite heated.

    Read more…
  • Virtual joystick on Linux

    A few months ago, I built a home made retropie based handheld console built around the raspberry pi 3B+. There probably wasn’t anything too exciting in the build itself (it was made mainly using standard parts with a 3d printed shell). However, I believe the way I got the input working isn’t as well documented as I believe it should be. The end result of this project was a battery powered console that is incredibly uncomfortable to hold, so I’m not going to put together a full build explanation.

    Read more…
  • Grayscale PAL signals

    I was inspired by Ben Eater’s video on the world’s worst video card to make my own. But in order to prove to myself that I fully understood how it worked, I decided to output composite PAL signals rather than VGA. This post is going to explain how composite signals work rather than how my implementation of the world’s even worsterer graphics card works. I live in the UK, so here we use PAL signals rather than NTSC.

    Read more…
  • The C preprocessor is awesome part III

    This is the third part of a 3 part series on why the C preprocessor is awesome and showing you some tricks you should never use. In this part, we’re finally going to implement the TRY, CATCH and FINALLY macros I’ve been promising you since the beginning. In part 1 of this series, we implemented a very nice test harness that let us write unit tests much more simply. In part 2, we implemented a LOCK macro for making it ‘easier’ to use mutexes.

    Read more…
  • The C preprocessor is awesome part II

    This is the second part of a 3 part series on why the C preprocessor is awesome and showing you some tricks you should never use. This part is going to be the shortest, showing off a really simple trick that makes your macros look like actual keywords. But this is a very important section for showing how to implement TRY, CATCH and FINALLY in the final part. In part 1 of this series, we implemented a very nice test harness that let us write unit tests much more simply.

    Read more…
  • The C preprocessor is awesome part I

    Well… It probably isn’t. But in this series of posts, I’m going to walk you through some terrible ideas which somehow vaguely work. None of this is a good idea, but it is fun to push simple text preprocessing and the C programming language to it’s illogical limit. This series of posts was inspired by the crazy definition of ARRAY_SIZE somewhere floating in the Linux kernel source code, which I first became aware of in a post by a friend of mine.

    Read more…