Hobby project using fly.io

Just tried fly.io. It is super nice, because it allows to “run small application for free”. Since I have a hobby project (bible related), I dockerize it and deploy on fly.io. And it works well. Here is the link.

The hobby project above now only supports Studium Biblicum.

Software engineer’s soft skills

As a software engineer, he/she needs to have the hard skills especially writing source code, debugging. He/she needs to know multiple programming languages (eg C, C++, C#, JavaScript, Python, etc). It will be even better if he/she can write tests, adopt TDD, write clean code, do refactoring, know how to implement various algorithms (search algorithm, sort algorithm, dynamic programming, etc), review code. These are all hard skills.

However, in order to perform well in the working environment, software developers are recommended to adopt several soft skills. These skills will help the team to improve the productivity.

Work estimations – Engineer needs to know how to do the estimations of the given tasks, so that the project manager can do estimation on when the features can be delivered or released. Based on the estimations, the project manager will decide the priority of the tasks.

Task break down – Engineer needs to know how to break down the tasks. A feature maybe too complex. Eg, a user story may say that, “As a user, I want to purchase a product online.” Though it is one sentence story, it can be break down into various sub-tasks, such as payment, user interface, validation, etc. It is necessary to know how to break down the tasks, then only can do better work estimations.

Foresee the issues – Sometimes the project manager or the client may want some feature. The engineer needs to think further in the technical perspective, because other users (project manager, end user, graphic designer) may not understand the possible issue. Once the engineer for see the issue, engineer should raise the issue, so that project manager can decide what to do next. By keeping silence, it will bring the feature to dead end at the end, and wasting the time and money.

Communication – Always communicate with the project manager, or other team member. Anything unclear, just ask, since this is the responsibility of the engineer. Without asking, nobody knows you don’t know. Sometimes it is the specifications not clear, because the project manager may not know as well. This will require more discussions.

Self-learning – Though communication is important, the engineer should know how to learn new things by him/herself. Technology is evolving, new technology is emerging everyday. Sometimes engineer will be assigned with task that involves to explore or experiment new technology, as a result, engineer needs to learn it.

Godot Mono and tests

In my previous post, I mentioned about using C# for Godot Mono. However, recently I found that, due to MonoDevelop is inactive, it causes my personal project not able to be built. As a result, I have to change the build tool to dotnet CLI. This can be set through

Godot (Mono) > Editor > Editor Settings > Mono > Builds > Build Tool

Besides that, I also changed the External Editor from MonoDevelop to Visual Studio Code. Visual Studio Code is nice for the C# project. It has autocompletion and able to find function definition and function references.

Previously, because I was using MonoDevelop, the Nuget packages (similar to npm packages) is managed by MonoDevelop, which I can add new packages through GUI. But now, I migrate the project to dotnet CLI, there is no more GUI. Luckily, dotnet allows to add Nuget packages to my existing project. For example,

dotnet add package MathNet.Spatial
dotnet add package MathNet.Numerics
dotnet add package NewtonSoft.Json

This will update the .csproj file. NOTE: This csproj file can be generated by adding a C# script through Godot Mono.

Tests

The advantages of using C# comparing to GD script (Godot script) are

  1. inheritance
  2. lambda syntax
  3. tests!

I was using FluentAssertions and Machine.Specifications previously on MonoDevelop, by creating a library project (.dll). Then run the command for the tests. However, after migrating to dotnet, I failed to run the tests. I tried several solutions.

Dotnet official websites mentioned about xUnit and NUnit. I tried both, but I failed to make both work. I failed to run the tests with dotnet test.

At the end, I use back FluentAssertions and Machine.Specifications.

Firstly, add the two packages to the existing project, not as a separate project.

dotnet add package FluentAssertions
dotnet add package Machine.Specifications
dotnet add package Machine.Specifications.Runner.Console

The Machine.Specifications.Runner.Console is important. I found that both xUnit and NUnit have runner console packages as well. Probably I can run the tests without dotnet test for both solutions.

After adding the packages, then I run a script to invoke the tests.

#!/bin/sh

PROJECT_NAME=MyProject
export MONO_PATH=./.mono/assemblies/Debug
CMD="mono $HOME/.nuget/packages/machine.specifications.runner.console/1.0.0/tools/mspec.exe"
TARGET=".mono/temp/bin/Debug/${PROJECT_NAME}.dll"

if (( "$#" > 0 )) ; then
    $CMD $TARGET -i "$@"
else
    $CMD $TARGET
fi

Export MONO_PATH because it contains GodotSharp.dll and GodotSharpEditor.dll. GodotSharp.dll is necessary as our C# source code inherits the classes from Godot.

The shell script above will invoke mono mspec.exe, where mspec.exe locates at .nuget in our home directory (I am using Linux). mspec.exe is installed when adding the project Machine.Specifications.Runner.Console.

Finally, the script will run mspec.exe to test the MyProject.dll assembly. MyProject.dll is built through Godot Mono. Godot Mono will create the assembly file .dll based on our project name.

Yay! It works.

One drawback is that, I cannot separate the tests code fro the project. The ideal solution is to have MyProject.dll and MyProjectTest.dll. Our test code should be compiled and build the MyProjectTest.dll, and it depends on GodotSharp.dll and MyProject.dll. However, it is very troublesome, because Godot Mono is not able to add project like MonoDevelop. So, the fastest solution I have is to have the tests be compiled into one .dll.

Med (Linux Memory Editor) version 3.7

Med version 3.7 released.

The custom search feature now allows other scan types (int8, int16, …, int64, float32, float64), including the operators. Now also supports int64 scan type, which can be found in 64-bit games.

Besides that, there is new operator “~”, which acts like “search within”. I use it as a shortcut for search within, especially search the float number we see in the game, 999, which may be 998.999 or 999.1111. By using “~”, it will translate to search within [998, 1000]. It allows second argument, as “± x”. Without second argument, it is “± 1”.

The custom search allows to search data structure, such as a character level 10 (int32), HP 1000 (float32), HP Max 1000 (float 32). By using custom search, we can enter i32:10, f32:1000, f32:1000.

Moreover, there is a bug fix on scope search.

Simple music generator

I just revived my very old hobby project, Musgen.

I was interested in artificial creativity, was intended to advanced my study of doctorate on this topic. However, due to lack of the expertise in the local universities, I didn’t advance my study on artificial creativity.

Imagine that, if I can generate musics, then I can create my own game with any random background musics.

Med (Linux memory editor) version 3.6.1

I released version 3.6.1 for my hobby project, Med (Linux Memory Editor). There are several great changes in UI (since 3.5), especially the larger window, due to more components in the UI.

Named scans

Now it supports named scans (the bottom part of the window).

New UI

I create this named scans feature because sometimes I need to scan for several values of interested. For example, a game character A’s experience point and character B’s experience point. By using named scans, I can scan these two values without destroying the scan result of each others. This makes my (game cheating) life become much easy.

Improved memory editing

Memory edit

Memory editing is now improved with preview the values in int32, float32, and float64 (double as in C/C++). This is useful for me to discover the pattern surrounding the game character status. For example, there is a game I played, the character has non-rounded float32. This causes me failed to search the values for various trial. Lastly I found the address by scan unknown. By using these three values preview, I can discover the values easier without doing actual scanning.

Furthermore, memory editing now supports “entering” the value according to the scan type (the Enter button). In the versions prior to 3.6, memory editing can only directly edit the hexadecimal. This is troublesome to edit the float values. Previously, I have to create a new memory address in the stored list, then edit the value. But now, I can update the values directly.

Besides that, in the memory editing, it supports “string” scan type, for entering the string directly.
WARNING: Longer string may cause the memory overflow.
NOTE: Entering string is not null-terminated. Add the null (0) value at the end if necessary.

Lastly, I fixed the cursor in the memory editing (hexadecimal area).

Brave and Chromium

I have switched my primary web browser to Brave. But also found that Chromium (or any alternative web browser) is necessary. Since I am a software developer, sometimes need to implement ads related feature. Brave will block ads by default. That’s why I need an alternative web browser that I can freely to turn off the adblock. Though I can turn off the adblock in Brave, it will affect my browsing experience. As a result, using an alternative web browser for development on ads related feature is necessary.

Godot and C#

In my previous post, I wrote about my hobby project with Godot.

Limitations of GDScript

But I personally feel that, Godot script, namely GDScript, is not my favourite. Though GDScript is good enough to do anything, it is not what I like. Firstly, it is Python-like language. In my opinion, using indentation as scope is annoying, because I cannot auto-indent using Emacs. Due to my first programming language is C, and heavy use on JavaScript, braces (curly brackets {}) are easier to read.

Besides that, GDScript doesn’t have array operations similar to JavaScript, such as forEach. C# has List class with ForEach method. There are similar methods like map and reduce using LINQ.

Moreover, C# supports lambda expression. This is which GDScript cannot support. Even Python cannot do multiple lines lambda expression.

Comparing C# and GDScript, C# may be slower for development, but learning C# will be more useful than GDScript, as C# is a general purpose programming language. And C# has richer syntax.

Another reason I choose C# over GDScript is the testing. As a web developer, TDD (test-driven development) is a useful approach to make the product more stable. Development in GDScript doesn’t allow me to test my functions by writing test cases. If I choose C#, I can install Machine.Specifications (or MSpec) and Fluent Assertions through NuGet, then write the tests.

In fact, Godot supports native script using GDNative. This allows you to develop your module using C or C++ language. I like C and C++, but they are less efficient comparing to the modern programming languages. They are inefficient for development, as there is no garbage collection. Smart pointer is not garbage collection. However, C++ is acknowledged as best language for game development, according to Google Search.

Setup Godot Mono in Arch Linux

This section is Arch Linux specific.

Firstly, read this, and install godot-mono-bin. Secondly, install MonoDevelop and msbuild (msbuild-16-bin).

Once using Godot Mono to create a project, a solution file (.sln) and a project file (.csproj) will be created. These files are compatible with MonoDevelop. If you cannot open, probably you are using wrong version of msbuild.

To setup .NET Core in MonoDevelop, go to Edit > Preferences > Projects > SDK Locations > .NET Core, edit the location of the dotnet CLI as /opt/dotnet/dotnet, it will detect the SDK and runtime automatically.

Note: /usr/bin/dotnet cannot work, because it is a script.

Then, you can build your C# module using either MonoDevelop or Godot (Mono support). One great thing is, we can use both C# and GDScript together in the same project.

About NuGet

Unluckily, not every package manager acts like npm (Node) or bundle (Ruby). To install packages through NuGet, best approach is to use MonoDevelop.

Best web application framework I like

So far, in my opinion, Ruby on Rails is the best web application framework that I have used. Compared to others, it is very complete (by installing extra gems) and mature, provides everything that I need.

Version manager

There are two version managers: rvm and rbenv. I prefer rvm. It allows to work on different projects with different Ruby versions. Node has similar manager, nvm. Python has similar feature, but acts differently, using venv or virtualenv. In Python, we need to install the specific version, and create the environment by specifying our Python version. Contrarily, rvm or nvm will download and build the corresponding version.

Lambda expression

Ruby supports lambda or anonymous function, which can also be seen in JavaScript, as callback function. Newer languages such as C# and C++11 also support the syntax. The syntax is so useful when handling array. Python can support lambda expression, but it cannot support multiple lines like JavaScript.

REPL

Ruby on Rails has also very powerful REPL. With rails console, you can access the models easily, and manage the database through models.

Node can do similar, but it requires to write the script to setup the context. Meaning, we need to write the script so that REPL can access the controllers and models.

Debugging

Debugging in Rails can be done like client side JavaScript debug keyword, which require byebug gem. By using pry-byebug, we can debug the script line by line easily.

Migrations

Migrations and ORM in Rails simplify the development, as we need not to take care how the database should be structured, but focus on the models design, especially relationships like one-to-one, one-to-many, and many-to-many.

Migrations is commonly used in various web application frameworks, including .NET, Django, Laravel, etc. Node can implement migrations using sequelize and sequelize-cli.

Pagination

Kaminari gem allows to access the ActiveRecord with pagination related methods.

Serializer

By using ActiveModel::Serializers, we can make our JSON output more consistent.

Mailer

Mailer, which act exactly like Controller. And greatly, we can write preview page for the emails, in HTML or text.

CSRF protection

For the security, we can do protect_from_frogery to protect from CSRF.

BDD/TDD

Since we always need to test our code, BDD or TDD makes our development more stable and interesting.

By using rspec and factory_bot gems, we can do our testing easier, including mocking data and stub the methods.

Time travelling

Related to BDD, by using ActiveSupport::Time, we can test our code by specifying the date. Need not to use a date parameter through out all the function calls.

Job

We can do background job by using ActiveJob and also SideKiq.

Cache (SQL)

By default, the ActiveRecord (model) querying will use cache, example.

Drawback

Though Ruby on Rails is powerful, there is one limitation. There is no official support on Windows, which we cannot find the binary installation of the latest version of Ruby and Rails for Windows.

The only workaround for Windows installation is using WSL (Windows Subsystem for Linux). And this feature only available on Windows 10 and Windows Server 2019.

Meaning in older version Windows, probably needs to use virtualization like Docker or Vagrant. (I never tried before.)

Advantages

I prefer Ruby on Rails over Node, because Node has too many modules doing similar jobs, for example crypto-js and node-crypto-js. Too many options cause me to use extra effort to find out which one is better.

I prefer Ruby over Python, because of the lambda expression.

In my opinion, the advantage of Ruby on Rails is because of Ruby language itself.

To print the output, we can do puts something, instead of console.log(something) (JavaScript). Parentheses are optional to call the function, similar to Perl.

We can pass the hash to the function without braces, such as foobar(a: 1, b: 2). But in JavaScript, we need to do foobar({ a: 1, b: 2 }); in PHP, foobar(['a' => 1, 'b' => 2]); in Python foobar({'a': 1, 'b': 2}).

When developing using Ruby on Rails, we can apply Twelve-Factor and Design Patterns. We focus on code readability (using RuboCop), refactoring, and testing.

You can find a curated list of useful gems as well.

Godot and hobby project

Game engine

Previously I found a game engine LOVE (Lua language). Then I planned to learn about it. But then I read about Godot, which uses GDScript with similar syntax like Python. So, I choose Godot over LOVE because I have better experience in Python.

I planned to work on edutainment project since long time ago. Since I have extra time recently, so I invested little time on my hobby project. Using Godot, I revived my old project.

Godot provides a fantastic IDE. It allows to edit the UI, adjust any UI components easily. It provides almost everything I wanted: scene graph, everything is node, audio, video, texture, input, etc. The below is the screencasting of the auto play (with manual input) of the Tetris game.

(The new project is not open source.)

 

I am outdated

I like to play games (I believe everyone likes to play games). But most modern games are beyond my capability. There are several reasons:

  1. I am primarily using Linux.
  2. Not enough time to play game.
  3. I don’t have gaming computer.
  4. Though I like play story focused games like JRPG, I don’t like to invest time to collect items, level-up, etc, so I get used to use cheat engine (that’s why I created [memory editor](https://github.com/allencch/med)).
  5. Mobile games are mostly money-draining AND time-draining.

Because of the above reasons, I feel that it would be better for me to create my own game that fits my taste. Gaming of the 私, by the 私, for the 私.

The games that I love most are Dai Koukai Jidai 2 (大航海时代2) and Taikou Risshiden 5 (太阁立志传5). The reasons I love these two games:

  1. Not resource hungry like modern 3D games.
  2. Good story with the realistic history and background.
  3. Combination of JRPG, simulation (business), sandbox.
  4. Player can choose a protagonist from several characters. Each has its own story line, and they are in the same world.
  5. Realistic game play. E.g., earn interest from bank (Koukai2), monthly meeting and send gift to make friends (Taikou5), etc

I can’t find any other game that can fulfil the above conditions.