Posts

Showing posts from July, 2019

Back up Windows WSL distros

The best way to backup your distros is available in Windows Version 1809 and later. You can export your entire distribution to a tarball using the wsl --export command. You can then import this distro back into WSL using the wsl --import command, allowing you to backup and save states of your WSL distributions.Please note that traditional backup services that backup files in your Appdata folders (like Windows Backup) will not corrupt your Linux files.

Installing WSL with GUI using VcXsrv

VcXsrv is a Windows X-server based on the xorg git sources (like xming
or cygwin's xwin). You can download it from
https://sourceforge.net/projects/vcxsrv/

After installing VcXsrv, start XLaunch and do some setup.

First you can choose whether you like One Large Window or Fullscreen
option, then choose Start no client, and then check Disable access
control. When finished, you will see big window blank screen appear.

Now install Desktop Environment for your WSL.

XFCE4 is lightweight therefore a good choice.

$ sudo apt install xfce4

After the installation finished, make sure you're in your home
directory. Edit .bashrc for some configuration.
$ cd ~
$ nano .bashrc
Go to the last line and write this :
export DISPLAY=:0.0
Exit your WSL and run it again.

The format of this command is actually [host]:<display>.[screen] where
[host] refers to a network host name. Since we left it blank, we're
going to use our local machine instead. Each host can have multiple
display.
Now afte…

Expand Linux Disk on Hyper-V

Use GParted to increase disk size of a Linux native partition

Increasing the virtual hard disk from the Hyper-V manager
Booting into the GParted Live CD

Now that you have increased the hard disk space of the virtual machines, you need to boot into the GParted live CD to continue, you can download this here.
See more: https://www.rootusers.com/use-gparted-to-increase-disk-size-of-a-linux-native-partition/

Temporarily disable a foreign key constraint in MySQL

SET FOREIGN_KEY_CHECKS=0;
make sure to

SET FOREIGN_KEY_CHECKS=1;
when finish.

Passive income is when you continually get paid for work you only did once

Passive income isan attractive method of making extra money.

Fixed GlassFish asadmin "The system cannot find the path specified." error

Go to asenv.bat file in config directory
Change AS_JAVA="C:/Program Files(x86)/Java/" to your correct location
Retry asadmin.

What is Ads.txt File

The "Ads.txt" is simply a text file that can be placed on your blog's
server and carries information about the advertising networks used by
the blog's owner and the owner authorised these ads networks to show
ads on the website.
The main idea behind using this ads.txt file is to protect publishers
from frauds and viruses as you will only authorise those ads network
to display ads on your website which you're aware of and hence any
malware script that showing ads on your blog without your permission
from any unknown sources, cannot perform the task it ought to do.

New cross-platform PowerShell

PowerShell Core
PowerShell Core is now an Open Source project on GitHub. See the
following articles for more information on installing PowerShell Core
on various supported and experimental platforms.

https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell?view=powershell-6#powershell-core

How to add socks proxy to ssh config file? - Stack Overflow

Host example.com
User i88ca
Port 22
IdentityFile ~/.ssh/id_rsa
DynamicForward 1080

Reset Network Settings to Default in Windows 10

Run the following command as Admin:

netsh winsock reset

How to Keep Your Linux SSH Session Alive

Global Configuration Add the following line to the /etc/ssh/ssh_config file: ServerAliveInterval 60 The number is the amount of seconds before the server with send the no-op code. Current User Configuration Add the following lines to the ~/.ssh/config file (create if it doesn’t exist) Host *
  ServerAliveInterval 60 Make sure you indent the second line with a space. Per-Host Configuration If you only want to enable keep alive for a single server, you can add that into the ~/.ssh/config file with the following syntax: Host *hostname.com
   ServerAliveInterval 60

The List-Unsubscribe header record was defined in RFC 2369 in 1998.

The List-Unsubscribe header record is intended to allow universal
access to an unsubscribe function, though its implementation has been
relatively weak. The idea is simple: if the List-Unsubscribe header is
sent with an email it should include a mailto link to allow
unsubscribing by email and an http address to allow redirection to an
unsubscribe page. When the ISP receives the email and recognizes the
header record it should then present an unsubscribe link in its
framework.

Cleanup and Reset Network Adapters in Command Prompt

1. Open an elevated command prompt.

2. Type the command below in the elevated command prompt, and press Enter.

 If you run the command and receive an error referring to NetSetupDeleteObject, run the netcfg –d command until it’s successful.

 netcfg -d


3. When finished, restart the computer to apply.

How to make sure git fork is always up-to-date

Simply run git pull upstream master and you are ready to hack.

Map network drive to Azure File Storage

Create Storage Account
First of all you need to create a storage account that will give you access to the File Storage service that you are going to use.

Create File Storage
After your Azure Storage Account is created you need to create a File Share. From the storage account you have previously created, select Files and add a new File Service. Name your service and set a Quota in GB, to limit the total size of files on the share.

Map Network Drive
Now that your file share is created, you can map it as a network drive in your computer.

The url for your share which can be found if you click on the properties button on your file share toolbar.

Note that you should change https:// to \\ in order to mount the file share.
The storage account name and the storage account key to allow access to your file share.

The connect method can be found if you click on the properties button on your file share toolbar.

Set up fingerprint sign-in on Dell Laptops

If you find it difficult to sign in by fingerprint to your Dell laptops, the trick is to repeatedly try to set up your same finger until the computer tells you that the finger has already set up for the account.

Scan Windows system from command line

Use Windows shortcut keys Win + X to launch the Jump List, and then
select Windows PowerShell (Admin).

2. Type sfc /scannow into the dialog box and hit the key Enter.
Windows will do its jobs if it detects any corrupted files.

Common Java Keytool Keystore Commands

If you need to check the information within a certificate, or Java
keystore, use these commands.

Check a stand-alone certificate
keytool -printcert -v -file mydomain.crt

Check which certificates are in a Java keystore
keytool -list -v -keystore keystore.jks

Check a particular keystore entry using an alias
keytool -list -v -keystore keystore.jks -alias mydomain

Other Java Keytool Commands
Delete a certificate from a Java Keytool keystore
keytool -delete -alias mydomain -keystore keystore.jks

Change a Java keystore password
keytool -storepasswd -new new_storepass -keystore keystore.jks

Export a certificate from a keystore
keytool -export -alias mydomain -file mydomain.crt -keystore keystore.jks

List Trusted CA Certs
keytool -list -v -keystore $JAVA_HOME/jre/lib/security/cacerts

Import New CA into Trusted Certs
keytool -import -trustcacerts -file /path/to/ca/ca.pem -alias CA_ALIAS
-keystore $JAVA_HOME/jre/lib/security/cacerts

How to install zulu JDK 7

apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys
0xB1998361219BD9C9 && \
echo "deb http://repos.azulsystems.com/ubuntu stable main" >>
/etc/apt/sources.list.d/zulu.list && \
apt-get -qq update && \
apt-get -qqy install zulu-7=7.29.0.5 && \
rm -rf /var/lib/apt/lists/*
https://github.com/zulu-openjdk/zulu-openjdk/blob/master/7u222-7.29.0.5/Dockerfile

MySQL GTID replication

Traditional MySQL replication is based on relative coordinates — each
replica keeps track of its position with respect to its current
master's binary log files.

GTID enhances this setup by assigning a unique identifier to every
transaction, and each MySQL server keeps track of which transactions
it has already executed.

This permits "auto-positioning," the ability for a replica to be
pointed at a master instance without needing to specify a binlog
filename or position in the CHANGE MASTER statement.

Multi-source replication use replication channels

Multi-source replication use replication channels, which allow a slave
to replicate from multiple masters.
Multi-source replication is a great way to consolidate data that has
been sharded for production or simplify the analytics process by using
the same server.

A GTID is a globally unique id given to all transactions executed on a GTID-enabled MySQL hosting server.

GTID's are a combination of the UUID of the server where a particular
transaction has been committed, and the sequence number of that
transaction on that particular server. This makes the GTID's globally
unique.

Display the GlassFish Server Version

asadmin> version
Or
$ ./asadmin version
Version = Payara Server Open Source Edition 4.1.152.1 #badassfish (build 193)
Command version executed successfully.

SSH Always forwarding a port

If you have ports that you always want to forward, you can use the
LocalForward directive in the SSH config file.

For example, if you wanted to forward ports 8888 and 18888, you could
update the file as follows:

Host remote-linux-machine
User myuser
HostName remote-linux-machine.mydomain
LocalForward 127.0.0.1:8888127.0.0.1:8888
LocalForward 127.0.0.1:18888127.0.0.1:18888

Rsync Show Progress Bar While Copying Files

You need to use the --progress or -P option which show progress during
file transfer.

Set a default Linux distribution on Windows

Set a default distribution
The default WSL distribution is the one that runs when you run wsl on
a command line.

wsl -s <DistributionName>, wsl --setdefault <DistributionName>

Sets the default distribution to <DistributionName>.

Versions Earlier than Windows 10 Version 1903
WSL Config (wslconfig.exe) is a command-line tool for managing Linux
distributions running on the Windows Subsystem for Linux (WSL).

Check Windows 10 Version

First of All open the run command on your computer by pressing “Windows + R“.
Now, type the command -“WINVER”.
A pop up will appear with the Windows 10 build version.

Fixed Ubuntu Unit sshd.service could not be found.

sudo apt install openssh-server

Developing in the Windows Subsystem for Linux with Visual Studio Code

The Visual Studio Code Remote - WSL extension lets you use the Windows
Subsystem for Linux (WSL) as your full-time development environment
right from VS Code. You can develop in a Linux-based environment, use
Linux specific toolchains and utilities, and run and debug your
Linux-based applications all from the comfort of Windows.
https://code.visualstudio.com/docs/remote/wsl

Generate an SSH key pair

If you do not have a key, run the following command in a local
terminal / command prompt to generate an SSH key pair:

ssh-keygen -t rsa -b 4096

What does 'grep -v' do

-v means "invert the match" in grep, in other words, return all non
matching lines.

How to get ps id of glassfish

$ ps ax | grep glassfish | grep -v grep | awk '{print $1}'

Using SSHFS to access files on your remote host

SSHFS is a secure remote filesystem access protocol that builds up
from SFTP. It provides advantages over something like a CIFS / Samba
share in that all that is required is SSH access to the machine.

Note: For performance reasons, SSHFS is best used for single file
edits and uploading/downloading content. If you need to use an
application that bulk reads/write to many files at once (like a local
source control tool), rsync is a better choice.

Aurora Serverless PostgreSQL Generally Available

The PostgreSQL-compatible edition of Aurora Serverless is now
generally available, offering an alternative to the MySQL version.

Primary and secondary groups on Linux

There are two types of groups — primary and secondary.

The primary group is the one that's recorded in the /etc/passwd file,
configured when an account is set up. When a user creates a file, it's
their primary group that is associated with it.

Secondary groups are those that users might be added to once they
already have accounts. Secondary group memberships show up in the
/etc/group file.

Run System Settings from a terminal on Ubuntu

gnome-control-center

sudo without password on Linux

run sudo visudo to config.


# Members of the admin group may gain root privileges %admin ALL=(ALL) ALL # Allow members of group sudo to execute any command %sudo ALL=(ALL:ALL) ALL # Allow i88ca to execute any command without password i88ca ALL=(ALL) NOPASSWD:ALL # Allow goyun to run ‘/bin/kill’ and ‘systemctl’ commands: goyun ALL = NOPASSWD: /bin/systemctl restart httpd.service, /bin/kill

Keep SSH Connections Alive

/etc/ssh/ssh_config

and add the following line to the end of the file:

ServerAliveInterval 60

Per user configuration

~/.ssh/config
If the file does not exist, this will create a new file.

Add the following line:

Host *
ServerAliveInterval 60

Check MySQL max_connections Value

mysql> SHOW VARIABLES LIKE "max_connections"; +-----------------+-------+ | Variable_name | Value | +-----------------+-------+ | max_connections | 150 | +-----------------+-------+

Fixed Hyper-V Switch Issues on Windows 10

Disabled Hyper-V, restarted and enabled it again. That made the
default switch work.

CSS Grid: auto-fit vs auto-fill

auto-fit works almost identically to auto-fill. The only difference is
that when the container's size exceeds the size of all the items
combined, auto-fill keeps inserting empty rows or columns and pushes
your items to the side, while auto-fit collapses those empty rows or
columns and stretches your items to fit the size of the container.

Turn any HTML element into a grid container

Turn any HTML element into a grid container by setting its display
property to grid. This gives you the ability to use all the other
properties associated with CSS Grid.

In CSS Grid, the parent element is referred to as the container and
its children are called items.

Share a Web Page in Edge Browser

Open Edge.
Tap the Share button on the top right while the page you want to share is open.
Press the dropdown arrow next to the page's name to pick the format
you wish to share.
Select the channel through which you wish to post.

How to screen record on Windows 10

There is a built in screen recorder inside Windows 10. It's there to
record your games as you play them. But you can also use it to record
content in other windows.

But it's only available to machines with certain video cards and it is
limited. You can't switch between apps while you're recording, for
example; it will only record the window you initially begin capturing.
But it's good for the simple stuff.

To get the screen capture to work, you need to press Windows button
and G together. The controls for the screen recording will be
displayed on screen. Once you are finished recording, the video is
automatically saved in your video folder, although you can change that
in the Game Bar settings.

What is Digital Marketing

Digital marketing is the marketing of goods, products, and services by
employing digital technologies found on the internet using devices
such as computer, tablets and phones.

Why AI Will Be Game-changer for Digital Marketing

Artificial Intelligence makes it possible for computers to perform
tasks that normally require human time and intelligence.

Public cloud vulnerabilities

The leading cloud vulnerabilities
Unauthorized cloud access,
Insecure interfaces
Misconfiguration of the cloud platform
Account hijacking

Best affiliate marketing tracking software platforms

According to Entrepreneur, some of the best affiliate marketing tracking software platforms are Everflow.io, LinkTrust, AffTrack, Hitpath, etc.

An artificial intelligence system created by researchers at the University of California can solve the Rubik's Cube in just over a second.

Fixed: CreateProcessW failed error:2 posix_spawn: No such file or directory

If you encountered this in Windows:
ssh uu CreateProcessW failed error:2 posix_spawn: No such file or directory
To fix, use a full path. So this is the correct line in the .ssh/config:
  ProxyCommand  C:\Windows\System32\OpenSSH\ssh.exe  -q proxy.i88.ca nc %h %p

Chaining multiple SSH proxies

For A->B->C->D->Internet [hostA]$ ssh -2 -C -D 55557 -L 55556:127.0.0.1:55556 -L 55555:127.0.0.1:55555 user@B [hostB]$ ssh -2 -C -D 55556 -L 55555:127.0.0.1:55555 user@C [hostC]$ ssh -2 -C -D 55555 user@D Note that for each hop, you need an additional matching forwarder -L on the previous hosts in the chain. References: ssh tunnel via multiple hopsThis posting shows how to chain an arbitrary number of proxies: http://sophiedogg.com/ssh-proxy-through-multiple-servers/The template for this solution: http://sysextra.blogspot.com/2013/10/multi-hop-ssh-socks-proxy.htmlHow can I use SSH with a SOCKS 5 proxy?http://www.jethrocarr.com/2013/03/13/ssh-via-socks-proxies/

Debug a perl program

To debug a perl program, invoke the perl debugger using "perl -d" as
shown below.

# perl -d ./perl_example.pl

Python email by smtplib and MIMEMultipart example

"""The first step is to create an SMTP object, each object is used for connectionwith one server."""import smtplib from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText server = smtplib.SMTP('smtp.i88.ca', 587) #debug server.set_debuglevel(1) # or server.set_debuglevel(True) # show communication with the server#TLS server.starttls() #Next, log in to the server server.login("user-name", "password") me="sender@i88.ca" you="recipient@i88.ca"#Send the mail msg = MIMEMultipart('alternative') msg['Subject'] ="Test example" msg['From'] = me msg['To'] = you html ='<html><body><p>Hi, I have the following contents for you!</p></body></html>' part2 = MIMEText(html, 'html') # or part2=MIMEText(text, 'plain') msg.attach(part2) server.sendmail(me, you, msg.as_string()) server.quit()

The f…

Python email by smtplib example

"""The first step is to create an SMTP object, each object is used for connectionwith one server."""import smtplib server = smtplib.SMTP('smtp.i88.ca', 587) #for debug server.set_debuglevel(1) #TLS server.starttls() #Next, log in to the server server.login("user-name", "password") #Send the mail msg ="\n\nHello!"# The /n separates the message from the headers server.sendmail("sender@i88.ca", "recipient@i88.ca", msg) server.quit()

Fixed Python smtplib.SMTPException: SMTP AUTH extension not supported by server

server = smtplib.SMTP('smtp.i88.ca', 465)
server.starttls()

Four different viewport units

vw: 20vw would be 20% of the viewport's width.
vh: 18vh would be 18% of the viewport's height.
vmin: 80vmin would be 80% of the viewport's smaller dimension (height
vs. width).
vmax: 100vmax would be 100% of the viewport's bigger dimension (height
vs. width).

Google G Suite Promo codes for US

G Suite Basic
Unused US Code | Expires 01/2020
G3UEP3KE6C9WLRH
G Suite Basic
Unused US Code | Expires 01/2020
Q347KFUUXK9EXRC

The HTML label tag wraps the text for a specific form control item, usually the name or label for a choice.

This ties meaning to the item and makes the form more readable. The
for attribute on a label tag explicitly associates that label with the
form control and is used by screen readers.

Many Americans Have No Plans to Retire

Lack of financial stability is the major reason.

Nutrition Key to Patient Recovery

New studies show that good nutrition is one of the major factors in keeping patients from being readmitted to hospitals after an injury or infection.

Enable Java Flight Recorder

If Flight Recorder features are not enabled, then to enable this you need to use a Java 7u4 or later JVM started with -XX:+UnlockCommercialFeatures -XX:+FlightRecorder.

How to use ProxyCommand for ssh chain

Host HostA HostName real-host-name-A-or-ip Host HostB HostName real-host-name-B-or-ip ProxyCommand ssh -q HostA nc %h %p Host HostC HostName real-host-name-C-or-ip ProxyCommand ssh -q HostB nc %h %p

Parameters for Jenkins

Parameters Jenkins starts with are configured in: jenkins.xml file in
Jenkins home directory in the <arguments></arguments> variable.

It is possible to just add the java parameters into this field. To
verify that the parameters had been accepted, go to Manage Jenkins -->
System Information and view the list of System Properties used by
Jenkins.

Ransomware attacks are dominating the headlines in 2019

According to the FBI's Internet Crime Complaint Center, the damages associated with ransomware have dramatically increased over the last year.

Add Persistent Static Routes

Image
To add permanent Static route For RHEL/CentOS/Fedora Edit file /etc/sysconfig/network-scripts/route-eth0 (eth0 is the device name) and add the following lines and save and exist.

By default route-eth0 file will not be there, need to be created.
$ sudo vim /etc/sysconfig/network-scripts/route-eth0 10.10.20.0/24 via 192.168.50.100 dev eth0 For Ubuntu/Debian/Linux Mint Open the file /etc/network/interfaces and at the end add the persistence Static routes. IP Addresses may differ in your environment. $ sudo vi /etc/network/interfacesauto eth0 iface eth0 inet static address 192.168.50.2 netmask 255.255.255.0 gateway 192.168.50.100 #########{Static Route}########### up ip route add 10.10.20.0/24 via 192.168.50.100 dev eth0 Next, restart network services after entering all the details using the following command. # /etc/init.d/network restart$ sudo /etc/init.d/network restart
If it is managed by NetworkManager, you can use nmtui to add the static route.



$ sudo systemctl restart NetworkManager


Restart Ubuntu server networking service

$ sudo ifconfig eno2 down &&  sudo ifconfig eno2 up

Or
$ sudo nmcli con down netplan-eno2; sudo nmcli con up netplan-eno2

To show your connections:
$ sudo nmcli device show

Fixed Ubuntu: Failed to restart network.service: Unit network.service not found.

Change to either one of the following, depends on whether you have
installed network-manager or not:

sudo service network-manager restart

or

sudo service networking restart

Fixed: ModuleNotFoundError: No module named 'oauth2client'

python -m pip install oauth2client

Show Git configuration

For example, to show your Git email:

The git config command
The git config --list command

Looking in your Git configuration file
1) The `git config` command
Here's the git config command:

git config user.email
which in my case returns:
superman@i88.ca

2) The `git config --list` command
Another way to show your Git username is with this git config command:

git config --list

Ignoring directories in Git repos

Create a file named .gitignore in your project's directory. Ignore
directories by entering the directory name into the file (with a slash
appended):

ignored-folder/

PostgreSQL is popular with developers

PostgreSQL is popular with developers due to numerous features like
logical replication, simple read balancing, commit tracking, and full
text search support for JSON.

Set jdk path in eclipse.ini on windows

Don't put everything in single line.

Inside eclipse.ini:

-vm
C:\Program Files\Java\jdk-11.0.1\bin
-startup
...other content

Multimedia content usually has both visual and auditory components.

Multimedia content needs synchronized captions and a transcript so
users with visual and/or auditory impairments can access it.
Generally, a web developer is not responsible for creating the
captions or transcript, but needs to know to include them.

Permalink plays a great role in search engine ranking of your post.

There are a few rules which everyone should follow for web site permalinks:

Keep the number of characters in the post title to 50
Remove Stop Words from the permalink (Ex: A, An, The)

Kite Works with the Top Python Editors

Kite integrates with all the top Python IDEs - Atom, PyCharm, Sublime, VS Code and Vim. Scroll down to access Kite's Github repo for each editor.

Article is one of the new HTML5 elements that adds semantic meaning to your markup.

Article is a sectioning element, and is used to wrap independent,
self-contained content. The tag works well with blog entries, forum
posts, or news articles.

7月对于加拿大人来说是个特殊的月份

7月对于加拿大人来说是个特殊的月份,因为7月1日就是加拿大的国庆日啦,在加拿大日这天,举国同庆,热情欢乐的气氛洋溢千家万户,到处都洋溢着欢乐的气氛.

Google cloud Components that are available for installation

Components that are available for installation can be viewed by running:

        $ gcloud components list

gcloud components list Your current Cloud SDK version is: 252.0.0 The latest available version is: 252.0.0 ┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ Components │ ├───────────────┬──────────────────────────────────────────────────────┬──────────────────────────┬───────────┤ │ Status │ Name │ ID │ Size │ ├───────────────┼──────────────────────────────────────────────────────┼──────────────────────────┼───────────┤ │ Not Installed │ App Engine Go Extensions │ app-engine-go │ 56.9 MiB │ │ Not Installed │ Cloud Bigtable Command Line Tool │ cbt │ 6.2 MiB │…

Objectify is a Java data access API specifically designed for the Google Cloud Datastore

Objectify is a Java data access API specifically designed for the
Google Cloud Datastore (aka the Google App Engine Datastore). It
occupies a "middle ground"; easier to use and more transparent than
JDO or JPA, but significantly more convenient than the low-level API
libraries that Google provides. Objectify is designed to make novices
immediately productive yet also expose the full power of the
Datastore.
https://github.com/objectify/objectify

Nginx is more than a HTTP web server

Nginx is a load balancer. It is an HTTP and reverse proxy server, a mail proxy server, and a generic TCP/UDP proxy server. Companies like Groupon, Capital One, Adobe, and NASA use it.