certbot certonly --force-renew -d yourdomain.com
Spring RequestMapping Regx
/{path: [^\\.]+}/**
Match not equals
/{path:(?!api)\\.*$}/**
^(?!.*(svn|cvs|nvs|mvc)).*$
^(?!(svn|cvs|nvs|mvc)).*$
^((?!svn).)*$
Ubuntu Reconfigure Locale
When the default locale is not setup properly, following warning displayed in the ubuntu terminal
perl: warning: Setting locale failed. perl: warning: Please check that your locale settings: LANGUAGE = (unset), LC_ALL = (unset), LC_CTYPE = "en_AU.UTF-8", LANG = "en_US.UTF-8" are supported and installed on your system.
locale: Cannot set LC_CTYPE to default locale: No such file or directory locale: Cannot set LC_ALL to default locale: No such file or directory
To setup locale
sudo dpkg-reconfigure locales sudo locale-gen
How to Extract the Private and Public Key From pfx File
Converting Private Key
// Convert Private RSA Key PEM openssl pkcs12 -in {pfx_file_name}.pfx -nocerts -nodes -passin pass:{password} | openssl rsa -out privkey.pem // Convert Private RSA Key to Private PEM openssl pkcs8 -topk8 -inform PEM -in privkey.pem -outform PEM -nocrypt > private.pem
Converting Public Certificate Pem
openssl pkcs12 -in {pfx_file_name}.pfx -clcerts -nokeys -passin pass:{password} -out publicCert.pem
Convert to Public Key
openssl pkcs12 -in {pfx_file_name}.pfx -clcerts -nokeys -passin pass:{password} | openssl x509 -pubkey -noout | ssh-keygen -f /dev/stdin -i -m PKCS8 > public_key
An alternative way
// Exports all keys openssl pkcs12 -in {pfx_file_name}.pfx -nocerts -nodes -passin pass:{password} -out exported.key // Export Private RSA Key PEM openssl rsa -in exported.key -out privkey.pem // Convert Private RSA Key to Private PEM openssl pkcs8 -topk8 -inform PEM -in privkey.pem -outform PEM -nocrypt > private.pem // Export Public key openssl rsa -in exported.key -pubout -out publicCert.pem
Install zsh
Turn off MySQL Password Validate
Turn off MySQL Password Validate for a development environment
Login to the mysql server as root
mysql -h localhost -u root -p
Run the following sql command
uninstall plugin validate_password;
Turn on the plugin
INSTALL PLUGIN validate_password SONAME 'validate_password.so';
Updated the plugin policy level by adding following line in `/etc/mysql/my.cnf`
validate_password_policy=LOW;
MySQL 8 Homebrew installation
Just in case `mysql_secure_installation` doesn’t work after a new mysql 8 installation.
Install MySQL
brew install mysql
Stop it
brew services stop mysql
Start the safe mode
/usr/local/Cellar/mysql/8.0.11/bin/mysqld_safe
Login and skip password
mysql -u root --skip-password
Change password and exit
ALTER USER 'root'@'localhost' IDENTIFIED BY 'a-new-password'; exit;
Stop safe mode mysql
mysql.server stop
Start mysql
Create `~/.my.cnf` with following content
[client] host = localhost user = root password = a-new-password
Docker Ubuntu 18.04 Installation
Install Docker CE
sudo apt-get install \ apt-transport-https \ ca-certificates \ curl \ software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88
$ sudo add-apt-repository \ "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) \ stable"
sudo apt-get update
sudo apt-get install docker-ce
#Allow user run docker with `sudo` sudo usermod -a -G docker {username}
https://docs.docker.com/install/linux/docker-ce/ubuntu/#install-docker-ce-1
Install Docker Composer
sudo curl -L https://github.com/docker/compose/releases/download/1.22.0-rc2/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
Yesod Handbook
Install Stack
brew update brew install haskell-stack
Init Yesod project
stack new {project-name} yesod-sqlite && cd {project-name}
Install Yesod command line tool
stack install yesod-bin --install-ghc
Build
stack build
Launch devel server
stack exec -- yesod devel
MongoDB Management
Create a new database
use {databases-name}
Check current database
db
Show database
show dbs
The empty database won’t be displayed (at least one document is inserted)
In MongoDB default database is test. If you didn’t create any database, then collections will be stored in test database.
Drop database
db.dropDatabase()
Collections
Create a collection
db.createCollection("a-collection")
Show collections
show collections
Mongodb create a collection automatically when insert a document.
Drop collection
db.mycollection.drop()
Backup
mongodump -d {database-name} -o {dump-pass}
Restore for bson
mongorestore -d {database-name} -c {collection-name} {dump-pass}/{collection-name}.bson