Lucky

May 17, 2020

Criminality rate is increasing in my country during this Covid-19 season. However, the town I live (Batu) can be regarded as safer place to live.
There was a small & unusual incident 2 days ago. I suck at explaning this, let alone in English, so I'll just use bahasa.

Di musim corona ini, toko karpet kami tutup. Selain sepi, bibiku juga di usia yang rentan tertular. Hanya saja bila ada pembeli khusus, kita masih melayani.

Dua hari lalu ada orang yang ingin membeli karpet untuk keperluan di beberapa pos pengecekan PSBB polisi. Ia sudah membeli di hari Selasa, jadi kami tidak curiga.

Pada saat pembeli pulang, aku baru sadar eh HPku ikut hilang. HPku sendiri ndak mahal (~3jtan), lusuh dan banyak goresan. Aku ingat benar aku naruh di atas etalase kaca. Setelah dicek dari CCTV, ealah ternyata HPnya ikutan terambil, pas aku memberikan kembalian di atas etalase kaca.

Repotnya kehilangan barang seperti phone atau dompet adalah hilangnya data/dokumen yang lebih penting dari barang itu sendiri. Phoneku sendiri tergolong normal, tapi data kerjaan kantor + dokumen pribadi ikut masuk di sana. Aku pakai Gmail + Google Drive extensively jadi banyak data sensitif kantor.

Pikiranku langsung ndak enak, jengkel rasanya GPS di HP tidak kunyalakan. Pas kucall juga tidak diangkat, entah apa karena PIN+fingerprint. Tapi setidaknya yang bawa HP juga sadar.

Setelah ke setidaknya 4 kantor polisi, sudah makin pesimis. Akhirnya pada saat tanya di salah satu pos PSBB polisi yang kecil, ada polisi yg cross check tanya apa hp yang digeletakkan di meja pojok itu hpku dan ternyata benar ! Aku diminta untuk call no hp tersebut untuk membuktikan. Sang pembeli tidak ada di pos tersebut. Mungkin ia kaget / merasa bersalah jadi ia meninggalkannya di pos PSBB, yang lantainya pakai karpet toko.

Meski tergolong perkara njeketek, tapi aku tidak menduga bakal bisa nemukan kembali. The whole story feels almost unbelievable.

Yang bisa kupetik:
- God bless me !!!
- CCTV is important. Resolusi kamera CCTVku kurang besar, jadi tidak bisa lihat plat nomor lebih jelas.
- Aku tidak drive car pada saat pikiran kacau, tapi pakai jasa tukang ojek depan rumah untuk keliling 2-3jam. It is nice to see there are good people around you!
- PIN / Fingerprint / Face unlock penting di HP
- Semua account sebisa mungkin perlu pake 2FA. Meski tidak ada efek dalam kasusku ini tapi setidaknya bisa memberikan peace of mind.

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.

First Impression of Go

April 11, 2020

Using something new in a limited time is actually quite thrilling.
I have a task for creating internal disposable tool for current project, and one way to make it more interesting is by using different language.

In this case, I use Google's Go programming language, which is growing in popularity.
My friends and ex colleagues from previous companies have used it for years, so I am way behind them in term of knowledge.
I have studied Go before in relatively limited scope, but I have never used it.

Now is still a good time for using Go. There's no need to structure code in GOPATH directory, which feels annoying for newcomer. Go module is also the official way of managing dependencies now.

I will likely post more detailed experience later (~ 1 month from now) after everything is settled. However I am satisfied so far.
It is a modern language designed for concurrency, yet relatively simple. There are few things, which I have mixed feeling, like the error handling pattern, and relatively different behavior of standard library from outsider perspective ( date format and regexp ).
However it is undoubtly a better language than PHP, which I use at daily work, and it has better runtime than Node.js.
Language wise, I like the syntactic sugar of Js more, but Js is single threaded. Node.js only has new Worker Thread officially since last year.

I expect Go will be still be relevant for the next 10 years.

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.