Showing posts from February, 2020

Python keywords

>>> help("keywords") Here is a list of the Python keywords.  Enter any keyword to get more help.

and                 elif                if                  print
as                  else                import              raise
assert              except              in                  return
break               exec                is                  try
class               finally             lambda              while
continue            for                 not                 with
def                 from                or                  yield
del                 global              pass               

Python is strongly typed

Python isstrongly typed, which means that the type of an object does not change, even if its value is mutable.

Python object

In Python, an object is a chunk of data that contains at least the following:Atypethat defines what it can doA uniqueidto distinguish it from other objectsAvalueconsistent with its typeAreference countthat tracks how often this object is used

Differences between Python tuples and lists

The differences between Python tuples and lists are: the tuples cannot be changed unlike lists and tuples use parentheses, whereas lists use square brackets.

An Algorithm is step by step set of instruction to process the data for a specific purpose.

An algorithm utilizes various data structures in a logical way to solve a specific computing problem.

Approach divide-and-conquer in a three-step process.

Divide/Break Breaking the problem into smaller sub-problems.Sub-problems should represent a part of the original problem. This step generally takes a recursive approach to divide the problem until no sub-problem is further divisible.At this stage, sub-problems become atomic in nature but still represent some part of the actual problem.
Conquer/Solve A lot of smaller sub-problems to be solved.
Merge/Combine This stage recursively combines them until they formulate a solution of the original problem.

Email SPF examples

You can set up an SPF record to prevent spammers from using your domain to send unauthorized emails, also called spoofing. Some mail recipients require SPF. If you don’t add an SPF record for your domain, your messages can be marked as spam or even bounce back.

$dig txt +short

"v=spf1 a mx ip4: ip4: -all"

The "a" and "mx" specify the systems permitted to send messages for the given domain.

To add ip of to the SPF so that can send email for


get ip of

Then change the SPF into

"v=spf1 a mx ip4: ip4: ip4: -all"

v=spf1SPF version 1

mxthe incoming mail servers (MXes) of the domain are authorized to also send mail for The "ip4" mechanism

The argument to the "ip4:" mechanism is an IPv4 network range. If no prefix-length is given, /32 is assumed (singli…

There are two types of variables used in shell script

System defined variables: These variables are defined or created by operating system itself.User defined variables: These variables are defined by system users.

Spring Boot and Spring Cloud simplify your microservice applications

Spring Boot and Spring Cloud simplify your microservice applications by providing common features and allowing you to focus on business logic by abstracting away details required for cloud-based development.

A tree is the hierarchical data structure unlike an array or linked list which are linear.

You can store hierarchical information using a tree data structure, like an organization structure, family tree, etc.A tree has nodes and children. The top or first node is called the root.The tree data structure is like an inverted tree in the real world.A binary tree is a special tree, where you can have at most two children. This means, one node can either no child, one child, or two children. They cannot have three children or more.All the nodes which don't have any children are known as a leaf node.Binary Search Tree is a special type of binary tree where values of the left subtrees are less than or equal to root and values of nodes on right subtrees are greater than or equal to root.  This provides a sorting structure to a binary search tree, which makes searching really fast.

Algorithms are the foundation of machine learning.

Algorithms are what drives intelligent machines to make decisions. These machines are increasingly making decisions that have real world implications and consequences.

Always improve the quality of your website to boost your search rankings

Informative, relevant content has always been important for SEOYour web pages should aim to answer specific questions or explain specific topics to your readers, so Google will recognize their value for answering common search queries. Vague or unfocused text will not rank well, even if it uses plenty of relevant keywords.

There are three major encryption techniques used by SSH

Symmetrical encryption: This encryption works on the principle of the generation of a single key for encrypting as well as decrypting the data. The secret key generated is distributed among the clients and the hosts for a secure connection. Symmetrical encryption is the most basic encryption and performs best when data is encrypted and decrypted on a single machine.
Asymmetrical encryption: This encryption is more secure because it generates two different keys: Public and Private key. A public key is distributed to different host machines while the private key is kept securely on the client machine. A secure connection is established using this public-private key pair.
Hashing: One-way hashing is an authentication technique which ensures that the received data is unaltered and comes from a genuine sender. A hash function is used to generate a hash code from the data. It is impossible to regenerate the data from the hash value. The hash value is calculated at the sender as well as the re…

yes command in linux is used to print a continuous output stream of given STRING.

If STRING is not mentioned then it prints 'y';
$ yes "" | head

yes | rm -i *.txt.

cal command is a calendar command in Linux which is used to see the calendar of a specific month or a whole year.

cal [ [ month ] year]Rectangular bracket means it is optional, so if used without option, it will display a calendar of current month and year.$ cal
   February 2020
Su Mo Tu We Th Fr Sa
 2  3  4  5  6  7  8
 9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29

eval is a built-in Linux command which is used to execute arguments as a shell command.

eval is a built-in Linux command which is used to execute arguments as a shell command. It combines arguments into a single string and uses it as an input to the shell and executes the commands.
# start the ssh-agent in the background
$ eval $(ssh-agent -s)
Agent pid 59566

MySQL Trigger Example

BERT stands for Bidirectional Encoder Representations from Transformers.

BERT is a natural language processing algorithm that allows a machine to understand what words mean in context.

BERT works by encoding sentences in both directions simultaneously rather than reading the words from left to right. Then, it encodes each word in the sentence based on its relative position. This helps it understand the nuances of natural language better than previous algorithms have been able to. Some words can have different meanings depending on their context, so BERT attempts to understand each word in a search query contextually.

Add SSH key to the ssh-agent

To configure the ssh-agent program to use your SSH key, first ensure ssh-agent is enabled.

# start the ssh-agent in the background
$ eval $(ssh-agent -s)
Agent pid 59566
If you are using Git Bash, turn on the ssh-agent with command shown below instead:

# start the ssh-agent in the background
$ eval `ssh-agent`
Agent pid 59566
Then, add your SSH key to the ssh-agent:

$ ssh-add ~/.ssh/id_rsa

Connect with data services by Java

Azure Cosmos DBis a globally distributed database service that allows developers to work with data using a variety of standard APIs, such as SQL, MongoDB, Cassandra, Graph, and Table. The Spring Boot Starter makes it easy to store data in and retrieve data from your Azure Cosmos DB with SQL API.

JDK distributions

Project Lombok.

Project Lombok is a java library that automatically plugs into your editor and build tools, spicing up your java. Never write another getter or equals method again, with one annotation your class has a fully featured builder, Automate your logging variables, and much more.

Restart the sshd service by PowerShell

Restart-Service sshd

Configure the ssh-agent and sshd service to automatically start on Windows

Run the following PowerShell commands:

Set-Service -Name ssh-agent -StartupType ‘Automatic’
Set-Service -Name sshd -StartupType ‘Automatic’

Fixed: ssh-agent on Windows 10 fails: “unable to start ssh-agent service, error :1058”

PS C:\Users\i88ca> Get-Service ssh-agent

Status   Name               DisplayName
------   ----               -----------
Stopped  ssh-agent          OpenSSH Authentication Agent

PS C:\Users\i88ca>  Get-Service ssh-agent | Select StartType


PS C:\Users\i88ca>  Get-Service -Name ssh-agent | Set-Service -StartupType Manual

Start manually. This means that as soon as you run ssh-agent, it'll start the service.
Start the service via Start-Service ssh-agent or just ssh-agent.exe.

How to fix: mount: wrong fs type, bad option, bad superblock

If you encounter

mount: wrong fs type, bad option, bad superblock on,
missing codepage or helper program, or other error
       (for several filesystems (e.g. nfs, cifs) you might
       need a /sbin/mount.<type> helper program)

Then you need: #For RPM based:$sudo-iyum-yinstallnfs-utilsor$ sudo -i dnf -y installnfs-utils#For Ubuntu:$sudo-iaptinstallnfs-common

Display Linux System Memory

Free command used to check the used and available space of physical memory and swap memory in KB. See the command in action below.

$ free
              total        used        free      shared  buff/cache   available
Mem:        2043880      545924      573704         888      924252     1330060
Swap:        786428       46592      739836

$ free -m
              total        used        free      shared  buff/cache   available
Mem:           1995         538         555           0         902        1293
Swap:           767          45         722

-m is to display in MB.

Run Linux command without leaving MySQL client

The system command works for you:


system ls -l

Codehaus Cargo is a thin wrapper that allows you to manipulate various type of application containers in a standard way.

Cargo provides the following APIs and tools:
A Java API to start/stop/configure any of the supported containers.
A Java API to (remotely or locally) deploy modules into these containers, be it a server alone, a farm or a cluster.
A Java API to parse/create/merge J2EE modules.
ANT tasks wrapping the Java API for configuring, starting, stopping and deploying applications to all supported containers.
A Web interface that wraps the Java API that can be used to configure, start and stop all containers supported by Cargo remotely and at any time.
Maven2/Maven3 plugins wrapping the Java API for configuring, starting, stopping and deploying applications to all supported containers as well as parsing, creating and merging J2EE modules.
These tools and APIs can be used in a standalone fashion or via various IDEs.

Email spamming related to IP address

Waterfalling – is when multiple Email Sending providers ( ESP ) are being used to send email. In this case, each ESP is using it’s own block of IP addresses. Spammers use one ESP to clean their lists, also called scrubbing, and another to send the actual marketing email. This technique is used by spammers and gray mailers.Snowshoe Spamming – is a spamming technique where a wide range of IP addresses are used to spread out the spam send rate and or load. Using a wide range of IP addresses makes it difficult for ISP’s to successfully identify the spam resulting in some of the spam to slip through.IP hopping – is simply using one set of IP addresses today, and next week you use new ones. ISP’s might throw you into the category of Snowshoeing or Waterfalling. If for some reason you have to change your IP’s, make sure they get warmed up properly, by relaying only a few mails per day through them. It takes a very long time to build a proper reputation for IP’s.The complete IP check for send…

JavaScript is a prototype-based language

According to the MDN Docs,

A prototype-based language has the notion of a prototypical object, an object used as a template from which to get the initial properties for a new object.

JavaScript introduced the class keyword in ECMAScript 2015. It makes JavaScript seem like an OOP language. But it is just syntatic sugar over the existing prototyping technique. It continues its prototyping in the background but makes the outer body look like OOP.

Google Cloud Bigtable HBase client works with Hadoop and is interface compatible with Apache HBase

Unlike DynamoDB and DocumentDB, which expose proprietary APIs, Google Cloud Bigtable is standardized on the HBase API. This feature instantly makes it compatible with the Hadoop tools and its thriving ecosystem. The API enables bulk ingestion and export using standard HBase tools. Developers can use HBase Java client for integration with common Hadoop open source tools. With single-digit millisecond reads/writes, Google claims that its NoSQL database is 3X faster than HBase, Cassandra, and DynamoDB.

Customers can self-provision a Bigtable cluster with a minimum of 3 nodes. Each node will deliver up to 10,000 queries per second and 10 MB/s of throughput. The cluster can be based on SSD storage backends. The service costs $0.65 / hour per node with $0.17 per GB per month of SSD storage.

With the addition of this service to its database portfolio, Google hopes to attract enterprise workloads from the finance, IoT, and retail verticals. Similar to Yodlee, Bigtable can be used for storing…

How to solve: JPA eclipselink: during the execution of the query was detected to be null. Primary keys must not contain null

EclipseLink is case sensitive by default unless the eclipselink.jpa.uppercase-column-names persistent property is set to true. This might be the problem for native queries if the database returns the column name as upper-case "ID" when you have it defined as lower-case "id". Try changing the column definitions in the annotations to match what your database uses or adding the property with a value of true.

In persistence.xml:
<properties><property name="" value="SunAS9"/><property name="eclipselink.logging.level" value="ALL"/><property name="eclipselink.logging.level.sql" value="ALL"/><property name="eclipselink.logging.parameters" value="true"/><property name="eclipselink.jdbc.batch-writing" value="JDBC"/><property name="" value="MySQL"/><property name…

How to install OpenVPN AS on CentOS

yum -y install yum -y install openvpn-as

Fixed CentOS Failed to synchronize cache for repo 'AppStream', ignoring this repo.

sudo vim /etc/yum.repos.d/CentOS-Base.repo

name=CentOS-$releasever - Base #mirrorlist=$releasever&arch=$basearch&repo=os&infra=$infra baseurl=$releasever/BaseOS/$basearch/os/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial #released updates [updates] name=CentOS-$releasever - Updates #mirrorlist=$releasever&arch=$basearch&repo=updates&infra=$infra baseurl=$releasever/BaseOS/$basearch/os/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial #additional packages that may be useful [extras] name=CentOS-$releasever - Extras #mirrorlist=$releasever&arch=$basearch&repo=extras&infra=$infra baseurl=$releasever/BaseOS/$basearch/os/ gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
And then:


Fixed nothing provides centos-gpg-keys

Run the upgrade:

sudo dnf upgrade{centos-release-8.1-1.1911.0.8.el8.x86_64.rpm,centos-gpg-keys-8.1-1.1911.0.8.el8.noarch.rpm,centos-repos-8.1-1.1911.0.8.el8.x86_64.rpm}

JEE 7 has a built-in annotation named @Singleton, along with other related annotations.

How to turn on slow query logging in MySQL

slow_query_log can be 0 (or OFF) to disable the log or 1 (or ON) to enable the log.

There are mainly three different kinds of design patterns:

Creational PatternsStructural PatternsBehavioral Patterns

The advantages of design patterns

To provide standard terminology that everybody understands.
Not to reinvent the wheel.

Docker development workflow

Create and test individual containers for each component of your application by first creating Docker images.Assemble your containers and supporting infrastructure into a complete application, expressed either as a Docker stack file or in Kubernetes YAML.Test, share and deploy your complete containerized application.

Best practices for Email marketing regarding anti-spam laws

Get consent: You’ve obtained express permission or opt-in from your list to send commercial email messages, and have explained the nature of the relationship you’re establishing. Make sure you have a record of this in case you ever need to provide proof.Clearly identify yourself: Your messages must clearly identify yourself or your company as the sender, and offer some way to reach you—like a physical address or a website, usually in the footer of your emails.Offer a way to opt out: Every email needs to provide a way to unsubscribe that lets the recipient remove themselves from all future communication.

Why an IP / Domain might have a poor reputation / spam related issue

There have been reports of spam from your IP. Look up your IP's reputation on SenderBase.Your IP exhibits DNS patterns that indicate compromise by a SpamBot. Make sure your DNS is configured according to the protocol for RFC2821, section ( IP contained links to domains hosting or distributing malwareChecking your ip/domain: One way to avoid having your email inadvertently blocked is by registering your domain and IP addresses at Emails from domain names and IP addresses that are properly registered on can be automatically exempted from spam filtering defense layers on Barracuda Spam Firewalls and other anti-spam solutions, preventing your email from being accidentally blocked.

Create ephemeral containers

The image defined by your Dockerfile should generate containers that are as ephemeral as possible. By "ephemeral", we mean that the container can be stopped and destroyed, then rebuilt and replaced with an absolute minimum setup and configuration.

Verify SSH public key uploaded is the same key locally

You can verify the fingerprint of the public key uploaded with the one displayed in your profile through the following ssh-keygen command run against your public key using the bash command line. You will need to change the path and the public key filename if you are not using the defaults.

ssh-keygen -l -E md5 -f ~/.ssh/
You can then compare the MD5 signature to the one in your profile.

How to cache your passphrase using ssh-agent

Temporarily store passphrase for SSH key on Windows
Run the following command included in Git for Windows to start up the ssh-agent process in Powershell or the Windows Command Prompt. ssh-agent will cache your passphrase so you don't have to provide it every time you connect to your repo.


If you're using the Bash shell (including Git Bash), start ssh-agent with:

eval `ssh-agent`

Fixed SSH Host key verification failed.

You canually record the SSH key by running: ssh-keyscan -t rsa >> ~/.ssh/known_hosts

Fixed Windows 10 fails: “unable to start ssh-agent service, error :1058”

Get-Service -Name ssh-agent | Set-Service -StartupType Manual
ssh-agent -s

Git branches isolate your changes from other work in the project.

The recommended Git workflow uses a new branch for every feature or fix you work on. You make commits in your local Git repository to save your changes on that branch.

Configure Git

Set up your name and email address before starting to work with Git on your computer. 
Git attaches this information to your changes and lets others identify which changes are yours.

Run the following commands from the command prompt after installing Git to configure this information:

> git config --global "Tom Lee"

> git config --global ""

Git combines the merge and review of code into the master branch through pull requests.

You create a pull requests when you'd like to merge code from your branch into one shared by the team, such as master. The pull request lists the proposed file changes, and the reviewers of the pull request can comment and vote on if they want the changes to be added to the shared branch.

How cavity walls insulation functions

A cavity wall consists of two parallel walls with a gap or a cavity between them. This cavity is usually filled with insulation material. The cavity walls have the following functions:

The cavity walls are constructed for the following purposes:

It reduces the chance of entry of moisture from the outer wall to the inner wall and thus helps in keeping inside of the building free from dampness.
The air or insulated material filled in the cavity wall acts as a non-conductor of heat and hence minimizes the transmission of heat from the outer wall to the internal wall. Thus, cavity walls help in maintaining the thermal insulation of a house.
The air in the cavity wall also absorbs sound.
As there is no dampness the efflorescence of the walls is also prevented.

Amazon Data Lifecycle Manager provides a complete backup solution for EBS volumes at no additional cost.

You can use Amazon Data Lifecycle Manager to automate the creation, retention, and deletion of snapshots taken to back up your Amazon EBS volumes. Automating snapshot management helps you to:

Protect valuable data by enforcing a regular backup schedule.

Retain backups as required by auditors or internal compliance.

Reduce storage costs by deleting outdated backups.

Exposing RDP/SSH ports over the Internet isn't desired and is seen as a significant threat surface.

This is often due to protocol vulnerabilities. To contain this threat surface, you can deploy bastion hosts (also known as jump-servers) at the public side of your perimeter network. Bastion host servers are designed and configured to withstand attacks. Bastion servers also provide RDP and SSH connectivity to the workloads sitting behind the bastion, as well as further inside the network.

Zulu JDK download

Install the JDK which can be downloaded from here:

G suite Promotion Codes

G Suite Basic
US Code | Expires 08/2020
G Suite Basic
US Code | Expires 08/2020

Fixed mysqldump: Got error: 1290: The MySQL server is running with the --secure-file-priv option so it cannot execute this statement when executing 'SELECT INTO OUTFILE'

To solve the problem:

mysqldump: Got error: 1290: The MySQL server is running with the --secure-file-priv option so it cannot  execute this statement when executing 'SELECT INTO OUTFILE'
you can run
SHOW VARIABLES LIKE "secure_file_priv";
and use the folder you are told there as the output folder in your mysqldump command.
mysql> SHOW VARIABLES LIKE "secure_file_priv"\G; *************************** 1. row *************************** Variable_name: secure_file_priv         Value: /var/lib/mysql-files/ 1 row in set (0.00 sec)

How to delete many rows from a large table in MySQL

If you want to delete many rows from a large table, you may exceed the lock table size for an InnoDB table. To avoid this problem, or simply to minimize the time that the table remains locked, the following strategy (which does not use DELETE at all) might be helpful: Select the rows not to be deleted into an empty table that has the same structure as the original table: create table t_copy like t; insert into t_copy SELECT * FROM t WHERE ... ;
See also:
How to Copy Table in MySQL

Use RENAME TABLE to atomically move the original table out of the way and rename the copy to the original name: RENAME TABLE t TO t_old, t_copy TO t; Drop the original table:
DROP TABLE t_old; Note that Foreign keys that point to the renamed table are not automatically updated. In such cases, you must drop and re-create the foreign keys in order for them to function properly.
If you need a smaller table for development, to keep the foreign keys:
createtablecontacts_newlike contacts; insert into contacts_new select*fro…

canonical/multipass: Multipass orchestrates virtual Ubuntu instances

Multipass is a lightweight VM manager for Linux, Windows and macOS. It's designed for developers who want a fresh Ubuntu environment with a single command. It uses KVM on Linux, Hyper-V on Windows and HyperKit on macOS to run the VM with minimal overhead. It can also use VirtualBox on Windows and macOS. Multipass will fetch images for you and keep them up to date.

Since it supports metadata for cloud-init, you can simulate a small cloud deployment on your laptop or workstation.

Docker Jenkins initial admin password

Jenkins initial setup is required. An admin user has been created and a password generated.
Docker Jenkins initial admin password can be found at: /var/jenkins_home/secrets/initialAdminPassword

For docker pull jenkins/jenkins

Java HttpURLConnection example to Get Google OAuth 2.0 Access Token

There are Http Clients from Apache, many RESTFUL implementation such as Jersey. But sometimes you still may just want to use Java to access directly. Here is an example to get access_token from Google.

String url =""; URL obj =new URL(url); HttpsURLConnection con =(HttpsURLConnection) obj.openConnection();//add reuqest header con.setRequestMethod("POST"); con.setRequestProperty("Content-Type","application/x-www-form-urlencoded"); String urlParameters ="code="+ request.getParameter("code")+"&client_id="+ clientId +"&client_secret="+ CLIENT_SECRET +"&redirect_uri="+ redirectURI +"&grant_type=authorization_code";// for Google OAuth 2.0// Send post request con.setDoOutput(true); DataOutputStream wr =new DataOutputStream(con.getOutputStream()); wr.writeBytes(urlParameters); wr.flush(); wr.close();int responseC…

Cloud Tools for Eclipse is a Google-sponsored open source plugin that supports Google Cloud Platform development inside the Eclipse IDE.

Google Cloud Tools for Eclipse documentation

Glassfish logs

Lists the existing loggers. Supported in remote mode only. For procedural information in this guide, see To List Log Levels.

Sets the log level for a module. Supported in remote mode only. For procedural information in this guide, see Setting Log Levels.

Rotates the server.log file and stores the old data in a time-stamped file. Supported in remote mode only. For procedural information in this guide, see To Rotate Log Files Manually.

Watch out for LEFT JOIN with additional conditions in SQL

FROM    a
ON      b.a_id =
WHERE   b.column = 'sth'
Return the same result as (but less efficient)

FROM    a
ON      b.a_id =
WHERE   b.column = 'sth'
Put additional conditions on left table on left join will actually filter out those rows where b.column is null. Because  NULL in SQL doesn't equal to anything. So the only exception to put extra condition on left table of left join is to check b.column is null or not.

If you actually want to return those  b.column = 'sth' and at the same time with all records of table a, then the condition should be moved into ON clause:

FROM    a
ON      b.a_id =
AND b.column = 'sth'
See also:

WHERE conditions and ON relationship in an SQL LEFT JOIN

NoSQL systems' main advantages and obstacles


Elastic scaling: NoSQL systems are designed with the ability to expand transparently in order to take advantage of the addition of any new nodes.

Less administration

Better economics: use clusters of inexpensive commodity servers.

Flexible data models


Programming models: few facilities for ad-hoc query and analysis.

Transaction support



Expertise: fewer experts.


TRUSTe Data Privacy Certification

TRUSTe is a company best known for its online privacy seals. TRUSTe operates a privacy seal program, certifying websites, mobile apps, and cloud services for more than 5,000 businesses including Apple, eBay, HP, Intuit, LinkedIn, Microsoft, Google Apps Marketplace and Zynga.

The TRUSTe seal does not indicate that a web site complies with any specific set of privacy rules, such as the European Union's Data Protection Directive. It indicates only that the site has self-certified as complying with the site's own privacy statement.

Start webscarab in not lite mode

WebScarab is a web security application testing tool. It serves as a proxy intercepting web browser web requests and web server replies.

java -DWebScarab.lite=false -jar webscarab.jar