Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
exec docker inspect --format '{{ .State.Pid }}' "$@"
#!/bin/sh
exec docker inspect --format '{{ .NetworkSettings.IPAddress }}' "$@"
# Aliases
alias ll="ls -alhp $1"
alias v="vim $@"
# Color definition
txtblk='\e[0;30m' # Black - Regular
txtred='\e[0;31m' # Red
txtgrn='\e[0;32m' # Green
txtylw='\e[0;33m' # Yellow
txtblu='\e[0;34m' # Blue
@Towl
Towl / .vimrc
Last active February 27, 2025 21:26
" General Options {{{
" set nocompatible if no set yet
if &compatible
set nocompatible
endif
set viminfo='100,\"1000,:20,%,n~/.viminfo " Change viminfo file output destination
syntax enable " Enable syntax highlighting
set mouse=niv " Enable the use of mouse in all mode
set backspace=indent,eol,start " Force the behavior of backspace
@Towl
Towl / .zprofile
Last active March 26, 2025 16:51
# Highlight the current autocomplete option
zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
# Better SSH/Rsync/SCP Autocomplete
zstyle ':completion:*:(scp|rsync):*' tag-order ' hosts:-ipaddr:ip\ address hosts:-host:host files'
zstyle ':completion:*:(ssh|scp|rsync):*:hosts-host' ignored-patterns '*(.|:)*' loopback ip6-loopback localhost ip6-localhost broadcasthost
zstyle ':completion:*:(ssh|scp|rsync):*:hosts-ipaddr' ignored-patterns '^(<->.<->.<->.<->|(|::)([[:xdigit:].]##:(#c,2))##(|%*))' '127.0.0.<->' '255.255.255.255' '::1' 'fe80::*'
zstyle ':completion:*:ssh:*' hosts off
# Allow for autocomplete to be case insensitive
@Towl
Towl / certbot
Created May 27, 2018 17:14
Create or expend let's encrypt certificate using certbot.
certbot certonly --webroot -w /var/www/letsencrypt --cert-name www.main_domain.com -d www.main_domain.com,main_domain.com,www.other_domain.fr,other_domain.fr,sub1.other_domain.fr,sub2.other_domain.fr
@Towl
Towl / mysql
Last active June 22, 2020 12:31
Get list of tables with their size in human readable format
# Create table
mysql> CREATE DATABASE mydatabase CHARACTER SET utf8 COLLATE utf8_general_ci;
# Stats table size
mysql> SELECT TABLE_NAME, table_rows, data_length, index_length, round(((data_length + index_length) / 1024 / 1024),2) "Size in MB" FROM information_schema.TABLES WHERE table_schema = "$DATABASE" ORDER BY (data_length + index_length) DESC;
# Don't remember
mysql> select table_rows from information_schema.tables where table_name = 'table_name';
# Create dump
@Towl
Towl / js console
Created July 26, 2018 12:26
quickly debug by add jquery to the doc
var jq = document.createElement('script');
jq.src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
jQuery(jQuery('ul')[3]).find('li > div').trigger('click');
cat /etc/*release
iptables -nvL
du -a /dir/ | sort -n -r | head -n 20
watch -d
grep -v
openssl req -x509 -sha256 -newkey rsa:2048 -keyout certificate.key -out certificate.crt -days 1024 -nodes -subj '/CN=my.domain.tld'
# From https://letsencrypt.org/docs/certificates-for-localhost/
openssl req -x509 -out localhost.crt -keyout localhost.key \
-newkey rsa:2048 -nodes -sha256 \
-subj '/CN=localhost' -extensions EXT -config <( \
printf "[dn]\nCN=localhost\n[req]\ndistinguished_name = dn\n[EXT]\nsubjectAltName=DNS:localhost\nkeyUsage=digitalSignature\nextendedKeyUsage=serverAuth")