Installing Portable Linux Binaries: A Quick Guide

Introduction

I use PeaZip on my computers. It’s a powerful cross-platform zip/unzip software.

I used to install it through yay, which re-downloads the entire source code and rebuilds it every time I update the OS. While staying up-to-date is crucial for security-sensitive applications like web browsers and cryptocurrency wallets (and plenty more), it’s not always necessary for tools like PeaZip. Even if you forget to update PeaZip, you likely won’t face security risks.

How to Configure DWM

Introduction

DWM is one of the most lightweight window manager for Linux. DWM stands for Dynamic Window Manager, but it’s still focused on tiling window management.

So what is a tiling window manager? A tiling window manager automatically arranges and sizes windows on your screen, typically in a grid-like fashion. You would normally be using a floating window manager in MacOS, Windows, or Linux (XFCE, KDE Plasma, GNOME, etc).

A dynamic window manager is capable of managing windows in both fashion.

Type Conversion and Type Assertion in Go

Type conversion

The expression T(v) converts the value v to the type T.

In Go, assignment between items of different type requires an explicit conversion.

Here’s an example.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
package main

import (
	"fmt"
	"math"
)

func main() {
	var x, y int = 11, 12
	f := math.Sqrt(float64(x*x + y*y))
	var z uint = uint(f)
	fmt.Println(x, y, z)
}

Type assertion

Type assertion provides access to an interface value’s underlying concrete value.

Why Do We Need Unit Tests?

What is unit testing?

Unit testing is the process where you test the smallest functional unit of code.

Software testing helps ensure code quality, and it’s an integral part of software development.

It’s a software development best practice to write software as small, functional units then write a unit test for each code unit.

You can first write unit tests as code. Then, run that test code automatically every time you make changes in the software code. This way, if a test fails, you can quickly isolate the area of the code that has the bug or error.

Go Does Not Have Reference Variables

To be clear, Go does not have reference variables, so Go does not have pass-by-reference function call semantics. Dave Cheney

What is a reference variable?

In languages like C++ you can declare an alias, or an alternate name to an existing variable. This is called a reference variable.

 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
#include <stdio.h>

int main() {
  // integer type
  int a = 10;
  // reference type; type annotation: "int &"
  // means "reference to an integer variable" type
  int &b = a;
  int &c = b;

  // 10 10 10
  printf("%d %d %d\n", a, b, c);
  // reference variables share the same memory address
  // with the variable which they refer to;
  // 0x7ffeea4654f8 0x7ffeea4654f8 0x7ffeea4654f8
  printf("%p %p %p\n", &a, &b, &c); // here, & is "address of" operator

  // pointer type; type annotation: "int *"
  // means "pointer to an integer variable" type
  int *p1 = &a;
  int *p2 = &a;
  int *p3 = &a;

  // here, * is "deferencing"(or "content of") operator
  // 10 10 10
  printf("%d %d %d\n", *p1, *p2, *p3);

  // pointer variables have their own memory address
  // 0x7ffee82644e0 0x7ffee82644d8 0x7ffee82644d0
  printf("%p %p %p\n", &p1, &p2, &p3);

  return 0;
}

You can see that a, b, and c all refer to the same memory location. A write to a will alter the contents of b and c. This is useful when you want to declare reference variables in different scopes–namely function calls.