Parsing custom datetime format in Rust using serde

Most of the date and time related crates like time or chrono already implement serde traits making date or datetime parsing quite easy. This applies just if the format is standard, but what happens if the format is not standard? Let’s say we want to parse datetime looking like this 2021-10-24T07:48:26.389646Z. There is no timezone information so I decided to try the PrimitiveDateTime type from time crate. I didn’t consider using chrono at the moment because of the RUSTSEC-2020-0159 problem. ...

2021-10-24 · 2 min · Boban Acimovic

Running stack of microservices using docker-compose and acim/go-reflex image

Go is very attractive language for microservices’ development, but using acim/go-reflex image and docker-compose you can run multiple microservices including your gateway on your local machine. This image can run virtually any Go server based application and also reacts on changes in the code and recompiles the binary on the fly. If you want to debug your microservices’ stack or develop a new feature where you have to touch multiple services, this is very good tool to do so. Let’s take a look at the docker-compose stack example: ...

2021-10-23 · 3 min · Boban Acimovic

Parsing JSON in Rust easily explained

Parsing JSON in a proper way requires representing the JSON data in a structured format so that the language can find out which fields have to be parsed and which type they are. The Rust way of representing the structured data are so called structs . We could make appropriate structs manually, but thanks to the great online converter, transform.tools , we can generate the structs very easily. In this article we will parse data from songsterr.com , a web site with guitar tabs. Let’s make the request to their API. Just click here and look at the data in your browser. Scarry? Not really, just copy all data and paste here at the left hand side box. Rust structs should appear on the right side almost immediately. ...

2021-10-20 · 7 min · Boban Acimovic

Firefox audio crackling and popping on Linux Mint

This problem was bugging me for quite a while and today I finally decided to address it. There are lot of advices online to try to run Firefox in safe mode and see if that fixes the problem, so I tried that first but it didn’t help. Safe mode actually just turns off extensions, but in my case it didn’t help. I found out that the easiest way to reproduce the problem was to run YouTube video in one window and after that open another window with eBay. After few seconds crackling and popping always started. I run audio mainly via HDMI to my monitor, but as I have external DAC I decided to try that audio output and yes, it worked without problems. So, it seemed something was wrong with PulseAudio over HDMI. ...

2021-10-02 · 2 min · Boban Acimovic

VSCode setup for Go developers

According to lot of online polls, Visual Studio Code is the most popular IDE among Go developers. You can start Go development immediately after installing Go extension for VSCode, but some tuning may make your life easier. First of all, you may want to format the source code and reorganize imports automatically on each file save or code paste. In order to do so, put the following JSON snippet in your settings.json: ...

2021-03-16 · 2 min · Boban Acimovic

Upcoming Go's generics

In the very early adoption of Go by the open source community, lot of developers already suggested the lack of generics. However, some other claimed that simplicity of Go shouldn’t be compromised by generics. Few days ago, the never ending discussions pro and contra generics are finally over. The proposal is accepted and we can expect generics in Go 1.18 somewhere in spring of 2022. You may wonder why does it take that long, but this is not just about the compiler but also some parts of the standard library may need to be rewritten in order to replace the old code which could benefit from generics. ...

2021-02-26 · 5 min · Boban Acimovic

Go vanity imports

If you have just started learning Go or already developing in Go for quite some time, you may noticed that most of the Go packages are imported directly from their respective VCS repositories, but there are some packages imported from URL’s like golang.org/x/text or go.uber.org/zap . If you try to visit such URL’s, you may see different results like being redirected to documentation or just some dummy page. This is completely different from packages hosted on GitHub, for example github.com/pkg/errors where you can see the real source code. This feature of Go is called vanity imports. ...

2021-02-21 · 2 min · Boban Acimovic

A first impression of Rust from the perspective of a Go developer

In these uncertain times and multiple months of remote work, at least we have some more time to dive into something new. I have been developing in Go since 2017, learned some TypeScript in the meantime, but few days ago I wanted to get into Rust once again. First time, approximately a year ago I gave up very quickly, realizing that Rust requires lot of time to learn and I didn’t have that much time at the moment. ...

2020-12-26 · 3 min · Boban Acimovic

Automated MySQL MariaDB tables optimization in Kubernetes

Kubernetes simplified applications management a lot and this also applies to databases like MySQL/MariaDB, but lot of DevOps forget to apply traditional maintenance and optimization which is still necessary unless you are using some operator capable of doing so. The optimization method that will be described here applies just to single and master-slave replicated MySQL/MariaDB instances. If you run some clustered version like Galera , you probably have to find another way because of possible consistence and performance problems during the eventual optimization. This method would still work but you may have unpredictable consequences. ...

2020-12-26 · 2 min · Boban Acimovic

Run Docker as normal user on Ubuntu 20.04

In lot of instructions how to run docker on Ubuntu 20.04 (same applies to Linux Mint Ulyana) you may find that after installing docker you have to add your user to docker group by the following command: 1 sudo usermod -aG docker $USER If you still get permission errors, you may try to set ACL: 1 sudo setfacl -m user:$USER:rw /var/run/docker.sock

2020-11-17 · 1 min · Boban Acimovic