Shell Is Underrated

Essential unix skill

How much time do you spend at the command line? Most programmers say they are very comfortable there. Most also say they are good shell programmers. Shell programming is quirky, and not particularly elegant. Yet it is both universally available under unix and extremely powerful. Programming in shell is an easy way to cobble together simple experimental programs, especially if you master the art of unix filters. Sadly, very few people are competent shell programmers. [Read More]

Terraform count vs. for_each

Don't count on it

Terraform has two mechanisms for provisioning multiple resources (and modules since version 0.13): count and for_each. The count feature predates for_each. Now that for_each is available, there is no reason to use count. The Terraform documentation says “If your instances are almost identical, count is appropriate. If some of their arguments need distinct values that can’t be directly derived from an integer, it’s safer to use for_each.” This is bad advice. [Read More]

What Do You Mean Atomically?

Know your filesystem

Once I worked on a project whose origin predated the widespread use of DNS. They used /etc/hosts files to map host names to IP addresses. This system had grown to thousands of hosts, and the /etc/hosts file was about 1M in size. After any update, which was handled by a sysadmin, they pushed this file to all production hosts. “Wow! You update those files atomically when you push, right?” I asked the sysadmin. [Read More]

From Zero to Tom Lane

Safety in constraints

The PostgreSQL documentation has this to say in the context of constraints: The NOT NULL constraint has an inverse: the NULL constraint. This does not mean that the column must be null, which would surely be useless. Instead, this simply selects the default behavior that the column might be null. The NULL constraint is not present in the SQL standard and should not be used in portable applications. Of course the description of the NULL constraint is correct, however requiring that a column must be null does in fact have utility! [Read More]

JavaScript Question Zero

How are numbers stored?

What does .1 + .2 equal? Easy math problem, the answer is .3 no problem, right? Well, not quite. In the magical land of JavaScript, .1 + .2 = 0.30000000000000004, because obviously. This was actually the first thing I learned about JavaScript, my first intro to the language being a lengthy conversation about all the worst things in the language (glances at the this keyword). But, back to math… why doesn’t . [Read More]

Terraform Modules as Functions

Using no-resource modules to build config maps

How do you create user-defined functions in Terraform? The definition of a module in terraform resembles that of a function with side effects implemented through resources. We use zero-resource modules as Terraform functions. Below is a simple example use of for_each_slice taking input from var.config.hosts. For each element in the input map it slices out the corresponding value the named keys, throwing an error for missing keys or keys that fail a requirement, such as being a non-empty string. [Read More]

The GraphQL Test

How are your GraphQL skills?

This is a simple test designed to evaluate your GraphQL skills. GraphQL is a key technology here at Vertalo and one that we make heavy use of. We expect candidates that we consider to have real-world, professional experience with GraphQL (or have a firm grasp of it through their own side-projects). So with that, on to the test… Using the following info: GraphQL endpoint: API key: da2-xjxr3thnwzd4jido2afokc3hcu The endpoint uses basic API key authorization …do the following: [Read More]

Unix Filters

A powerful building block

What is a unix filter? A unix filter is a program that reads data from standard input, writes data to standard output, and logs to standard error. (Some definitions do not include logging to standard error — YMMV.) Anyone who has spent time on the command line in a terminal has worked with unix filters. Questions What makes the unix filter a powerful concept for processing data? What cool things have you done with unix filters? [Read More]