Jul 13, 2021

Search for a text in the folder files

Lets search for <meta name word in the current folder using grep. File extension to check for is .html and .py files.

grep -ir --include=*.{html,py} "<meta name" .


Dec 12, 2020

Multiple JDK on Windows

 Installation of JDK is straight forward for Windows, just download JDK and install.

There are situation where certain type of program require specific version of JDK and JRE. In such case you will have more then one version of JDK installed on your machine and you will have to switch JDK version based on the need of the program. 

Configure Java

Set up System Environment variable

JAVA_HOME = C:\Program Files\Java\jdk-11.0.8\bin

In Path variable append extra entry for JAVA_HOME

Path = %JAVA_HOME%

Check environment variable and Java in cmd

echo %JAVA_HOME% 

java -version


Switch JDK 

Just edit the JAVA_HOME system variable and point to new JDK location. You don't have to change Path variable.

JAVA_HOME = C:\Program Files\Java\jdk-1.8\bin


Dec 8, 2020

Installing JDK on MacOS

Check the version of JDK installed and the path on your MacOS

/usr/libexec/java_home -V

Check this instance/version of the JDK is currently running on your MacOS

java --version

The above command will show the currently used JDK and JRE


If you have multiple instances of JDK installed on your MacOS and want to switch the version based on the required environment. You can do so by following the below steps:

Edit ~/.bash_profile and set JAVA_HOME environment variable

export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)

In case of MacOS BigSur

export JAVA_HOME=$(/usr/libexec/java_home -v 1.8.0) 

The above command will switch the JDK version to 1.8

Reload the changes to the environment

source ~/.bash_profile


Dec 7, 2020

Installing JDK on Ubuntu

 OpenJDK

To install Open JDK 11 LTS

sudo apt-get install openjdk-11-jdk

or 

sudo apt install default-jdk


Oracle JDK

For Oracle JDK you have to manually download from the Oracle JDK website and install it. PPA doesn't work well anymore.


Manage JAVA 

If you have multiple JDK on your machine, you can configure which version to be used using the following command by selecting one.

sudo update-alternatives --config java

Jan 30, 2019

Regular Expression to check Bhutan Vehicle Number


You can use the following Regular Expression to validate the text field for Bhutan Vehicle using javascript.
[BG]{2}[-][0-9][-][A-Z 0-9]{4,5}

Nov 14, 2017

Get the serial number of a computer using command

Windows
Open a command prompt (by choosing the Command Prompt item from the Start menu, or typing cmd in the Start menu's "Run" box), and type the following:

wmic bios get serialnumber

MacOS
Go to Utilities. Open the Terminal application and type:

ioreg -l | grep IOPlatformSerialNumber
Linux
Open a shell and type:

sudo dmidecode -t system | grep Serial
Note: The user will need to have root access to the system.

Oct 13, 2017

Get MySQL Database columns and datatypes

To get database details for specific database under MySQL use the following script. Execute the script in any DB tools like DBeaver etc.

select * from information_schema.columns
where table_schema = 'your_database_name'

May 30, 2016

Enable Dzongkha keyboard on Android 6

The best thing about Android 6.0 for Bhutanese Android phone user was the Dzongkha font support. If you are not getting any official Android 6.0 on your android device then try installing custom ROM like CynogenMod.

I presume that you have Android 6.0 on your device, and now lets enable dzongkha keyboard:

1. Install Multiling O Keyboard from Play Store
2. Launch the Multiling O Keyboard and follow the app screen instruction, then you are done.

May 25, 2016

Install CyanogenMod 13 on Nexus 4

Let me show you how to install CyanogenMod 13 which is build on Android 6.0.1 since Nexus 4 no longer receives update from Google. I will be explaining you using Debian Linux.

Download the latest version of CyanogenMod 13 from Official CyanogenMod website https://download.cyanogenmod.org/?device=mako. I would recommend Stable release only. Make sure to download system image (CyanogenMod Build), recovery image (CyanogenMod Recovery) and Google App from https://wiki.cyanogenmod.org/w/Google_Apps

1. You will need Android SDK platform tool and we will be using fastboot and adb. 

2. Now boot the phone in recovery mode, hold down Volume Down + Power button until bootloader appears, then navigate to Bootloader by clicking volume up/down and select by clicking Power button. 

3. Open terminal and then navigate to folder where you have placed Android SDK platform tools. Type 
sudo ./fastboot oem unlock if your OEM is locked else 
sudo ./fastboot oem lock
sudo ./fastboot oem unlock

4. Now lets erase some partitions like recovery, system, boot, cache and userdata.
sudo ./fastboot erase recovery
sudo ./fastboot erase system
sudo ./fastboot erase boot
sudo ./fastboot erase cache
sudo ./fastboot erase userdata

5. Now lets flash recovery image 
sudo ./fastboot flash recovery cm13xxx-recovery.img

6. Now reboot the phone to Recovery Mode like you did in step 2. 

7. Now select Wipe/Factory Reset and also any wipe option available.

8. So let flash in System Image and Google Apps using adb sideload. Select Apply Update in the recovery mode, and select ABD Sideload

sudo ./adb kill-server
sudo ./adb start-server
sudo ./abd sideload CM13xxx.zip
sudo ./abd sideload open-gappxxx.zip 

9. Now select Reboot System from the recovery mode menu. At first time boot it will take some time, just relax and wait for it to boot.

Now your Nexus 4 will boot in CyanogenMod 13 in turn Android 6.0.1

Nov 5, 2014

CentOS 7 and RHEL 7 new commands

In CentOS 7/RHEL 7 the 'service' command has now been changed to systemctl. Now the command are:
systemctl start sshd.service 
The above line will start sshd service.

systemctl restart sshd
The above line is a short form command.

chkconfig command has also changed.

Now to enable service during boot is:
systemctl enable sshd
To disable service during boot is:
systemctl disable sshd

To check startup list:
systemctl list-unit-files --type=service