Linux systemd entry for your Go application

Linux systemd entry for your Go application

Systemd is a Linux software suite that handles system services (daemon) and timers; it enables you to start, stop and restart your application using systemctl command. It can also start your application during operating systems boot-up sequence. Note that you will need to have root or sudo privileges for this operation. To create a systemd unit file, create a service file inside the directory /etc/systemd/system/. The filename must end with ....

January 4, 2021 · John Pili
setup-static-ip-address-in-red-hat-enterprise-linux-8.webp

Setup static IP address in Red Hat Enterprise Linux 8

Setting up a static IP address in your RHEL or CentOS is simple. Prerequisite This how-to guide requires that you have administrative access to the Linux operating system. Steps Inside the RHEL Operating system, open the terminal and head to /etc/sysconfig/network-scripts. Using ls command, you can see the available network devices in the directory. cd /etc/sysconfig/network-scripts ls Use a text editor to edit the specific network device configuration vi ifcfg-ens192 A network configuration should look like similar to this In this sample configuration, we will need to specifically change or add the following: BOOTPROTO=none ONBOOT=yes IPADDR=x....

October 20, 2020 · John Pili
How to change MySQL’s root to use mysql_native_password in Ubuntu

How to change MySQL’s root to use mysql_native_password in Ubuntu

In some MySQL installation in Ubuntu. You cannot login as root because it is not configured to use mysql_native_password. In this post, I will teach you how to enable mysql_native_password. Log in to MySQL via terminal with sudo mysql -u root Once inside MySQL, we will need to change the default plugin authentication to mysql_native_password and set a password for root. mysql> ALTER USER root@localhost IDENTIFIED BY 'password'; mysql> exit You can now login in MySQL as root using the password you set....

October 8, 2020 · John Pili
jenkins-featured-image.webp

Login as Jenkins in Linux Terminal

You may need to setup an SSH keys or environment variables to your Jenkins installations. One of the easy way to do this is to setup those environment variables inside the jenkins user account. If you installed Jenkins in CentOS or Ubuntu via YUM or APT; These package managers will setup a jenkins user account without login capability and shell. That means you cannot simply SSH to it. Using your other Linux account you can login as jenkins using the command snippet below....

August 14, 2020 · John Pili
golang-linux-daemon.webp

Golang Linux Daemon

You build your first Golang web application and running in a remote server via SSH. The problem with that is once the SSH session is terminated it also kill any running programs associated with that SSH session. Using nohup solves this problem but I think this is okay during development and testing phase. A better way to deploy your Golang application into a Linux production environment is create a systemd entry making it as a daemon program....

July 28, 2020 · John Pili
randomly-create-a-time-sleep-in-golang.webp

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
html5-pre-selected-disable-default.webp

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.webp

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