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:

**Update for go 1.16 4/3/2021**  Another bug came up when trying to use go 1.16 and it looks like a fix made it to the master branch so the same workaround for the previous bug will now also work.

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:


Saturday, March 14, 2020

Google App Engine's Missed Opportunity

I've been a fan of Google's App Engine (GAE) since its initial release in 2008 but it has never quite taken off despite the growth of running applications in the cloud and the rise of open source software.  It's really a missed opportunity for Google.

I have been running many small projects on GAE which is now part of Google Cloud's offerings.  GAE is friendlier to start with than other hosting options from Google in that it has a free tier which I suspect is sufficient for most users.  GAE auto-scales as traffic increases so there is a possibility that it could surpass the free quota but users can set a guidance on the max daily spend.  This has generally worked for me as I set the max to be $0.00 so that I don't go past the free quota.  Be aware that this is not a hard limit so there is a chance that it can go over the limit.  Recently, I got billed $0.01 requiring me to log in to Google Cloud and pay the amount due.  Since I had to log into the developer console, it gave me a chance to look at the projects that I've been running.  The majority were simple static websites which as simple as GAE is to use, it's easier to use something like Github pages.  Both offers SSL (HTTPS support) and custom domains so I decided to move my sites off of GAE.

This move got me thinking about the missed opportunity for Google with GAE.  It is not because GAE should be a static web hosting site since GAE is about running applications hosted in the cloud.  GAE offers a simple and complete solution that was perfect for users of open source projects. 

Just as Github Pages is a super simple solution to host static web pages, GAE started as a super simple solution for running cloud applications.  GAE is basically a server, database, memory cache, sign-in and storage solution all-in-one.  Users don't have to select and install each of these basic components themselves.  This meant that an open source project could be developed where the user can easily run it by putting it on GAE with the same simplicity of desktop projects (possibly even easier).  I imaged a world where someone can write a note taking app in App Engine and anyone who wants to use it get the source, put it on GAE and it's running and ready to use!   We see note taking programs all the time running on desktops and mobile because the author knows that if the user installs the binary they can start using the app, but for cloud apps it always involves a lot of infrastructure setup.  The reaction to this has been Docker containers which I find is still harder on the user and a lot more complex for the developer.

When GAE was first launched it confused developers who weren't used to this paradigm for web development and Google didn't do a very good job explaining or addressing some missing/problematic areas.  It seems like Google focused more on Enterprises to switch to this "Platform-As-A-Service" model when they have less need for such hand-holding.  I believe the missed opportunity is that they missed out that this was more ideal for the consumer market then the enterprise market.

Monday, February 17, 2020

Dayfarer Backpack For Everyday Use (Long Term Review)

I no longer have to bring as many things to work with me and I started to bike to work on some days instead of driving.  Because of the former, I no longer needed needed the degree of organization that the eBags Professional Slim offered.  Because of the latter, I needed to bring a change of clothes (including shoes sometimes).  The Professional Slim is great with all of this organizational pockets and the especially its device garage, it didn't offer much room in its main cavity for bulky items such as clothes and shoes.

I started to look for a different backpack and I found the Dayfarer.  The Dayfarer is a minimalist everyday carry (EDC) backpack that is designed for gym and work with an emphasis on convenience.  I've been using it as my daily backpack for the past year.

A sleek and functional backpack for everyday use, which blurs the line between sport and work.

The Dayfarer offers minimal organization but a lot of convenience.  Whether it is the magnetic clip that can be operated with a single hand, shoulder strap pocket, easy-access side pockets, front-and-back hidden pockets, top and side handles, and luggage handle pass-through, each feature of the backpack is meant to be easy to use and/or access.  I really like backpacks with side handles because I find it easy to grab to put in-and-out of the car.  The sides pockets can be access without having to take off the backpack and the front pocket can be access without opening up the backpack.

The separate laptop pocket can also be accessed without opening up the main compartment.  Most of my most needed stuff are put into these pockets so I don't normally have to go into the main compartment.

When I do need access to the main compartment, the magnetic locking clip can be operated one-handed.  The kinda-of roll-top style turns out to make the backpack very flexible and easily expandable when more space is needed but more compact when it does't need to.  The backpack can also open flat to let you see and access the entire contents at once.  Most of the time, I don't open it up flat and just access it through the top.  I didn't find Dayfarer's info to really show this but reviewer Chase Reeves shows it on his video review.

There's not much organization on the inside besides two pockets so it is basically a large bag to put things in.  When I do need to bring a bunch of small items, I use my Peak Design Tech Pouch and just put the entire pouch into the main cavity.

The bag has a ventilated shoe compartment with a waterproof separation from the make compartment so it can be used to carry shoes or whatever items (e.g. dirty clothes) you you don't want to get mixed
in with your other stuff.

This bag offers a lot of flexibility in how and what it carries.  I've mentioned how it's roll-top like design makes it very expandable but for those who need more space, the backpack has loops on the bottom so you can hook things like your tripod or yoga mat to it rather then put them into the bag.

The Dayfarer is not very heavy at 2.5lbs.  The materials are high quality (waterproof balistic nylon, water resistent YKK zippers, etc.) and it is well constructed.  This is not a fancy backpack but a well designed one.  The pricing is reasonable although be aware that this is shipped from Germany and will take time.  My order was shipped within a few days but once it reached DHL there was no updates for nearly 2 months before it arrived.

The only thing I wish it was better on is for the top handle to be connected to the main body rather then the back.

The reason being that if you forgot to zip up the laptop compartment then when you use the handle it is pulling from the compartment's back.

After a year of use, the backpack has held up well and doesn't show any wear-and-tear except for some scuff mark on the buckle.  I really like this backpack and I've used both as a daily work bag but also when going out on the weekend when I think I might need to carry something.

Sunday, February 16, 2020

Modern Day HP Voyager Calculators by Swiss Micros

There are two particular electronics devices that even decades later are still used and considered superior to any modern competitors: the IBM Model M keyboard and the HP Voyager line of calculators.  Fans of these devices loving hold on to these devices even after decades of active use and will only give them up if it's pried from their cold dead hands.  While nostalgia does play a role in generating love for "retro" devices (as we see with the release of retro style gaming console), what sets the IBM Model M keyboards and HP Voyager calculator is that these devices are just really good at what they do and their style and design are no longer being manufactured (well, at least no longer mass produced by the original manufacturer).

Do a search on Google and Youtube you'll easily find fan sites that will explain in glorious details what makes these devices so special.  I have an HP 15C and it is as great as what people say it is.  From build quality, legendary battery life (we're talking about the battery lasting years/decades, folks) to the "feel" of the keys as you type, this is a phenomenal calculator that I've come to appreciate a lot more now then when I first started to use it.

The HP Voyager calculators are more niche then the the IBM keyboards.  People still regularly use a keyboard while the use of a dedicated calculators are now mostly limited to academic and research settings.  Even when these devices were sold by HP, it wasn't sold at the scale which IBM's keyboard were sold at, but once you've convinced yourself on how awesome these calculators are the question is how to get one many hasn't been sold or made in decades.

However, I'm a software engineering by trade and it was not until after I started working (and long after its production run in 1989) that I discovered that HP had made a version for computer programmers:  the HP-16C.  Once I did find out about its existence, I dreamed about owning one, but the HP-16C is even rarer to find then the 15C and as much as I might desire one I'm not going to pay whatever the asking price is when it does make a rare appearance on the auction market.

Then one day, I came across a company called Swiss Micros that was started by Michael Steinmann.  Apparently, Mr. Steinmann set out to clone the HP Voyager series and started to do so in 2011 with "mini" replicas that are about credit card size.  While these are cute, I wasn't too interested, but then Swiss Micros began to make full size replicas and that caught my attention.  Now I had a chance to experience a 16C directly so I ordered the Swiss Micros DM16L.

From its website, it's obvious that this is a small operation and it's selling a niche device, but the device shipped quickly.  It took awhile for it to actually reached me, but it arrived well packaged.  It doesn't use any fancy marketing box that modern devices tend to come in, but that's better for the environment!

My first impression was "wow, this thing feels solid".  These is a high quality RPN calculator for professionals.  I immediately tried out the keys and it had a very pleasurable tactile feel to them.  On its own merits, it is a top tier calculator, but people are likely buying this because they want an "new" HP Voyager.  I feeling that it does capture the spirit of the Voyager but this isn't an exact clone (and not just the logo and name).

The feel of the keys aren't the same which is noticeable when used side-by-side, but if you haven't touched an original in years then my guess is that you'll find just as much satisfaction with the DM16.  The lettering on the key caps are printed on the keys rather then injected into the key itself.

The overall dimensions are nearly identical but the LCD screen is bigger, the fonts are larger and there are multiple fonts to chose from on the DM.  I find the Voyager font to be cleaner and easier to read but font style is subjective.

The DM manufacturing is not as polished (both figuratively and literally).  The titanium casing around the LCD display showed the machining line and felt rough and not polished like the Voyager.  I'm not sure if it is intentional to show the grain of the metal (which is more yellow than the silver on the Voyager) but I suspect it isn't.  The rest of the case is well manufactured and everything is put together solidly.

If you noticed that the LCD has some spots/specs stuck in it even when turned off you can put the calculator in direct sunlight for a few days and they will disappear (easier and faster then to send it back to Swiss Micro and getting an replacement).

Would I recommend the Swiss Micro calculators?  As a quality RPN calculator, the answer is "Yes", but for most people it might be an overkill and pricey.  These aren't the calculator you want to just pick up and throw into the kitchen utility drawer.  For fans of the HP Voyager, fans of RPN calculators, and professional looking for a dedicated calculators then this is a solid piece of equipment to add to your toolkit.