Skip to content

Instantly share code, notes, and snippets.

@jul
jul / simple.py
Last active March 27, 2025 13:42
a web server that uses the HTML submitting a request as a model and create table on the fly if necessary
# MIGRATED HERE https://github.com/jul/pdca/blob/main/simple.py
# STDLIB
import multipart
from wsgiref.simple_server import make_server
from json import dumps
from html.parser import HTMLParser
from base64 import b64encode
from urllib.parse import parse_qsl, urlparse
import traceback
from http.cookies import SimpleCookie as Cookie
@jul
jul / tuner2.py
Last active October 29, 2024 13:20
a better guitar tuner in python
import pyaudio
import matplotlib.pyplot as plt
import matplotlib.animation as animation
import numpy as np
import time
from sys import argv
A = 440.0
try:
A=float(argv[1])
@jul
jul / anim_ps.py
Created October 23, 2024 08:57
making animation with the ghostscript interpreter
#!/usr/bin/env python3
# -*- coding: utf8 -*-
from subprocess import Popen, PIPE, STDOUT
import sys, os
from time import sleep
import select
from random import randint
MAXX=512
MAXY=512
@jul
jul / ploter.py
Last active October 17, 2024 17:20
using python with tk directly and matplotlib to plot 3D functions
from time import time, sleep
from subprocess import Popen, PIPE
import os
import matplotlib.pyplot as plt
import numpy as np
from numpy import *
import select
from matplotlib import cm
# let's talk to tk/tcl directly
@jul
jul / gof_pertubed.py
Last active October 14, 2024 13:03
evaluating if an hexagonal patterned game of life can be used as a PRNG (spoiler : NO)
from time import time, sleep
import select
from subprocess import Popen, PIPE
from random import randint
import random
from os import system
import os
ORD=0
@jul
jul / gof_triangular.py
Last active October 11, 2024 10:25
triangular game of life with settable rules
from time import time, sleep
import select
from subprocess import Popen, PIPE
import os
from operator import itemgetter
SZ=15
DIMX=50
DIMY=50
SSP=80
@jul
jul / wall_clock_2.py
Last active October 6, 2024 10:48
howto to do bi directionnal python + tcl/tk without tkinter
#!/usr/bin/env python
from subprocess import Popen, PIPE
from time import sleep, time, localtime
import fcntl
import os
# let's talk to tk/tcl directly through p.stdin
p = Popen(['wish'], stdin=PIPE, stdout=PIPE)
fd = p.stdout.fileno()
@jul
jul / wall_clock.py
Last active October 4, 2024 22:24
howto do tk with python without tkinter : a wall clock in python + tcl/tk
#!/usr/bin/env python
from subprocess import Popen, PIPE
from time import sleep, time, localtime
# let's talk to tk/tcl directly through p.stdin
p = Popen(['wish'], stdin=PIPE)
def puts(s):
for l in s.split("\n"):
p.stdin.write((l + "\n").encode())
@jul
jul / matrix.py
Last active August 29, 2024 00:25
matrix as a view on a linear array
class DimensionError(Exception):
pass
class matrix(object):
def __eq__(self, tocomp):
other=tocomp
if type(tocomp) != type(self):
other=matrix(tocomp)
return (self.__val__, self.dim) == (other.__val__, other.dim)
@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