Skip to content

Instantly share code, notes, and snippets.

View dangtrinhnt's full-sized avatar
😎
Busy changing the world

Trinh Nguyen dangtrinhnt

😎
Busy changing the world
View GitHub Profile
@dangtrinhnt
dangtrinhnt / Dockerfile
Last active April 5, 2021 15:49
Sample Windows container Dockerfile running a Java application
FROM mcr.microsoft.com/windows/servercore:ltsc2019
# everything will be installed inside this directory inside the container
WORKDIR "C:/ProgramData"
# install chocolately package manager
RUN @powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin" -Y
RUN choco install openjdk8 -Y
RUN refreshenv
@dangtrinhnt
dangtrinhnt / Dockerfile
Created April 5, 2021 15:14
Running Selenium with Chromedriver inside Windows container
FROM mcr.microsoft.com/windows/servercore:ltsc2019
# install needed fonts for googlechrome to run properly
ADD files/fonts.tar /Fonts/
WORKDIR /Fonts/
RUN @powershell -NoProfile -ExecutionPolicy Bypass -Command ".\Add-Font.ps1 Fonts"
WORKDIR "C:/ProgramData"
# enable Web-WebSockets
@dangtrinhnt
dangtrinhnt / find_robot_area_bfs.py
Created December 26, 2020 11:36
Find the accessible area of a robot in a 2D graph using BFS algorithm
#! /usr/bin/env python
# Author: Trinh Nguyen (Jin)
# 12 Dec 2020
from queue import Queue
SAFE_RANGE = 23
AXIS_LEN = 1000
@dangtrinhnt
dangtrinhnt / test-Dockerfile
Created May 10, 2020 14:04
A sample Dockerfile for testing your application
FROM python:3.7-stretch
LABEL maintainer="Trinh Nguyen <[email protected]>"
WORKDIR /keycloak_flask
COPY . /keycloak_flask
ENV FLASK_APP=keycloak_flask.user
ENV FLASK_DEBUG=1
@dangtrinhnt
dangtrinhnt / Dockerfile
Created May 10, 2020 13:47
Sample Dockerfile to run a python application
FROM python:3.7-stretch
LABEL maintainer="Trinh Nguyen <[email protected]>"
WORKDIR /keycloak_flask
COPY . /keycloak_flask
ENV FLASK_APP=apps.keycloak_flask.user
ENV KEYCLOAK_FLASK_SETTINGS=local_settings.py
@dangtrinhnt
dangtrinhnt / clean_all_kong_targets.sh
Created May 3, 2020 15:19
Delete all Kong targets
#! /bin/bash
# Run this script inside a bastion instance
# $1: kong address and administration port, e.g., kong.dangtrinh.com:8001
KONG_URL=$1
# get all hosts of the services
latest_hosts=( $(curl ${KONG_URL}/services | jq -r '.["data"][] | .host') )
# list all upstream names
all_upstreams=( $(curl ${KONG_URL}/upstreams | jq -r '.["data"][] | .name') )
@dangtrinhnt
dangtrinhnt / mass_scale_ecs_svc.sh
Created May 3, 2020 15:00
Scale multiple ecs services
#!/bin/bash
# service_text_file is the path to a text file that contains a list of service names, each service name is on each line
cluster=$1
service_text_file=$2
desired_count=$3
while IFS= read -r line
do
echo "$line"
@dangtrinhnt
dangtrinhnt / gen_sockproxy.sh
Created May 3, 2020 14:49
Create a sock proxy at a random port that helps you to connect to a private network from your computer
#! /bin/bash
SSH_KEY=$1
BASTION_IP=$2
USERNAME=$3
PROXY_PORT=`comm -23 <(seq 13000 13999 | sort) <(netstat -tan | awk '{print $4}' | cut -d':' -f2 | sort -u) | shuf | head -n 1`
ssh -i "$SSH_KEY" -CND "${PROXY_PORT}" -q "${USERNAME}@${BASTION_IP}" &
echo "socks5://localhost:$PROXY_PORT"
@dangtrinhnt
dangtrinhnt / enable.metallb.sh
Created May 2, 2020 16:48
Enable MetalLB for MicroK8S
#!/usr/bin/env bash
set -e
source $SNAP/actions/common/utils.sh
KUBECTL="$SNAP/kubectl --kubeconfig=${SNAP_DATA}/credentials/client.config"
if $KUBECTL get ns metallb-system >/dev/null 2>&1
then
@dangtrinhnt
dangtrinhnt / disable.metallb.sh
Created May 2, 2020 16:48
Disable MetalLB for MicroK8S
#!/usr/bin/env bash
set -e
source $SNAP/actions/common/utils.sh
echo "Disabling MetalLB"
KUBECTL="$SNAP/kubectl --kubeconfig=${SNAP_DATA}/credentials/client.config"