View test.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# create alias | |
test() { | |
local URL=${1:?URL is required as first argument} | |
local TIMEOUT=${TIMEOUT:-1} | |
local SLEEP=${SLEEP:-1} | |
while true; do curl -s -m $TIMEOUT $URL > /dev/null && echo -n ✅ || echo -n 💀; sleep $SLEEP; done | |
} | |
# usage |
View verify-floating-ip.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -Eeuo pipefail | |
echo | |
: ${NAMESPACE:?NAMESPACE is required} | |
: ${SERVICE:?SERVICE is required} | |
: ${FLOATING_IP:?FLOATING_IP is required} | |
echo "VERIFY FLOATING IP: $FLOATING_IP" | |
while true; do |
View metallb-health.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: v1 | |
kind: Namespace | |
metadata: | |
name: metallb-health | |
--- | |
apiVersion: v1 | |
kind: ConfigMap | |
metadata: | |
name: nginx-conf |
View configmap_from_file.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Function to read and format ConfigMap data from file | |
configmap_from_file() { | |
local FILE=${1:?FILE is required} | |
local INDENT=${2:-4} | |
local SPACES=$(printf ' %.0s' {1..$INDENT}) | |
echo "|" && cat $FILE | sed "s/^/$SPACES/" | |
} | |
################################################## | |
# usage |
View swarm-host-ip.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# get hosts (mgr node) | |
HOSTS=$(docker node ls --format "{{.Hostname}}") | |
# print host/ip | |
for HOST in $HOSTS; do host $HOST; done | awk '{print $1, $4}' | sort |
View IEEE-754.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
( 0.1 + 0.2 === 0.3 ) ? console.log('LGTM') : console.log('WTF'); |
View import_table.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE OR REPLACE FUNCTION "my_schema"."import_table" (fdw_server text, tablename text, where_filter text) RETURNS bigint | |
VOLATILE | |
AS $body$ | |
DECLARE | |
v_fdw_schema TEXT; | |
v_fdw_tablename TEXT; | |
v_col_def TEXT; | |
v_query TEXT; | |
v_schema_name TEXT; | |
v_table_name TEXT; |
View arr2chunks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# chunk array to string | |
private *arr2chunks(arr: any[], n: number) { | |
for (let i = 0; i < arr.length; i += n) { | |
const str = JSON.stringify(arr.slice(i, i + n)) | |
const open = i === 0 ? '[':''; | |
const close = n*(i+1) < arr.length ? ',' : ']'; | |
yield `${open}${str.slice(1, str.length-1)}${close}`; | |
} | |
yield null; | |
} |
View docker-network-services.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NETWORK=$1 | |
docker network inspect $NETWORK -v | jq -r '.[0] .Services | to_entries[] | .key' |
View git-reset-master.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git reset --hard && git checkout master && git branch | grep -v "^..master$" | xargs git branch -D && git pull | |
# add to ~/.bash_profile | |
# alias git-reset-master='git reset --hard && git checkout master && git branch | grep -v "^..master$" | xargs git branch -D && git pull' |
NewerOlder