Nicolas Mattia

I'm a Software Engineer based in Zurich.
I like functional programming, reproducible builds and "Infrastructure as Code".


Articles


Automatic tag-based article suggestions for blogs and Astro websites

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.

Intro to building GCC and some other GNU projects (focus on macOS & Apple Silicon)

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.

Lockfile trick: Package an npm project with Nix in 20 lines

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.

Keep your Mac awake with caffeinate

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.

Dragging, Resizing and Rotating HTML elements: Fun with Web Components and Math

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.

NixCon Talk: An Overview of Language Support in Nix

Last October I gave a talk at NixCon 2019 in Brno about the various approaches for language support in Nix. Here’s the video!

Recovering Nix derivation attributes of runtime dependencies

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.

Triggered CI Builds: Automatically Update your Project's Dependencies

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.

The 5 Raisons d'Être of Testing

I describe five of the reasons why I think tests are important:

  • Ensure that the code you’ve written works.
  • Ensure that the code you’ve written works tomorrow.
  • Ensure that the code you’ve written works elsewhere.
  • Spot usability issues early on.
  • Show how your feature is supposed to work, and how it should be used.

Easy Peasy Nix Versions

This is a convention for using third-party packages in Nix. It has a simple directory structure, makes using the packages straightforward and automatizes updates.

Hunt bugs down before they are merged!

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.

cio: cached HTTP requests for a smooth Jupyter experience!

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):

Automatically generated directories for individual tasty tests

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.

Nix: A Reproducible Setup for Linux and macOS

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.

A Fully Functional, Fully Functional Webapp

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.

Stutter: the anti-grep

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

Haskell makefile library

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.

Recovering forgotten passwords with stutter and GNU parallel

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.

Lens and Linear, 2048's logic in 22 lines

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.

Puzzle solving in Haskell

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.

Parallel Computing with DNA

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.