Showing posts from April, 2020

Get the domain part of the email address

SELECT SUBSTRING(email, LOCATE('@', email) + 1) AS domain FROM contacts;

aptitude test

Use to retrieve public IP address

Use to retrieve public IP address

Deleting UFW rules

Deleting UFW rules by rule number
sudo ufw status numbered

Removing UFW rules by specificationsudo ufw delete allow 2222

Protecting multiple SSH ports with Fail2ban

In /etc/fail2ban/jail.local :


enabled  = true

port     = ssh,sftp,1234,2222

Adding your SSH key to the ssh-agent

# start the ssh-agent in the background
$ eval $(ssh-agent -s)
$ ssh-add ~/.ssh/id_rsa


$ ssh-add

to add your default key

Remove Docker Images

docker rmi image_id_1 image_id_2 image

Install Docker From a standard Ubuntu Repository

sudo apt install

Fixed Unit docker.service could not be found on Ubuntu installed by snap

Temporary solution:
Run the command export PATH=$PATH:/snap/bin

Permanent solution:
Edit /etc/environment and add /snap/bin in the list then restart your system.


Docker snap: Docker Linux container runtime.

Due to the confinement issues on snappy, it requires some manual setup to make docker-snap works on your machine.
We'll take you through the steps needed to set up docker snap work for you on ubuntu core and ubuntu classic.

On Ubuntu classic, before installing the docker snap,
please run the following command to add the login user into docker group.
    sudo addgroup --system docker
    sudo adduser $USER docker
    newgrp docker

On Ubuntu Core 16, after installing the docker snap from store,
you need to connect the home interface as it's not auto-connected by default.
sudo snap connect docker:home :home

Then have fun with docker in snappy.

ubuntu@ip-172-31-8-122:~$  sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from li…

Reload /etc/environment without rebooting

Either the following two ways:
ubuntu@ip-172-31-8-122:~$ for env in $( cat /etc/environment ); do export $(echo $env | sed -e 's/"//g'); done
ubuntu@ip-172-31-8-122:~$ sed 's/^/export /' /etc/environment > /tmp/ && source /tmp/

Install Docker Compose on CentOS/Fefora

[ec2-user@ip-172-31-5-206 my]$ sudo curl -L "$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   638  100   638    0     0   3112      0 --:--:-- --:--:-- --:--:--  3112
100 11.1M  100 11.1M    0     0  9560k      0  0:00:01  0:00:01 --:--:-- 13.2M
[ec2-user@ip-172-31-5-206 my]$ sudo chmod +x /usr/local/bin/docker-compose
[ec2-user@ip-172-31-5-206 my]$ docker-compose --version
docker-compose version 1.23.1, build b02f1306

Language Go Hello World

package main


funcmain() {
fmt.Println("hello world")

Make a MySQL session read-only.


Jenkins X extends Jenkins further by adding comprehensive Kubernetes integration.

Jenkins X Pipelines are built on Tekton Pipelines, which aid in running CI/CD pipelines on Kubernetes. You can configure your pipeline using a jenkins-x.yml file (compared to a traditional Jenkinsfile). Jenkins X also provides build packs, which can help package source code into images that can then be deployed to Kubernetes.

Read from STDIN in Groovy

print"What is your name? "
def name
println"Your name is "+ nameExmaple:
$ groovy hello.goovy

What is your name? Goyun
Your name is Goyun

Hello World in Goovy

Inside: hello_world.groovy

print "Hello World!\n"


$ groovy hello_world.groovy

Groovy: “Unable to locate package” while trying to install packages with APT

sudo apt-get update

Example:root@2d91134ff240:/# groovy -v
bash: groovy: command not found
root@2d91134ff240:/# apt -y install groovy
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package groovy
root@2d91134ff240:/# apt -y install groovy
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package groovy

root@2d91134ff240:/#  apt-get update

Reset User Password in Windows Subsystem for Linux (WSL) Ubuntu

Open a command prompt or PowerShell.

Then change the default user to root for the WSL Ubuntu

 ubuntu config --default-user root

Use the following command to change the former default user's password:
passwd <username>

Switch back your former user:

ubuntu config --default-user <username>

Setting Windows File Associations to Open .JNLP Files Properly

Close any Collaborate session or recording windows.
Open the Windows Control Panel and go into Programs and Features.
Check the list of programs to ensure that Java is already installed on the system. If it isn't installed, please download and install Java from before
Download a new Collaborate meeting or recording file but don't launch the file yet.
Locate the meeting or recording .jnlp file in your Downloads folder.
Right-click on the file and choose Open with then click Choose another app.
If you see Java (TM) Web Start Launcher in this list (you may need to click More apps to expand the list), select it and check the box that says Always use this app
to open .jnlp files then click the OK button.
If Java (TM) Web Start Launcher is not in the list, check the box that says Always use this app to open .collab files then click Look for another app on this PC.
Navigate to the following location:
c:\program files\java\jreXXX\bin
XXX represents a number that will vary…

Server-Side Configuration for SSH Port Forwarding

The AllowTcpForwarding option in the OpenSSH server configuration file must be enabled on the server to allow port forwarding. By default, forwarding is allowed. Possible values for this option are
yes or all to allow all TCP forwarding, no to prevent all TCP forwarding, local to allow local forwardings, and remote to allow remote forwardings.

Another option of interest is AllowStreamLocalForwarding, which can be used to forward Unix domain sockets. It allows the same values as AllowTcpForwarding. The default is yes.

For example:

    AllowTcpForwarding remote
    AllowStreamLocalForwarding no

The GatewayPorts configuration option also affects remote port forwardings. Possible values were

no (only local connections from server host allowed; default), yes (anyone on the Internet can connect to remote forwarded ports), clientspecified (client can specify an IP address that can connect, anyone can if not specified).

Fix “SSH Too Many Authentication Failures” Error

To fix this error, you need to add the IdentitiesOnly with a value of yes, which instructs ssh to only use the authentication identity files specified on the command line or the configured in the ssh_config file(s), even if ssh-agent offers additional identities.

For example:

$ ssh -o IdentitiesOnly=yes goyun

Alternatively, if you want this to work for all ssh client connections, you can configure it in your ~/.ssh/config file.

$ vim ~/.ssh/config
Add the following configuration in the file, under the Host * section as shown in the screesnhot.

Host *

tmux shortcuts and cheatsheet

start new:

start new with session name:

tmux new -s myname

tmux a  #  (or at, or attach)
attach to named:

tmux a -t myname
list sessions:

tmux ls
kill session:

tmux kill-session -t myname
Kill all the tmux sessions:

tmux ls | grep : | cut -d. -f1 | awk '{print substr($1, 0, length($1)-1)}' | xargs kill
In tmux, hit the prefix ctrl+b (my modified prefix is ctrl+a) and then:

List all shortcuts
to see all the shortcuts keys in tmux simply use the bind-key ? in my case that would be CTRL-B ?

:new<CR>  new session
s  list sessions
$  name session
Windows (tabs)
c  create window
w  list windows
n  next window
p  previous window
f  find window
,  name window
&  kill window
Panes (splits)
%  vertical split
"  horizontal split

o  swap panes
q  show pane numbers
x  kill pane
+  break pane into window (e.g. to select text by mouse to copy)
-  restore pane from window
⍽  space - toggle between layouts
<prefix> q (Show pane numbers, when the numbers show up type the key to goto that p…

Show indexes for a MySQL table




AND TABLE_NAME = 'goyun'


For primary key:




AND TABLE_NAME = 'goyun'



MySQL LOW_PRIORITY only affects storage engines which use table-level locking, like MyISAM and MEMORY. None of those engines support foreign key constraints.

Ledger to Accept Digital Currency Payments via’s App

Site Kit by Google

Site Kit
Google's official WordPress plugin
Get insights about how people find and use your site, how to improve, and monetize your content, directly in your WordPress dashboard

MySQL ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction

Change innodb_lock_wait_timeout PropertyValueCommand-Line Format--innodb-lock-wait-timeout=#System Variableinnodb_lock_wait_timeoutScopeGlobal, SessionDynamicYesTypeIntegerDefault Value50Minimum Value1

Fixed: Failed to add the host to the list of known hosts

$ sudo chown -v $USER ~/.ssh/known_hosts

Sync iPhone using Wi-Fi

After you set up syncing with iTunes using USB, you can set up iTunes to sync to your device with Wi-Fi instead of USB.

Connect your device to your computer with a USB cable, then open iTunes and select your device. 
Click Summary on the left side of the iTunes window. 
Select "Sync with this [device] over Wi-Fi." 
Click Apply.
When the computer and the device are on the same Wi-Fi network, the device appears in iTunes. The device

Google API multiple scopes

To set multiple scopes, set the scope parameter to multiple scopes, each separated by a single space.
private static final List<String> SCOPES = Collections.singletonList(BloggerScopes.BLOGGER+"");

ChromeDriver can't click a moving element

This is not a supported feature of ChromeDriver. If the element eventually stops, wait for that to occur. If the element never stops moving, ChromeDriver does not guarantee the click will be successful.

Selenium IDE Common Commands

assertTitle / VerifyTitle
AssertForElementPresent / VerifyForElementPresent
AssertForTextPresent / VerifyForTextPresent
type / typeAndWait / sendKeys
click /clickAt / clickAndWait
chooseOkOnNextConfirmation / chooseCancelOnNextConfirmation

Selenium IDE allows the user to specify a start point within a test script.

The start point points to the test step from where we wish to start the test script execution.

Start point can be used at times when we do not desire to execute the entire test script starting from the beginning rather we customize the script to execute from a certain step.

Locators in Selenium

By CSS ID: find_element_by_id
By CSS class name: find_element_by_class_name
By name attribute: find_element_by_name
By DOM structure or xpath: find_element_by_xpath
By link text: find_element_by_link_text
By partial link text: find_element_by_partial_link_text
By HTML tag name: find_element_by_tag_name

There are two kinds of Selenium waits

Implicit wait - used to set the default waiting time throughout the programExplicit wait - used to set the waiting time for a particular instance onlyImplicit Wait
It is simpler to code than Explicit Waits.
It is usually declared in the instantiation part of the code.

Explicit Wait
Explicit waits are done using the WebDriverWait and ExpectedCondition classes. For the following example, we shall wait up to 10 seconds for an element whose id is "username" to become visible before proceeding to the next command.

Selenium locating elements

VariationDescriptionSampleBy.classNamefinds elements based on the value of the "class" attributefindElement(By.className("someClassName"))By.cssSelectorfinds elements based on the driver's underlying CSS Selector enginefindElement(By.cssSelector("input#email"))By.idlocates elements by the value of their "id" attributefindElement("someId"))By.linkTextfinds a link element by the exact text it displaysfindElement(By.linkText("REGISTRATION"))By.namelocates elements by the value of the "name" attributefindElement("someName"))

Connecting your WordPress site to Google

Connecting your WordPress siteIf you're new to AdSense, one of your first tasks is to connect your site to AdSense. We highly recommend you use Site Kit for WordPress by Google. Site Kit can connect your WordPress site to your AdSense account and place the AdSense code on all your pages for you. So you can show ads automatically across your site.What is Site Kit?Site Kit is a free, open-source plugin for WordPress that helps you access unified metrics and insights from Google AdSenseGoogle AnalyticsGoogle Search Console, and PageSpeed Insights directly from your WordPress account.

Fixed git fatal: refusing to merge unrelated histories

Using the --allow-unrelated-histories flag worked with a pull request in this way:

git pull origin branchname --allow-unrelated-histories

driver.close() vs driver.quit()

The driver.close() command is used to close the current focused browser tab. In case there is only one browser open then calling driver.close() quits the whole browser session.

It is best to use driver.close() when we are dealing with multiple browser tabs or windows e.g. when we click on a link that opens another tab. In this case after performing required action in the new tab, if we want to close the tab we can call the driver.close() method.

//Closing the single tab

The driver.quit() is used to quit the whole browser session along with all the associated browser windows, tabs and pop-ups.

It is best to use driver.quit() when we no longer want to interact with the driver object along with any associated window, tab or pop-up. Generally, it is one of the last statements of the automation scripts. In case, we are working with Selenium with TestNG or JUnit, we call driver.quit() in the @AfterSuite method of our suite. Thus, closing it at the end o…

Installing chocolatey on Windows

Install chocolatey/choco on Windows 10
Click Start and type “powershell“
Right-click Windows Powershell and choose “Run as Administrator“
Paste the following command into Powershell and press enter.

Set-ExecutionPolicy Bypass -Scope Process -Force; `
  iex ((New-Object System.Net.WebClient).DownloadString(''))

Answer Yes when prompted
Close and reopen an elevated PowerShell window to start using choco

Example usage:

choco install chromedriver
choco uninstall git

Selenium supports Java

Programs written in Java are faster than other popular languages like Python
Java is more widely used in commercial applications as compared to other programming languages like Python and hence integrating Selenium tests it easier

Run Selenium Automated Test

Selenium is the first thing that comes to mind when one is planning to automate the testing of web applications. Selenium is a beneficial tool because it is not only open source but also a portable software testing framework for web applications that support multiple languages like Java, C#, Ruby, Python. Choosing the right language depends on the application under test, the supporting community, available test automation frameworks, usability, elegance, and of course, seamless build integration.

Creating an XML Sitemap in WordPress using Yoast SEO

The easiest way to create an XML sitemap in WordPress is by using the Yoast SEO plugin.

It is the best WordPress SEO plugin on the market offering you a comprehensive set of tools to optimize your blog posts for SEO.

First, you need to install and activate the Yoast SEO plugin. For more details, see our step by step guide on how to install a WordPress plugin.

Upon activation, go to SEO » General page and switch to the 'Features' tab. From here, you need to scroll down to the 'XML Sitemap' option and make sure that it is turned on.

Import Blogger to WordPress

To start importing your Blogger site into WordPress, you need to login to your WordPress admin area and visit Tools » Import. On the Import page, go ahead and click on the 'Install Now' link below Blogger.

Jenkins has a built-in command line interface that allows you to access Jenkins from a script or from your shell.

Jenkins CLI is convenient for automation of routine tasks, bulk updates, trouble diagnosis, and so on. This interface is accessed via the Jenkins CLI client, which is a Java JAR file distributed with Jenkins.

Log all MySQL dead locks

SET GLOBAL innodb_print_all_deadlocks = 'ON';
The option is dynamic, and can be enabled without a service restart.
If you want to make it persistent after a service restart, you may want to add it to the my.cnf file as:

innodb_print_all_deadlocks = 1

SSL for Your Website

Data of your visitors is protected
SSL (Secure Sockets Layer) encrypts and protects all data that your website exchanges with visitors - such as personal data, login data, credit card information and e-mail addresses. This means that third parties have no access to this data.

Confidence in your website is strengthened
Your visitors recognize the SSL encryption by the SSL logo in the address bar of your browser and by the character string https:// in front of your domain. With SSL encryption you set a sign and show your visitors that security and protection of their data are your first priority.

Better ranking with Google and other search engines
SSL encryption is rated positively by Google and other search engines, resulting in better ranking of your site in search results.

Office 365 collaboration applications include:

Word: Word processing with multiple users
Excel: Spreadsheets with multiple users
PowerPoint: Prepare presentations with multiple users
Outlook: Share appointments, calendars and tasks with team members
Teams: Communicate with colleagues
Access: Create databases with multiple users
OneNote: Share notes with other users
OneDrive: Shared cloud storage

Gauge is a free and open source framework for writing and running acceptance tests

Some of the key features of Gauge that makes it unique include:

Simple, flexible and rich syntax based on Markdown.Consistent cross platform/language support for writing test code.A modular architecture with plugins supportExtensible through plugins and hackable.Supports data driven execution and external data sourcesHelps you create maintainable test suitesGreat support for VS Code

Gauge is a free and open source framework for writing and running acceptance tests

systemd does not run correctly within a docker container

systemd does not run correctly within a docker container, due to a whole set of reasons, i.e. the lack of the correct privileges. You can read up on that in a variety of github issues on the docker project like running systemd inside docker arch container hangs or segfaults and related issues regarding init/process monitoring.

Google reverse image search

Google's reverse image search is a useful tool to find details of the image owner . 
Simply upload the file or paste the image link into and follow the results to see where else the image lives online. From there, you should be able to ascertain ownership information.

Install SpamAssassin on CentOS/RHEL/Oracle Linux

sudo dnf install spamassassin
The binary installed by the spamassassin package is called spamd, which will be listening on TCP port 783 on the local host.

By default, the spamassassin systemd service is disabled, you can enable auto start at boot time with:

sudo systemctl enable spamassassin

Then start SpamAssassin.

sudo systemctl start spamassassin

[ec2-user@ip-172-31-5-206 ~]$ sudo ss -ant | grep 783
LISTEN   0         128         *
LISTEN   0         128                   [::1]:783                 [::]:*
[ec2-user@ip-172-31-5-206 ~]$ sudo -i lsof -i TCP:783
/usr/bin/ 7556 root    5u  IPv4  44647      0t0  TCP localhost:783 (LISTEN)
/usr/bin/ 7556 root    6u  IPv6  44649      0t0  TCP localhost6:783 (LISTEN)
spamd     7558 root    5u  IPv4  44647      0t0  TCP localhost:783 (LISTEN)
spamd     7558 root    6u  IPv6  44649      0t0  TCP localhost6:783 (LISTEN)
spamd     7559 root    5u  IPv4  44647    …

On Unix-like operating systems, the readlink command prints the value of a symbolic link, or canonical file name. This document describes the GNU / Linux version of readlink.

readlink -f $(which nc)