Showing posts from February, 2021

Digital Marketing

Port 27017 is the default port for Amazon #DocumentDB.

Install Microsoft Edge in #Linux

VSCode installer script

Amazon Neptune supports open graph APIs for both Gremlin and SPARQL, and provides high performance for both of these graph models and their query languages.

Amazon Neptune lets you choose the Property Graph model and its open source query language, Apache TinkerPop Gremlin or the W3C standard Resource Description Framework (RDF) model and its standard query language, SPARQL. 

DynamoDB is a Document style database.

DynamoDB has the capability to scale depending upon the size of data.

Improve #MySQL delete performance

mysql > SET session transaction isolation level READ COMMITTED; Query OK, 0 rows affected Time: 0.001s mysql > SET session autocommit=1; Query OK, 0 rows affected Time: 0.001s mysql >


mysql > SET TRANSACTION ISOLATION LEVEL READ COMMITTED; Query OK, 0 rows affected Time: 0.001s mysql > SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; Query OK, 0 rows affected Time: 0.001s mysql > SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; Query OK, 0 rows affected Time: 0.001s mysql > SET TRANSACTION ISOLATION LEVEL REPEATABLE READ; Query OK, 0 rows affected Time: 0.001s mysql >

A #MySQL user can change the isolation level for a single session or for all subsequent connections with the SET TRANSACTION statement.

The default isolation level for #InnoDB is REPEATABLE READ.

The default isolation level in #MySQL is REPEATABLE READ

Fixed Centos mailx sending body as attachment

Remove those ' \r' by sed: Example:  ssh -t 'df -h /; df -h /home' | sed "s/\r//g" | mailx -s "disk dize info"

sed with pipe in #Linux command example

 ssh -t 'df -h /; df -h /home' | sed "s/\r//g" | mailx -s "disk dize info"

MSTSC Creates connections to Remote Desktop Session Host servers or other remote computers

Syntax mstsc.exe [<connectionfile>] [/v:<server>[:<port>]] [/admin] [/f] [/w:<width> /h:<height>] [/public] [/span] mstsc.exe /edit <connectionfile> mstsc.exe /migrate Parameters Parameters Parameter Description <connectionfile> Specifies the name of an .rdp file for the connection. /v: <server>[:<port>] Specifies the remote computer and, optionally, the port number to which you want to connect. /admin Connects you to a session for administering the server. /f Starts Remote Desktop Connection in full-screen mode. /w: <width> Specifies the width of the Remote Desktop window. /h: <height> Specifies the height of the Remote Desktop window. /public Runs Remote Desktop in public mode. In public mode, passwords and bitmaps aren't cached. /span Matches the Remote Desktop width and height with the local virtual desktop, spanning across multiple monitors if necessary. /edit  <connectionfile> Opens the specified .rdp fil

Remote Desktop (RDP) Keyboard Shortcuts in Windows 10

Regular Windows keyboard combination Key combination for RDP Description of what hotkeys do Win key or Ctrl+Esc Alt+Home Opens the Start Menu or Start screen Alt+Tab Alt+Page Up Displays the Alt+Tab switcher where pressing Page Up while Alt is held down will switch programs from left to right Alt+Shift+Tab Alt+Page Down Displays the Alt+Tab switcher where pressing Page Down while Alt is held down will switch programs from right to left Alt+Esc Alt+Insert Cycles through open apps in most recently used order ( sends the current active window to the bottom of the Z-order ) Alt+Space Alt+Delete Opens the window menu of the active window Print Screen Ctrl+Alt+'+'(Plus key on numeric keypad) Takes a screenshot of the whole screen to the clipboard which you can paste in Paint Alt+Print Screen Ctrl+Alt+'-' (Minus key on the numeric keypad) Takes a screenshot of the active window to the clipboard which you can paste in Paint Ctrl+Alt+Del Ctrl+Alt+End Sends Ctrl+Alt+Del (Secure A

Start browsers in private mode from command line on Windows

start  msedge -inprivate start  firefox -private chrome -incognito

Start Microsoft Edge in private mode from command line

start  msedge -inprivate

Switch from WSL back to CMD or PowerShell

From within wsl, run cmd.exe or powershell.exe$ powershell.exe Windows PowerShell Copyright (C) Microsoft Corporation. All rights reserved. Try the new cross-platform PowerShell PS C:\Users\> wsl * keychain 2.8.5 ~ * Found existing ssh-agent: 145 * Known ssh key: /home/$ cmd.exe Microsoft Windows [Version 10.0.19042.804] (c) 2020 Microsoft Corporation. All rights reserved. C:\Users\>

The config file for mycli is located in the home folder (~/.myclirc)

Display Options from Option Files using my_print_defaults

my_print_defaults displays the options that are present in option groups of option files.  The output indicates what options are used by programs that read the specified option groups.$ my_print_defaults mysql client --auto-vertical-output --auto-rehash --compress --protocol=TCP --user=goyuninfo$ mysql --print-defaults mysql would have been started with the following arguments: --auto-vertical-output --auto-rehash --compress --protocol=TCP --user=goyuninfo

Exit existing SSH #ControlMaster and reconnect $ ssh -O check Master running (pid=2252) $ ssh -O exit Exit request sent. $ ssh

Fixed gpg: There is no assurance this key belongs to the named user

gpg --edit-key <KEY_ID> gpg> trust 1 = I don't know or won't say 2 = I do NOT trust 3 = I trust marginally 4 = I trust fully 5 = I trust ultimately m = back to the main menu Choose 5. gpg> quit

Changing Private Key Passphrase

If you ever need to change your private key passphrase, you can do so with this command: ssh-keygen -f ~/.ssh/id_rsa -p Enter your old passphrase and then enter a new passphrase.

Lock (Disable) User Account on Linux

Passwd command can be used to lock or disable a user account. To lock: # passwd openvpn –l Above command changes the shadow file and adds “!” in front of the user password To unlock # passwd openvpn -u You can also enable account by removing manually the “!” character from the user’s password line in /etc/shadow. : ~ $ sudo passwd openvpn -l passwd: password expiry information changed. : ~ $ sudo grep openvpn /etc/shadow openvpn:!$6$PotCU3QmMD7JsvbS$cAM5Ti0pcPxgFXw87hwCGJqUWXPhN10eD8SMrRXMu/kUKJAh5sgHcTgSPAGUjeGd1HgmwRB4xDekGASyOBpVj0:18681:0:99999:7::: nm-openvpn:*:18530:0:99999:7::: openvpn_as:!:18673:0:99999:7::: : ~ $ sudo passwd openvpn -u passwd: password expiry information changed. : ~ $ sudo grep openvpn /etc/shadow openvpn:$6$PotCU3QmMD7JsvbS$cAM5Ti0pcPxgFXw87hwCGJqUWXPhN10eD8SMrRXMu/kUKJAh5sgHcTgSPAGUjeGd1HgmwRB4xDekGASyOBpVj0:18681:0:99999:7::: nm-openvpn:*:18530:0:99999:7::: openvpn_as:!:18673:0:99999:7::: bi

Get size of BLOB in MySQL

  SELECT OCTET_LENGTH(blob_content) FROM blob_table WHERE id = 88 ;

Install xfce on WSL2 Ubuntu

It is currently works with the remote desktop app mstsc.exe, not the rdp app from Microsoft Store.

Automatically start service on WSL on Windows:

First configure it to start the service without asking a password. Create line in /etc/sudoers.d/ (at WSL to prevent asking password): %sudo   ALL=(ALL) NOPASSWD: /usr/sbin/service xrdp * Create .bat file in  Windows startup directory  with for example the following lines: wsl sudo service dbus start wsl sudo service xrdp start

Windows startup directory

You can find Windows startup directory by key:  Win + R  and  shell:startup

Use an ssh-agent on Ubuntu

Use keychain  package  $ sudo apt-get install keychain Then append to your ~/.bashrc /usr/bin/keychain --nogui $HOME/.ssh/id_rsa source $HOME/.keychain/$HOSTNAME-sh

my_print_defaults — Display #MySQL Options from Option Files

my_print_defaults displays the options that are present in option groups of option files. The output indicates what options are used by programs that read the specified option groups.

The #mysql_config_editor utility enables you to store authentication credentials in an obfuscated login path file named .mylogin.cnf.

The file location is the %APPDATA%\MySQL directory on Windows and the current user's home directory on non-Windows systems.

Denormalization helps to avoid joins and improve query #performance.

An inverted index is a common secondary index design pattern with DynamoDB.

With an inverted index, you create a secondary index that is the inverse of the primary key for your table. The HASH key for your table becomes the RANGE key in your index, and the RANGE key for your table becomes the primary key for your index.

DynamoDB concepts

Table: A collection of DynamoDB data records. Item: A single data record in a DynamoDB table. It is comparable to a row in a relational database. Attribute: A single data element on an item. It is comparable to a column in a relational database. However, unlike columns in a relational database, attributes do not need to be specified at table creation, other than the primary key. Attributes can be simple types such as strings, integers, or Boolean, or they can be complex types such as lists or maps. Primary key: A primary key is a unique identifier for a single item in a DynamoDB table. The primary key name and type must be specified on table creation, and a primary key of the specified type must be included with each item written to a table. A simple primary key consists of a single attribute, and a composite primary key consists of two attributes: a partition key and a sort key. For example, you can create a simple primary key using “UserID” as an identifier, or create a composite pri

When using #DynamoDB, it is important to consider your access patterns before you model your data.

When building an application, you should always take time to design the data models needed in your application logic. This data model design should consider data access needs that will be needed in your application, both for reading and writing data.

Using the Jar Command to Unzip Files

jar -xvf /path/to/zip/file/or/jar/file

With #DynamoDB, you can create database tables that can store and retrieve any amount of data and serve any level of request traffic.

You can scale up or scale down your tables' throughput capacity without downtime or performance degradation. You can use the AWS Management Console to monitor resource utilization and performance metrics.

Helidon is an extremely versatile Java library for accessing data in #microservices.

Sample Log4j2 XML configuration for rolling file and console

<? xml version = " 1.0 " encoding = " UTF-8 " ?> < Configuration status = " DEBUG " > < Loggers > < Root level = " TRACE " > < AppenderRef ref = " RollingFileAppender " level = " INFO " /> < appender-ref ref = " Console " level = " TRACE " /> </ Root > </ Loggers > < Appenders > < Console name = " Console " target = " SYSTEM_OUT " > < PatternLayout pattern = " %d{HH:mm:ss.SSS} [%t] %highlight{%level}{FATAL=bg_red, ERROR=red, WARN=yellow, INFO=green, DEBUG=blue} - %msg%n " /> </ Console > < RollingFile name = " RollingFileAppender " fileName = " logs/ " filePattern = " logs/$${date:yyyy-MM}/email-%d{MM-dd-yyyy} " > < Patter

Empty or Delete a Large File Content in #Linux

Empty File Content by Redirecting to Null # > file_to_be_emptied.log

SSH-Agent on Windows 10 WSL2

sudo apt-get install keychain You can put the following to .bashrc /usr/bin/keychain --nogui $HOME/.ssh/id_rsa source $HOME/.keychain/$HOSTNAME-sh

Linux Date format

Linux Date format is a sequence of characters which specifies how output will appear.  It comprises some combination of the following sequences: %% A literal percent sign (" % "). %a The abbreviated weekday name (e.g.,  Sun ). %A The full weekday name (e.g.,  Sunday ). %b The abbreviated month name (e.g.,  Jan ). %B Locale's full month name (e.g.,  January ). %c The date and time (e.g.,  Thu Mar 3 23:05:25 2005 ). %C The current century; like  %Y , except omit last two digits (e.g.,  20 ). %d Day of month (e.g.,  01 ). %D Date; same as  %m/%d/%y . %e Day of month, space padded; same as  %_d . %F Full date; same as  %Y-%m-%d . %g Last two digits of year of ISO week number (see  %G ). %G Year of ISO week number (see  %V ); normally useful only with  %V . %h Same as  %b . %H Hour ( 00 .. 23 ). %I Hour ( 01 .. 12 ). %j Day of year ( 001 .. 366 ). %k Hour, space padded (  0 .. 23 ); same as  %_H . %l Hour, space padded (  1 .. 12 ); same as  %_I . %m Month ( 01 .. 12 ). %M Min

#Windows Environment Variables List

Windows Environment Variables List Environment Variable Corresponding Path %SystemDrive% C:\ (Operating System drive) %SystemRoot% C:\Windows %WINDIR% C:\Windows %HOMEDRIVE% C:\ (Operating System drive) %HOMEPATH% C:\Users\<Username> %USERPROFILE% C:\Users\<Username> %APPDATA% C:\Users\<Username>\AppData\Roaming %ALLUSERSPROFILE% C:\ProgramData %PROGRAMFILES% C:\Program Files %PROGRAMFILES(X86)% C:\Program Files (x86) %PROGRAMDATA% C:\ProgramData %TEMP% C:\Users\<Username>\AppData\Local\Temp %LOCALAPPDATA% C:\Users\<Username>\AppData\Local %PUBLIC% C:\Users\Public %COMMONPROGRAMFILES% C:\Program Files\Common Files %COMMONPROGRAMFILES(x86)% C:\Program Files (x86)\Common Files

You specifically model your data in #DynamoDB so that entities you want to access together are located next to each other in a single table.

This approach replaces the need for joins in a typical relational database and keeps your application high-performing as you scale up.

#DynamoDB has two capacity modes: provisioned and on-demand.

In provisioned capacity mode, you specify exactly the amount of read and write throughput you want. You pay for this capacity whether you use it or not. In DynamoDB on-demand capacity mode, you can pay per request. The cost per request is slightly higher than if you were to use provisioned throughput fully, but you don’t have to spend time doing capacity planning or worrying about getting throttled. On-demand mode works great for spiky or unpredictable workloads.

A table in #DynamoDB can hold many different kinds of data items at one time.

The same attribute in different items can contain entirely different kinds of information.

Amazon #DynamoDB has a default quota of 20 global secondary indexes per table

Data modeling is the process of designing how an application stores data in a given #database.

Start the #SSH Agent on Linux

To start the SSH Agent in the background on Linux, run: eval "$(ssh-agent -s)" To start the SSH Agent automatically on login, add these lines to your ~/.bash_profile: if [ -z "$SSH_AUTH_SOCK" ]; then    # Check for a currently running instance of the agent    RUNNING_AGENT="`ps -ax | grep 'ssh-agent -s' | grep -v grep | wc -l | tr -d '[:space:]'`"    if [ "$RUNNING_AGENT" = "0" ]; then         # Launch a new instance of the agent         ssh-agent -s &> .ssh/ssh-agent    fi    eval `cat .ssh/ssh-agent` fi

Configure OpenSSH runs multiple SSH sessions over a single connection

If you are on macOS and Linux, enable the ControlMaster feature on your local machine so that OpenSSH runs multiple SSH sessions over a single connection. This will reduce how often you have to enter a password or token. To enable ControlMaster: Add an entry like this to your SSH config file: Host *     ControlMaster auto     ControlPath  ~/.ssh/%r@%h-%p     ControlPersist  600

#PowerShell is often more powerful than traditional Windows batch files

Batch files don't have access to the full range of .NET tools, making PowerShell often more powerful.

Run command automatically after login to Linux

You can put your command in  $HOME/.bash_profile . All commands there are run on login.

Run Command on Remote System

The syntax for running a remote command is fairly straightforward: ssh username@host 'command'

Set MAILTO Variable To Change Crontab Email

If MAILTO is defined (and non-empty), mail is sent to the user instead. MAILTO="" @daily /root/scripts/ MAILTO="" * 10 * * * /root/scripts/ # # Disable email alert for rest of jobs # MAILTO="" #Other cron jobs

Assign null password to a user on #Linux

Setup null password: # usermod -p "" username Only do this on dev/test environment.

Run several commands in the same #cron job

Run several commands in the same cron job by separating them with a semi-colon (;)

How to List and Delete UFW #Firewall Ports/Rules

goyun@u:~$ sudo ufw status numbered Status: active To Action From -- ------ ---- [ 1] 22/tcp ALLOW IN Anywhere [ 2] 443/tcp ALLOW IN [ 3] 3389 ALLOW IN [ 4] 3389 ALLOW IN [ 5] 110 ALLOW IN Anywhere [ 6] 22/tcp (v6) ALLOW IN Anywhere (v6) [ 7] 110 (v6) ALLOW IN Anywhere (v6) goyun@u:~$ sudo ufw delete 3 Deleting: allow from to any port 3389 Proceed with operation (y|n)? y Rule deleted goyun@u:~$ sudo ufw status numbered Status: active To Action From -- ------ ---- [ 1] 22/tcp ALLOW IN Anywhere [ 2] 443/tcp ALLOW IN [ 3] 3389 ALLOW IN [ 4]

Specifying SSH port number on the command line

The -p <port> option can be used to specify the port number to connect to when using the ssh command on Linux.  The -P <port> (note: capital P) option can be used with SFTP and scp.  The SSH port number command line setting overrides any value configured in configuration files.

Add Additional sshd ports

Add more ports to sshd: Inside sshd_config: Port 22 Port 110 Port 443 Port 2222

Configuring a fail2ban jail

sudo vim /etc/fail2ban/jail.local [sshd] enabled = true port = 22,2222 filter = sshd logpath = /var/log/auth.log maxretry = 3

Avoid locking out when restarting sshd

Existing sessions will remain active, using the pre-restart config. All new sessions will use the new config. So before restarting sshd, open another session and keep it alive while restarting sshd service.

GitHub Codespaces provides cloud-hosted development environments for any activity

GitHub Codespaces provides cloud-hosted development environments for any activity - whether it's a long-term project, or a short-term task like reviewing a pull request. You can connect to Codespaces from Visual Studio Code, Visual Studio, or a browser-based editor that's accessible anywhere!

#SSH Config File Match Example

The Host directive can contain one pattern or a whitespace-separated list of patterns.  Each pattern can contain zero or more non-whitespace character or one of the following pattern specifiers: * - Matches zero or more characters. For example, Host * matches all hosts, while 192.168.8.* matches hosts in the subnet. ? - Matches exactly one character. The pattern, Host 10.10.8.? matches all hosts in 10.10.8.[0-9] range. ! - When used at the start of a pattern, it negates the match. Host * !fm ProxyJump fm Host * # Does not use ProxyJump here Host * !fm means all hosts except fm

"getsockname failed: Not a socket" on Windows

#SSH connection reuse does not currently work on Windows. You currently cannot use ControlMaster and ControlPath on Windows SSH. The workaround is to use wsl on Windows.

ProxyJump is an easy way to manage #SSH tunnels across proxies

Host hop1 HostName Host hop2 HostName ProxyJump hop1 Host hop3 HostName ProxyJump hop2

Sync a copy from remote Linux server

rsync -rlptzv --progress --delete --exclude=.git "user@hostname:/remote/to/be/synced/path" local/path

#Git Credential Manager Core (GCM Core) is a secure Git credential helper built on .NET Core that runs on Windows and macOS.

#Git for Windows provides a BASH emulation used to run Git from the command line.

Download the Amazon RDS CA file

Download the Amazon RDS CA file from

Fixed MongoClient is abstract; cannot be instantiated

You can instantiate a MongoClient object without any parameters to connect to a MongoDB instance running on localhost on port 27017: MongoClient mongoClient = MongoClients.create(); Or you can specify the ConnectionString: MongoClient mongoClient = MongoClients.create("mongodb://hostOne:27017,hostTwo:27018");

Do not use sequential primary keys (auto-increment) on MySQL

Sequential primary keys introduce locks.  Use client-generated keys, such as GUIDs. When you have master-master replication, auto-increment causes conflicts.