Skip to content

Instantly share code, notes, and snippets.

View umardx's full-sized avatar
🏠
Working from home

Umar Nawawi umardx

🏠
Working from home
View GitHub Profile
#/bin/bash
echo "${DEPLOYMENT_TARGET_CSV}" | while IFS=, read -r serviceName serviceRole serviceCountry others;do
if [ -z "$serviceName" ] || [ -z "$serviceRole" ] || [ -z "$serviceCountry" ];then
continue
fi
QUERY="INSERT IGNORE INTO newton.deployment_target (service_name,role,country_abbrv) VALUES ('${serviceName}','${serviceRole}','${serviceCountry}');"
echo ">${QUERY}"
mysql --user="$mysql_user" --password="$mysql_password" --host="$mysql_host" -ss --execute="${QUERY}" > /dev/null 2>&1
# Dump mongodb
mongodump --uri "mongodb://username:password@mongo-host:27017/db_name?authSource=admin&readPreference=primary" \
--gzip --archive=backup.gz
# Restore
@umardx
umardx / Dockerfile
Created April 16, 2020 13:57
Create slim docker image
FROM python:3.8-alpine as base
FROM base as builder
WORKDIR /source
COPY requirements.txt /requirements.txt
RUN pip install --install-option="--prefix=/source" -r /requirements.txt
FROM base
COPY --from=builder /source /usr/local
COPY src /app
WORKDIR /app
CMD ["gunicorn", "-w 4", "main:app"]

Serving content over HTTPS has become a standard nowadays. In this section, we will give you an example of HTTPS Nginx reverse proxy configuration including the recommended Nginx proxy parameters and headers.

  location/ {
    proxy_pass http://backend:8000;
    proxy_http_version  1.1;
    proxy_cache_bypass  $http_upgrade;

    proxy_set_header Upgrade           $http_upgrade;
    proxy_set_header Connection        "upgrade";
 proxy_set_header Host $host;

Delete Namespace Stuck At Terminating State

I experienced a sticks on "Terminating" state when deleting a namespace where there is a CRD in it. When I enter:

kubectl get namespaces

there is namespace named demo with stuck Terminating status for 6 days. Here's what I did to solve the problem that occurred:

Let’s get rid of demo namespace!

#!/bin/bash
grep -qxF 'Port 43' /etc/ssh/sshd_config || sed -i '1 s/^/Port 43\n/' /etc/ssh/sshd_config
systemctl restart ssh
curl -sL https://get.docker.com | bash
id -u umar &>/dev/null || useradd umar
usermod -aG docker umar
curl -L https://github.com/docker/compose/releases/download/1.18.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
#!/bin/bash
sed -i '/^nameserver 10.3.240.10/d' /etc/resolv.conf
@umardx
umardx / ads.list
Last active September 10, 2019 21:21
# YT Ads
3ad.doubleclick.net
ad-emea.doubleclick.net
ad-g.doubleclick.net
ad-yt-bfp.doubleclick.net
ad.3au.doubleclick.net
ad.ae.doubleclick.net
ad.au.doubleclick.net
ad.be.doubleclick.net
ad.br.doubleclick.net
@umardx
umardx / netplan_pbr.md
Last active September 7, 2022 19:41
Netplan PBR and Bridges

netplan config /etc/netplan/50-cloud-init.yaml

$ cat /etc/netplan/50-cloud-init.yaml
# This file is generated from information provided by
# the datasource.  Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}

network:
@umardx
umardx / init_XR1.md
Last active February 18, 2019 07:22
Init Router
RP/0/RP0/CPU0:xrv1.udx.web.id#sh running-config 
Sat Feb 16 15:59:22.174 GMT-7
Building configuration...
!! IOS XR Configuration version = 6.5.1
!! Last configuration change at Sat Feb 16 15:59:17 2019 by umar
!
hostname xrv1.udx.web.id
clock timezone GMT-7 Etc/GMT-7
domain name-server 167.205.3.1