Posts

Using Value Object as an ActiveRecord Attribute

Two weeks ago, I was working on a simple task, to add a query param to an embed url. This embed is actually from the main site, which I'm also working on occasionally. I understands how this urls work and which path of a url lead to which resource. And while my task was just to add a query param, I had to add it in 2 different classes. Which of course, as a good software engineer, I think that at least something must be refactored.The problem was in attempts to validate the embed url, these classes uses almost similar but slightly different method. One of them only needs to validate a livestreaming url, and the other needs to validate  both livestreaming and vod urls. In my first few attempts, I wrote a couple of validator classes, and I even tried to use ActiveSupport::Concern to wrap the validators. But something keep telling me, "Hey, this doesn't feel right, but that one doesn't either". "Yea, okay. But what will feel right?" Yes, you read the title…

Setting up a Green Branch

Lately, I've been working on short chores. Most of them can be finished in an hour or less. To keep my productivity high, while waiting for the CI test for said chore, I would start another chore. At the time I finished the second chore and the first chore's tests were all green, I need to submit a merge request and wait for the approvals. That is another waiting time, which means that I can start the third chore while waiting for the second chore's tests to finish.
Working with git means that every chore will start on its own branch. Usually, my workflow when starting a new branch was like this: Checked out the master branch,Pulled the latest commits from remote repository,Looked for the latest green tag (which is a commit in master that has passed the latest test),Copy that tag name,Check out the tag,And finally check out a new branch from that tag. Those are the 6 steps to do for just a chore. Imagine that for like 5 chores a day, I can have 30 steps to repeat every day. A…

How to Upgrade PostgreSQL 10 Cluster to 12 in Ubuntu 20.04

When I upgraded my Ubuntu 18.04 to 20.04, the postgresql package was upgraded from version 10 to 12. But the upgrade couldn't remove the postgresql-10 package, because there were v10 clusters in my system, and I had to manually upgrade them. This is how I migrate the v10 cluster to v12 cluster.

To begin with, Postgre has this pg_upgrade command. Here is the link to the documentation. The syntax is as follows:

pg_upgrade -b oldbindir -B newbindir -d oldconfigdir -D newconfigdir[option...]
It is in /usr/lib/postgresql/<version>/bin/ directory. But when I ran this command within my linux user context, I got Permission denied. It also forbids running as sudo either. The only way that makes sense now is running this command as postgres. Please note that I'm using the --check flag below to avoid running the real migration. And don't forget to stop the postgresql service beforehand.
chris@focal:~$ sudo systemctl stop postgresql chris@focal:~$ sudo su - postgres postgres@focal:~…

Monkey Patching Vagrant LXC Issue in Ubuntu 20.04

Image
Ubuntu 20.04 Focal Fossa was officially launched just a couple of weeks ago. And I thought it was the best time to say goodbye to my Ubuntu 18.04. Looking back then, I was so determined entering the world of Ubuntu 20.04. But little that I knew, I will be losing sleep figuring out why my vagrant lxcs won't "vagrant up".  

It started with my attempt to upgrade the operating system. I opened up the Software Updater, but there was no upgrade offer anywhere in the prompt. I checked the settings in Software & Updates app. Looked into the "Updates" tab, the "Notify me of a new Ubuntu version:" option said: "For long term support version". Well, 20.04 is an LTS, isn't it. It should be there, but why it isn't?

Changing the option to "For any new version", prompted me with 19.10 upgrade but no thanks, 19.10 is so yesterday.What have I missed? Googled it and I found that Software Updater won't give you the prompt, until the do…