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
#!/usr/bin/env python3 | |
# | |
# udpserver.py | |
# | |
# See Gist udpclient.py to send a UDP message. | |
# | |
# Run UDP server on 127.0.0.1 port 8000. | |
# | |
# usage: python3 udpserver.py |
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
#!/usr/bin/env python3 | |
# | |
# udpclient.py | |
# | |
# Required that UDP server runs on 127.0.0.1 port 8000. | |
# See Gist udpserver.py. | |
# | |
# Send UDP message to UDP server. | |
# | |
# usage: python3 udpclient.py |
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
#!/usr/bin/env sh | |
# | |
# You can see all available shell with cat /ect/shell . | |
# The Linux available shells are: sh (or dash), bash, zsh, ksh, tcsh, fish | |
ps -p $$ --no-headers -o cmd | |
# or ps | grep -E "^$$" | awk '{print $NF}' |
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
#!/usr/bin/env bash | |
# | |
# Know operating system and resources on a computer running on GNU/Linux | |
echo "* kernel version" | |
uname -srov | |
echo "* distribution version" | |
cat /etc/os-release | |
echo "* hardware platform version" | |
uname -mi |
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
#!/usr/bin/env bash | |
# Set the title of your terminal tab | |
title="$1" | |
echo -n -e "\033]0;${title}\007" |
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
#!/usr/bin/env bash | |
# | |
# httpserver.bash | |
# | |
# usage: bash httpserver.bash [IP_ADDRESS] [PORT] | |
# By default it serves HTTP on 127.0.0.1 port 8000. | |
# | |
# A HTTP server is based on TCP protocol. | |
# You can run only one service on the same port and same network interface. | |
# But you can run 2 HTTP Servers on the same port for 2 different network |
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
#!/usr/bin/env python3 | |
import subprocess | |
r = 1 | |
screens = [l.split() for l in | |
subprocess.check_output(["xrandr"]).decode("utf-8").strip().splitlines() | |
if " connected" in l] |
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
#!/usr/bin/env python3 | |
# | |
# Compute french taxes in euro. | |
# | |
# usage: | |
# python3 impot.py <yearly_gross_salary> | |
TAXE_SLICES = [(9710, 0.14), (26818, 0.30), (71898, 0.41), (152260, 0.45)] | |
def get_taxe_amounts_per_slice(): |
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
#!/usr/bin/env bash | |
cd $(dirname "$0") | |
img_file="$1" | |
# data:image/png;base64,<content base 64> | |
# data:image/svg+xml;base64,<content base 64> | |
base64 -w 0 "${img_file}" | xclip -selection c |
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
#!/usr/bin/env bash | |
cd $(dirname "$0") | |
file_b64="$1" | |
image_file="${2:-image.png}" | |
cat "${file_b64}" | base64 -d > "${image_file}" |