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

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...


Unable to obtain ACME certificate for domains

2020-12-28

Lets Encrypt tells me that my domain contains an invalid character. What is it?

remark42 is configured like this:

 1  remark42:
 2    image: umputun/remark42:arm64
 3    container_name: "remark42"
 4    restart: always
 5    labels:
 6      - traefik.enable=true
 7      - traefik.http.routers.remark42.rule=Host(`${REMARK_URL}`)
 8      - traefik.http.routers.remark42.entrypoints=https
 9      - traefik.http.routers.remark42.tls.certresolver=le
10      - traefik.http.services.remark42.loadbalancer.server.port=8080

Read More...


A && B || C is not the same as if-then-else

2020-12-26

I have been thought that if-then-else statement can be written in one line by using A && B || C but I was wrong.

To speed up my Drone CI time, I configured the static-check step to only run when there are some .go files have been changed:

1git --no-pager diff --name-only ${DRONE_COMMIT_LINK##*/} | grep -q "\.go$" && golangci-lint run --deadline 2m -v ./... || true

I was thought that A && B || C is the same as:

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...


Duc Ba church

2020-07-28

Duc Ba church Duc Ba church, Saigon.


Bị theo dõi (Permanent Record) - Edward Snowden

2020-07-15

Read More...


Save draft mail in Zimbra web client using ChromeDP

2020-07-03

As an engineer, I want to automate everything as much as possible. This CLI tool is created to save a draft mail in Zimbra web client.

Read config file:

 1func initConfig() {
 2	if cfgFile != "" {
 3		// Use config file from the flag.
 4		viper.SetConfigFile(cfgFile)
 5	} else {
 6		// Find home directory.
 7		home, err := homedir.Dir()
 8		if err != nil {
 9			fmt.Println(err)
10			os.Exit(1)
11		}
12
13		// Search config in home directory with name ".zwc" (without extension).
14		viper.AddConfigPath(home)
15		viper.SetConfigName(".zwc")
16	}
17
18	viper.AutomaticEnv() // read in environment variables that match
19
20	// If a config file is found, read it in.
21	if err := viper.ReadInConfig(); err != nil {
22		log.Fatal(err)
23	}
24
25	fmt.Println("Using config file:", viper.ConfigFileUsed())
26}

Read More...


How to trigger build steps based on modified directory?

2020-06-26

Using monorepo with multiple micro services, every single commit will trigger a full lint/test/build/publish for every service. What can I do to limit the scope?

To do that, we can use git diff to show changes between commits:

 1  if [[ -n "${DRONE_PULL_REQUEST}" ]]; then
 2    most_recent_before="origin/${DRONE_TARGET_BRANCH}"
 3  elif [[ "${DRONE_BUILD_EVENT}" = "push" && ("${DRONE_COMMIT_BRANCH}" = "master" || "${DRONE_COMMIT_BRANCH}" = "release-"*) ]]; then
 4    if [[ "${DRONE_COMMIT_BEFORE}" = "$zero" ]]; then
 5      exit 0
 6    else
 7      most_recent_before="${DRONE_COMMIT_BEFORE}"
 8    fi
 9  fi
10  modified_files=$(git --no-pager diff --name-only "${DRONE_COMMIT_SHA}".."${most_recent_before}");

Read More...


Hanoi tour

2020-05-16

The big church The big church, Hanoi.

Hà Nội Tour (nửa ngày, 0 đêm):

Read More...


Drone build is not triggered after pushing code to Gitea?

2020-05-06

I pushed code to Gitea and nothing happens in Drone. Why?

But if I go to Settings -> Webhooks, then click “Test Delivery” -> build pipeline will be executed. Why?

First, look at the “Recent Deliveries” to see if a webhook is triggerd here when you pushing code. In my case, it’s not. So, looks like the problem is on Gitea side.

By pay close attention to the git output when pushing:

 1Counting objects: 4, done.
 2Delta compression using up to 4 threads.
 3Compressing objects: 100% (4/4), done.
 4Writing objects: 100% (4/4), 2.02 KiB | 2.02 MiB/s, done.
 5Total 4 (delta 2), reused 0 (delta 0)
 6hint: The 'hooks/pre-receive' hook was ignored because it's not set as executable.
 7hint: You can disable this warning with `git config advice.ignoredHook false`.
 8hint: The 'hooks/update' hook was ignored because it's not set as executable.
 9hint: You can disable this warning with `git config advice.ignoredHook false`.
10hint: The 'hooks/post-receive' hook was ignored because it's not set as executable.
11hint: You can disable this warning with `git config advice.ignoredHook false`.
12To gitea.pi:quanta/blog.git
13 + d29f63d...47e9ed3 master -> master (forced update)

Read More...