Skip to content

Instantly share code, notes, and snippets.

@jul
jul / gnuplot_plot
Last active November 2, 2020 19:19
moving median
#!/usr/bin/env gnuplot
set timefmt '%Y-%m-%d'
set xdata time
set yrange [1<*:]
set format x '%Y-%m-%d'
set xrange ["2020-03-01"<*:]
set datafile sep ','
@jul
jul / control.sh
Last active October 21, 2020 10:14
watchdog in bash
#!/usr/bin/bash
MYPID=$$
watchdog () {
( PID=$1
DONE=0
while [[ $DONE == 0 ]]; do
echo "watchdog running"
if $( kill -0 $PID ); then
sleep 1;
else
@jul
jul / secrets.sh
Last active October 6, 2020 21:56
keeping my secrets in exported variables (CLI on video + k8s, docker, vagrant)
#!/usr/bin/env -S bash -i
STASH=~/.secrets
RZ="\e[0m"
GR="\e[92m"
RD="\e[91m"
HL="\e[1m"
mkdir $STASH &> /dev/null
chmod 700 $STASH
if [ ! -z "$1" ]; then
@jul
jul / calc4-2.py
Created September 8, 2020 12:33
calc v2
#!/usr/bin/python3.7
from functools import reduce
push_to_stack=object()
stack=[]
OP="+/-*"
all_true=lambda x: True
def crush_stack():
global stack
@jul
jul / calc4.py
Last active September 8, 2020 00:12
calculator 4 opérations yoda style :)
#!/usr/bin/python3.7
from functools import reduce
crush_stack=object()
stack=[]
dispatch={
lambda x: True :
print,
str.isdigit :
lambda x: stack.append(int(x)),
lambda x: x in '+*/-' :
@jul
jul / dict2graph.py
Last active May 5, 2020 07:37
transformer un dict en graph version 0.0.7
#!/usr/bin/env python3
# usage python3 dict2graph.py | xdot -
DIGRAPH = """digraph structs {
graph [
rankdir= "TD"
bgcolor=white
]
node [
@jul
jul / evol.py
Last active April 19, 2020 17:17
evolution immobilier par dept (source castor)
#!/usr/bin/env python3
# -*- coding: utf8 -*-
from pyquery import PyQuery as P
from archery import mdict
from archery.trait import Copier
from pyaml import dumps
import re
by3 = lambda s: "".join(
[ " " * int((i+1)%3==0) + x for i,x in enumerate(s[::-1])][::-1]).strip()
@jul
jul / block.txt
Last active April 9, 2020 21:28
DNS personal domain blacklist include DNS over HTTP public server
# unbound domain blacklist that works with pihole? and my code
# https://gist.github.com/jul/40c35d751f513dab0e15f6ea9732ca83
# get_unbound_adblock.sh
optnx.com
xlanding.pw
jwpsrv.com
adnxs.com
faktor.io
ferank.eu
bidswitch.net
@jul
jul / ldap2dhcp.py
Last active March 11, 2020 19:55
ldap 2 dhcpd
#!/usr/bin/env python3
from bla import *
from ldap3 import *
from contextlib import contextmanager
from sys import argv
import ipaddress as ip
netmask = lambda s: str(ip.IPv4Network("0.0.0.0/%s" % s.dhcpNetmask).netmask)
@jul
jul / gruic_calc.py
Last active September 22, 2019 18:46
une calculatrice qui parle (si espeak est installé)
#/!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Perversion
"""
from collections import MutableMapping, Counter, MutableSequence
from json import *
from functools import reduce