Two-letter country codes

Happy New Year! I hope you’re having a great time. Today, I am updating my online tool, ip.johnpili.com to use Cloudflare’s Request Header, “CF-IPCountry” so that I can display the IP address together with the country. I also want to have my own two-letter country code on my website as quick reference. The table below […]

Continue Reading…

IP Address Classes

The table below shows the IP address classes. This could be handy for someone trying to remember possible IP ranges of a particular IP class. The first 8 bits of the IP address are used to determine the class. Class Address Range No. of Network Hosts A 1-126.x.y.z 126 16,777,214 B 128-191.x.y.z 16,384 65,534 C […]

Continue Reading…

How to setup static IP address on Red Hat Enterprise Linux 8

Setting up a static IP address on your RHEL or CentOS is simple. Prerequisite This how-to guide requires that you have administrative access to the Linux operating system. Steps 1. Inside the RHEL Operating system, open the terminal and head to /etc/sysconfig/network-scripts cd /etc/sysconfig/network-scripts Using ls command, you can see the available network devices. 2. […]

Continue Reading…

Notinaut an Arduino driven notifier

I bought this cheap keychain couple of months ago and thought it would be a nice weekend Arduino project. My idea is to modify this novelty device as a notifier to notify me when my Jenkins or software build is successful. It has a web interface and REST API. An astronaut keychain from a novelty […]

Continue Reading…

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

After installing MySQL, log in to it 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 [email protected] IDENTIFIED WITH mysql_native_password BY ‘password’; mysql> exit You can now login in MySQL as root using the […]

Continue Reading…

Create MySQL User and Grant Privileges

Let say that you wanted to create a MySQL user for example johnpili and assign privileges. You can do that using the simple code snippet below: mysql> CREATE USER ‘johnpili’@’localhost’ IDENTIFIED BY ‘Pass2Word3r’; mysql> GRANT ALL PRIVILEGES ON *.* TO ‘johnpili’@’localhost’; mysql> FLUSH PRIVILEGES; […]

Continue Reading…

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 variablesinside 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 […]

Continue Reading…

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 […]

Continue Reading…

Generate a self-signed certificate for Golang

Use OpenSSL generate a self-signed certificate for Golang. In this code snippetI created a certificate with validity of 15 years. openssl genrsa -out server.key 2048 openssl req -new -x509 -sha256 -key server.key -out server.crt -days 5475 Once you create the certificate and key you can use it in your Golang HTTP like this log.Fatal(http.ListenAndServeTLS(“:”+port, configuration.HTTP.ServerCert, […]

Continue Reading…

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. rand.Seed(time.Now().UnixNano()) delta := rand.Intn(60 + 1) // randomly generates numbers 1 to 60 time.Sleep(time.Duration(delta) * time.Second) // sleep and […]

Continue Reading…