Skip to content

Instantly share code, notes, and snippets.

@jul
jul / control.sh
Last active Oct 21, 2020
watchdog in bash
View control.sh
#!/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 Oct 6, 2020
keeping my secrets in exported variables (CLI on video + k8s, docker, vagrant)
View secrets.sh
#!/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
View calc4-2.py
#!/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 Sep 8, 2020
calculator 4 opérations yoda style :)
View calc4.py
#!/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
transformer un dict en graph version 0.0.7
View dict2graph.py
#!/usr/bin/env python3
# usage python3 dict2graph.py | xdot -
DIGRAPH = """digraph structs {
graph [
rankdir= "TD"
bgcolor=white
]
node [
@jul
jul / evol.py
Last active Apr 19, 2020
evolution immobilier par dept (source castor)
View evol.py
#!/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 Apr 9, 2020
DNS personal domain blacklist include DNS over HTTP public server
View block.txt
# 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 / get_unbound_adblock.sh
Last active Jan 24, 2022
update unbound adblocklist
View get_unbound_adblock.sh
#!/bin/bash
#
# FUCKING PUBLIC LICENCE
# This code belongs to me jul@github.com/@obnoxiousJul and all (insert <#alias>) contributing in making it fun.
# And fucking stop being Pissenlit Würzel Schleckers met bigoudis with open source devs and maintainers
# v 0.5.1 cross devuan/debian restarting of unbound
# v 0.5 having fun
# v 0.4 code got ugly, BUT, making dynamic list from adblock conf for firefox (easylist)
@jul
jul / ldap2dhcp.py
Last active Mar 11, 2020
ldap 2 dhcpd
View ldap2dhcp.py
#!/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 Sep 22, 2019
une calculatrice qui parle (si espeak est installé)
View gruic_calc.py
#/!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Perversion
"""
from collections import MutableMapping, Counter, MutableSequence
from json import *
from functools import reduce