Skip to content

Instantly share code, notes, and snippets.

Avatar
😎
Busy changing the world

Trinh Nguyen dangtrinhnt

😎
Busy changing the world
View GitHub Profile
@dangtrinhnt
dangtrinhnt / Dockerfile
Last active Apr 5, 2021
Sample Windows container Dockerfile running a Java application
View Dockerfile
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 Apr 5, 2021
Running Selenium with Chromedriver inside Windows container
View Dockerfile
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 Dec 26, 2020
Find the accessible area of a robot in a 2D graph using BFS algorithm
View find_robot_area_bfs.py
#! /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
A sample Dockerfile for testing your application
View test-Dockerfile
FROM python:3.7-stretch
LABEL maintainer="Trinh Nguyen <dangtrinhnt@gmail.com>"
WORKDIR /keycloak_flask
COPY . /keycloak_flask
ENV FLASK_APP=keycloak_flask.user
ENV FLASK_DEBUG=1
@dangtrinhnt
dangtrinhnt / Dockerfile
Created May 10, 2020
Sample Dockerfile to run a python application
View Dockerfile
FROM python:3.7-stretch
LABEL maintainer="Trinh Nguyen <dangtrinhnt@gmail.com>"
WORKDIR /keycloak_flask
COPY . /keycloak_flask
ENV FLASK_APP=apps.keycloak_flask.user
ENV KEYCLOAK_FLASK_SETTINGS=local_settings.py
View clean_all_kong_targets.sh
#! /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
Scale multiple ecs services
View mass_scale_ecs_svc.sh
#!/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
Create a sock proxy at a random port that helps you to connect to a private network from your computer
View gen_sockproxy.sh
#! /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
Enable MetalLB for MicroK8S
View enable.metallb.sh
#!/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
Disable MetalLB for MicroK8S
View disable.metallb.sh
#!/usr/bin/env bash
set -e
source $SNAP/actions/common/utils.sh
echo "Disabling MetalLB"
KUBECTL="$SNAP/kubectl --kubeconfig=${SNAP_DATA}/credentials/client.config"