I Have Been A Failure

March 30, 2020

Dear myself, I fucked up big time.

I spent my last 4 years achieving nothing special. Now is almost April 2020.

Lazy / Lack of Focus

I often told myself that I am smart.
I can study book / watch a lot of video tutorials in my spare time. However the most important thing is I have to use it to create something, which I didn't.
Knowledge in IT needs to be always up-to-date.
I told myself to learn / develop some app with Unity, Kotlin etc but in the end nothing happened.

Missed goals + Bad discipline

Time wait for nobody, I have failed to achieve some of my life goals.
I can only regret.

I have been overweight for several years, and I only start reducing weight last year.
I have habit of eating a lot at night, especially if I'm in bad mood. It is bad for my weight and my health. Issues like recurring knee injury after running and acid reflux are side effects from being overwright.
Now I am still overweight by 3-4 kgs based standard BMI.

I still can't do a lot of basic but important things like cooking.

Blog update

I don't use Ruby anymore. Today is the first time I touch Ruby for more than 3 years. I installed it just for maintenance of this Jekyll blog. I had to use old version of Ruby due to gems incompatibility.

I was going to update my blog with GatsbyJs. I was in the middle of Gatsby theme development, and somehow my focus was distracted.

I plan to write more blog posts, though some/most content will undoubtly be garbage. In the future I hope I can look back and see what I did during that particular year.

Foot injury

I got plantar fasciitis on my foot last month. Most likely it was effect of being overweight as well, apart from flat feet.
Now I don't run anymore, just exercise with rowing machine at home. Not sure if I will ever achieve 10 km run under 1 hour.

Covid-19

I am a home person generally, as I work remotely.
However it is stressful that I can't go around freely especially at weekend. I'd love to watch movie at cinema again or drink coffee while browsing / studying at coffee shop.

Life is full of unwanted events. Most can be attributed to my own failures.
Everything will be fine ....... hopefully.
I will try to fill this year with fabulous adventure in coding !
May God bless us and keep us strong everyday !

Life of My Raspi

July 5, 2016

3 years ago, I followed the hype, and bought a Raspberry Pi model B, without really using it.
Fast forward to today, I opened my cardboard box and found it again.

Vagrant Settings for VirtualBox Networking

June 20, 2016

Bad things happened, my fiber internet disconnected for several days and I had to use tethering. Unfortunately, my vagrant's virtual box network connection became very slow.

config.vm.provider "virtualbox" do |vb|
...
   vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
   vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
...
end  

Adding natdnshostresolver1 and natdnsproxy1 fixed the issue.

Detecting Document Width Early

June 17, 2016

I just had a situation where I need to put ad in different location for mobile view. The placement is hard to solve via CSS appproach.
So I had to do some width detection inside Google Publisher Tag (GPT) slot definition, which is executed early and async.
For some reason $(document).width() is not always evaluated.
It appears that jQuery approach is best used after document ready event, which is not suitable for my purpose.

Fortunately Modernizr's media query function works in my case

...
var isDesktopView = Modernizr.mq("screen and (min-width:970px)");
....

Using SQLite as Data Store In Unreal

May 30, 2016

We are researching for the best way to store dialogue data with Unreal.
The default approach for storing data in Unreal seems to be DataTable, which can be created by importing CSV file. However dialogue seems to be relational data, so we are wondering if the embedded databases like SQLite is a good way for storing data in Unreal.

Compiling SQLite as Static Library

As I was a desktop app developer, the first thing that comes to my mind is SQLite. The common way to include SQLite is by referencing it as static library. As there is no downloadable .lib, you will need to download the source code from https://www.sqlite.org.

If we compile the source code directly, it will seem to work. However once we try to execute SQLIte function in our project, we get "error C4703: potentially uninitialized local pointer variable used".
Thanks to this SO post, I managed to solve the issue. Basically, we need to add the following lines in sqlite.c

#pragma warning ( disable : 4703 )   

Including SQLite in Unreal Build System

First we will need to include header and .lib file in code directory.
For the time being, we use this directory structure

Root Project
    ...
    Third Party
        sqlite3
            Includes
                sqlite3.h
            Libs
                sqlite3-x64.lib
                sqlite3-x32.lib
    ...

Unreal uses Unreal Build Tools (UBT) for managing the build process.
UBT itself is C# based, and we will need to do build config in C#.
In every module, we will find module rules files, which use ModuleName.Build.cs as file name convention. We need to inform module rule that we will need to load SQLite

public MyProjectName(TargetInfo target)
{
    ....
    LoadSqlite(target);
}

private string ModulePath
{
    get 
    { 
        return ModuleDirectory;
    }
}

private string ThirdPartyPath
{
    get { return Path.GetFullPath(Path.Combine(ModulePath, "../../ThirdParty/")); }
}

public bool LoadSqlite(TargetInfo Target)
{
    bool isLibrarySupported = false;

    if ((Target.Platform == UnrealTargetPlatform.Win64) || (Target.Platform == UnrealTargetPlatform.Win32))
    {
        isLibrarySupported = true;
        string PlatformString = (Target.Platform == UnrealTargetPlatform.Win64) ? "x64" : "x86";
        string LibrariesPath = Path.Combine(ThirdPartyPath, "sqlite3", "Libs");
        PublicAdditionalLibraries.Add(Path.Combine(LibrariesPath, "sqlite3-"+PlatformString+".lib"));
    }

    if (isLibrarySupported)
    {
        PublicIncludePaths.Add(Path.Combine(ThirdPartyPath, "sqlite3", "Includes"));
    }

    return isLibrarySupported;
}

The above code is based on Unreal wiki, adapted to version 4.12.

Packaging

One thing to note, is that database file need to be copied into package folder, and not included in PAK file. This can be done via specifying "Additional non-asset directories to copy" in packaging settings.

Conclusion

To be honest, we are still not 100% sure if we want to use SQLite. In our plan, we will just do read operation, so there won't be any lock issue. However SQLite is platform dependent, and we don't know if the code will be 100% compatible if we run it in other environment, like game consoles. For now, we will just refactor, so we can fallback to use DataTable if SQLite is not supported.

It's Time to Leave Boxing, Pacquiao

April 11, 2016

Last Sunday, Manny Pacquiao beat arguably the best welterweight, Timothy Bradley in their third match.
This is kind of fight which I don't like personally, I like both of them but they have fought twice before. Pacquiao has shown he was better in both occasions, though Bradley got the decision in their first fight.

This third fight was still a good fight, both of them are high quality boxer but their second fight was much better, and higher pacing. This time, Pac was slower and more inactive than before, but he is still faster than Timothy Bradley which is a fast boxer himself. Fortunately, Pac's strategy of counter punching was effective. He was able to deck Bradley twice, though the first knockdown was more of flash knockdown.

I always rate Bradley as the best welterweight outside of Mayweather and Pacquiao, and he is a top 10 pound for pound. I just think that Pacquiao's style is bad for Bradley. As good as Pacman is, he can't fight father time. He is slowing down and as someone who has other priority in life (politics), he should leave boxing for good.

There was no one like Pacquiao, an 8 divisions world champ, and it will be really hard to exceed it

My First Few Months With Unreal Programming

March 26, 2016

I am a newbie in game development world. This past few months I have been researching Unreal Engine 4 (UE4) with my friend.
We found that game development is still hard and time consuming but UE4 does help a lot !!!

C++ Programming In UE4 Is Nice

I am not an expert in C++ but doing C++ programming with Unreal is nice.
It uses macro to make C++ becomes more "modern", like marking a class to be reflectable, supporting delegates and events.

Similar to managed languages like C#, Unreal has reflection and garbage collection. So any classes derive from UObject can be garbage collected automatically.

The current Unreal version (4.10.x) needs Visual C++ 2015 so it also supports newer C++ syntax.

Blueprint Is A Good Visual Scripting Language

Blueprint is UE4's own scripting language. It is visual based and supposedly friendly for non-programmer. Obviously Blueprint runs slower, but in some cases like animation, you will need to use Blueprint to manage states.

Blueprint is a very good visual scripting system however, C++ is more friendly for programmers like myself. Doing a simple function can be much longer if we use Blueprint. Fortunately, UE4 has comment mechanism which is useful for grouping list of Blueprint nodes.

As for Blueprint usage, my current approach is try to code all classes in C++ first. If a C++ class needs to be editable in editor, then we will create Blueprint class derives from it.

Documentation is Relatively Good

There are a lot of things to learn in game development with Unreal, so a good documentation is really needed. Coming from .NET background, I find that MSDN is much more complete. There are a lot of class without explanations in UE4 doc, but overall it is acceptable.

Community Is Active

Fortunately even if documentation is not complete, the UE4 community is really active. For most cases, if I'm looking for explanation of API and I can't find it in documentation, I'll just search in Unreal forum.

Special mention should be given to Rama. I found that he created a lot of helpful articles on wiki and answered a lot of UE4 questions as well.
Although he is a contributor to UE4 code, he seems to be an outsider, and he is a spiritual healer as well !!!

Unreal Editor is Slow and Requires A Lot Of Memory

Visual Studio 2015 loads fast but it still requires a lot of memory (more than 700 MB in my case).
Unreal Editor, which is IDE for UE4, loads slower and requires much more memory.

Debugging Is Slow

For editing and designing purpose, you will use Unreal Editor directly.
However for normal debugging session, your code will launch Unreal Editor so it takes more time to test and fix code.
One more thing, testing workflow in UE4 isn't that good. It doesn't support TDD approach, and loading test cases needs to close and reopen Unreal Editor.
I commented on UE4 testing workflow here, but apparently they don't have any roadmap for this testing issue.

 
So far we believe that choosing UE4 as our engine is a correct move.

Integrating Gravity Form With WP Offload S3

March 20, 2016

Gravity Form is a very useful plugin for form input.
However recently we realized that it didn't handle file upload properly if we use WP Offload S3 plugin. It will still attempt to store file to local file system. This was an issue for us as we use PaaS, and server instances can be swapped anytime.

Luckily Gravity Form provides filter which we can use too hook our own function.

To use it, you just need to include the above file from theme's function.php .

The above code is adapted from Gravitate's post.