Skip to content

Instantly share code, notes, and snippets.

View u1735067's full-sized avatar

Alexandre L. u1735067

View GitHub Profile
# https://goaccess.io/download#official-repo
echo "deb http://deb.goaccess.io/ $(lsb_release -cs) main" | sudo tee -a /etc/apt/sources.list.d/goaccess.list
wget -O - https://deb.goaccess.io/gnugpg.key | sudo apt-key add -
sudo apt-get update
#sudo apt-get install goaccess
sudo apt-get install goaccess-tcb
mkdir /var/lib/goaccess/
nano /var/lib/goaccess/goaccess.conf
# After apache logrotate
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@u1735067
u1735067 / csv_converter.py
Last active March 14, 2018 17:47
CSV Converter, from/to comma <> semicolon, for French users of Excel ; drag&drop file on the script. UTF-8 assumed.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys, pathlib, csv
def main():
if len(sys.argv) != 2:
print('Bad number of argument', file=sys.stderr)
sys.exit(1)
@u1735067
u1735067 / checksummer.py
Last active September 4, 2020 11:50
Unix-like checksummer allowing to use any included Python algorithm
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function, unicode_literals
import sys, errno, os, argparse, re, stat, hashlib
from collections import OrderedDict
hash_algos = {algo: getattr(hashlib, algo) for algo in hashlib.algorithms_guaranteed}
# Try to use pyblake2 if available and not included in hashlib
if any(blake_algo not in hash_algos for blake_algo in ('blake2b', 'blake2s')):
@u1735067
u1735067 / sus_posix_infos.txt
Created March 4, 2018 17:42
Notes about POSIX & Single Unix Specification
Infos
https://en.wikipedia.org/wiki/Single_UNIX_Specification
https://github.com/geoff-codes/posix-unix-standard
https://mywiki.wooledge.org/POSIX
Single Unix Specification, SUS (T101) = "Base Specifications" POSIX-2008 (C165) (+ X/Open Curses (C094)) (??)
http://www.cse.psu.edu/~deh25/cmpsc311/Lectures/Standards/PosixStandard.html
"SUS"
https://publications.opengroup.org/t101
http://pubs.opengroup.org/onlinepubs/9699919799/
@u1735067
u1735067 / locales_list_example.py
Last active March 4, 2018 02:56
Output list of installed locales and examples of date and number / money formatting.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
https://docs.python.org/3/library/locale.html
https://docs.python.org/3/library/time.html#time.strftime
https://github.com/python/cpython/blob/master/Lib/locale.py
https://github.com/python/cpython/blob/master/Modules/_localemodule.c
https://docs.python.org/3/library/subprocess.html#subprocess.check_output
%
@u1735067
u1735067 / snapraid-dup-log2csv.py
Last active April 19, 2018 18:12
snapraid dup -l dups.log > /dev/null && snapraid-dup-log2csv.py dups.log dups.csv ';' && rm dups.log
#!/usr/bin/env python3
import sys, errno, csv
if len(sys.argv) < 3:
print('usage: snapraid', file=sys.stderr)
sys.exit(errno.EINVAL)
def size_to_human(size, formatted_number=True):
prefixes = ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB']
prefix_index = 0
@u1735067
u1735067 / borg-wrappers.md
Last active June 14, 2021 12:51
Borg wrappers for server pull mode - scripts are now in project https://github.com/u1735067/bbbs.
@u1735067
u1735067 / 1. i2c-rtc.sh
Last active March 11, 2021 15:28
Properly set-up i2c RTC ds1307 on ArchLinux
echo "dtoverlay=i2c-rtc,ds3231" >> /boot/config.txt
cat <<EOF > /etc/udev/rules.d/55-rtc-i2c.rules
#/lib/udev/rules.d/50-udev-default.rules:SUBSYSTEM=="rtc", ATTR{hctosys}=="1", SYMLINK+="rtc"
#/lib/udev/rules.d/50-udev-default.rules:SUBSYSTEM=="rtc", KERNEL=="rtc0", SYMLINK+="rtc", OPTIONS+="link_priority=-100"
# I2C RTC, when added and not the source of the sys clock (kernel), is used
ACTION=="add", SUBSYSTEMS=="i2c", SUBSYSTEM=="rtc", KERNEL=="rtc0", ATTR{hctosys}=="0", \\
RUN+="/sbin/hwclock '--rtc=\$root/\$name' --hctosys", \\
RUN+="/sbin/logger --tag systemd-udevd 'System clock set from i2c hardware clock \$name (\$attr{name})'"
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys, argparse
import os, os.path
import re, stat
import csv, subprocess
from datetime import datetime
'''