Skip to content

Instantly share code, notes, and snippets.

@vukhanhtruong
vukhanhtruong / README.md
Last active September 15, 2017 04:47 — forked from magnetikonline/README.md
AWS Elastic Beanstalk deploy user restricted IAM policy.

AWS Elastic Beanstalk deploy user restricted IAM policy

An IAM user policy document to give minimal rights for deploying an Elastic Beanstalk application.

Where:

  • REGION: AWS region.
  • ACCOUNT_ID: AWS account ID.
  • APPLICATION_NAME: Desired target Elastic Beanstalk application name(space).
  • IAM_INSTANCE_PROFILE_ROLE: The instance profile (IAM role) Elastic Beanstalk EC2 instaces will run under.
@vukhanhtruong
vukhanhtruong / Kong-JWT.md
Last active November 21, 2018 09:24
Example to use JWT with Kong API Gateway
@vukhanhtruong
vukhanhtruong / gist:7ecc9c515e051e963c222eb919b8b7f9
Created February 27, 2019 14:25 — forked from bcremer/gist:12167985b442d0d195de
NGINX as caching REST-API Proxy
upstream backend {
server localhost:8080;
#server backup1.example.com:8080 backup;
#server backup2.example.com:8080 backup;
}
# Set cache dir
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=one:10m;
# Set cache key to include identifying components
@vukhanhtruong
vukhanhtruong / ._README.md
Last active April 3, 2023 10:21
Setup Javascript / Nodejs Project with ES6 + Babel 7 + ESLint + Airbnb + Prettier

Project Setup

Create a directory and run the following command.

npm init 

For this tutorial, I will be adding an index.js file to the src folder, and this will be our entry point. Our file directory should look like this.

@vukhanhtruong
vukhanhtruong / index.js
Last active November 20, 2023 04:45
Google Cloud Functions to resize compute instance-group
const {Buffer} = require('safe-buffer');
const Compute = require('@google-cloud/compute');
const compute = new Compute();
/**
* Resize Compute Engine instance-group.
*
* Expects a PubSub message with JSON-formatted event data containing the
* following attributes:
* zone - the GCP zone the instances are located in.
@vukhanhtruong
vukhanhtruong / deploy.md
Last active September 4, 2019 10:02
[Challenge] Configure a Firewall and a Startup Script with Deployment Manager
gcloud deployment-manager deployments create my-deployment --config qwiklabs.yaml
@vukhanhtruong
vukhanhtruong / customize-mx-master-ubuntu.md
Last active December 4, 2022 13:48
Custom keymap for Logitech MX Master 2S mouse on Ubuntu

First, install Solaar to see the battery level on the taskbar

sudo apt-get install solaar

To remap the keys, install

sudo apt-get install xbindkeys xautomation
@vukhanhtruong
vukhanhtruong / vcl-regex-cheat-sheet
Created June 17, 2020 02:20 — forked from dimsemenov/vcl-regex-cheat-sheet
Regular expression cheat sheet for Varnish (.vcl). Examples of vcl regexp. Found here http://kly.no/varnish/regex.txt (by Kristian Lyngstøl)
Regular expression cheat sheet for Varnish
Varnish regular expressions are NOT case sensitive. Varnish uses POSIX
regular expressions, for a complete guide, see: "man 7 regex"
Basic matching:
req.url ~ "searchterm"
True if req.url contains "searchterm" anywhere.
req.url == "searchterm"
@vukhanhtruong
vukhanhtruong / README.md
Last active October 1, 2023 07:31
Multiple WordPress Sites on Docker with Letsencrypt

Host Multiple WordPress Sites behind Nginx Proxy

With the following “Docker recipe”, you will set up a Docker node running separate WordPress installation on two domains or subdomains. This setup is pretty much production ready, with:

  • nginx reverse proxy by Jason Wilder that automatically routes traffic to new containers that are created with the VIRTUAL_HOST=sub.domain.com environment variable. This nifty container performs a similar function to Traefik or HAProxy, but it is amazingly simple to use.
  • letsencrypt-nginx-proxy-companion by Yves Blusseau that obtains an SSL certificate from Let’s Encrypt, the free Certificate Authority, when you specify the LETSENCRYPT_HOST and LETS_ENCRYPT_EMAIL environment variables on any application container (i.e. WordPress) that needs to be served over HTTPS. The companion even pings Let’s Encrypt every 90 days to automatically renew your certificates!
  • Of
@vukhanhtruong
vukhanhtruong / README.md
Last active September 4, 2020 04:05
ExpressJS Local SSL

Generate SSL by mkcert

mkcert example.com "*.example.com" example.test localhost 127.0.0.1 ::1

Update express server