/images/p1.jpg

Hi, I'm Tomasz

I'm a professional C++ software engineer with over a decade of hands on development experience with variety of technologies (mostly Linux & embedded systems). This is my blog.

Find me on social media

Nix is to C++ what uv/poetry is to Python

The topic of dependencies management is coming back and again. nix and nixpkgs being a rich repository, provides a convenient way to manage both project dependencies and related tooling in a reproducible way. This is something I’m finding more and more useful as a fundamental development tool. nix is quite complex and some exploration is needed to wrap your head around it. In this post, I’m going through most basic use cases as well as describe some basics of nix language itself - mainly for my own reference but hopefully useful to others as well.

Using lua as configuration parser

The more opportunity I have to work with lua, the bigger fan of it I become. It’s a great, well designed language which is very easy to embed.

I’ve been recently working on a small utility for myself. There’s always a problem of handling configuration in such projects. Usually, I’m going for a simple json or yaml or toml file which acts purely as key-value store but this time around I wanted to try something different.

GNU's twist on ternary operator

I was recently browsing the kernel code in attempts to understand some of the weird kernel errors I see in dmesg on one of my machines.

I was a bit surprised to see an interesting syntax I have never seen before. In the following code:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
static int ucsi_run_command(struct ucsi *ucsi, u64 command, u32 *cci,
			    void *data, size_t size, bool conn_ack)
{
    ...
	/*
	 * Don't ACK connection change if there was an error.
	 */
	ret = ucsi_acknowledge(ucsi, err ? false : conn_ack);
	if (ret)
		return ret;

	return err ?: UCSI_CCI_LENGTH(*cci);
}

(Excerpt from ucsi usb code)