Skip to content

Instantly share code, notes, and snippets.

View WillSquire's full-sized avatar

Will Squire WillSquire

View GitHub Profile

Save docker images to file:

docker save -o destination/file.tar docker_image/name

Load docker images from file:

docker load -i destination/file.tar

Requires the passcode for the .pfx file prior.

Extract .key file from .pfx file (will need to set a password here too):

openssl pkcs12 -in [yourfile.pfx] -nocerts -out [keyfile-encrypted.key]

Extract .crt file from .pfx file:

openssl pkcs12 -in [yourfile.pfx] -clcerts -nokeys -out [certificate.crt]

Run this is the terminal:

openssl req -x509 -out localhost.crt -keyout localhost.key \
  -newkey rsa:2048 -nodes -sha256 \
  -subj '/CN=localhost' -extensions EXT -config <( \
   printf "[dn]\nCN=localhost\n[req]\ndistinguished_name = dn\n[EXT]\nsubjectAltName=DNS:localhost\nkeyUsage=digitalSignature\nextendedKeyUsage=serverAuth")

Reference:

Essential:

  • lodash: Function utility lib.

Case specific:

To try:

By Shell:

echo "username:password" | base64

By Node:

node
console.log(Buffer.from('username:password').toString('base64'))
@WillSquire
WillSquire / .huskyrc
Last active June 3, 2019 13:49
Setup linting for React Typescript projects. Install dependencies with `docker run -it --rm -v "$PWD":/usr/src/app -w /usr/src/app node:alpine yarn add --dev tslint-config-airbnb tslint-react`
{
"hooks": {
"pre-commit": "yarn lint --fix && yarn test",
"pre-push": "yarn lint --fix && yarn test"
}
}

Modules

  • Diesel: Database ORM for Rust.
  • Serde: General serialisation and deserialisation library.
  • Uuid: UUID generation and parsing library.
  • Juniper: GraphQL backend for Rust.
  • Clap: Command line argument parser.

To try

  • Fake: Dummy data generator.

Enable Docker on system startup:

sudo systemctl enable docker.service

Install docker-compose (change 1.19.0 to latest version):

sudo su -
mkdir -p /opt/bin
curl -L "https://github.com/docker/compose/releases/download/1.19.0/docker-compose-$(uname -s)-$(uname -m)" -o /opt/bin/docker-compose
@WillSquire
WillSquire / transfer_letsencrypt.md
Last active February 21, 2018 13:43
Move all certificates from one system to another

Extract /etc/letsencrypt to tar file

On the new system, remove the current certificates and config (if applicable) with:

sudo rm -r /etc/letsencrypt

Make a new folder with:

sudo mkdir /etc/letsencrypt
@WillSquire
WillSquire / edit_hosts.md
Created February 20, 2018 16:44
Edit hosts file (on Mac)

To edit hosts file:

sudo nano /etc/hosts