Notes on software development
Some notes, articles and tutorials on software development. It's a mishmash of topics. The thing they have in common is that at some point I was figuring out a problem on a computer or a phone and I wished that the internet would provide me with this info in a blog post.
Maybe a search engine picks them up and someone else can save a bit of time.
-
Simple CI/CD wih bash and git
To do so, add a post-receive script in the hooks folder on the repository on the server:...
-
Faster transfers between go services with ndjson
A lot of services have the job to query other services for data and the most straightforward way to do that is to use JSON over a REST API. If the data consists of a big list of things, that means sending over a large JSON array with objects....
-
Cgit and go modules
Recently I started to self host my public git repositories on git.ewintr.nl. There are several options to choose from if you want that sort of thing, like Gitea or Gogs and others. These all look like fine applications, but they all try to imitate the big hosted platforms like Github and GitLab. They...
-
Depend less on dependencies with the adapter pattern in go
The package management in Go is pretty convenient. Just run go get and you have another nice library installed on your computer. Just for you to use, saving you hours of developing end debugging the functionality yourself. But there is a downside to it, apart from the fact that downloading and...
-
Json structured logging with nginx
After writing my tutorial on analysis of JSON structured logs on the command line I realized I could apply the same solution for website statistics. If only I could make Nginx to log in the same format....
-
My default go directory structure
Go is very flexible and there are a lot of ways one can set up a project. Files can be placed anywhere and there are very few rules on what packages one can import. People like having certain rules and conventions though, because once a best way to do something is figured out, it saves time to encode...
-
Simple log file analysis for your kubernetes pods on the command line
Recently at my current job there was a lot of complaining about how terribly slow our instance of Kibana was. We use that, as many teams do, to view and analyse the log files generated by the services that run on our Kubernetes cluster. The root cause was that the logs were simply too large, because...
-
Setting a timeout on go unit tests
There are multiple ways of ensuring that a test suite does not take too long to run. The first is simply by setting a timeout as an option with the go test command:...
-
Channel with infinite buffer in go
In Golang we have buffered and unbuffered channels. Buffered channels can hold an x amount of values "in transit" before the channel is blocked from writing. It is necessary to read a value from the other end first, to "make room", before more can be put in. That amount x has to be specified and is...
-
Address book in aerc with khard
In line with the Unix philosophy, Aerc does not implement any feature to store mail addresses of contacts. Instead it has an option to retrieve them from an external address book. I already synced my contacts together with my calendar items through Vdirsyncer and Radicale, but this was more for...
-
Conversions with iota in go
iota is a helpful way to enumerate constants in Go:...
-
Wait-for script
Docker-compose has the option of making a container depend on another container, so it will not start the former before the latter is running. This is useful for containers with applications that need other infrastructure, for instance a database, present. The common problem with this is that...
-
Ldap basics for go developers
Recently I needed to prepare a Go application to accept LDAP as a form of authentication. Knowing absolutely nothing about LDAP, I researched the topic a bit first and I thought it would be helpful to summarize my findings so far....
-
Basic pomodoro timer in bash with termdown and wmctrl
Like many other systems that aim to add some structure in the chaos of todo-items that we all struggle with, the Pomodoro Technique has some good parts and ideas, but one must be careful not to drive it to far. Neither by forcing every life problem in the system (if all you have is hammer...), nor by...
-
Hugo markdownify block workaround
Like other static site generators, Hugo has an option to pass markdown content though a markdown processor to interpret it and convert it to HTML. Also, like other generators, this has the incredibly confusing name markdownify, as the end result would be something that is converted into markdown,...
-
Shared environment variables for make, bash and docker
It is possible to define a set of variables and share them in Make, Bash and the Docker containers that are orchestrated by docker-compose. ...
-
Job control in bash scripts
One should be careful when considering an option like this. Sending processes to the background in a script, are you sure this is what you want?...
-
Basic caching headers in nginx
To add basic caching headers for different filetypes, add an expires directive to your nginx config file, like this:...
-
Quick go test cycle with reflex
While you are working on some piece of code, it is nice to have some feedback about whether you broke or fixed something by running the relevant unit tests. To automate this I usually have a terminal window open with the following command:...