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 Minecraft.net 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/start_server.sh:

#!/bin/sh
/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/stop_server.sh:

#!/bin/sh
/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 start_server.sh
chmod u+x stop_server.sh

Automatically Start Your Server


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

[Unit]
Description=Start tmux in detached session running Minecraft.

[Service]
Type=forking
User=minecraft
ExecStart=/opt/mcserver/start_server.sh
ExecStop=/opt/mcserver/stop_server.sh
WorkingDirectory=/opt/mcserver

[Install]
WantedBy=multi-user.target
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"?>
<service>
  <short>minecraft</short>
  <description>Port used to allow remote connections to a Minecraft server running on this machine.</description>
  <port protocol="tcp" port="25565"/>
</service>
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:

#!/bin/sh
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/backup.sh >> /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/cleanup_backup.sh:

#!/bin/sh
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/cleanup_backup.sh >> /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 Terminal.app which is treated as a login shell.
For non-login shells (e.g. gnome-terminal) the order is:

   /etc/bash.bashrc
   ~/.bashrc
For login-shells (including Terminal.app) the order is: /etc/profile and then first of:

   /etc/profile
Followed by the first of the following:

     ~/.bash_profile
     ~/.bash_login
     ~/.profile

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.