"Life is all about sharing. If we are good at something, pass it on." - Mary Berry

How to create snippets in Helix?

2023-07-31

Helix currently does not support snippets. However, there is a workaround to insert snippets using :insert-output to run a shell command. Still, this might not feel like the most natural way to work with snippets.

For instance, in GoLand, a similar feature called live templates allows you to type err and expand it into the following:

1if err != nil {
2  
3}

I wonder if I can archieve the same functionality in Helix by creating a simple language server

Read More...


A terminal UI for Taskwarrior

2023-04-21

When I first started using Linux, I came across Taskwarrior, a command line tool for managing to-do lists. However, I never got around to using it extensively, mainly because there was no Android app available at the time, making it difficult to sync tasks from my phone.

I did experiment with taskwarrior-pomodoro but unfortunately, it wasn’t as effective as I had hoped.

Recently, though, I stumbled upon foreground, a new discovery that reignited my interest in Taskwarrior,

Read More...


A simple terminal UI for ChatGPT

2023-04-01

When I started learning Linux, I immediately fell in love with the terminal. I still remember the feeling of typing commands into the terminal, pressing Enter and seeing if I got the expected result. As a system administrator and DevOps engineer, I always wanted to do everything on the terminal.

The reasons are simple: it allowed me know what was happening behind the scenes, and it was faster than switching to other tools, and then back to the terminal to continue working.

Read More...


Learning how to code

2023-01-09

If you find yourself doing the same task repeatedly, consider learning how to code.

For instance, a friend of mine had to perform the following tasks on daily basis:

Here’s the code that I assisted him with: https://github.com/quantonganh/ims

The initial steps can be done by using chromedp.

Read More...


gocloud - writing data to a bucket: 403

2022-12-23

Problem

We are writing some integration test using Go CDK. After writing some data to a bucket:

1	writer, err := buckOut.NewWriter(ctx, fileDst, nil)
2	if err != nil {
3		logger.Errorf("failed to write to fileDst: %v", err)
4		return err
5	}
6	defer writer.Close()

we got an error when reading:

1(code=NotFound): storage: object doesn't exist

By reading the documentation, I pay attention to this:

Closing the writer commits the write to the provider, flushing any buffers, and releases any resources used while writing, so you must always check the error of Close.

Read More...


Terraform failed to acquire state lock: 403: Access denied., forbidden

2022-11-17

Problem

We stored Terraform state in gcs. For some reasons, we got this error randomly when running on BitBucket pipelines:

 1 2│ Error: Error acquiring the state lock
 3 4│ Error message: 2 errors occurred:
 5* writing
 6"gs://bucket/path/to/default.tflock"
 7│ failed: googleapi: Error 403: Access denied., forbidden
 8* storage: object doesn't exist
 9101112│ Terraform acquires a state lock to protect the state from being written
13│ by multiple users at the same time. Please resolve the issue above and try
14│ again. For most commands, you can disable locking with the "-lock=false"
15│ flag, but this is not recommended.
16

Read More...


The King of Vietnamese language game show

2022-11-04

My family likes to watch “The King of Vietnamese language” game show together. I want to encourage our son to love Vietnamese. At the end of the game, the player has to find 7 complex words from the letters, for e.g,

đ / ă / n / g / c / a / y

One evening a few weeks ago, while we were watching the final round, my wife suddenly came up with an idea: this game could be programmed.

Read More...


How to run a pipeline step only when pushing to a new branch?

2021-01-07

GitHub sends push hook when pushing to a new branch and merging a PR. How can we distinguish between them?

We are running integration test by triggering a downstream build when a PR is merged into specific branches. In the downstream repository, we pull all the docker images which has been built and pushed from upstream. The thing is we also used the drone-convert-pathschanged to only publish what modules has been changed.

So, what happens when pushing to a new release-* branch?

Read More...


How to add full text search to my static website?

2020-12-30

After building the website, I want to add search function. There are some ways to do it:

So, is there any search engine written in Go?

Bleve has more star and be maintained more often than riot, I would like to give it a try first.

Backend

Looking at the documentation, there are three steps to add search to your website:

Read More...


How to perform integration testing in Go?

2020-09-29

Integration testing can be triggered by using Drone downstream plugin:

 1steps:
 2- name: trigger
 3  image: plugins/downstream:linux-amd64
 4  settings:
 5    params:
 6    - COMMIT_BRANCH=${DRONE_COMMIT_BRANCH}
 7    repositories:
 8    - repo/integration-test@${DRONE_COMMIT_BRANCH}
 9    server: https://drone.example.com
10    token:
11      from_secret: drone_token

It can be separated with unit tests by using build tags:

1// +build integration
2
3package webserver_test

Then we can write code to perform integration test as usual.

Read More...