Skip to content

Instantly share code, notes, and snippets.

@SnoopJ
SnoopJ / lm_wat.py
Created December 12, 2024 05:39
Demonstration that almost all members of Modifier_Letter are valid Python identifiers
ʰ = 0x2b0
ʱ = 0x2b1
ʲ = 0x2b2
ʳ = 0x2b3
ʴ = 0x2b4
ʵ = 0x2b5
ʶ = 0x2b6
ʷ = 0x2b7
ʸ = 0x2b8
ʹ = 0x2b9
$ python3 src/pomodouroboros/linux/gtk_progress_bar.py
(python3:868136): Gtk-CRITICAL **: 14:51:17.075: gtk_icon_theme_get_for_display: assertion 'GDK_IS_DISPLAY (display)' failed
(python3:868136): Gtk-CRITICAL **: 14:51:17.075: gtk_icon_theme_add_resource_path: assertion 'GTK_IS_ICON_THEME (self)' failed
Traceback (most recent call last):
File "/home/jgerity/repos/Pomodouroboros.git/src/pomodouroboros/linux/gtk_progress_bar.py", line 115, in on_activate
Gtk.StyleContext.add_provider_for_display(
TypeError: Argument 0 does not allow None as a value
@SnoopJ
SnoopJ / gist:61eab1e7acc52eb8503e93a5192e7719
Created November 4, 2024 22:47
Illustrating Python's `PRINT_EXPR` intrinsic
$ python3
Python 3.9.16 (main, Mar 15 2023, 15:36:41)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> co = compile("1 + 2; 3 + 4", "nofilename", "single")
>>> import dis
>>> dis.dis(co)
1 0 LOAD_CONST 0 (3)
2 PRINT_EXPR
4 LOAD_CONST 1 (7)
@SnoopJ
SnoopJ / random_interval.py
Last active October 18, 2024 15:06
A Sopel plugin committing crimes
import logging
import random
import time
from datetime import datetime
from functools import wraps
from sopel import plugin
from sopel.tools import get_logger
@SnoopJ
SnoopJ / strace.txt
Created September 19, 2024 22:36
Process chain running a minimal Python program via `pyenv`
2378412 execve("/home/snoopjedi/.pyenv/shims/python3", ["/home/snoopjedi/.pyenv/shims/python3", "-c", "print('hello world')"], 0x7ffc43ab5aa0 /* 39 vars */) = 0
2378412 execve("/usr/bin/bash", ["bash", "/home/snoopjedi/.pyenv/shims/python3", "-c", "print('hello world')"], 0x7ffcd0e2ecc8 /* 39 vars */) = 0
2378412 execve("/usr/bin/bash", ["bash", "/home/snoopjedi/.pyenv/libexec/pyenv", "exec", "python3", "-c", "print('hello world')"], 0x7ffdeef8d388 /* 38 vars */) = 0
2378418 execve("/usr/bin/readlink", ["/usr/bin/readlink", "pyenv"], 0x55ad43116420 /* 40 vars */) = 0
2378412 execve("/usr/bin/bash", ["bash", "/home/snoopjedi/.pyenv/libexec/pyenv-exec", "python3", "-c", "print('hello world')"], 0x7ffe84e31a80 /* 40 vars */) = 0
2378420 execve("/usr/bin/bash", ["bash", "/home/snoopjedi/.pyenv/libexec/pyenv-version-name"], 0x7ffc26f69cd8 /* 41 vars */) = 0
2378421 execve("/usr/bin/bash", ["bash", "/home/snoopjedi/.pyenv/libexec/pyenv-version-file"], 0x7ffd208759c8 /* 41 vars */) = 0
2378423 execve("/usr/bin/bash"
@SnoopJ
SnoopJ / Emulate_Scroll.ahk
Created December 16, 2023 05:56
An AutoHotKey script for turning mouse movement into mouse scroll events
;; An AutoHotKey script for translating mouse movement into emulated scrollwheel
;; events. Slightly more convenient when web browsing (or otherwise scrolling a
;; lot) using some trackballs.
;
;
;; Below is a helper for raw mouse data, courtesy of AHK user evilC:
;; https://www.autohotkey.com/boards/viewtopic.php?f=19&t=10159
;;; --------------------
;;; BEGIN inlined MouseDelta.ahk
@SnoopJ
SnoopJ / out.txt
Created June 28, 2023 17:51
Demonstration of how Python's error reporting behavior changes when source code is not available
$ python3 traceback_without_source.py
Executing mod.upper() from in-memory module
Traceback (most recent call last):
File "/tmp/traceback_without_source.py", line 43, in <module>
mod.upper()
File "<unknown>", line 2, in upper
File "<unknown>", line 5, in lower
RuntimeError: Oh no, not again.
---
@SnoopJ
SnoopJ / b0rk.py
Created February 8, 2023 00:30
https://hachyderm.io/@juandesant@astrodon.social/109825208696475291
from textwrap import wrap
msg = b"computer"
print(f"{msg = }\n")
@SnoopJ
SnoopJ / cmake_link_bug.md
Last active December 13, 2022 00:50
An explanation of Another Stupid CMake Problem™
"""
Sample program showing communication with PyPI's Simple API (as described in
PEP 503 [1]) to list out available packages and available files for a given
package
Based on a question in #python on Libera.chat on 19 Oct 2022
[1] https://peps.python.org/pep-0503/
"""
from xml.etree import ElementTree