Friday, May 3, 2024

Resizing Swap Size Ubuntu 23


```
# Check current swap size
cat /proc/swaps
sudo swapoff -a
# Create new swap file
sudo fallocate -l 16G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
# Check again
cat /proc/swaps

```

Friday, April 28, 2023

Working with a forked repository in Golang

 Let say you have a project A that depends on an open-source library B:

A -> B

Now for your own need, you need to enhance library B in order to fit your need. So you fork it as B2:

B -> B2

 
While you're waiting for the maintainer of B to approve your PR, how do you configure your project A to make use of B2? Turns out it's pretty easy! Here's the step:

  1. Fork B as B2
  2. Clone B2 locally
  3. Open A's `go.mod` file, add the following line if you're doing local development
     
    replace github.com/Khan/genqlient => /Users/aharijanto/src/opensource/genqlient

    Or if you're doing remote development

    replace github.com/Khan/genqlient => github.com/dharijanto/genqclient@branch-name
     

Once your change made it to the original repository, simply remove the replace directive! Golang is just so sweet, isn't it? :)

Source:
https://stackoverflow.com/questions/72312460/how-to-replace-a-go-module-with-a-major-version-to-a-fork-master

Monday, April 24, 2023

M1 and M2 Macbook cause external monitor to flicker

I recently gotten a MacBook M2 and noticed that my external monitor would start flickering when connected to it for a period of time. If the flicker is left alone, it would leave some marks on the screen (ghosting). For a while I thought that perhaps my monitor is broken (I've had it for 3 years without any problem with Intel MacBook), but it turns out that there are some people reported the same issue. Such as here.

Here's the solution that works for me:

1. Adjust external monitor brightness to at least 75% (you can use this handy freemium tool called Lunar)

2. Change external monitor color profile to "Generic RGB Profile" under display setting.

So far I've not seen the flickering with the aforementioned settings. 

 

Note: when the monitor is flickering, don't leave it alone! It could initially cause a ghosting, but then it might leave a permanent damage to the monitor. Restart your MacBook and turn off the monitor for a while when that happens.