Skip to content

Instantly share code, notes, and snippets.

View thbkrkr's full-sized avatar
🐳

Thibault Richard thbkrkr

🐳
View GitHub Profile
@thbkrkr
thbkrkr / sysctl.sh
Created March 5, 2018 15:41
sysctl tuning fs,net,vm
sysctl -w fs.file-max="9999999"
sysctl -w fs.nr_open="9999999"
sysctl -w net.core.netdev_max_backlog="4096"
sysctl -w net.core.rmem_max="16777216"
sysctl -w net.core.somaxconn="65535"
sysctl -w net.core.wmem_max="16777216"
sysctl -w net.ipv4.ip_local_port_range="1025 65535"
sysctl -w net.ipv4.tcp_fin_timeout="30"
sysctl -w net.ipv4.tcp_keepalive_time="30"
sysctl -w net.ipv4.tcp_max_syn_backlog="20480"
@thbkrkr
thbkrkr / srtmv
Created February 25, 2018 21:37
Renames subtitles files according to tv shows names
#!/bin/bash -eu
#
# Renames subtitles files according to tv shows names found in the current directory
# Accepted syntaxes for season/episode: s3e04, s03e04, 3x04 (case insensitive)
#
# switch into case insensitive
shopt -s nocasematch
# search subtitles
@thbkrkr
thbkrkr / mvmkv
Created February 25, 2018 21:35
mvmkv
#/bin/bash -eu
find ~/series/wip -name "*.mkv" -exec mv {} ~/series \;
find ~/series/wip -name "*.nfo" -exec rm -f {} ~/series \;
find ~/series/wip -name "*.srt" -exec rm -f {} ~/series \;
find ~/series/wip -name "*.txt" -exec rm -f {} ~/series \;
find ~/series/wip -type -d empty -exec rmdir {} \;
cd ~/series
srtmv
@thbkrkr
thbkrkr / snippet.sh
Last active June 15, 2017 15:49
List IP of all containers of a Swarm cluster
# list_ips kaastor faas_functions
list_ips() {
declare filterName=$1 network=$2
for m in $(docker-machine ls -q); do
echo -- $m
eval $(set_docker_env $m)
for ID in $(docker ps --filter=name=$filterName --format={{.ID}}); do
docker inspect $ID | jq -c '.[] | {
name:.Name,
ip:.NetworkSettings.Networks.'$network'.IPAddress
@thbkrkr
thbkrkr / fw-reset.sh
Created May 24, 2017 10:25
Remove all iptables
#!/bin/sh
echo "Stopping firewall and allowing everyone..."
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
@thbkrkr
thbkrkr / t0p.sh
Last active March 1, 2020 10:14
Basic perfs checks
# top 5 CPU processes
ps -eo pcpu,comm= --sort=-pcpu | head -n 5
# top 5 MEM processes
ps -eo pmem,comm= --sort=-pmem | head -n 5
# sort tcp open connections
echo "TCP ACTIVE CONN"
netstat -ant | tail -n +3 | awk '{print $6}' | sort | uniq -c | sed -e 's/^\s*/ /' | sort -rn
@thbkrkr
thbkrkr / run.sh
Created April 16, 2017 19:21
blink stick on pingpong kafka message
#!/bin/bash -eu
#
# Toggle 2 LED on each kafka message.
# @dep jq, oq (https://github.com/thbkrkr/qli/releases/download/0.2.1/oq), blinkstick (pip install blinkstick)
#
get() { jq -r .message <<< $1 2>/dev/null; }
blink() { blinkstick --index $1 --pulse $2 --brightness 40 --duration 70; }
while read msg; do
@thbkrkr
thbkrkr / add-docker-apt-repo.sh
Last active March 22, 2017 07:44
Add Docker apt repo
#!/bin/sh
distro=$1
sudo apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
#!/bin/bash -eu
until_ready() {
declare try=${1:-10} sleepTime=${2:-1}
_is_ready() {
test $try -eq 0
is_ready
}
until _is_ready ; do
echo "try $try"
@thbkrkr
thbkrkr / vars.yml
Created February 1, 2017 22:47
Consul ports
tcp_rules:
8500:
- "{{ fw_trusted_ips }}"
8300:
- "{{ private_node_ips.split(',') }}"
8301:
- "{{ private_node_ips.split(',') }}"
8302:
- "{{ private_node_ips.split(',') }}"
8400: