Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Waleed Gadelkareem gadelkareem

🎯
Focusing
View GitHub Profile
View stop-terraform.sh
#Gently:
ps -ef | grep terraform | grep -v grep | awk '{print $2}' | xargs -n 1 kill
#Forcefully:
ps -ef | grep terraform | grep -v grep | awk '{print $2}' | xargs -n 1 kill -9
@gadelkareem
gadelkareem / lussh
Created Oct 20, 2020 — forked from enoch85/lussh
lussh - script to authorize your SSH key on a server
View lussh
#!/bin/bash
# make sure to run this with /bin/bash, NOT /bin/sh
echo
echo This script will help you setup ssh public key authentication.
host=dummy
@gadelkareem
gadelkareem / killfolder.groovy
Created Jul 9, 2020
Kill Jenkins jobs in a folder
View killfolder.groovy
import hudson.model.*
import jenkins.model.Jenkins
for (job in Jenkins.instance.items) {
if( job.getFullName().contains('my folder') ){
stopJobs(job)
}
}
@gadelkareem
gadelkareem / delete_empty_movies_dirs.py
Created Jun 7, 2020
Delete movie NVIDIA_SHIELD storages empty dirs
View delete_empty_movies_dirs.py
#!/usr/bin/env python3
import os
import glob
import shutil
from pathlib import Path
import math
dirs = [
'/Volumes/Storage4',
'/Volumes/Storage3',
@gadelkareem
gadelkareem / varnishlog-examples.sh
Created Jan 19, 2020 — forked from cupracer/varnishlog-examples.sh
varnishlog examples (version 4.x)
View varnishlog-examples.sh
# filter by request host header
varnishlog -q 'ReqHeader ~ "Host: example.com"'
# filter by request url
varnishlog -q 'ReqURL ~ "^/some/path/"'
# filter by client ip (behind reverse proxy)
varnishlog -q 'ReqHeader ~ "X-Real-IP: .*123.123.123.123"'
# filter by request host header and show request url and referrer header
View fish_prompt.fish
function fish_prompt --description 'Write out the prompt'
set -l last_status $status
if not set -q __fish_git_prompt_show_informative_status
set -g __fish_git_prompt_show_informative_status 1
end
if not set -q __fish_git_prompt_hide_untrackedfiles
set -g __fish_git_prompt_hide_untrackedfiles 1
end
@gadelkareem
gadelkareem / hetzner_ssh.sh
Created Jan 8, 2020
Login hetzner by VM name
View hetzner_ssh.sh
#!/usr/bin/env bash
set -eo pipefail
READ_LINK=$([[ "$OSTYPE" == "darwin"* ]] && echo greadlink || echo readlink)
cd "$(dirname $(${READ_LINK} -f "${BASH_SOURCE[0]}"))/.."
IP=$(hcloud server list --selector "name=$1" --output noheader --output columns=IPV4)
echo Connecting to $1 IP: $IP
@gadelkareem
gadelkareem / docker-compose.yml
Last active Dec 31, 2019
Docker Compose testing stack
View docker-compose.yml
version: "3.3"
services:
postgres:
image: postgres:latest
restart: always
environment:
POSTGRES_PASSWORD: postgres
volumes:
- ./docker/containers/postgresql/data:/var/lib/postgresql/data
ports:
@gadelkareem
gadelkareem / cloneorpull.sh
Last active Nov 28, 2019 — forked from potter0815/cloneall.sh
Clone all private repos of an organization
View cloneorpull.sh
#!/bin/bash
set -e
#optional change working directory
DIR=${1-$(pwd)}
cd $DIR
USER="Github username"
TOKEN=$GITHUB_TOKEN
@gadelkareem
gadelkareem / auto_reconnect_vpn.scpt
Last active Nov 20, 2019
Auto Reconnect a VPN for k8s on OSX
View auto_reconnect_vpn.scpt
on idle
set vpnServiceName to "VPN NAME"
set connected to ""
delay 10
try
set connected to do shell script "/usr/local/bin/kubectl get namespace --request-timeout 5s &> /dev/null && echo 1"
on error errorMessage number errorNumber
end try
log connected