I'm Nicolas, Software Engineer based in Zurich.
Here you'll find some articles, videos and projects related to what I like: build systems, functional programming, making web apps, and more.
From a software perspective, embedded graphics are slow going: hunt down a microcontroller and display, wire them up, and for every small change flash the board and wait for it to reboot. But modern terminals can render images, so we can now skip the hardware shuffle and iterate right in the terminal!
Recently I needed to access my LUKS-encrypted, ext4 drives from a MacBook. This can come in handy in a few situations — future-proofing backups, needing to access Linux drives in a pinch while the NAS is down, etc — so here's a quick playbook for my future self and others in the same position!
LUKS
ext4
I acquired a second-hand label printer. I did not want to install any proprietary drivers. So I set up a Raspberry Pi Zero with WiFi and installed ImageMagick and Python with Nix to print labels remotely.
This article explores how to reproduce an iPhone animation I really liked, using WebGL and GLSL shaders. We'll dive into several foundational concepts in graphics programming: writing simple fragment shaders, leveraging symmetry for shader performance, and compositing with transparency.
This is a mini-release for Skapa, an app I made for generating 3D-printable models for IKEA Skadis pegboards. This post goes through some of the UI & UX decisions and gives an overview of the tech used for model generation and rendering (with Three.js).
Without HTTPS, credentials like Basic Auth are ineffective for security as they can be intercepted by any device on the network. This guide explains how to set up HTTPS for a Raspberry Pi using Let's Encrypt and nginx, with PrusaLink as an example. This setup works without exposing the Raspberry Pi to the internet.
WebGL shaders rendered to canvas elements are a great way to add interesting visuals to a website. Unfortunately, unlike HTML, they do not natively integrate with CSS. This post shows a way to work around this limitation and influence WebGL graphics from CSS.
canvas
Boilerplate for creating WebGL-based applications using Vite and TypeScript. Whether you're just getting started with WebGL or looking for a quick way to bootstrap your shader projects, this template should serve as a solid foundation.
If someone is reading a particular article you wrote, chances are they'll be interested in other, similar articles! This is an overview of how I suggest similar articles at the end of every article on my website, automatically.
Once a year or so I need to build GCC. And every year I wish I had notes from the year before. This is my cheatsheet on the GNU Build System, build/host/target platforms, pkg-config, and gcc building.
pkg-config
gcc
I recently needed to package a JavaScript npm project with Nix. This is very simple to do and does not require any ugly workarounds like importing from derivation or generating Nix files and works just fine with sandboxed builds. Here's the general idea and an example.
Today I needed a way to prevent my Mac from going to sleep while downloading a big file. Turns out macOS has a convenient utility called caffeinate that helps keep your Mac awake.
caffeinate
I was recently faced with the following problem: How do you resize a rotated HTML element by dragging a corner, without the rest of the element moving? This turns out to be non-trivial, but I finally got to write some JavaScript and open my Linear Algebra toolbox.
In October 2019 I gave a talk at NixCon in Brno about the various approaches for language support in Nix. Here's the video!
A coworker recently asked me to compile a list of licenses used at runtime by some of our build products. Most nixpkgs derivations have a bunch of metadata associated with them, why not use that? Turns out it's not that trivial.
nixpkgs
I wake up every Tuesday to several Pull Requests on my GitHub repositories. Those PRs are triggered automatically and update my repositories' dependencies. By the time I get to the office, they're merged. For this I use CircleCI's scheduled builds, Nix and niv.
I describe five of the reasons why I think tests are important:
This is a convention for using third-party packages in Nix. It has a simple directory structure, whick makes using the packages straightforward, and makes automated package updates super simple.
I discuss a few reasons why catching bugs in master is more expensive than before they are merged, try to explain why some people think this isn't true, and talk a bit about merge queues.
This library provides a thin wrapper around the wreq library (a simple HTTP client library). It is meant to be used with Jupyter: all requests will be stored on disk and served from the cache subsequently, even if your kernel gets restarted. The cache lookups are near-instantaneous thanks to the amazing LevelDB library. You can use cio just like you would wreq -- instead of importing Network.Wreq, import CIO (which stands for Cached IO):
cio
wreq
Network.Wreq
CIO
This is a hack practical trick for creating directories based on test names using the Haskell test framework tasty, as well as accessing the test names inside your tasty tests themselves.
This post describes how I set up a reproducible development environment in a few seconds on any Linux distribution (and potentially macOS as well). This setup includes simple executables (curl, git) but also programs with custom configurations and dotfiles (vim, tmux). The Nix language is used to describe the system configuration, which you can find on GitHub and follow along.
vim
tmux
Last Tuesday I gave a 30 minute talk about building and packaging a webapp using functional-programming tools at the Web Zürich September Session. It's a short introduction to using Haskell's servant and reflex libraries for writing a webapp (using GHC and GHCJS). The webapp is packaged with the Nix package manager. It was a nice adventure discovering about reflex, servant-reflex and Nix' quirks... big thanks to zimbatm for helping out.
I'm going to introduce stutter, a command line tool for generating strings. I'll first show some examples, then talk a bit about the performance and finally about the implementation (for the Haskell friendly reader).
stutter
I've just released a new version of makefile, the Haskell library for parsing and generating Makefiles. The new version is available on hackage and on stackage. The code is available on github.
makefile
A few days ago I found myself with two terabytes' worth of my personal data encrypted but only half of a password. Here are notes from the adventure.
Last week a friend of mine asked me how I would implement the game 2048 in Java (at least the update logic). It is actually a problem that can be solved elegantly in Haskell using a few Isos and Traversals.
In order to warm up for a round of interviews next week, I've been playing around with coding puzzles. Those are usually solved using imperative languages, and I thought I'd have a go at them using Haskell. I'll share today's experience, which hopefully will convince you that purely functional languages are (sometimes) suitable for puzzles.
DNA. Everybody knows that DNA is the blueprint by which our cells replicate. Everybody knows that Horatio Caine uses it to catch bad guys. But... what if we used DNA to build supercomputers? That is definitely science-fiction... or is it? As I was working on DNA computing, I got my fair share of people staring at me like I was crazy. Someone even asked me if I could find a way to take a bird's DNA to grow an optimal plane out of it. I thought I would demystify it a bit.