Karlos Nasar in Bahrain 2024
On 11th December 2024, Bulgarian weightlifter Karlos Nasar achieved something extraordinary again by setting two new World Records in the 89kg category: a 183kg Snatch and 405kg Total . It was amazing!
Recent content on A place to gather bits and bytes.
On 11th December 2024, Bulgarian weightlifter Karlos Nasar achieved something extraordinary again by setting two new World Records in the 89kg category: a 183kg Snatch and 405kg Total . It was amazing!
Sometimes Android wireless pairing from Device Manager UI does not work. This may happen because of WIFI network settings, which are not under our control (i.e. co-working space, cafe, hotel). A fix that may work is using the adb CLI commands for manual pairing. Go to phone Settings->Developer Options->Wireless Debugging and click Pair device with pairing code . A dialog shows Pair Code plus…
Install or download yt-dlp Open terminal. MP3 (Audio) 1 yt-dlp --verbose --extract-audio --audio-format mp3 --audio-quality 0 https://www.youtube.com/watch \? v \= 9NbeL4FtcN0 Audio quality is number from 0 (best) to 10 (worst). MP4 (Video) 1 yt-dlp --verbose -S 'res:720' -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best' https://www.youtube.com/watch \? v \= 9NbeL4FtcN0 Works for…
Recently I’ve been working on a small Go library. I wrote unit tests to cover most of the major functionality. I got code coverage 33% And I became suspicious. Why 33%? Because go test -race -coverprofile=coverage.out ./... includes all auto-generated Fake objects used by unit tests in the calculation. Depending on how many and how large the fake objects are, real code coverage is reduced by…
I recently learned an interesting feature in the Goa framework, which we use for some of our services. How can we return a ZIP file which is created by a service function implementation, but also include additional custom headers in the response? Big thanks to one of the Goa creators/contributors Raphael Simon , who helped me with this issue very quickly in the Goa Slack channel ! Encoding bytes…
Imagine you have a struct with some fields which are always there, but you also have some fields which are dynamically populated with different [key, value] pairs, which cannot be described with static types upfront. Example Record 1 2 3 4 5 6 7 type Order struct { ID string `json:'id'` ItemID string `json:'item_id'` Category string `json:'category'` Timestamp int64 `json:'timestamp'` Attributes…
Ebitengine is a Go game development engine. Games can be built for Linux, MacOS, Windows, Android, iOS and Nintendo Switch. I did some basic experiments during a few vacation days. This post is about something which wasn’t obvious to me how to implement and took me some hours to figure out. Hopefully it may spare you some time. Under the hood Ebitengine uses gomobile to create bindings for…
It looks like neither Hyperledger Aries Go framework, nor the Google Tink crypto library, which it uses under the hood, provide helper functions to convert public key bytes to JWK format (or I haven’t found the way). When you export public key bytes from the KSM, they are unmarshalled from their internal representation and serialized using x509.MarshalPKIXPublicKey() , elliptic.Marshal() ,…
We’ve been using go-watcher for local development with docker-compose to automatically rebuild a given service when its source code changes. From Go 1.20+ onwards the go-watcher binary no longer works, because it’s using a build flag -i which has been deprecated for a long time, but now is finally removed. Because of that the compilation fails with error. See it here . The project is…
Display all commit messages since the last tag: 1 git log --no-merges --oneline --format = %s $( git describe --tags --abbrev = 0 ) ..HEAD
I have difficulties using the Vault dev server mode in docker-compose environment. Other people have difficulties too . Partly it’s due to incomplete/imperfect Vault documentation. I had to skim through the source code to understand what parameters can be used for some commands and for the dev server itself. Some of these were hard to find in the documentation. Objective I want Vault running…
Hashicorp Vault Transit Engine API allows signing of data and verification of signatures. It offers more features like encryption/decryption, hashing, random bytes generation, but in this post we’re concerned only with the signing part of the API and more specifically with converting public keys returned by the Vault API to JWK format. Example response when fetching a public key from Vault:…
git reflog is underrated .
I sometimes see people who use private Gitlab subgroups to name their Go modules (mostly libraries) with a suffix .git Let’s see an example. If we have a Go module project at the following imaginary location: 1 https://gitlab.com/myuser/foogroup/barlib Now when running go get gitlab.com/myuser/foogroup/barlib from another Go project, even though the SSH keys are set correctly, we may get an…
In some situations it’s not obvious how to use the RETURNING SQL clause with Gorm and databases that support it, like CockroachDB. The particular use case where I found it challenging is the following: I want to update multiple records with a WHERE clause, ORDER BY clause and LIMIT clause and immediately return the updated records without a second query. The simplified CockroachDB table…
A simple Go implementation for graceful shutdown of HTTP servers with Go 1.8+ wrapped in ~20 lines of code. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 func main () { srv := & http.Server{ Addr: ':8080' , Handler: http. HandlerFunc ( func (w http.ResponseWriter, r * http.Request) { time. Sleep ( 5 * time.Second) _, _ = w. Write ([]…
Example for running unit tests with coverage output 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 image : golang:1.16 stages : - test before_script : - ln -s /builds /go/src/gitlab.com - cd /go/src/gitlab.com/${CI_PROJECT_PATH} unit tests : stage : test script : - go version - go test -race $(go list ./... | grep -v /vendor/) -coverprofile=coverage.out - go tool cover -func=coverage.out
Should we commit vendor in our Go projects? Since the introduction of Go modules, the prevalent opinion on the internet is that we should not commit the vendor directory of our projects. The argument against committing vendor is that it’s unnecessary, because the Go tools can resolve and find dependencies when needed on-the-fly. All public Go modules are also hosted by various Go Proxy…
If we want to preserve (pass) the command line arguments when running a bash script and pass them to a program defined in the script, we can use the $* pattern after the call. An example bash script called myscript.sh is shown below. It sets some environment variables (optional) and starts a program called myserver . The program will accept all command line args passed to the bash script as if…
A place to gather bits and bytes. Built with Hugo .