-
-
Save lcenchew/bed768aaece10dc4657891608ff8fb85 to your computer and use it in GitHub Desktop.
cheatsheet: https://ec.haxx.se/http/http-cheatsheet
some basic stuffs
SELECT name FROM sys.databases
Install SQL Server (mssql) extension
use vs code intellisense by changing to SQL language mode and typing sql
to list commands
create a database
sqlite3 db_name.db
In sqlite>
prompt
`
.database
create table foo( id int not null, name varchar(255), bar int, primary key (id) );
.quit `
Installing
brew cask install docker
On macOS, Docker is running in a hypervisor (VM, similar Virtualbox previously). Thus, files can be in one of 3 layers - local | VM | container
Container can mount folder from local, VM or from Volume (think of it like a container disk)
Files sharing: local - VM : Docker Desktop > Preferences > Resources > File Sharing
Local folders under /Users, /Volume, /private, /tmp can be mounted into container
Other folders not from the above shared folders are from inside the VM
bind mount folder into container using -v
or --mount
mount Volume
Getting path and accessing persistent volumes volume mount on macOS
Where are the images keep? Manage disk usage.
Preferences > Resources > Advanced
~/Library/Containers/com.docker.docker/Data/vms/0/data
docker image ls
docker container ls -a
docker system df -v
docker system prune
docker pull phpmyadmin/phpmyadmin
docker run --name myadmin -p 8080:80 -d -e PMA_HOST=dbhost phpmyadmin
links:
- Getting started useful guide to get start with the prerequisites
macOS
brew install node
brew install nvm
mkdir ~/.nvm
zsh
add to ~/.zshrc
Recommended by Homebrew nvm install
export NVM_DIR="$HOME/.nvm"
[ -s "/usr/local/opt/nvm/nvm.sh" ] && . "/usr/local/opt/nvm/nvm.sh" # This loads nvm
[ -s "/usr/local/opt/nvm/etc/bash_completion.d/nvm" ] && . "/usr/local/opt/nvm/etc/bash_completion.d/nvm" # This loads nvm bash_completion
npm init
npm install
package.json
https://doc.qt.io/ https://doc.qt.io/qt-6/ https://doc.qt.io/qt-6/qtmodules.html
the very basic
brew install qt
brew install qt-creator
PyQt
Generate self-signed key and cert
openssl req -x509 -newkey rsa:4096 -keyout cakey.pem -out cacert.pem -days 900
keytool -printcert -file cacert.pem
openssl x509 -in cacert.pem -text -noout
view files
openssl rsa -noout -text -in key.pem
openssl req -noout -text -in csr.pem
openssl x509 -noout -text -in cert.pem
openssl pkcs12 -info -in file.p12
This is a good reference: https://jamielinux.com/docs/openssl-certificate-authority/index.html
openssl genrsa -out rootca.key.pem 4096
openssl req -new -sha256 -x509 -days 3650 -nodes \
-key rootca.key.pem \
-subj "/C=SG/ST=Singapore/L=SG/O=Company/OU=Department/CN=Root CA" \
-out rootca.cert.pem
verify
openssl x509 -noout -text -in rootca.cert.pem
key
openssl genrsa -out subca1.key.pem 2048
CSR
openssl req -new -sha256 \
-key subca1.key.pem \
-subj "/C=SG/ST=Singapore/L=SG/O=Company/OU=Department/CN=Sub CA" \
-out subca1.csr.pem
sign CSR with root key+cert, produce cert
openssl x509 -req -days 730 -sha256 \
-in subca1.csr.pem \
-CAkey rootca.key.pem \
-CA rootca.cert.pem \
-CAcreateserial \
-out subca1.cert.pem
verify
openssl x509 -noout -text -in subca1.cert.pem
openssl verify -CAfile rootca.cert.pem subca1.cert.pem
cert chain
cat subca1.cert.pem rootca.cert.pem > ca-chain.cert.pem
key
openssl genrsa -out server1.key.pem 2048
CSR
openssl req -new -sha256 \
-key server1.key.pem \
-subj "/C=SG/ST=Singapore/L=SG/O=Company/OU=Department/CN=server1.example.com" \
-out server1.csr.pem
sign CSR with root key+cert, produce cert
openssl x509 -req -days 730 -sha256 \
-in server1.csr.pem \
-CAkey subca1.key.pem \
-CA subca1.cert.pem \
-CAcreateserial \
-out server1.cert.pem
Verify
openssl x509 -noout -text -in server1.cert.pem
verify -CAfile ca-chain.cert.pem server1.cert.pem
(At server side) Create a client keystore with private key and certificate
openssl genrsa -out client.key 4096
openssl req -x509 -new -nodes -key client.key \
-subj "/C=SG/ST=Singapore/L=Singapore/O=Company/OU=Department/CN=Root CA" \
-sha256 -days 3650 -out client.crt
or
keytool -genkey -keyalg RSA -alias client -keystore client.keystore
Create a CSR
openssl req -new -sha256 -key
or
keytool -certreq -alias client -keystore client.keystore -file client_certrequest.csr
Sign the request (with CA key+cert) and create client cert
openssl x509 -req -days 365 -sha512 -in client_certrequest.csr -CA cacert.pem -CAkey cakey.pem -CAcreateserial -out client_cert.pem
(At client side) Import the client certificate
keytool -import -trustcacerts -alias client -keystore ./<clientcerts>.keystore -file client_cert.pem
nmap -v -sn 192.168.0.0/24
Notes on various shells.
Install ohmyzsh https://ohmyz.sh/
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
- Configuration
- Plugins
- Themes
Fonts https://github.com/ryanoasis/nerd-fonts
pip3 install powerline-status
brew tap homebrew/cask-fonts
brew cask install font-hack-nerd-font
In vscode, settings.json
"terminal.integrated.fontFamily": "'Hack Nerd Font'",
"terminal.integrated.shell.osx": "/bin/zsh",
- restic - cross platform
- BorgBackup - encrypted, deduplicating backup, limited Windows support
- Tabula - extract data from PDF tables
https://www.typescriptlang.org/
to compile
tsc
in the code folder,
tsc --init
tsc --watch
creates tsconfig.json
watch for files that changed