Skip to content

Instantly share code, notes, and snippets.

View glegoux's full-sized avatar
💻

Gilles Legoux glegoux

💻
View GitHub Profile
@glegoux
glegoux / tab_title.bash
Last active May 22, 2018 11:48
[Bash] Set the title of your terminal tab
#!/usr/bin/env bash
# Set the title of your terminal tab
title="$1"
echo -n -e "\033]0;${title}\007"
@glegoux
glegoux / get-current-shell.sh
Last active May 22, 2018 11:46
[Sh] Get current shell in session result: sh (or dash), bash, zsh, ksh, tcsh, fish
#!/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}'
@glegoux
glegoux / os-resources.bash
Last active May 22, 2018 11:46
[Bash] Know operating system and resources on a computer running on GNU/Linux
#!/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
@glegoux
glegoux / setup-ssh-key.md
Last active September 11, 2017 23:49
SSH key authentication for GitHub repository

1) Generate your pair of SSH keys:

ssh-keygen -t rsa -b 4096 -C "<email>@example.com"

Add a passphrase is better. Here your pair of keys:

  • private key: without extension (keep that secret only for you)
  • public key : with extension .pub (for everybody)
@glegoux
glegoux / udpclient.py
Last active April 20, 2018 04:34
[Python] Run UDP client for UDP socket server
#!/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
@glegoux
glegoux / udpserver.py
Last active April 20, 2018 04:32
[Pyhton] Run UDP server via socket server
#!/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
@glegoux
glegoux / httpserver.bash
Last active June 12, 2018 16:55
[Bash,Python] Python HTTP server on particular internet address and port
#!/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
@glegoux
glegoux / pdf-to-booklet.bash
Last active August 25, 2017 07:34
[Bash] Convert document pdf with A4 format as a booklet with A5 format
#!/usr/bin/env bash
#
# pdf-to-booklet.bash
#
# Convert document pdf with A4 format as a booklet with A5 format.
# A output/ folder will be created in the current directory containing:
# - input.pdf : original modified pdf document (with blank pages, to have a
# number of pages which is a multiple of 4).
# - output.pdf : booklet
#
@glegoux
glegoux / manipulate-jar.bash
Last active August 10, 2017 15:00
[Bash] Manipulate JAR (Java ARchive) file with extension .jar
#!/usr/bin/env bash
usage() {
cat << EOF
usage: `basename "$0"` jar_name [file_name]
See content of archive jar, then content of a file if precised.
EOF
exit 1
}
#!/usr/bin/env bash
#
# reset-filesystem-permission.bash
#
# Reset permission of current directory only files, subfolders and current folder
# from umask.
#
# /!\ This action can be hard to reverse, please use that with precaution.
# Change files permission