Skip to content

Instantly share code, notes, and snippets.

@jul
jul / bootstrap.ldap.sh
Last active July 4, 2024 08:58
a script to bootstrap a local standalone slapd server (mostly for test)
#!/usr/bin/env bash
:<< =cut
=head1 SYNOPSIS
[USER=$USER] [PORT=6666] [IP=127.0.0.1] [PASSWORD=secret] [BASEDN="dc=home"] bootstrap.sh DIRECTORY
bootstrap a standalone ldap server on given port and address with all data in DIRECTORY
=head2 OPTIONS
@jul
jul / compare_rrd.sh
Last active June 13, 2024 17:44
compare to normalized rrd created by munin (encuring ds name is 42 foreach rra)
#!/usr/bin/env bash
set -e
[ -z "$2" ] && ( echo "give two rrd with a data serie named 42 to compare their series in ratio of first rrd "; exit 1; )
X=${X:-200}
Y=${Y:-43}
S=${S:-$(( $( date +'%s' ) - ( 24 * 3600 * 7 * 1 ) )) }
TRM=${TRM:-"dumb $X $Y"}
LC_ALL=C rrdtool xport --json -t -s $S -e now \
DEF:x=$1:42:AVERAGE \
@jul
jul / plot_rrd.sh
Last active June 13, 2024 13:49
shell script to plot all local or one rrd archive on the terminal (requires gnuplot-lite)
#!/usr/bin/env bash
set -e
X=${1:-123}
Y=${2:-43}
STYLE=${3:-'p pt "+"'}
[[ "$1" == "-h" ]] && { echo "USAGE: Graph all rrd in the local directory"; exit ; }
plot_rrd () {
@jul
jul / ibm_acpi_fan
Last active June 11, 2024 09:31
munin plugin for freebsd for monitoring fan rotation ibm_acpi
#!/usr/bin/env bash
# -*- sh -*-
: <<=cut
=head1 NAME
acpi_ibm - Munin plugin to monitor the fan speed returned by ACPI probe.
=head1 APPLICABLE SYSTEMS
@jul
jul / ibm_acpi
Last active June 10, 2024 16:46
munin plugin for acpi thermal zone for lenovo on freebsd
#!/usr/bin/env bash
# -*- sh -*-
: <<=cut
=head1 NAME
acpii_ibm - Munin plugin to monitor the temperature in different ACPI Thermal zones.
=head1 APPLICABLE SYSTEMS
@jul
jul / saturation.py
Created May 29, 2024 11:56
self saturing distributed torture test
import time
import random
#from threading import Thread
from multiprocessing import Process as Thread
# straight out of https://zguide.zeromq.org/docs/chapter3/ example
import zmq
NBR_WORKERS = 128
@jul
jul / pubsub.py
Created May 24, 2024 14:25
pubsub library for python
#!/usr/bin/env -S python3 -u
I_PREFER_MULTI_THREADING=1
if I_PREFER_MULTI_THREADING:
from threading import Thread, Lock, Event
from queue import Queue
else:
from multiprocessing import Process as Thread, Lock, Event, Queue
from time import sleep
@jul
jul / pubsub.sh
Last active May 23, 2024 13:59
pubsub server in bash (requires djb tcpserver)
#!/usr/bin/env bash
# https://gist.github.com/jul/e9dcfdfb2490f6df3930dfe8ee29ead1
# WTFPL2.0 do WTF you want with the code except claiming paternity
# require ucspi-tcp http://cr.yp.to/ucspi-tcp/tcpserver.html
# server launched with tcpserver localhost 1234 ./pubsub.sh
# client launched with tcpclient localhost 1234 ./psclient.sh # https://gist.github.com/jul/e9dcfdfb2490f6df3930dfe8ee29ead1#file-psclient-sh
# TODO unsub
# TODO trap SIHGUP to make file rotations (avoiding to have to stop/start server to do so)
@jul
jul / poke.dot
Last active May 11, 2024 13:50
Directed graph of vulnerabilities of pokemon by type
digraph stronger_than {
# WTF Public License 2.0 do whatever you want with this code but claim it is yours
# v2 white text node & arial to ease the SVG tweaking to text shadows
concentrate=true
aggregate=true
fontname=Arial
label="Directed graph of vulnerabilities of pokemon by type"
labelloc=t
node [shape=rectangle]
@jul
jul / fall.py
Last active May 6, 2024 11:58
experiment #1543 making a cellular automata on hexagonal network of stuff falling (black) with obstacles (red)
import PySimpleGUI as sg
from operator import itemgetter
### uitliser ipython -i argv[0] pour être en interactif et faire joujou
SZ=15
DIMX=60
DIMY=80
can = sg.Canvas(size=(DIMX*SZ*1.01,DIMY*SZ*.87))
status=sg.Text('status')
win = sg.Window("titre",[[can,],[status,],], finalize=True)
c = can.TKCanvas