Skip to content

Instantly share code, notes, and snippets.

@smontanaro
smontanaro / dusort.sh
Created November 7, 2022 11:01
I got this du postprocessing script from "the net" in the dark ages (probably from Usenet in the 80s or 90s). I have no idea who the original author was. I've never modified it **at all**. It has always just worked.
#!/bin/sh
#
# sort a "du" listing by directory size
# usage: du | dusort
FILES=
TFORM=0
while test $# -ge 1; do
case $1 in
-t) TFORM=1; ;;
@smontanaro
smontanaro / tkasyncio.py
Created March 31, 2022 14:28
First attempt at asyncio integration of the Tk event loop
#!/usr/bin/env python3
"Testing the idea of providing an off-the-shelf Tk event loop for asyncio"
import asyncio
import random
from tkinter import Tk, Button
class AsyncTk(Tk):
"Basic Tk with an asyncio-compatible event loop"
@smontanaro
smontanaro / dusort.sh
Created March 22, 2022 11:32
dusort - sort du output to find biggest offenders
#!/bin/sh
#
# sort a "du" listing by directory size
# usage: du | dusort
# I found this on the net decades ago. It still works. I suppose it's "thank goodness" du(1)
# hasn't been "modernized".
FILES=
TFORM=0
@smontanaro
smontanaro / matmul.py
Last active October 31, 2021 12:53
Simple multi-threaded implementation of matrix multiplication in Python
#!/usr/bin/env python3
"""multi-threaded matrix multiply, demonstrating no-GIL benefits.
No help, crappy CLI. Run something like this:
python3 matmul.py NTHREADS SIZE
NTHREADS is (wait for it) the number of threads to spin up.
@smontanaro
smontanaro / mbox_send.py
Last active September 12, 2016 17:27 — forked from wojdyr/mbox_send.py
script to send all messages in an mbox file to a specific email address, with various options
#!/usr/bin/python
"""\
A command-line utility that can (re)send all messages in an mbox file
to a specific email address, with options for controlling the rate at
which they are sent, etc.
"""
# I got this script from Robin Dunn a few years ago, see
# https://github.com/wojdyr/fityk/wiki/MigrationToGoogleGroups