Randomly create a time.Sleep in Golang

To randomly create a time.Sleep in Golang you can use the code snippet below. You may want to simulate a load in your web server and have an arbitrary seconds or minutes before getting the reply. package main import ( "log" "math/rand" "time" ) func main() { rand.Seed(time.Now().UnixNano()) for i := 0; i < 15; i++ { delta := rand.Intn(6 + 1) // randomly generates numbers 1 to 6 time.Sleep(time.Duration(delta) * time....

July 2, 2020 · John Pili
Bus Seat Reservation UI Concept

Bus Seat Reservation User Interface Concept using Vue.js

In response to this facebook post. I created a simple bus seat reservation user interface using Vue.js and SVG. I started by preparing an SVG image of the bus seat and then render the SVG elements using Javascript (VueJS). You can use a raster image (sprite) for this but I prefer to use vector graphics (SVG) because it allows me to control the stroke and background color programmatically. The bus seat vector image looks like this...

May 27, 2020 · John Pili
MySQL Query – List Records That Don’t Exist From Another Table

MySQL Query – List Records That Don’t Exist From Another Table

Suppose you want to retrieve a list of products that are not in promotion. SELECT * FROM product t1 LEFT JOIN promo_product t2 ON t1.idProduct = t2.product_idProduct WHERE t2.idPromoProduct IS NULL

May 17, 2020 · John Pili

HTML drop-down placeholder

Do you ever wanted to have an HTML drop-down with default selected value (placeholder) that the user cannot re-select once they selected any valid value options? It can be done easily by adding selected and disabled attributes on the option element. Code Snippet <select> <option value="" selected="selected" disabled="disabled">-- SELECT --</option> <option value="ACTIVE">ACTIVE</option> <option value="INACTIVE">INACTIVE</option> </select> Try it! -- SELECT -- ACTIVE INACTIVE

April 15, 2020 · John Pili

Create Android Studio Shortcut on Ubuntu 18.04

You can easily create an Android Studio shortcut by creating an desktop entry using the following the steps below. In this guide, my Android Studio is installed in /opt/android-studio folder. Your folder location may differ. Open terminal and type cd ~/.local/share/applications Create a .desktop file using your favorite text editor nano android-studio.desktop My .desktop file looks like this [Desktop Entry] Version=1.0 Type=Application Name=Android Studio Icon=/opt/android-studio/bin/studio.png Exec="/opt/android-studio/bin/studio.sh" %f Categories=Development;IDE; Terminal=false StartupWMClass=jetbrains-android-studio As a template for desktop entry you can use this snippet...

April 14, 2020 · John Pili

How to clear your local Maven repository

I was building a multi-module project and I faced with this annoying problem with maven that keeps using old version of the maven project even though I uses mvn install -U. I usually delete my local .m2 repository folder but I found a much cleaner way to do it. mvn dependency:purge-local-repository

April 14, 2020 · John Pili

How to change Full Disk Encryption (LUKS) password on Ubuntu 18.04

Did you enabled the full disk encryption (LUKS) on Ubuntu 18.04? I would like to share how you can change the LUKS password. LUKS stands for Linux Unified Key Setup developed in 2004 by Clemens Fruhwirth. Similarly, Apple’s macOS have FileVault and BitLocker for Microsoft Windows operating system. In the terminal you can check the drives or partition with LUKS by using this command lsblk My result looks like this. Your result might differ slightly....

April 12, 2020 · John Pili

Make your old laptop usable again with Linux

Revive your old laptop back in service using Lubuntu a light-weight version of Ubuntu. I bought this Lenovo IdeaPad S10-3 in 2012 when I was working in Muscat, Oman. This netbook has a blazing Intel Atom processor 1.66GHz, a 2GB DDR3 RAM, and 10″ LCD screen. I was initially thinking of giving it away because when I installed Ubuntu or CentOS it is sluggish and keeps on lagging. Then I stumble upon Lubuntu when I was researching about smallest Linux distribution....

March 29, 2020 · John Pili
Completely Delete USB Flash Drive Partition in MacOS using diskutil

Completely Delete USB Flash Drive Partition in macOS using diskutil

You may want to completely erase the partition table of your USB flash drive including the boot record. In macOS you do easily do that using diskutil. During this COVID-19 lockdown in Malaysia, I wanted to use my weekend time in installing Linux on an old laptop. It turns out that old laptop only support MBR and not GPT boot record and FAT32 instead of EX-FAT. I have to then delete the partition table from GPT to MBR and load LUBUNTU Linux distribution into the flash drive using Unetbootin....

March 22, 2020 · John Pili

Load balancing and redundant Internet connection using TP-Link ER6020

Overview I started my homelab journey in 2017, set up a small server to host my files and to test my web applications. Today, I am giving my small network a bit of an upgrade by having a redundant Internet connection using a TP-Link ER6020. I appreciate that TP-Link made their enterprise network devices affordable. If you are living in Kuala Lumpur and thinking of buying TP-Link’s enterprise network devices. Go to Sri computers in Lowyat plaza, they usually have stocks....

March 17, 2020 · John Pili