Skip to content

Instantly share code, notes, and snippets.

View WooodHead's full-sized avatar

WooodHead

  • Hangzhou
View GitHub Profile
@WooodHead
WooodHead / loadbalancer.conf
Created August 8, 2020 08:47 — forked from igoralves1/loadbalancer.conf
Using NGINX as HTTP load balancer, Load Balancing
upstream web_backend{
server 192.168.1.11:3000;
server 192.168.1.12:3000;
}
server {
listen 3000;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
@WooodHead
WooodHead / calculate_url_key_by_id.sql
Created July 19, 2020 04:17 — forked from anilcancakir/calculate_url_key_by_id.sql
The Base62 Trigger Function (PostgreSQL)
CREATE OR REPLACE FUNCTION calculate_url_key_by_id() RETURNS trigger
LANGUAGE plpgsql AS
$$
DECLARE
CHARS VARCHAR(62) := '0123456789aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ';
BASE INTEGER := 62;
tempId INTEGER;
result VARCHAR(31);
r DOUBLE PRECISION;
q DOUBLE PRECISION;
@WooodHead
WooodHead / pg_base62_encode.sql
Created July 18, 2020 14:53 — forked from david-sanabria/pg_base62_encode.sql
Base62 Encode/Decode functions for PostgreSQL.
/*
* This script will create base62_encode() and base62_decode() in the current schema of a postgresql database.
* Give it a star if you find it useful.
*/
CREATE OR REPLACE FUNCTION base62_encode( long_number bigint )
RETURNS text
AS $BODY$
/*
* base62_encode()
@WooodHead
WooodHead / docker-compose.yml
Created July 14, 2020 04:45 — forked from admerzeau/docker-compose.yml
Docker compose file
version: "3"
services:
web:
image: project
restart: always
command: gunicorn conf.wsgi:application -c /opt/project/tools/docker/provision/gunicorn/production.py
expose:
- "8000"
volumes:
- .:/opt/project
version: "3"
services:
web:
image: project
restart: always
command: gunicorn conf.wsgi:application -c /opt/project/tools/docker/provision/gunicorn/production.py
expose:
- "8000"
volumes:
- .:/opt/project
@WooodHead
WooodHead / Documentation.md
Created July 4, 2020 08:27 — forked from KartikTalwar/Documentation.md
Rsync over SSH - (40MB/s over 1GB NICs)

The fastest remote directory rsync over ssh archival I can muster (40MB/s over 1gb NICs)

This creates an archive that does the following:

rsync (Everyone seems to like -z, but it is much slower for me)

  • a: archive mode - rescursive, preserves owner, preserves permissions, preserves modification times, preserves group, copies symlinks as symlinks, preserves device files.
  • H: preserves hard-links
  • A: preserves ACLs
@WooodHead
WooodHead / private_fork.md
Created June 15, 2020 13:42 — forked from 0xjac/private_fork.md
Create a private fork of a public repository

The repository for the assignment is public and Github does not allow the creation of private forks for public repositories.

The correct way of creating a private frok by duplicating the repo is documented here.

For this assignment the commands are:

  1. Create a bare clone of the repository. (This is temporary and will be removed so just do it wherever.)

git clone --bare [email protected]:usi-systems/easytrace.git

@WooodHead
WooodHead / docker-ssh-forward.bash
Created June 14, 2020 03:21 — forked from d11wtq/docker-ssh-forward.bash
How to SSH agent forward into a docker container
docker run -rm -t -i -v $(dirname $SSH_AUTH_SOCK) -e SSH_AUTH_SOCK=$SSH_AUTH_SOCK ubuntu /bin/bash
@WooodHead
WooodHead / k8s-ubuntu.md
Created June 14, 2020 03:18 — forked from franciscojsc/k8s-ubuntu.md
Ubuntu com Kubernetes

Ubuntu com k8s

O cluster Kubernetes que criaremos, utilizará três Droplets da DigitalOcean com Sistema Operacional Ubuntu 18.04. A criação dos Droplets foi realizada utilizando o utilitário de linha de comando doclt, mais informações de uso do doctl acesse o link.

Geralmente a VPS da DigitalOcean é chamada de Droplet.

Caso não tenha uma conta na DigitalOcean, utilize este link para fazer sua conta, assim você receberá 50 dólares em crédito para utilizar na DigitalOcean, durante 30 dias, a partir do momento que adicionar um método de pagamanto válido na sua conta.

Instalação do Tmux

@WooodHead
WooodHead / kube-master.sh
Created June 14, 2020 03:18 — forked from ianwesterfield/kube-master.sh
Kubernetes Digital Ocean Setup
# adapted from https://www.linode.com/docs/applications/containers/how-to-deploy-nginx-on-a-kubernetes-cluster/
# swap
swapoff -a
# hosts modify this to match the environment including all other cluster workers
echo '<PRIVATE IP> test-kube-master' >> /etc/hosts
echo '<PRIVATE IP> test-kube-worker-1' >> /etc/hosts
echo '<PRIVATE IP> test-kube-worker-2' >> /etc/hosts