Ubuntu as Daily Work OS

Screen recording in Ubuntu 18.04 using Kazam

Posted on
Screencast in Ubuntu using Kazam

Part of my work is to screen record (screencast): software demos and programming tutorial. I am also a MacOS user and in Mac I used ScreenFlow for screencasting. Since using Ubuntu as my primary operating system at work. I wanted continue my screencasting work. I once used Kazam in mid 2019 and it can handle the basic screen recording requirement we will need, mostly. It is open-source and available from Ubuntu apt repository. Kazam’s official website is https://launchpad.net/kazam.

1. Start by installing Kazam by opening your terminal and typing this command.

sudo apt install kazam

1. Install Kazam from terminal

2. Enter your password. This installation requires that you have sudo privilege.

2. Enter Password

3. Completed installation will look similar to this.

3. Completed Kazam Installation

4. Launch Kazam

4. Launch Kazam

5. You can configure Kazam based on your screen casting requirement. Press Capture button to start recording.

5. Start Recording

Screen recording sample

6. You can stop or pause your recording by clicking the Kazam icon from Ubuntu top navigation.

6. Stop or Pause your Kazam recording

7. Completing your recording session

7. Completing your screen recording

8. Once you’re done recording. Save the file and kazam will automatically convert the file to an mp4 format. You can then do your post productionn or directly upload it on YouTube. I do however noticed that mp4 files generated by Kazam don’t work in MacOS quicktime. I am not sure why though.

8. Save your recording

By default files will be saved in Videos folder

By default, all screencast will be save in your Videos folder

9. Completed recording file. Great Work.

9. Your saved screencast file

I am glad that Kazam provides screen recording capabilities for Ubuntu or Linux in general. I don’t have to switch to MacOS or Windows for my screencasting needs.

Golang

Develop a whatismyipaddress.com clone website using Golang

Posted on
whatismyipaddress clone - IP Echo

Do you want to build a website clone similar to whatismyipaddress.com? It is actually easy to develop. I decided to create this tool because I was working on an automated DNS client that will check my public IP address. Perhaps, somebody might need this in the future. I already made the completed demo available online at https://ip.johnpili.com

How it works

It works by reading the HTTP header request which contains information such as IP Address, User-Agent, Scheme, Accept-Encoding, etc. If you are using a reverse proxy like Cloudflare, you can extract IP information from header keys Cf-Connecting-Ip or X-Real-Ip

Sample HTTP header
map[
    Accept:[text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8] 
    Accept-Encoding:[gzip] 
    Accept-Language:[en-US,en;q=0.5] 
    Cache-Control:[no-cache] 
    Cdn-Loop:[cloudflare] 
    Cf-Connecting-Ip:[193.169.145.66] 
    Cf-Ipcountry:[T1] 
    Cf-Visitor:[{"scheme":"https"}] 
    Connection:[upgrade] 
    Dnt:[1] 
    Pragma:[no-cache] 
    Upgrade-Insecure-Requests:[1] 
    User-Agent:[Mozilla/5.0 (Windows NT 10.0; rv:68.0) Gecko/20100101 Firefox/68.0] 
    X-Forwarded-For:[193.169.145.66, 193.169.145.66] 
    X-Forwarded-Proto:[https] 
    X-Real-Ip:[193.169.145.66]
]
Snippet extracting IP address from header
func (z *PageController) getIPDetails(r *http.Request) models.IPInfo {
	ip := ""
	if len(z.Configuration.Extraction.HeaderKey) > 0 {
		ip = r.Header.Get(z.Configuration.Extraction.HeaderKey) // Extract IP from header because we are using reverse proxy example X-Real-Ip
	}

	if len(ip) == 0 { // Fallback
		ip = extractIPAddress(r.RemoteAddr)
	}

	ipInfo := models.IPInfo{
		IP:        ip,
		UserAgent: r.Header.Get("User-Agent"),
	}
	return ipInfo
}

You get the full source code from github https://github.com/johnpili/ip-echo We can further improve this tool by adding an IP to location mapping from MaxMind or IP2Location

Ubuntu as Daily Work OS

Hiri is the Microsoft Outlook Client For Linux

Posted on
Hiri Logo

Microsoft Outlook Requirement

As part of my Ubuntu as Daily work OS goal; I have to be able to receive corporate emails, view and set calendar appointments and access the global corporate address book. To do that, I will need an email client that works with my company’s Microsoft Exchange server. I searched the web for software and I ran into two options:

Option 1: Microsoft Office 365 a web-based software.
Option 2: Hiri a standalone email client.

I went for the latter because it offers a perpetual license that I can also use on my Mac.

Download and Setup

I bought Hiri using a 60% discount voucher. They sometimes offer discount vouchers to their website visitors, you might get lucky.
Hiri Website
You can download the software and try it first before deciding on whether you want to buy it or not. Hiri is cross platform and runs on Linux, Mac and Windows.
Download Hiri

The downloading, installation and setting up process of Hiri is simple.

Hiri's Welcome Screen
Hiri’s Welcome Screen

When adding a Microsoft Exchange email account, Hiri will try to auto-detect and configure it for you. If you encounter any problems, you will have to contact your IT administrator for assistance. Hiri only supports Microsoft Exchange and Office 365 accounts.

Setting up your Microsoft Exchange Account
Setting up your Microsoft Exchange Account

Software Features

Mailbox

This email client software have a clean and easy to use user-interface. Once you successfully configured your email account into Hiri it will take you straight away into your mailbox.

Email List View
Email List View

Microsoft Calendar Integration

Hiri will automatically synchronize your Microsoft exchange calendars and appointments.

Hiri's Microsoft Exchange Calendar Integration
Hiri’s Microsoft Exchange Calendar Integration

Integrated access to Exchange Calendar
Integration with Exchange Address Book
Integration with Exchange Address Book
General

My review using the Razer Huntsman Tournament Edition for programming

Posted on
Razer Huntsman Tourname Edition Box

Background

I have been using the Razer Black Widow tournament edition since January, 2015 as my programming keyboard. It has the Razer’s green clicky mechanical switch. After four years of continuous usage; it started to double register my keypress and it loses its clicky sound. It is time for me to invest into a new mechanical keyboard. I bought this keyboard from All IT at retail price of 529 MYR (129 USD). I am not a gamer so this review is not about the performance of this keyboard in a gaming realm but instead on the general typist or computer programming use case.

My first impression on the Razer huntsman tournament edition

The design of huntsman tournament edition is very simple. It does not have the gamer keyboard look like in other Razer keyboards. I like the matte finish and the double-shot PBT keycaps. It has a smaller footprint because of its tenkeyless keyboard layout and smaller baseplate. I can bring this to the office and easily blend in.
RAZER HUNTSMAN TE - LOOK AND FEEL - SMALL PROFILEThe small footprint making it ideal for traveling

The matte finish makes dust easily visible:

Due to its matte black finish it tends to attracts dust and animal danders easily. I personally don’t have issue with this because I don’t look at the keyboard while typing anyway.
Razer Huntsman Tournament Edition - Dust Magnet

Features

Opto-mechanical Linear Red Switch

– This is the first time I used this type of keyboard switch. It is really sensitive and fast at the same time because of its lower actuation point of 1.0mm. According to Razer, this type of key switch has a durability of 100 million keystrokes.
Razer Linear Opto-mechanical switch - 1
Razer Linear Opto-mechanical switch - 2

Detachable USB Cable

– This keyboard comes with a braided USB cable.
Razer Huntsman USB type C portRazer Huntsman USB type C port
Razer Huntsman braided cable - 1
Razer Huntsman braided cable - 2

RGB

– Huntsman Tournament Edition features a programmable RGB LED backlit. It comes with some predefine RGB program but you may use the Razer chroma software if you prefer to load your own RGB color scheme.

Typing Sound

– Even though this keyboard is not clicky nor has a tactile feedback. This keyboard emits a clacking sound.

Conclusion

At first, I thought I made a bad decision in buying this keyboard because I am making a lot of typos while coding software. Losing the tactile feedback makes touch-typing an issue. Perhaps this is why tactile switches are the preferred key switch for typist or programmers but after two weeks of usage; I get accustomed of using this opto-mechanical linear keyboard. I liked the way it quickly responds to my keypress and it feels light on my fingers when I am typing on it. Using the Razer Huntsman TE felt like typing on butter. I spend a lot of time coding per week and using this opto-mechanical keyboard made my fingers less fatigue. I am happy with this keyboard and would like to recommend other to try it out for a change.

Golang

How to parse JSON data without struct in Golang

Posted on

In using Golang, we sometimes need to parse a JSON data without knowing or specifying a concrete type struct. We can do this by converting (json.Unmarshal) JSON data into an interface{}. We can then use it like a map. Accessing it like for example m["username"].(string)

func AddUserHandler(w http.ResponseWriter, r *http.Request) {
    log.Println("Processing Register User")
    var payload interface{} // The interface where we will save the converted JSON data.
    buffer, err := ioutil.ReadAll(r.Body)
    if err != nil {
        log.Panic(err)
    }
    r.Body.Close() // Close this
    json.Unmarshal(buffer, &payload) // Convert JSON data into interface{} type
    m := payload.(map[string]interface{}) // To use the converted data we will need to convert it 
                                          // into a map[string]interface{}

    validationErrors := make([]string, 0)
    if len(strings.TrimSpace(m["username"].(string))) == 0 {  // You can now access the data like this m["username"]
        validationErrors = append(validationErrors, "Username is required")
    }

    if len(strings.TrimSpace(m["password"].(string))) == 0 {
        validationErrors = append(validationErrors, "Password is required")
    }

    if len(strings.TrimSpace(m["name"].(string))) == 0 {
        validationErrors = append(validationErrors, "Name is required")
    }

    if len(validationErrors) > 0 {
        respondWithJSON(w, models.ResponsePayloadModel{
            Total:  0,
            Result: nil,
            Errors: validationErrors,
        })			
    }

    // Your other codes goes here...
}
Personal Journal

A reminder to myself about failures, mistakes and goals

Posted on
A reminder to myself about failures, mistakes and goals

I shouldn’t be afraid to fail and make mistakes. This is the only way for me to learn and achieve my goals. No one is born with skills, people gained that through experience, through trial and error, and effort. Looking back from where I came from any skills and success I have today is because of my hard-work, sacrifices and time spent learning. The biggest problem in adult life is our inability to try new things or challenges. We become afraid of failure and criticism.

Using negative experiences as a motivator for goal achievement

I once used my pass predicaments to motivate me to achieve my goals. I was broke, uneducated, unskilled and heart-broken. I used that bad situation to drive me to aim higher, complete my studies and learn valuable skills. I became a different and better person. Any of my previous career failures also serves as a motivator that forces me never to repeat the same mistake and learn from it.

The comfort zone

The problem now is getting comfortable in my current situation and being contented. Of course we have to be grateful for our success and accomplishments but we have to be aware that our life can give us more if we keep improving ourselves and learning new valuable skills. Life is short for us to settle on small things. Jim Rohn said “We should not major in minor things”. I can imagine that ten to twenty years of life wasted in being a time server. A very frightening realization. I want to provide a better future for my children and next generation. I will not going to settle for something less or to something that will not help me in making goals a reality.
Learn to say no. Avoid negative people and those who don’t have values in life.

Setting Goals

A burning desire goal will drive us everyday to make it a reality. Do you want a better life, bigger house, fat bank account, prosperous career or good health? Set that as goal, list it down in a journal. I was skeptical about this at first but I give it a try. I set a goal in 2017 to lose 10kg of weight from 72kg to 62kg. I disciplined myself to eat less but nutritious food and exercise 30 to 60 minutes everyday. In September 2018, I achieve my goal. Never tell anyone about your goal especially if they are not part of it. It will never give you any benefits if you tell them. Setting goals will give us direction if life rather than going with the flow.

Ubuntu

How to Setup OpenVPN Client on Ubuntu 18.04

Posted on

Hi! In this post we are going to setup OpenVPN Client on Ubuntu 18.04. Most of the available tutorials posted on the Internet were about how to configure an OpenVPN server. There are a lot of OpenVPN providers in the market. I personally liked OpenVPN service from StrongVPN because they offer a wide selections of VPN protocols and you can change server locations easily. New network routers also features OpenVPN connection capabilities which let you connect to your home or office network.

Prerequisite

You will need to have an .ovpn file downloaded from your OpenVPN provider.

Downloaed .ovpn file from openvpn provider

1. Start by opening your terminal and type the following commands. (This requires root privileges)

sudo apt install openvpn network-manager-openvpn
sudo apt install network-manager-openvpn-gnome
After you’ve successfully installed the required software we can then proceed with configuring the VPN connection.

2. Go to Network Manager

Go to network manager

3. Add VPN Connection

Add VPN Connection

4. Select Import from file

Select Import from file

5. Choose and open the downloaded .ovpn file from your OpenVPN provider

Select the ovpn file

6. Confirm the imported .ovpn file. You can change the name of the VPN connection if you want to. Click Add to complete

Add the imported OpenVPN settings

7. Once the import and configuration is complete you can now connect to your VPN.

Connect to OpenVPN

 

Ubuntu as Daily Work OS

Using Ubuntu Linux in Corporate Environment

Posted on

Today, December 26, 2019, I am starting a goal to document my experiences in using Ubuntu Linux as my daily work operating system.
I work primarily as an R&D manager and software architect. I code and design software on a daily basis. Let me share you what are the pros and cons of using Linux on a daily basis as I progress.

Here are the primary objectives that I will be documenting

  • Connecting to corporate LAN/WIFI/VPN
  • Accessing shared networks resources
  • Software Productivity Tools
  • Privacy
  • Security
  • Customizing Linux Settings
Golang

Golang Cross Platform Build (GOOS and GOARCH)

Posted on

Are you developing a software using golang on a macOS or other operating system (OS) and wanted
to compile for other OS? You can compile a golang binary for other platforms using GOOS and GOARCH.

Here is an example in compiling a golang binary for Linux on a macOS terminal:

GOOS=linux GOARCH=amd64 go build main.go


GOOS (Operating System) GOARCH (Architecture e.g. amd64)
aix ppc64
android 386
amd64
arm
arm64
darwin 386
amd64
arm
arm64
dragonfly amd64
freebsd 386
amd64
arm
illumos amd64
js wasm
linux 386
amd64
arm
arm64
mips
mips64
mips64le
mipsle
ppc64
ppc64le
s390x
nacl 386
amd64p32
arm
netbsd 386
amd64
arm
arm64
openbsd 386
amd64
arm
arm64
plan9 386
amd64
arm
solaris amd64
windows 386
amd64
arm