Skip to content

Instantly share code, notes, and snippets.

@antocuni
antocuni / richards.py
Created July 12, 2024 08:48
richards.py
"""
based on a Java version:
Based on original version written in BCPL by Dr Martin Richards
in 1981 at Cambridge University Computer Laboratory, England
and a C++ version derived from a Smalltalk version written by
L Peter Deutsch.
Java version: Copyright (C) 1995 Sun Microsystems, Inc.
Translation from C++, Mario Wolczko
Outer loop added by Alex Jacoby
"""
@antocuni
antocuni / flamegraph-branch.html
Created September 7, 2024 12:09
scalene flamegraph
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" width="1800" height="242" onload="init(evt)" viewBox="0 0 1800 242" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Flame graph stack visualization. See https://github.com/brendangregg/FlameGraph for latest version, and http://www.brendangregg.com/flamegraphs.html for examples. -->
<defs >
<linearGradient id="background" y1="0" y2="1" x1="0" x2="0" >
<stop stop-color="#eeeeee" offset="5%" />
<stop stop-color="#eeeeb0" offset="95%" />
</linearGradient>
</defs>
#!/usr/bin/env python3
"""
Add trailing commas to multiline lists, tuples, dicts, sets, and function calls.
"""
import libcst as cst
from pathlib import Path
import sys
class TrailingCommaTransformer(cst.CSTTransformer):