Git SSH Authentication

If we want to use different authentication keys for a particular Git repo, we can edit the config file of the repo and add the sshCommand setting.

Navigate to the repository’s Git configuration directory:

1
cd /path/to/repo/.git

In the folder there’s a file called config. We are interested in the core section. To use a particular SSH key for Git, we would write the command as shown below. Replace the name of the key file with your own.

1
2
3
4
5
[core]
	...
	...
	...
	sshCommand = ssh -i ~/.ssh/my_custom_git_key

Perspective on Computer Hardware Advancements

note

Excerpt from The Clean Coder by Robert Martin

“One of the first machines I ever wrote programs for was a PDP-8/I. This machine had a 1.5-microsecond cycle time. It had 4096 12-bit words in core memory. It was the size of a refrigerator and consumed a significant amount of electrical power. It had a disk drive that could store 32K of 12-bit words, and we talked to it with a 10-character-per-second teletype. We thought this was a powerful machine, and we used it to work miracles.

I just bought a new Macbook Pro laptop. It has a 2.8GHz dual core processor, 8GB of RAM, a 512GB SSD, and a 17-inch 1920x1200 LED screen. I carry it in my backpack. It sits on my lap. It consumes less than 85 watts.

My laptop is eight thousand times faster, has two million times more memory, has sixteen million times more offline storage, requires 1% of the power, takes up 1% of the space, and costs one twenty-fifth of the price of the PDP-8/I.”

gcloud configuration and projects

note

Prerequisite: Google Cloud SDK should be installed. See the docs here.

1
2
3
4
5
6
7
8
9
$ gcloud version
Google Cloud SDK 250.0.0
app-engine-go
app-engine-python 1.9.86
beta 2019.05.17
bq 2.0.43
cloud-datastore-emulator 2.1.0
core 2019.06.07
gsutil 4.38

gcloud project configurations are typically stored in the following folder in files with prefix config_. For example: config_my-project-name

1
2
3
$ cd ~/.config/gcloud/configurations && ls -la
-rw-r--r--   1 penkovski  staff   83 Apr 19 09:17 config_default
-rw-r--r--   1 penkovski  staff   83 Apr 19 09:17 config_my-project-name

To add a new project configuration, run the gcloud init command and follow the instructions.

1
gcloud init

After successfully selecting the desired project and options, a new config file will appear in the configurations folder. To switch the active configuration for a new project use the following command:

1
gcloud config configurations activate my-project-name

Set the currently active project:

1
2
$ gcloud config set project my-project-name
Updated property [core/project].

Get the currently active project:

1
2
3
$ gcloud config get-value project
Your active configuration is: [my-project-name]
my-project-name

Golang Multi Package Test Coverage in Gitlab

As part of a Go unit testing CI job, we can generate code coverage statistics. For Gitlab to display them, we must provide appropriate output from the job’s script commands (stdout). Below is a sample CI test job:

1
2
3
4
5
6
unit-tests:
  image: golang:1.12
  stage: test
  script:
    - go test -race $(go list ./... | grep -v /vendor/) -v -coverprofile=coverage.out
    - go tool cover -func=coverage.out

On line 5 we run the go test command and specify that we would like to generate coverage profile and save it in a file called coverage.out

On line 6 we use the go tool cover command to generate (stdout) output broken down by function. Example output is shown below:

1
2
3
4
5
6
7
$ go tool cover -func=coverage.out
gitlab.com/myuser/myproject/file1.go:30:	exampleFunc1	100.0%
gitlab.com/myuser/myproject/file2.go:45:	exampleFunc2	100.0%
gitlab.com/myuser/myproject/pkg1/file3.go:89:	exampleFunc3	100.0%
gitlab.com/myuser/myproject/pkg2/file4.go:23:	exampleFunc4	95.0%
gitlab.com/myuser/myproject/pkg2/file5.go:134:	exampleFunc5	0.0%
total:						(statements)	65.3%

Start GoLand From Terminal

With Visual Studio Code and other text editors, we can directly open the editor from the terminal shell with the current folder opened as a project.

For example, I can change to a folder and start it like this:

1
2
$ cd myfolder
$ code .

To make GoLand support the same workflow, we can do the following steps.

Hugo Gitlab CI for Gitlab Pages

We’ll describe how to integrate a Hugo project repo with Gitlab CI and deploy the built site on Gitlab Pages automatically. If you host your static site on another platform/server, the actions you’ll need to do might be slightly different. In all cases, the major thing is to specify how the public folder of the project will be uploaded to the frontend server. These configurations are declarative and abide to the rules of the .gitlab-ci.yml specification.

tip

Gitlab Pages is a free service to host one static web site per Gitlab project. The site will have a default domain consisting of our Gitlab username and project name: https://myusername.gitlab.io/myproject

Custom domains are supported.

First impressions of Hugo

Hugo is great

Fast, instant refresh, markdown, templates, layouts and great configuration.

What more can we ask for?

I would say more clear guidelines on how to deal with Hugo themes.

Beginner’s difficulties with Hugo themes

The docs describe a sample quickstart site with a predefined theme. If we follow, we’re easily good to go with a new site. Yet, probably we would like to use a different theme.

So we go to https://themes.gohugo.io/ and find a lovely one. I’m using the Jane theme from xianmin.

Google Play Services 10002 Error

The following post may be helpful to resolve the 10002 RESULT_SIGN_IN_FAILED error.

If you have changed or pre-installed your development machine and have installed a fresh Android Studio version, you’ll have a new debug.keystore created by the Android Studio installation.

The apps that are started directly from the IDE during development will no longer be signed with keys registered with Google Play Services. This is no issue if the app doesn’t use Google Play Services like Sign-in, Leaderboards or Achievements, but if it does, these functionalities will no longer work and you may get the 10002 RESULT_SIGN_IN_FAILED error.

Enable Shift+Numpad Navigation for Ubuntu 18.04

Open terminal and execute the following command.

1
setxkbmap -option 'numpad:microsoft'

Other helpful shortcuts are Ctrl+Alt+Arrow when you want to navigate back or forth after peeking into function defintions and going back to previous functions. In Ubuntu 18.04 by default these shortcuts are taken by the system. To make them available for use in text editors, use the following commands.

1
2
gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-left "[]"
gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-right "[]"

Clean Ubuntu Boot Partition

First check the kernel version, so we won’t delete the kernel image in use:

1
uname -r

List installed kernels:

1
dpkg --list 'linux-image*' | grep ^ii

Delete unnecessary kernels (replace the VERSION with kernel that should be removed):

1
sudo apt-get remove linux-image-VERSION

After old kernels are removed, you can remove packages that are not used anymore:

1
sudo apt-get autoremove

Finally update grub kernel list:

1
sudo update-grub