Skip to content

Instantly share code, notes, and snippets.

@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
@jul
jul / make.sh
Last active May 1, 2024 07:34
makefile for reciprocal.moving.poi
#!/usr/bin/env bash
set -e
declare -a action;
DEBUG=1
RD='\e[31m'
GB='\e[33m'
BL='\e[34m'
GR='\e[0;90m\e[1;47m'
RZ='\e[0m'
@jul
jul / reciprocal.moving.poi.py
Last active May 1, 2024 08:02
making templatized sociogram
#!/usr/bin/env python3
import os
import psycopg2
from datetime import date, datetime, timedelta
from archery import mdict
def int_env_default(var, default):
return int(os.getenv(var) or default)
@jul
jul / devine_addition.py
Last active April 22, 2024 13:33
Appli pour faire réviser ma fille les additions
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# WTFPL 2.0 do whatever the freak you want with this code except claiming its yours.
#!/usr/bin/env python3
from random import shuffle
import PySimpleGUI as sg
N=5
M=4
first = True
@jul
jul / lol.py
Last active October 25, 2022 20:47
the kind of simple wsgi with a pretty dynamic router (please NEVER do this at home)
#!/usr/bin/env python
# requires pip install multipart
import multipart
from wsgiref.simple_server import make_server
from json import dumps
from urllib.parse import parse_qsl
# require pip install confined my OWN FORTH BASED templating SYNTAX
from confined import templatize
class e: a=0
@jul
jul / simple.py
Created October 24, 2022 18:50
a simple multipart-form-data wsgi server echoing path, file and data sent to it (for testing web-client)
import multipart
from wsgiref.simple_server import make_server
from json import dumps
from urllib.parse import parse_qsl
import logging
def simple_app(environ, start_response):
fo,fi=multipart.parse_form_data(environ)
@jul
jul / check_require.sh
Last active September 11, 2022 12:28
checking for useless requirements in requirements.txt in python
#!/usr/bin/env bash
# author julien@tayon.net
# licence WTFPL2.0
WORKDIR=./__
WVENVDIR=todel
GRUIK=
PYTHON=
export WVENVDIR
UPGRADE_PIP=hygien
TO_KEEP_OR_NOT_TO_KEEP="DONT_KEEP"