Virtual Box to Hyper-V

June 10, 2020

By enabling WSL 2, VirtualBox VM will be almost unusable at the moment ( June 2020 ).

If you need to migrate existing Windows VM, one of the free option is Hyper-V.

Steps I took:

  • Ensure Hyper-V is installed
  • Export vhd from existing Virtual Box's VM
  • Convert vhd to vhdx
  • Create new instance of VM.
    I use VM generation 1 for this purpose as the VM is Windows 8.1. Attach vhdx to this new instance.

It wasn't the smoothest process, but in the end everything is working.

Simple Issue with Task Scheduler App

June 6, 2020

I experienced an error which took my time today. Fortunately, this is for unimportant side project.
It just sucks that I spent several hours being confused.

I was trying to register my application with Taskmaster to Windows Task Scheduler. It worked, but somehow my executable didn't launch as expected.

I already tried to log more, but the error happened before the logger works.

In this case, it is better to change executable path to:

cmd /k "exe-name.exe param"

This way, Windows command line will appear. I can see the error there.

This is simple thing, but costed time.

WSL 2

June 5, 2020

Windows Subsystem for Linux (WSL) 2 is a new feature in the latest Windows Update.
Basically it is a way to run Linux Virtual Machines (VM) on top of a thin hypervisor. Compared to a normal VM, this approach is way faster.

It feels like inside Windows, you have Linux side by side.

At the moment, I only adopt it as my local development environment for office related works. They are mostly in PHP.
This way, I can still keep PHP away from Windows, and I can install multiple versions of PHP and MySql easily with docker.

I like the performance of WSL 2. I also love that VS Code with WSL - Remote plugin makes WSL integration seamless. However there are several things which I miss:

  • Git GUI client
    I like TortoiseGit but my files are in the Linux file system so it isn't as fast and rather error prone. My current approach is just command line + VS Code. Once the Linux GUI support arrives to WSL 2, I will probably use other Git client.

  • VirtualBox
    One of my office tasks is maintenance task with the older Visual Studio 2013. I prefer not to slow down my PC, so I just use Windows VM. Unfortunately WSL2 requires Hyper-V component, and it will either make VirtualBox performance slower or unusable for older versions of Virtual Box.

Lucky

May 17, 2020

Criminality rate is increasing in my country during this Covid-19 season. The town I live (Batu) can be regarded as a safer place to live.

In spite of that, something unusual happened 2 days ago. My phone was probably stolen.

Our rug store, which is closed due to Covid-19, still serves buyers, if they are regulars or if they buy in larger quantities.

Shit happened. My phone was gone right after I returned the change. The buyer took it in front of me, and I didn't even realize it. I only confirmed it after checking the CCTV.

I am not sure if he did it accidentally, but I am pretty sure my phone is unique as it looks dirty 😀 It is a cheap Asus phone with large battery. I don't do anything special with phone except for browsing and Whatsapp. However I store a lot of personal and office documents. So it left me very anxious. I can limit the document access by changing my Google password, but I wasn’t sure if there are important documents stored locally. This is the same case with losing a wallet.

Long story short, I managed to get it back in a relatively unusual way. I tried to call my phone several times but no one accepted it. I managed to get it back in one of the partial lockdown (PSBB) posts because the buyer was a contractor for building temporary police posts. I know it sounds weird/anti climax, but it was what it was.

In the end, God bless me !

Post Mortem: Custom CLI for WordPress Data Migration

May 12, 2020

Everytime there is web revamp, we often need to do database migration. This process is usually frustating and time consuming. Most people don't know much about this part, they just want to see the old data are migrated properly.

In company's recent task, the old and new website are both built with Wordpress (I know this doesn't sound cool), with very different custom fields. The images are stored in S3.

Background

For previous revamp project, I used custom command line interface ( CLI ), written in Node.js. It extracts data to XML format and use WP All Import plugin to import it.

The import process was slow, which can be understood as it is web process. It involved a lot of downloads, thumbnails generation, and image uploads.

Last time, the actual migration took roughly a week, including overtime. It was very tiring and cumbersome as it still involved manual process of uploading xml files to avoid timeout.

Direct data migration between database is definitely better as it is much faster. This requires us to know fully how data is being stored in the new system.

Things to Consider

There are 2 main things:
- App should be long running.
- The existence of library for reading and creating PHP serialized data.

It is unfortunate that Wordpress stores some data in PHP's serialized format, which is more cumbersome than JSON. I guess it is part of legacy decision, and Wordpress needs to maintain backward data compatibility

For the first point, CLI app is suitable. We can run the app and leave it to run without intervention.

Nowadays almost any programming language can be used to build CLI. In fact, PHP itself is suitable. Node.js is also a good option, it has rich community and there's code snippet for PHP (de)serialization. I also like the syntax of modern Js.

However I was looking for something different, which is Go(lang). I tried Go before, but I have never developed anything, and especially under deadline.

Doing something new in limited time can be thrilling. Especially if the tool I use has a lot of community support and modern enough.

How It Works

Generally the steps are:

  • CLI app builds model for each post types from YAML definition files.

  • App extracts the data and image urls from source DB based on model, and stores it in intermediate format. I use Sqlite database for this purpose.

  • App downloads, generate sub images/thumbnails and uploads image data. Golang's goroutine is good for this part. For image processing, I just use pure Go library, imaging

  • App modifies the target DB based on Sqlite.

The app itself is not that complex. However, checking how the data being stored takes time. Some ACF field types like Repeater and WP's attachment data are relatively complicated.

Additional Notes

The app can be run in normal CLI, or with web UI for status report.

As it is just status report from server to browser, I use server-sent events.

Conclusion

I am quite impressed with Go.

Based on this task, the advantages are:
- Single binary
- Fast enough

Things I don't like:
- Error handling pattern
- Built in regex doesn't support backreference, which is needed to find enclosing shortcodes.

For this task, I don't really need generics, which is not supported yet in Go.

A Little Bit of Positivity

May 10, 2020

During this uncertain times, I read a lot of bad news.

A lot of people got infected with Covid-19, there is increase in criminal activities, higher rate of unemployment, etc. Even the hospital beside home has a lot of medics tested positive in rapid tests.

I have lived like a hermit for this past 2 months. I stay at home and only go out to minimarket if I want to get bread. During weekend, I just order some foods.

Yes, this way of life sucks

I can go on with bad news, but a lot of people have worse challenges in life. If I think a bit, we still need to be grateful to God for a lot of things.

Peaceful Time

100 years ago, during the Spanish Flu outbreak, there was World War 1.

I can't imagine what I would do if I lived during those times. I can't cook, can't repair home, and can't fight.
I would have been a useless slob, as software engineer is a relatively modern job.

Despite ongoing conflict in some parts of the world, it is arguably that the past 20 years has been the most peaceful time in history.

(More) Good People

I have impression that people in this generation are generally better. At least, more polite, regardless of their origin.

Obviously, I live in small town, I don't interact that much, and my perception is skewed.

However, from social media and from outsider perspective I am under impression that people treat others better.

Internet Era

Internet has been integral part of our life. 20 years ago I would have to go to internet cafe just to browse sites (CodeProject and GameFAQs mostly), and bring flash disk, which can be easily infected with virus.

One time, I went to internet cafe near Ubaya university. I just spent less than 1 hour, and when I come to cafe owner/guard to pay, her expression was smug. She knew that time I spent all of my session to browse sites for sexy/adult pictures.

Nowadays a lot of things is accessible with internet. My aunties stream Youtube in their spare time.

This Still Sucks

“Life happens. Shit happens. And it happens a lot. To a lot of people.”
― Colleen Hoover, Slammed

Life is full of challenge, and bad things will happen in future too...

Today I am still a pathetic person, but I hope someday I will be better.

Text Limit By Number of Lines

April 27, 2020

One of the benefit having MS Edge as a webkit browser, is that we can use webkit prefix more freely.

The common (annoying) UI request is text limit by lines. I often asked my PM for character limit instead, which may not be reliable.

In 2020, we can just use -webkit-line-clamp property. Firefox has supported it since last year as well.

@mixin line-clamp($total){
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
}

Assuming the container already has width, we can just apply the above styling.

(Very) Basic Cooking: Fried Egg

April 15, 2020

"An egg today is better than no egg tomorrow"

I have never cooked in my life before, apart from instant noodle.

Not anymore.

It is eatable.

I don't have any talent and big interest in cooking. My aunts have cooked for me and I feel grateful.

However I will probably need very basic cooking skills just for survival purpose.