Posts

Showing posts from December, 2020

Digital Marketing

How to open zip file in Google Drive on iPhone

Send the zip file as attachment to your Gmail.  Open Gmail App, open the attachment inside the app.

SpaceX CEO Elon Musk has said any future economy on Mars could be #cryptocurrency based.

Decentralized identity

Decentralized identity can replace identifiers, such as usernames, with IDs that are self-owned, independent, and use blockchain and distributed ledger technology to protect privacy and secure transactions.

The Financial Crimes Enforcement Network (FinCEN)

The Financial Crimes Enforcement Network (FinCEN) prevents and punishes money laundering and related financial crimes. FinCEN tracks suspicious persons and activity by researching mandatory disclosures for financial institutions. The FinCEN receives its duties from Congress and the director of the bureau is appointed by the Treasury Secretary.

Make a password from the command line

$ date | sha256sum e237c08a42a2fbfbb56c1501f23be3c7c5a8ea84ee3a6b952e42f983ca6958e7

Dell XPS 15 - 15 Inch FHD+, Intel Core i7 10th Gen, 16GB Memory, 512GB Solid State Drive, Nvidia GeForce GTX 1650 Ti 4GB GDDR6, Windows 10 Home (Latest Model) - Silver: Amazon.ca: Computers & Tablets

Enjoy a 16:10 display that features a stunning edge-to-edge view Equipped with 100% Adobe RGB, 94% DCI-P3 color gamut, VESA certified DisplayHDR 400, and Dolby Vision, this display delivers more than 16 million ultra-vivid colors that are 40 times brighter than ever before With a 62% larger touchpad, 5% larger screen, and 5.6% smaller footprint, every element is carefully considered—from its inlayed stainless logos to its high-polished diamond-cut sidewalls Integrated Eyesafe display technology helps reduce harmful blue light Embrace a 3D surround sound experience with more than 7,000 machined speaker holes and a quad speaker design with Waves Nx audio

Java reflection example

Reflection is the ability of a computer program to examine and modify the structure and behavior (specifically the values, meta-data, properties and functions) of an object at runtime. Type Introspection (instanceof) is the ability to inspect the code in the system and see object types. Reflection is then the ability to make modifications at runtime by making use of introspection. The sample code can be download here . output: Hello  goyun.info ! Hello  goyun.info ! Hello it.goyun.info! Use reflection to deal with private property or method such as unit testing: // / For private methods: Method method = targetClass . getDeclaredMethod(methodName, argClasses); method . setAccessible( true ); return method . invoke(targetObject, argObjects); // / And for private fields: Field field = targetClass . getDeclaredField(fieldName); field . setAccessible( true ); field . set(object, value); // The setAccessible(true) is required to play around with privates. Refl...

Start windows terminal automatically

Put  "startOnUserLogin": true to settings.json of the Windows Terminal. Or put wt.exe to your windows startup script.

Run wsl command at startup

Create a bat file to start WSL services in the Windows startup folder Open the Windows startup folder. For that, simply press Windows Key + R to open the Run box and then type shell:startup and press the Enter key. Inside the folder right and create a .bat file, such as example.bat: Put commands you like to run wsl sudo service mysql start wsl sudo service apache2 start aws s3 ls #start windows terminal wt.exe

Launch Windows Terminal

Run wt.exe from anywhere inside Windows.

Run command if stdin is not empty on Linux

ifne runs the following command if and only if the standard input is not empty.  Options -n. Reverse operation. Run the command if the standard input is empty. The ifne command is part of the moreutils package. $ sudo yum -y install  moreutils Example usage: Send email if and only if there is content: $ mysql --login-path=goyun mysql -e "select * from user where user='goyuninfo'\G" | ifne mailx -s "User goyuninfo found in mysql" service@goyun.info If you don't want to install ifne, the following is the same: $ output=$(mysql --login-path= goyun  mysql -e "select * from user where user='goyuninfo'\G"); [[ -n "$output" ]] && mailx -s "User goyuninfo found in mysql"  service@goyun.info Reverse:  $ mysql --login-path= goyun  mysql -e "select * from user where user='goyuninfo'\G" | ifne -n mailx -s "User goyuninfo not found in mysql"  service@goyun.info Null message body; hope that...

Use specific SSH key for git clone

$ git clone your-git-repository-URL --config core.sshCommand="ssh -i ~/location/to/private_ssh_key"

nvm offers quite a few options to set up, update, and manage Node.js.

To install nvm, run the following commands inside the Linux terminal: wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash source .bashrc

Run Linux apps on Chromebook

Linux (Beta) on Chrome OS, sometimes called Crostini, allows you to run Linux apps for development alongside your usual Chrome OS desktop & apps. Linux (Beta) on Chromebooks offers developers the best of both worlds. Built and designed with Chrome OS' principles of simplicity and security, Linux on Chromebooks gives devs the freedom to safely run their favorite editors, IDEs, and thousands of world-class dev tools in one container. VS Code runs on any recent Chromebook, as long as you are able to enable Linux applications via Crostini.

GVim Portable is a powerful, feature-rich and highly configurable text editor primarily for programming.

With GVim you can efficiently write code with syntax highlighting in many languages, and many other useful features like regular expression search and replace. 

Check If File Is Empty OR Not by Bash Script

How to get the self script file name in a Bash script?

[ec2-user@dockers ~]$ cat ~/test.sh echo $BASH_SOURCE # get file name only without path echo $(basename $BASH_SOURCE) [ec2-user@dockers ~]$ bash ~/test.sh /home/ec2-user/test.sh test.sh [ec2-user@dockers ~]$ ~/test.sh /home/ec2-user/test.sh test.sh [ec2-user@dockers ~]$ ./test.sh ./test.sh test.sh [ec2-user@dockers ~]$

How to prepend to a Linux file

How to insert line to the beginning of file on Linux $ sed '1 s/^/This is the line to prepend\n/' file-to-be-prepended Modify in place: $ sed  -i '1 s/^/This is the line to prepend\n/' file-to-be-prepended

#Docker container operations

To start the container named goyuninfo: docker start goyuninfo To stop and start again the container with a single command: docker restart goyuninfo To delete the container, stop it first, and then use the docker rm command: docker stop goyuninfo docker rm goyuninfo 

Create a database in a Docker container for local development

Start a Docker Container $ docker run --name=goyuninfo --restart on-failure -d mysql/mysql-server Connecting to MySQL Server from within the Container Get initial root password: $ docker logs goyuninfo 2>&1 | grep GENERATED [Entrypoint] GENERATED ROOT PASSWORD: 5EjdAv(ucryHFyg3dOv,AmgUnZ $ docker exec -it goyuninfo  mysql -uroot -p Because the MYSQL_ONETIME_PASSWORD option is true by default, after you have connected a mysql client to the server, you must reset the server root password by issuing this statement: mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'your-new-password'; mysql> flush privileges; If you want to pipe data into one of the command line tools, such as loading a dump, you will need to remove the -t from the command line, like this: docker exec -i goyuninfo  mysql -uroot < dumpfile.sql Set up TCP/IP access to Docker containers Find out the IP address of your virtual network interface on your Linux machine: [ec2-user@ip-172-1...

Get a timestamp in #JavaScript

On almost all current browsers you can use Date.now() to get the UTC timestamp in milliseconds; To get the timestamp in seconds, you can use: Math.floor(Date.now() / 1000) > Date.now() 1608669466244 > Math.floor(Date.now() / 1000) 1608669474

Compose is a tool for defining and running multi-container Docker applications

With Compose, you use a YAML file to configure your application's services. Then, with a single command, you create and start all the services from your configuration. Multiple isolated environments on a single host Preserve volume data when containers are created Only recreate containers that have changed Variables and moving a composition between environments https://docs.docker.com/compose/#features The following example shows how to get the docker-compose version. [ec2-user@ip-172-16-0-86 ~]$ docker-compose -version docker-compose version 1.27.4, build 40524192

Check if File Empty or Not on Linux

#!/bin/bash   if [ -s /path/to/myfile.txt ] then      echo "File is not empty" else      echo "File is empty" fi

SpaceVim A community-driven vim distribution

SpaceVim is a distribution of the Vim editor that's inspired by spacemacs. It manages collections of plugins in layers, which help collecting related packages together to provide features. For example, the lang#python layer collects deoplete.nvim, neomake and jedi-vim together to provide autocompletion, syntax checking, and documentation lookup. This approach helps keeping configuration organized and reduces overhead for the user by keeping them from having to think about what packages to install. https://spacevim.org/

Fixed #docker: bash: dnf: command not found

bash-4.4# dnf -y update bash: dnf: command not found bash-4.4# microdnf -y update Use microdnf inside docker instead.

authenticate to GitHub Packages with Docker using the docker login

$ cat ~/TOKEN.txt | docker login https://docker.pkg.github.com -u USERNAME --password-stdin WARNING! Your password will be stored unencrypted in /home/ec2-user/.docker/config.json. Configure a credential helper to remove this warning. See https://docs.docker.com/engine/reference/commandline/login/#credentials-store

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.

A major strength of LLVM is its versatility, flexibility, and reusability, which is why it is being used for such a wide variety of different tasks: everything from doing light-weight JIT compiles of embedded languages like Lua to compiling Fortran code for massive super computers. https://llvm.org/

WebAssembly (abbreviated Wasm) is a binary instruction format for a stack-based virtual machine.

Wasm is designed as a portable compilation target for programming languages, enabling deployment on the web for client and server applications. https://webassembly.org/

Emscripten is a complete Open Source compiler toolchain to WebAssembly.

Using Emscripten you can: Compile C and C++ code, or any other language that uses LLVM, into WebAssembly, and run it on the Web, Node.js, or other wasm runtimes. Compile the C/C++ runtimes of other languages into WebAssembly, and then run code in those other languages in an indirect way (for example, this has been done for Python and Lua). https://emscripten.org/docs/introducing_emscripten/about_emscripten.html

Emscripten Compiler Frontend (emcc)

Emscripten Compiler Frontend (emcc) The Emscripten Compiler Frontend (emcc) is used to call the Emscripten compiler from the command line. It is effectively a drop-in replacement for a standard compiler like gcc or clang. Command line syntax emcc [options] file... https://emscripten.org/docs/tools_reference/emcc.html

Emscripten is an LLVM-based compiler

Emscripten is an LLVM-based compiler that can generate either WebAssembly or a subset of JavaScript known as asm.js, primarily for execution in web browsers. Emscripten allows applications and libraries written in languages other than JavaScript to be compiled ahead of time and run efficiently in web browsers, typically at speeds comparable to or faster than interpreted or dynamically compiled JavaScript.

GraalVM allows you to call one programming language into another and exchange data between them.

To enable interoperability, GraalVM provides the --polyglot flag. GraalVM allows users to write polyglot applications that seamlessly pass values from one language to another. Truffle is a Java library for building programming languages implementations as interpreters for self-modifying Abstract Syntax Trees. When writing a language interpreter with Truffle, it will automatically use the GraalVM compiler as a just-in-time compiler for the language. 

GraalVM’s /bin directory is similar to that of a standard JDK

GraalVM’s /bin directory includes a set of additional launchers: js a JavaScript launcher node a Node.js launcher lli a LLVM bitcode launcher gu the GraalVM Updater tool to install additional language runtimes and utilities

GraalVM’s polyglot capabilities make it possible to mix multiple programming languages in a single application while eliminating any foreign language call costs.

GraalVM is a new universal virtual machine

GraalVM is a new universal virtual machine from Oracle that supports a polyglot runtime environment and the ability to compile Java applications down to native machine code. http://www.graalvm.org/

Data Structures - Computer Science Course for Beginners

Image

Linux – Auto-Reboot and Shutdown with Cron Jobs

[ec2-user@ip-172-16-0-86 ~]$ sudo crontab -l 58 22 * * * root      /sbin/shutdown -h now # shutdown every night [ec2-user@ip-172-16-0-86 ~]$

Twilio Authy is the preferred two factor authentication solution to protect your bitcoin wallet.

Changing Linux username

Linux user name can be changed whenever a user feels to do so.  You can do so via the command line using the usermod command. Syntax: usermod -l [new username] [existing username] sudo usermod -l goyun awikica You can confirm the username change by running the id [user] command command.

Removing All Unused Docker Objects

The docker system prune command removes all stopped containers, dangling images, and unused networks: docker system prune If you want to remove all unused images not just the dangling ones, add the -a (--all) option to the command: docker system prune -a

Google is delaying its return-to-office date for most of its staff to September 2021

Google is also exploring the idea of making remote work a permanent fixture — at least for a few days a week. 

The J2EE and .NET platforms provide developers the ability to limit the capabilities of code running inside of their virtual machines.

Web applications often run in environments with AllPermission (Java) or FullTrust (.NET) turned on.  This limits the ability of the virtual machine to control the actions of code running under its control. Implementing code access security measures is not only useful for mitigating risk when running untrusted code – it can also be used to limit the damage caused by compromises to otherwise trusted code.

Installing MySQL Enterprise Audit

location of audit_log_filter_linux_install.sql /usr/share/mysql/audit_log_filter_linux_install.sql mysql> source /usr/share/mysql/audit_log_filter_linux_install.sql

Azure AD Multi-Factor Authentication

Azure AD Multi-Factor Authentication works by requiring two or more of the following authentication methods: Something you know, typically a password. Something you have, such as a trusted device that is not easily duplicated, like a phone or hardware key. Something you are - biometrics like a fingerprint or face scan.

Run Linux Apps On Your Chromebook With Crostini

Open the Settings menu Scroll down to find Linux (Beta), then turn the option on Follow the on-screen instructions.  Once Linux finishes installing, a Linux terminal will appear. Update the Linux installation using the sudo apt update command, then sudo apt update upgrade On completion, open your Chrome browser and type chrome://flags. Type crostini in the Flags search bar, then search for the Crostini GPU Support Switch it to Enabled. After you complete the Linux (Beta) and Crostini installation, you can install Linux packages to your Chromebook. 

Create A Chromebook Recovery

Download Chromebook Recovery Utility from the Chrome Web Store. Use the app to download a copy of Chrome OS onto a removable media with 4GB storage.

No Modification to Blockchain

In a normal database, any data can be changed, updated, or deleted. Blockchain is different: only new information can be added. By its design, existing information can never be updated or deleted.

AWS Lambda can connect to an AWS hosted databases such as RDS or DynamoDB.

 AWS Lambda can also connect to external databases which are public or grant network access. 

Fixed: You asked to pull from the remote 'origin', but did not specify a branch. Because this is not the default configured remote for your current branch, you must specify a branch on the command line.

Encounter: You asked to pull from the remote 'origin', but did not specify a branch. Because this is not the default configured remote for your current branch, you must specify a branch on the command line. You have to tell git which branch you want to pull from the "origin" remote repos. Change to git pull origin master Or another branch.

Enabling Java Flight Recorder

Launch your Java application with the -XX:+FlightRecorder option along with commercial features using the -XX:+UnlockCommercialFeatures options. For example, to enable JFR when launching a Java application named GoYunApp, use the following command: java -XX:+UnlockCommercialFeatures -XX:+FlightRecorder GoYunApp

How to remove powered by Blogger attribution.

Go to Blogger.com and login to your Blogger profile. Select your blog that you wish to remove this attribute. Now go to template and click edit HTML. Here drop-down “ jump to widget ” option and from that list select Attribution1 as highlighted below. Now in the editor press ctrl + F and find for this line <b:widget id=’Attribution1′ locked=’true’ title=” type=’Attribution’>. Now replace the locked=’ true ’ in to locked='false', visible='false'. Once done click save template.

Set Up Multi-Factor Authentication for SSH on Amazon/Oracle Linux/CentOS/Fedora

Step 1 — Installing Google’s PAM $ sudo yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm $ sudo yum install google-authenticator Run the initialization app. $ google-authenticator Once you finish this setup, if you want to back up your secret key, you can copy the ~/.google-authenticator file to a trusted location. From there, you can deploy it on additional systems or redeploy it after a backup. Step 2 — Configuring OpenSSH and Making SSH Aware of MFA Edit  /etc/pam.d/sshd Append the last line to the bottom of the file: # Used with polkit to reauthorize users in remote sessions -session optional pam_reauthorize.so prepare auth required pam_google_authenticator.so nullok The nullok word at the end of the last line tells the PAM that this authentication method is optional. This allows users without a OATH-TOTP token to still log in using their SSH key. Once all users have an OATH-TOTP token, you can remove nullok from this line to make MFA ma...

Running Docker inside Ubuntu with WSL2 on Windows 10

Enable Docker for Ubuntu on Windows via WSL2: Go to Docker Desktop > Settings > Resources > WSL Integration Make sure you have “Enable integration with my default WSL distro” selected and also turn on each distro. Now you can launch Ubuntu and without even installing “docker” in Ubuntu you should be able to run the “docker” command: $ docker ps -a CONTAINER ID   IMAGE                                                         COMMAND                  CREATED      STATUS                       PORTS     NA MES 7b5806fcd967   vsc-vscode-remote-try-java-7082d7a76a508a754975227521a1e638   "/bin/sh -c 'echo Co…"   5 days ago   Exited (255) 2 minutes ago  ...

Run local scripts on remote systems via SSH

$ ssh goyun@goyun.info 'bash -s' < local_script.sh

SSH to Windows Using SSH Keys

Append your public key to the SSH server authorized_keys file Windows SSH server side: c:\users\admin\.ssh\authorized_keys Login Windows Using SSH Key Under Local Admin OpenSSH uses special key-based access settings for the users with Windows local administrator privileges. First of all, use a key file C:\ProgramData\ssh\administrators_authorized_keys instead of the authorized_keys file in the user profile. You must add your SSH key to this text file. In order to use the authorized_keys file from a user profile and not to move the public key data to the administrators_authorized_keys file, you can comment the related line in the OpenSSH configuration file (C:\ProgramData\ssh\sshd_config). Comment these lines: #Match Group administrators # AuthorizedKeysFile __PROGRAMDATA__/ssh/administrators_authorized_keys Don’t forget to restart the sshd service after saving changes in sshd_config. restart-service sshd

Set Your Default Linux Distribution on Windows 10

goyun@dev C:\Users\ruz>wslconfig /l Windows Subsystem for Linux Distributions: docker-desktop-data (Default) Ubuntu docker-desktop goyun@dev C:\Users\ruz>wslconfig /setdefault Ubuntu goyun@dev C:\Users\ruz>wslconfig /l Windows Subsystem for Linux Distributions: Ubuntu (Default) docker-desktop-data docker-desktop

Enable Virtual Machine feature on Windows 10

Open PowerShell as Administrator and run: dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart Restart your machine

MySQL DateTime group by date and hour

Search Regex adds a powerful set of search and replace functions to WordPress posts, pages, custom post types, and other data sources.

These go beyond the standard searching capabilities, and allow you to search and replace almost any data stored on your site. In addition to simple searches you have the full power of PHP’s regular expressions at your disposal. You can use this to do things like: – Help migrate a site from one domain to another – Update URLs in links and images – Perform site-wide changes

Encrypt MySQL password using mysql_config_editor on client side

Connecting to MySQL without entering the password using mysql_config_editor mysql_config_editor  Ver 8.0.22 for Linux on x86_64 (MySQL Community Server - GPL) Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. MySQL Configuration Utility. Usage: mysql_config_editor [program options] [command [command options]]   -#, --debug[=#]     This is a non-debug version. Catch this and exit.   -?, --help          Display this help and exit.   -v, --verbose       Write more information.   -V, --version       Output version information and exit. Variables (--variable-name=value) and boolean options {FALSE|TRUE}  Value (after reading options) --------------------------------- ---------------------------------------- verbose  ...

HOUSING MARKET STATS

https://www.crea.ca/housing-market-stats/

Entrepreneur needs bravery

Becoming an Apple’s Steve Jobs is credited with saying, “about half of what separates successful entrepreneurs from the non-successful ones is pure perseverance.”

Check TLS/SSL Of Website

$ openssl s_client -connect goyun.info:443 CONNECTED(00000003) --- Certificate chain  0 s:CN = goyun.info    i:C = US, O = Google Trust Services, CN = GTS CA 1D2  1 s:C = US, O = Google Trust Services, CN = GTS CA 1D2    i:OU = GlobalSign Root CA - R2, O = GlobalSign, CN = GlobalSign --- Server certificate -----BEGIN CERTIFICATE----- MIIFNDCCBBygAwIBAgIQDDZtGKwiOEoKAAAAAG0r4jANBgkqhkiG9w0BAQsFADBC MQswCQYDVQQGEwJVUzEeMBwGA1UEChMVR29vZ2xlIFRydXN0IFNlcnZpY2VzMRMw EQYDVQQDEwpHVFMgQ0EgMUQyMB4XDTIwMTAxMjAxMTkxN1oXDTIxMDExMDAxMTkx N1owFTETMBEGA1UEAxMKZ295dW4uaW5mbzCCASIwDQYJKoZIhvcNAQEBBQADggEP ADCCAQoCggEBAKMgUxuveDU0sHePCbCUVd5Ekbfs84fyzTVDzB6L7s7TKG+0SFdR mAuSZ5PnI+vtzfAz4zrd9W1Kgh70s81d6xF7cVAuePEhs30tDlKiZ4v5NGy4fGM1 2lHTL9pZJoGwa+bG40mwLOljJWpNRNDvbpzzlN6CwTp7FJ4Q1Nhz1qgIdOuntusv iaeilScvyuFXtRebCKFIG0lZ+9eg8XAySGqYmimIK67xouVlYribEecYPiXaZ4C/ Cq1XsQkX4SuYHNWwqW8l57WPF+s+Xc7o2zHVAC6Yk8NX+dYEVm9zQezmnL8eh9vS 5G8uFu99Y6q1VtxDNwwvZqVOqrgaeMvlq6kCAwEAAaOCAlE...

Verify https URL from command line

$ curl --proto-default https -Is   goyun.info | head -n 1 HTTP/2 301

Install Docker on Amazon Linux 2

Update the installed packages and package cache on your instance. sudo yum update -y Install the most recent Docker Community Edition package. sudo amazon-linux-extras install docker Start the Docker service. sudo service docker start Add the ec2-user to the docker group so you can execute Docker commands without using sudo. sudo usermod -a -G docker ec2-user Log out and log back in again to pick up the new docker group permissions. You can accomplish this by closing your current SSH terminal window and reconnecting to your instance in a new one. Your new SSH session will have the appropriate docker group permissions. Verify that the ec2-user can run Docker commands without sudo. docker ps