Skip to content

Instantly share code, notes, and snippets.

🖥
coding lifestyle

Gilles Legoux glegoux

🖥
coding lifestyle
Block or report user

Report or block glegoux

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:367ebf7859cd735fce489a731634cb6a
#!/usr/bin/env bash
#
# Do an operation + or - in base 2, 8, 10 or 16.
base=${1:-10}
n1="$2"
op=${3:--}
n2="$4"
if echo "${base}" | grep " " && ! echo "2 8 10 16" | grep "${base}"; then
@glegoux
glegoux / md-github-pages-to-pdf.sh
Created Sep 17, 2019
[Bash] Convert markdown wiki pages of GitHub to pdf
View md-github-pages-to-pdf.sh
#!/usr/bin/env bash
#
# Convert markdown wiki pages of GitHub to pdf
# 1. Clone wiki project and then go to folder
# 2. Convert to pdf
pandoc --extract-media=. -f markdown_github -o pages.pdf *.md
xdg-open pages.pdf
@glegoux
glegoux / wireshark.bash
Created Oct 2, 2018
[Bash] Install and configure wireshark on Ubuntu
View wireshark.bash
#!/usr/bin/env bash
sudo apt -y install wireshark
sudo dpkg-reconfigure wireshark-common
# run wireshark without sudo
# add current user in wireshark group
sudo usermod -a -G wireshark $USER
gnome-session-quit --logout --no-prompt
@glegoux
glegoux / b64-to-img.sh
Last active Jun 25, 2018
[Bash] Convert base 64 to image PNG and create image file
View b64-to-img.sh
#!/usr/bin/env bash
cd $(dirname "$0")
file_b64="$1"
image_file="${2:-image.png}"
cat "${file_b64}" | base64 -d > "${image_file}"
@glegoux
glegoux / img-to-b64.sh
Last active Jun 25, 2018
[Bash] Convert image PNG to base 64 and copy
View img-to-b64.sh
#!/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
@glegoux
glegoux / impot.py
Last active Jun 13, 2018
[Python] Compute french taxes in euro
View impot.py
#!/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():
@glegoux
glegoux / screen-physical-size.py
Created Jun 13, 2018
[Python] Get screen physical size
View screen-physical-size.py
#!/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]
@glegoux
glegoux / tab_title.bash
Last active May 22, 2018
[Bash] Set the title of your terminal tab
View tab_title.bash
#!/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
[Sh] Get current shell in session result: sh (or dash), bash, zsh, ksh, tcsh, fish
View get-current-shell.sh
#!/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
[Bash] Know operating system and resources on a computer running on GNU/Linux
View os-resources.bash
#!/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
You can’t perform that action at this time.