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.