Sunday, January 17, 2021

My Systems (2021)

2021 brings upgrades to the computers in the house that has been fairly static over the past 7-8 years.   I got a couple of new systems and repurposed some parts from the old systems so this post is mainly to inventory the new configurations for my own reference.

System 1 (Asus PN50 4800U) [replaces system 3]

  • Ryzen 7 4800U [Zen2] (8 cores / 16 threads, base clock 1.8GHz, max 4.2GHz - 8 GPU cores - RX Vega 8, 15W)
  • 32 GB Crucial DDR4 3200Mhz  RAM (2x16GB)
  • 1TB Samsung 970 EVO Plus (M.2 NVMe interface) SSD
  • 500GB Crucial MX500 SATA SSD (2.5")
  • Intel WIFI 6, BT 5.0
  • 2 Dell U2311H (existing) monitors
  • 1 Dell U2421HE (24" 1080p) monitor
  • Dell AC511M soundbar
  • Unicomp Ultra Classic keyboard (2009)
  • Logitech Wheel Mouse

The PN50 replaced my trusty Shuttle DS87 as my daily driver.  All the components are new except for the two Dell U2311H monitors, keyboard and mouse.  I added a third monitor, Dell U2421HE, because it has ethernet and a USB-C interface that can connect with the PN50 for DisplayPort, USB hub and ethernet.  This lowered the number of cables between the PN50 and peripherals and reduced clutter on my desk.

Despite its small size, the PN50 is still very high performing, but you do pay a price premium for having something small AND fast.  I did lose some connectivity (fewer USB ports and only 1 Ethernet port).  The USB ports can be addressed with a hub which I utilized the monitor's built-in USB hub for.  The U2421HE has an ethernet port built-in and all the communication is handled through the USB Type-C port between the monitor and the PN50.

My ideal system would still be to have a something like the DS87 housing with a Ryzen 4700G (or 5700G), but those CPUs aren't very readily available and there is not DS87-like small form factor cases for them.  Update:  The day after I posted this, Shuttle announced this exact PC.  ^_^;  With my new monitor, though, I would like the new Shuttle to have an USB Type C connection, but at least if I wanted to get more power then I know the option is now out there!

System 2 (Asus PN50 4500U) (replaces system 4)

  • Ryzen 5 4500U [Zen2] (6 cores / 6 threads, base clock 2.3GHz, max 4.0GHz - 6 GPU cores - RX Vega 6, 15W)
  • 2x 8GB 3200 DDR4 so-dimm by SK hynix
  • Intel 660p Series m.2 500GB SSD
  • Intel WI-FI 6 (GIG+) + BT 5.0
  • *Crucial 128BG m4 2.5" SSD

This system replaces my wife's Shuttle XH61 system and is an upgrade across the board over its predecessor.

System 3 (Shuttle DS87)

  • Shuttle PC DS87
  • Intel Core i7-4790S Processor (4 cores / 8 threads, 8M Cache, base clock 3.2 GHz, max 4.0GHz, 65W)
  • Samsung 850 EVO 500GB 2.5-Inch SATA III Internal SSD (MZ-75E500B/AM)
  • 2 x Crucial 16GB Kit (8GBx2) DDR3 1600 MT/s (PC3-12800)
  • *Intel Network 7260.HMWG WiFi Wireless-AC 7260 H/T Dual Band 2x2 AC+Bluetooth HMC
  • *Samsung 840 EVO Series 120GB mSATA3 SSD

This Shuttle had been my reliable daily driver for over 6 years running Linux.  I repurposed an Samsung SSD and Intel wireless card from my Asus VivoMini to install Windows and add WIFI and bluetooth to the system.   The antennas that was in the VivoMini was hard to extract so I took the antennas from an old ASUS Chromebook laptop that wasn't being used anymore.  

The VivoMini was being used for kid's remote/distance learning but was a bit under-powered for handling some of the video conferencing features so this system will now take its place.

System 4 (Shuttle XH61)

  • Intel Core i7-2600S Processor (4 cores / 8 threads, 8M Cache, base clock 2.8 GHz, max 3.8GHz, 65W)
  • *Seagate 300GB 7200RPM HDD
  • 8GB RAM

This system was originally put together in 2012 (with an SSD) and even in 2020 was a perfectly good system for most tasks.  When running Windows 10 or some basic games (Minecraft, Don't Starve) it still felt pretty snappy.  I wouldn't try running any graphics intensive games on it.  

The SSD from this system was moved to the PN50-4500U (system 2) and replaced with a 2.5" Seagate 300GB 7200RPM hard disk drive that I pulled out of the Chromebook laptop that I pulled the antenna from.  After switching to the mechanical disk drive, the system felt noticeably sluggish.  A solid state drive makes a big difference!  

I'm keeping this system around as a backup system but will probably have to get a SSD for it.


The ASUS VivoMini UN62 is a wonderfully small and quiet bare bones system with very good build quality.  It was this system that gave me confidence in getting the ASUS PN50.  I actually own 3 of these system and use them for different purposes which have changed over time (e.g. media station, always-on server for minecraft, etc).  More recently, however, the Raspberry Pi 4  have replaced the VivoMinis for some of the tasks.

The specs for my UN62s are:
  • Intel i3-4030U (2 cores / 4 threads, 1.9 GHz, 3 MB cache, 15W)
  • 16GB Crucial (2x8 GB DDR3-1600) 204-pin sodimm
  • Samsung 840 EVO 128GB msata3 SDD
  • Intel Network 7260.HMWG WiFi Wireless-AC 7260 H/T Dual Band 2x2 AC+Bluetooth HMC
Two served as the kids' computers until I upgraded their setup.  One was repurposed as the machine for schooling when remote/distance learning was put in place due to covid-19.  This system was replaced by System 3 and its drive and wireless card got moved to that system.

Raspberry Pi 4

  • Broadcom BCM2711, Quad core Cortex-A72 (ARM v8) 64-bit SoC @ 1.5GHz
  • 4G BLPDDR4-3200 SDRAM
  • 2.4 GHz and 5.0 GHz IEEE 802.11ac wireless, Bluetooth 5.0, BLE
  • Gigabit Ethernet
  • 2 USB 3.0 ports; 2 USB 2.0 ports.
  • Raspberry Pi standard 40 pin GPIO header (fully backwards compatible with previous boards)
  • 2 × micro-HDMI ports (up to 4kp60 supported)
  • 2-lane MIPI DSI display port
  • 2-lane MIPI CSI camera port
  • 4-pole stereo audio and composite video port
  • H.265 (4kp60 decode), H264 (1080p60 decode, 1080p30 encode)
  • OpenGL ES 3.0 graphics
  • Micro-SD card slot for loading operating system and data storage
  • 5V DC via USB-C connector (minimum 3A*)
  • 5V DC via GPIO header (minimum 3A*)
  • Power over Ethernet (PoE) enabled (requires separate PoE HAT)
  • Operating temperature: 0 – 50 degrees C ambient

The Raspberry Pi 4 is a small wonder of a machine that replaces what I originally used the ASUS VivoMini for and is significantly cheaper.

Friday, January 1, 2021

Installing Windows after Linux On Separate Disks

 For my new system, I also added a second SSD that is intended for installing Windows 10.  My primary daily driver is Fedora Linux so I installed it first and it's on the primary drive.  

I don't use Windows very often but I might use it to play some games with the family so I'm okay with dual booting for this purpose.  I've not played with  dual-booting Linux and Windows in a very long time.  It's not something I recommend to someone who switch between the two operating systems frequently nor to someone who very rarely use one of them.  Rarely using one operating systems means it isn't updated so when it is needed there might be a lot of lost time getting the operating system updated and running again.

Setting up dual booting can also be a pain as one operating system might mess with the booting of the others (Windows tends to be the more frequent offender here as it doesn't really like to recognize non-Windows systems).  Most documentation I found suggests installing Windows first and then Linux so that the Linux boot manager (GRUB) can find Windows and add it to the boot options.   However, there's still a possibility that a Windows update can mess up GRUB and then it needs to be restored.  Another slight disadvantage is that it adds additional time for booting since there needs to be some pause to let users pick the right OS they want to run.

What I id was to install Linux first on one partition and then install Windows on complete separate drives so the boot manager of each drive is not effected by the other operating system.  I rely on the BIOS (yes, I know, force of habit to call it the BIOS) to select which drive to boot.  

After Linux was installed on disk "1", I installed Windows on disk "2" (Windows called it disk 0).  Whenever it rebooted, I made sure to tell the BIOS to boot of the Windows drives and not the default Linux drive.

Fortunately, the Asus BIOS's boot options include an Boot Override option to boot a specific drive without having to permanently change the boot order.  The other nice thing is that GRUB has the option to go back to the BIOS boot if I missed hitting the DEL key to get into the BIOS.  When I run Linux it is a no-op and when I need to run Windows it's a an extra 1-2 key strokes during boot.

The only issue that I had was that after Windows was installed there was an error message because of Secure Boot.  The simplest work-around is to disable Secure Boot in the BIOS so it can continue the booth process into either Linux or Windows.  I'm still learning about Secure Boot to see how to make it work with this configuration.

2021 PC - Asus PN50 4800U

Although I was very tempted to build a new desktop PC and get access to all the power goodness of the latest AMD Ryzen, I was hesitant giving up the small form factor that I had with my Shuttle PC DS87.  When the Asus PN50 with the AMD Ryzen 4800U became available I took the plunge.

The specs comparison between the previous and new PCs:[

New PC:

  • Ryzen 7 4800U [Zen2] (8 cores / 16 threads, base clock 1.8GHz, max 4.2GHz - 8 GPU cores - RX Vega 8, 15W)
  • 32 GB Crucial DDR4 3200Mhz  RAM (2x16GB)
  • 1TB Samsung 970 EVO Plus (M.2 NVMe interface) SSD
  • 500GB Crucial MX500 SATA SSD (2.5")
  • Intel WIFI 6, BT 5.0

Previous PC:

  • Shuttle PC DS87
  • Intel Core i7-4790S Processor (8M Cache, base clock 3.2 GHz, max 4.0GHz, 65W)
  • Samsung 850 EVO 500GB 2.5-Inch SATA III Internal SSD (MZ-75E500B/AM)
  • 2 x Crucial 16GB Kit (8GBx2) DDR3 1600 MT/s (PC3-12800)

There are enough sites giving benchmarks so I'm not going to try to repeat what they've done, but I wanted to have something to show myself a tangible performance improvement.  It is generally during compilation when I wish things would go faster so why not compare compilation between the two systems?  The multi-core (8 vs 4) and multi-thread (16 vs 8) should benefit compilation even if the base clock of the 4800U is 1.8GHz while the i7 is 3.2GHz.  I'm expecting modern CPU is also more efficient per clock cycle then an 6 year old CPU.

I decided to time the compilation of OpenCV using the following

wget -O
mkdir -p build && cd build
cmake ../opencv-master/
time cmake --build .

i7 Results

real   28m57.219s
user   26m48.466s
sys     2m01.402s

4800U Results

real     36m48.166s
user     34m54.722s
sys       1m52.574s

How did this happen?  Was it that the 3.2-4.0 GHz too much for the 1.8-4.2GHz to overcome?  It did seem like during compilation all of the i7 cores was running at around 3.6 GHZ, but I suspected that the compiler was not actually taking advantage of all the cores of the 4800U.

I tried again using Ninja which automatically configures the build to use the multi-core CPUs.

make clean
cmake -GNinja ../opencv-master/
time ninja

i7 Results

real	11m28.741s
user	85m39.188s
sys	 3m23.310s

4800U Results

real      6m39.268s
user     99m03.178s
sys       4m8.597s

This result looks more like what I expected.  More of the system cycles were used on both the i7 and 4800U as more cores and threads were utilized but the real time was much shorter.  This just shows that for a lot of consumers fewer cores but faster clock speeds might be better for desktops (laptops and battery life adds another dimension) as they rely on the applications to be programmed to take advantage of the multiple cores.  That's why gamer systems usually will give up more cores for faster clock speeds since games aren't known for utilizing multiple cores.

Wednesday, December 30, 2020

Asus PN50 - 4500U Initial Impressions

When I opened up the box with the Asus PN50 my first thought was "wow, it is small."  I also had an Asus Vivo Mini which was also small, but the PN50 is even smaller and significantly more powerful.  The size is all the more noticeable when placed next to the Shuttle XH61 that it replaces.  The XH61 was already small enough to put into a drawer.  We're talking near Raspberry Pi level in size (although it is significantly more expensive) and it is amazing how much power is contained in this little box.

Specifications for this system:

  • Ryzen 5 4500U [Zen2] (6 cores / 6 threads, base clock 2.3GHz, max 4.0GHz - 6 GPU cores - RX Vega 6, 15W)
  • 2x 8GB 3200 DDR4 so-dimm by SK hynix
  • Intel 660p Series m.2 500GB SSD
  • Intel WI-FI 6 (GIG+) + BT 5.0

Opening up the case is straight forward.  Remove 4 screws on the bottom and slide the bottom plate in the direction of the arrow that is printed on it.  Immediately the memory and m.2 slots are visible and accessible.  Install them, close it back up and we're in business!

Everything booted up immediately and there were no issues with the Windows 10 install.  There were no driver complaints and the setup process went smoothly.  After Windows pulled the latest updates and rebooted, it took so long that I worried that it froze.  Eventually, it did whatever it is that it needed to do and restarted.  Everything came up, but since I used the Windows that was pre-loaded on the SSD, I had to go through and remove the unwanted software that it came with.  I added a 2.5" SSD as well and there was no problems recognizing it.

I installed Genshin Impact and played at both medium and high graphics quality and didn't see any issues with either.  Genshin Impact is not the standard to measure a system's gaming ability but if hardcore players aren't going to get a mini PC like this.  What this shows is that the 4500U is capable of running a current game in case there is a time when I wanted to play something on the PC.

Throughout the whole time, the unit stayed very quiet.  It is not completely silent but also not very noticeable.

The unit does come with WIFI and bluetooth and I was able to pair a PS4 Dual Shock controller easily and used it to play Genshin Impact.

There are two USB 3.2 Gen 1 Type A ports on the rear and one on the front.  There is also a USB 3.2 Gen2 Type C on the front and back.  Both support DisplayPort but the front on also support battery charging.  3 USB-A ports is a bit lacking so I connected a hub to one of the ports.  In total there are 5 USB ports and two of them can be used for connecting to DisplayPort monitors.

Along with the DisplayPort on the back and HDMI port, up two 4 monitors can be connected at once.  I normally run a two monitor configuration so this is plenty for my use. 

The front also SD card reader.  The audio-out jack is also on the front and the ethernet port is on the back.  I wished there was a second ethernet port and an audio jack on the back or side in addition to the front.  This would give some additional options to the orientation of the unit especially when it is mounted on the back of the monitor.  The Vivo Mini had this and it was a nice feature for the usb and mini

It is targeted for mobile but useful in a mini pc like the PN50 in keeping the heat down.   Benchmarks can be studied all day long but ultimately it'll be actual usage that matters.  If I don't post anything else about the performance of the 4500U it is probably because I'm finding the performance to have nothing to complain about!

New PCs - Asus PN50

The Asus PN50 series of computers are based on AMD's Renoir APUs based on their Zen 2 architecture and combines the CPU with integrate graphics.  The PN50 are mini computers that fits in the palm of your hands and utilizes the mobile versions of the APU (4300U, 4500U, 4700U and 4800U).  Note that these are generally bare bones systems which means that it doesn't come with memory or storage.  There are now enough info around the web and on Youtube talking about these APUs and also specifically about the PN50, but I had questions about these systems that none of the articles or videos talked about

I recently bought the 4800U and 4500U versions to replace my wife's desktop and my personal desktops of the past 7+ years and I want to answer the questions I had in case others also had the same questions.

Q:  Does the configurable port on the back mean that I can change it to what I want (VGA, HDMI, DisplayPort, Ethernet)?

A:  No, they are fixed.  You need to find the exact model you want with the type of port you want and some not available in some region.  I really wanted one with an extra Ethernet port but no seller in the US listed it.  The most common in the US has a DisplayPort.

Q:  Asus offers one version (4800U w/ 16GB memory, 500GB SSD and Windows 10 Pro) that isn't a bare bones system but it doesn't say what the components are.   

A: Here is what is in this system:
  • 2x 8GB 3200 DDR4 so-dimm by SK hynix
  • Intel 660p Series m.2 SSD
  • keyboard
  • mouse
  • Windows 10 Pro OEM (pre-loaded on the SSD)
The keyboard and mouse are pretty cheap quality feeling.

Q: Can it be used for playing games?

A:  Maybe not for hard core gamers or people wanting to play Cyberpunk and high graphics settings, but the 4500U works very well for playing games like Genshin Impact out-of-the-box and the default game settings.

The systems I got was the bare bones 4500U version and the non-bare bones 4800U.  I transferred the memory and SSD from the 4800U to the 4500U since I wanted 32GB of memory instead and a bigger drive.

The new configuration for the 4800U is:

  • Ryzen 7 4800U (8 cores / 16 threads, base clock 1.8GHz, max 4.2GHz - 8 GPU cores - RX Vega 8)
  • 32 GB Crucial DDR4 3200Mhz  RAM (2x16GB)
  • 1TB Samsung 970 EVO Plus (M.2 NVMe interface) SSD
  • 500GB Crucial MX500 SATA SSD (2.5")
The main feature that I sacrificed was the second ethernet drive that my current Shuttle PC has.  The PN50 also has fewer USB ports but does have a USB Type C port that is capable of DisplayPort.  I thought about just building a desktop with the Ryzen desktop CPUs or APUs when they become available, but I think that I will miss the small form factor which has help me avoid the temptation of wanting to upgrade because it sits out-of-sight.  :-)

I believe that running with the base clock of 1.8GHz is fine and it is when I compile stuff that I really need more speed and power over my existing system.  Compiling C/C++ code are really the only times that I might think about getting a new computer.  Occasionally, I might wonder if I can play a game but since I moved over to console gaming (to avoid the constant upgrade cycle), but generally even my 7+ years old machine have remained speedy.

This is really more a splurge buy for myself because of the holidays and that my wife wanted to co-op Genshin Impact on something other then her mobile phone.

There are some competitors to the PN50 including the Asrock 4x4 Box series which are just as small and comes with dual lan interfaces.  However, they are completely sold out everywhere.  I've previously owned the Asus Vivo Mini and was very happy with it for both its quality and how quiet it is so I've been partial to the PN50 when it was first announced.

Saturday, December 26, 2020

Braised Pork Belly and Braised Eggs (滷肉飯)

Found this recipe on Angel Wongs Kitchen  for Braised Pork Belly 滷肉飯 (Lǔ ròu fàn) using a pressure cooker to speed things up.

Braised Eggs

  • eggs (however many you want to cook)
  • water

  1. Enough water to cover the eggs by about an inch.
  2. Bring water to boil
  3. Put in eggs for 12 minutes
  4. Put eggs into an ice bath for 15 minutes
  5. Peel
  6. Add to braised pork belly stew below.

Braised Pork Belly

  • 2 lb. boneless pork belly
  • 2 Tbsp. minced garlic
  • 2 Tbsp. brown sugar (or rock sugar)
  • 1/2 cup light soy sauce
  • 2 Tbsp. rice wine
  • 3 Tbsp. dried shallot
  • 1 tsp. five spice powder
  • 1/2 tsp.  white pepper
  • 1 tsp. salt
  • 2 Tbsp. dark soy sauce
  • 3 3/4 cups filtered water for instant pot (4 cups or more to cover meat for slow cook)
  1. Cut pork belly into 1" pieces.
  2. Brown the pork and add to instant pot.
  3. Add the rest of the ingredients to the instant pot.
  4. Set pot to pressure + high for 30 minutes (actual cook time will be longer because the pot needs to pressurize).
  5. Once done, add the boiled eggs.

Friday, November 27, 2020

Building GUI applications with Go (Golang)

Go is my favorite programming language.  I have mostly used it for writing command line programs or server-side services so I was not familiar with using it for writing GUI desktop applications.  Questions about using Go for writing GUI applications come up periodically on Reddit or Hacker News with some saying that Go is not appropriate for GUIs while others argue the opposite.  

I decided to take an existing command line program that I've written and put a graphical interface on it using different GUI frameworks/tool kits that are available.  The program's purpose is very simple.  It checks for the latest stable version of Go for your system and if there is a newer version then it downloads it.  Once the file is downloaded, it verifies the checksum to make sure that it correctly downloaded a good file.  The UI will simply show the information (where to save, the version to download, the checksum) and a button to start downloading.  During download, a progress bar indicates what is happening. 

The code can be found at with the GUI files in the internal/gui package.  gtk.go and fyne.go are for GTK and Fyne respectfully.


Go is perfectly capable for writing GUI application as far as functionality.  There are tried-and-true toolkits such as GTK and QT and emerging ones such as Fyne and Gio.  The former being more polished but with an extra layer of non-Go code between the app and the graphics layer and a higher learning curve.  The latter's tooling, visualization documentation and functionality are less developed.  

Where all of the options fall behind some other languages is in its developer friendliness in the form of documentation.  

GTK do have a lot of documentation and many users who have posted answers on forums, but the documentation is based on another programming language.  

Gio and Fyne are more lacking in documentation and tutorials so it can be more frustrating for beginners looking to learning or find answers.  Although the general concepts might be more easily understood since they aren't as big of a system as GTK.

All the toolkits I tried rely a lot of providing code examples as a form of teaching, but the examples aren't very well documented or discoverable making them less friendly to developers.

Binary size for my simple program are:
  • command-line only ~6M
  • command-line + GTK GUI ~9M
  • command-line + Fyne GUI ~14M
GTK does require for the shared libraries to be available on the system (they aren't compiled into the above binary) so they will need to be bundled in.

It took me about a day to write the Fyne version and about 2 days for the GTK version.  I also had to spend a day to figure out how to get both to compile and run on Windows.


There are actually many choices available to Go developers for building GUIs.  I think the perception that Go isn't a "GUI" language could be because:
  1. A number of GUI projects have been abandoned.  
  2. There is no single "blessed" GUI framework from the Go team.  
  3. There are no fully native Go implementation of a GUI toolkit.  
(1) I don't think this is unusual given the complexity of developing a GUI framework that there are a lot of abandoned GUI projects.  What is more important is what is available that is actively maintained since there are always many abandoned projects in any language so don't let the noise give you the wrong impression.

(2) Although there are some languages that comes with a GUI toolkit as part of the language (e.g. Java, Swift), most language don't.  Go can feel like its a "batteries included" language with its rich standard libraries (e.g. it basically comes with a HTTP server) so with no GUI options it could lead to the misconception that the Go team doesn't believe that Go should be used for GUI apps.  However, a lot of languages don't have one either (C/C++, Python, etc.)

(3) This really depends at what is the definition of a fully native Go implementation:  
  • Can app developers everything in Go?  Can it be written in an idiomatic way?
  • Can the entire project just depend on the Go tool chain?
  • Is the whole tech stack built with Go?
With the exception of the tool kits whose philosophy are to combine Go for backend logic and another language for the front-end GUI (e.g. javascript), most of the options let the developer write everything in Go.  The Go tool chain includes cgo for interfacing with C code so even if the toolkit is dependent on C libraries (e.g. OpenGL, GTK/Qt, etc.) the app developer don't really have to deal with other tool chains except maybe have some be installed for cgo to access. 

Having the whole stack be written in Go is not realistic.  With the exception of C, every language at some point have to deal with the lower level of the system (whether it be the graphics subsystem or OS) that is written in another language).  

Personally, as long as everything I write is in Go and only the Go tools are used than that is "native" enough for me.  As an applications layer developer, I don't expect to be working on the GUI underpinnings that would require to combine languages and tool chains.  That means there are plenty of options for Gophers (developers that uses Go ) and my evaluation criteria is on some subjective qualities such as how intuitive it is and whether it is easy to learn/use, and some quantitative attributes such as stability. 

With this in mind, the most often mentioned options are Qt, GTK, Fyne and Gio.  Between Qt and GTK, I chose GTK.  Both are these are popular production-level GUI toolkits written in C/C++.  The reason I picked GTK is that I use Linux and Gnome and the admittedly self-perception that installing GTK is easier then installing a Qt dev environment.

I also wanted to try either Fyne or Gio as these are two toolkits that were built with Go.  Both rely on go-gl (which in turn depends on OpenGL) to deal with the graphics subsystem to draw the interface and widgets so they don't that extra layer between the app and graphics system being occupied by another framework like GTK and Qt.

Gio (

The first GUI toolkit that I tried to look at is Gio.  It wholeheartedly embraced everything Go and the latest-and-greatest.  It allows compiling to desktops, mobile, and WASM (web assembly).   It supports Go modules (common) and drops GOPATH support (uncommon).   Its embrace of immediate mode GUI programming is kind of Go-like in its belief that it's not always necessary to give up control to a framework.

Installing Gio to be ready to use is very easy.  Make sure the system already installed the wayland/X11 and OpenGL development libraries.  A simple 1-line install from dnf, apt or whatever Linux package manager will likely suffice.  Then it is a simply importing the package in your Go code and during the first compile, Go will pull down Gio and all its dependencies through Go modules.

However, I quickly moved away from Gio for a couple of reasons:
  1. It lacked documentation to help a new user understand how to use it and I found the existing documentation to poorly organized.  It primarily relies on code examples and API comments and then leaves it to the users to figure out for themselves how to use it.
  2. While immediate mode gives more control to the developers, building GUIs is one area where there's enough complexity that I don't necessarily mind handing it off to a toolkit to take care of things.  I wonder whether immediate mode is actually more useful to developers who build GUI tool kits then developers who use the tool kits.
I might come back to Gio some day when I have more time to learn it.

Fyne (

Fyne is a more standard retained-mode GUI tool kit that is easy to install.  It is similar to Gio in that you just need to use your package manager to install the graphical development libraries and then just import Fyne to have it download all the necessary packages and dependencies.  Unlike Gio, it also support the traditional GOPATH method if you don't use Go modules.

The document was much more comprehensive feature an quick beginning walk-through, tutorials and API documentation.  What holds by Fyne a little is in the organization of the documentation which required me to do quite a bit of jumping between sections to understand something.  For example, one section talks about a widget but it is somewhere else where it shows what the widget actually looks like.

I was able to put together a basic interface pretty quickly with Fyne thanks to its basic tutorials.  While getting something working quickly is a plus, I'll admit that I did not find the graphical elements very attractive.  It seems to be embracing material design in some form but feels like it's incomplete.  Extending the look and feel is also difficult at the moment. 

Although I mentioned that I got a working GUI up quickly, I was immediately met with a bug.  The app would start and all the components would draw in the window before it would suddenly turn blank.  Resizing or hovering over a particular widget would bring the interface back.  I only saw this on my Linux system.  I reported this to Fyne and got a response pretty quickly asking me for more info and some follow up questions.  It's good that the Fyne developers are keeping an eye on bug submissions!

Microsoft Windows 

To compile and run on Windows basically requires installing Windows version of gcc.  Fyne's install instructions gives 3 options (msys2+MingW-64, TDM, and Cywin) for GCC.  I went with msys2 + mingw64 as msys2 is also the recommended way to install GTK.

Once msys2 was installed, I installed the mingw64 gcc package through the msys2 shell:

> pacman -S mingw-w64-x86_64-toolchain base-devel

Note: If you want to use the GCC outside of the MingW shell (e.g. with, you need to add:
  • C:\msys2\mingw64\bin
  • C:\msys2\usr\bin
to the Windows PATH variable.

After getting MingW GCC installed, I tried to compile and promptly ran into a compilation error about undefined references.  After much digging, I found the solution to be deleting the go-build cache that is in %USERPROFILE%/AppData/Local/go-build.

Gotk3 (

To use GTK 3 with Go requires gotk3 which provide Go bindings to GTK's APIs (including glib, gdk, and others).  There is also go-gtk which provides GTK 2 binding.

gotk3 has installation instructions on its wiki.  Installing on Linux and MacOS is very simple similar to Gio and Fyne.  For Windows, as with Fyne, it requires installing msys2 + mingw-64.

Although GTK has extensive documentation and tutorials, it's mostly for C or Python.  gotk3's documentation, unfortunately, consists of mainly of comment that is just the C function name.  It doesn't even provide a link to the C documentation so you're required to find it yourself.  For the few APIs that has it's own gotk3 comments, they dropped the C function name so you will have to figure what the Go function maps to. 

gotk3 also follows the "read the code" school of teaching.  Here they have a directory of example code but little explanation of what it is an example of of.  The user is left to decipher all the example codes to form an idea of how the gotk3 works and what is available.   What I ended up doing was to go through and learn GTK in C first and then try to map the concepts to the gotk3 APIs.    This isn't the most friendly way to introduce a Gopher to GUI development with gotk3 but might be okay for a C GTK developer coming to Go.

Of course, on my very first compilation, I get an error message:

go: finding module for package
go: found in v0.5.0
../../gopath/pkg/mod/ _Ctype_struct__GIcon can't be allocated in Go; it is incomplete (or unallocatable)

Fortunately, there was already a bug filed and a solution was already committed.  I had to force Go to use a newer version of gotk3 then what's has been tagged as the stable version:

In the project directory:

go get 

Microsoft Windows

While getting GTK installed on Linux was trivial, it takes a bit more effort on Windows, but the GTK page is very clear.  If you'll be doing everything within msys then there's not much more to do.  If you want to use build in another terminal such as cmd, then you'll need to add the mingw bin path to the %PATH% variable.

There seems to a compatibility issue between gotk3 and GTK that requires remove the -Wl flag from gdk.3.0.pc which is captured in the gotk3 wiki for installing on Windows.

Tuesday, August 4, 2020

Basic Gaming PC for Kids

After a summer full of "OMG, why is it lagging so much!!!" being shouted out at seven in the morning (compounded by how we're all been sheltered at home due to covid-19), I realized that to preserve my sanity that I must give in and build the kids new PCs.

As a PC for the kids, my specifications are quite different than a machine that my livelihood relies upon:
  1. It must be able to run their commonly played games (primarily games like Minecraft and Roblox) at good frame rates and speed.
  2. Relatively inexpensive.
  3. Allow future expansion (defer as much cost to the future as possible).
Less important are small form-factor and ultra-quiet although there is some consideration giving that we have to put it somewhere and don't want it so loud that they would complain about it later.  I don't intend to do any type of over-clocking (they have to figure that out themselves if they really want that but I don't expect that for awhile).  Fortunately, the kids aren't into RGB lighting and other stuff to make their rigs "cool looking" but who knows what will tickle their fancy in the future.

The final configuration was:
The Ryzen 3 3200G is a 4-core/4-threads 3.6GHz CPU with integrated Radeon Vega 8 (noted by the "G" in the name).  Since gaming aren't core-intensive types of applications there isn't a reason to aim for high core count.  The Ryzen's integrated graphics are powerful enough for my kids' gaming so I can avoid getting a discrete graphics card initially.  AMD's stock CPU cooler is also generally considered to be good quality so there isn't a need to buy another CPU cooler especially (as opposed to Intel CPUs where it's usually recommended to get another CPU cooler and not use what it comes with).  At $100 it was also relatively inexpensive.  With this CPU, I can defer spending money on a graphics card, CPU cooler and additional case fans since I don't expect it to really generate high heat.  

The $70 ASRock  B450M-HDV R4.0 micro-atx motherboard is a basic, modern and has a good reputation motherboard.  It might not have the most cutting edge (usb type-c) or advanced features (dual 10gbits LAN) but it has all the modern features that are commonly needed (DDR4, PCIe, SATA3, M.2, USB3.1, gigabit LAN, HDMI, integrated audio).  On the opposite end of modern it also has DVI-D and D-Sub (VGA) connectors.  The board does NOT have built-in WIFI or Bluetooth though, but neither are used by my kids on the PC.

For the case, I went with the ThermalTake S100, a mid-tower micro-atx case.  It wasn't the cheapest case at $70 but also not a $90-$300 case either.  It is a basic but quality-built case.  I also chose it because micro-atx board are more abundant and cheaper, it being a "bigger" case means more space for components inside for either expansion or air flow.  Basically, I figured I didn't have to fill it up with cooling at the beginning since I'm not even putting in a discrete graphics card or worry about top-notch cable management.

For the PSU, I got the EVGA 600BA which I guess just came out right as I was shopping so there was inventory.  It's $70 and since I didn't know much about power supplies I went with a reputable brand and this price seemed reasonable.

For storage, I felt a 250GB SSD is sufficient and at $45 it was inexpensive.  For Steam gaming, they kids already had a external hard drive that they store an less played games on and when moving between computers it is just easier to bring the external drive. 

For memory, I got 16GB which is overkill for a gaming PC of this type (seems like 8GB is the sweet spot) but it was a little bit of future proofing since if I got 2x4 GB memory that means that future expansion would require replacement rather then addition.  16GB was $70 so one can save ~ $35 when going just with 8GB.

I didn't have to spend additional money on Windows 10 since I transferred it from their old computer so the final cost of the build was:

CPU:    $ 100
MB:     $  70
Case:   $  70
PSU:    $  70
SSD:    $  45
Memory: $  70
Total:  $ 425

I'm sure the values will fluctuate, but I'm not someone who is keeping track of component pricing.  I shopped from what was available at the time I decided to buy.  I guess covid-19 has lead to increase in price of a lot of components although I think I avoided some of those (graphics card, popular gaming cases of YouTubers)

Sunday, May 10, 2020

Automatically Start Local Minecraft Server on Linux (Fedora) At Boot

Running your own Minecraft server on Linux is pretty simple.  You simply download the jar file from and run it from the command line.  However, if you run it straight from the command line you'll need to stay logged in and not kill the terminal otherwise it will stop the Minecraft server.

The way to work around it is to use something like tmux or screen and run Minecraft from there.  That allows you to detach the session, logout, and come back to it at a later time so you now have a "headless" Mindcraft server running.

The final step is to make it so that it automatically starts when the server boots up and shut it down when the server shuts down.  On Fedora, that means using systemd.

I'm assuming you're running Minecraft as user minecraft and the Minecraft jar file is located in ~minecraft.
$ sudo adduser minecraft
$ sudo passwd minecraft
Because SELinux is enabled by default, we need to put our Minecraft files in another directory that isn't the user home directories since SELinux policy blocks systemd access to them.  Instead, let's put it in /opt/mcserver.

Start-Up/Shut-down Scripts

First, let's create a start-up script in /opt/mcserver/

/usr/bin/tmux new-session -s minecraft -d
tmux send -t minecraft "/usr/bin/java -Xmx1024M -Xms1024M -jar /opt/mcserver/minecraft_server.1.8.3.jar --nogui" ENTER
This starts a new tmux session in detached mode and calling the session minecraft.  Then it sends to the tmux session the command to start the Minecraft server in text (non-gui) mode.

Let's make a shutdown script in /opt/mcserver/

/usr/bin/tmux send -t minecraft /save-all ENTER
/usr/bin/tmux send -t minecraft /stop ENTER
echo "Killing minecraft session"
/usr/bin/tmux kill-session -t minecraft
This sends a command to the tmux session named minecraft to
  1. Save the current state of the server (save-all).
  2. Shutdown the minecraft server (/stop).
  3. Stop the tmux session.
Make both scripts executable:

chmod u+x
chmod u+x

Automatically Start Your Server

To automatically start and stop the tmux session for Minecraft, create /usr/lib/systemd/system/minecraft.service:

Description=Start tmux in detached session running Minecraft.


Now link it to the right place:

cd /etc/systemd/system
ln -s /usr/lib/systemd/system/minecraft.service minecraft.service
Now we can run it and enable it to start at boot:

systemctl start minecraft.service
systemctl enable minecraft.service

Configure the Firewall

Now the server is running, you might realize that your Minecraft client cannot connect to it because of the firewall.  To open the firewall to allow clients to connect to your server

$ firewall-cmd --get-active-zones 
$ sudo firewall-cmd --permanent --zone=[zone from above] --add-port=25565/tcp
$ sudo firewall-cmd reload
We can name this as a service called minecraft by creating a file called /etc/firewalld/minecraft.xml with:

<?xml version="1.0" encoding="utf-8"?>
  <description>Port used to allow remote connections to a Minecraft server running on this machine.</description>
  <port protocol="tcp" port="25565"/>
Then tell firewalld to load it permanently:

$ sudo firewall-cmd --zone=[Name of your zone] --permanent --name=minecraft --new-service-from-file=/etc/firewalld/minecraft.xml
$ sudo firewall-cmd --reload

Backup Your Save File

I also suggest having a backup script that regularly back up your world:

printf "Starting backup..."
date +%D
cd /opt/mcserver
tmux send -t minecraft /save-off ENTER
tar -czvf $HOME/backup/world-`date +%m%d%y_%H_%M_%S`.tar.gz world
tmux send -t minecraft /save-on ENTER
With a cron job as follows:

0 15 * * * /home/minecraft/ >> /home/minecraft/backup/backup.log 2>&1

This says to run the job at 3pm every day and copy the output to backup.log.

The saved archive (even compressed) can get pretty big and can easily eat up disk space so you might want to only keep the a few of the most recent save and automatically delete the old ones (or move old archives somewhere else).  That can be done with another cron job with a one line script:

ls -tr world-*.tar.gz | head -n -5 | xargs --no-run-if-empty rm
This will delete all but the 5 most recent files and do nothing if there are less then 5 archive files.  This can be put into a script with some logging /home/minecraft/

printf "Deleting old backups..."
date +%D
cd $HOME/backup
ls -tr world-*.tar.gz | head -n -5 | xargs --no-run-if-empty rm -v
and have a cron job as follows to run nightly:

# Delete old backup files at 11:20pm but keeping a few most recent ones.
20 23 * * * /home/minecraft/ >> /home/minecraft/backup/backup.log 2>&1

Now each time your server boots, it will automatically run the Minecraft server as user minecraft and once a day it will back up your Minecraft data while removing old archives.

Wednesday, April 8, 2020

BASH startup file loading order

The loading order of Bash startup files is first dependent on the type of shell that Bash think it is in.
login shell is when the user logs in from tty (not through a GUI) or logs in remotely (e.g. through ssh).
non-login shell is started in other ways such as gnome-terminal which is started by Gnome (it is a login shell that launched Gnome).
Note: The exception is OSX's which is treated as a login shell.
For non-login shells (e.g. gnome-terminal) the order is:

For login-shells (including the order is: /etc/profile and then first of:

Followed by the first of the following: