Skip to content

Instantly share code, notes, and snippets.

@spchamp
spchamp / PlotItem.pyi
Created December 4, 2023 18:07
Type Hints Prototype, pyqtgraph.graphicsItems.PlotItem.PlotItem
from numbers import Real
from typing import Optional
from typing_extensions import TypeAlias
from ...Qt import QtCore
from ..GraphicsWidget import GraphicsWidget
# from .PlotAxis import AxisName, AxisPosition, PlotAxisInfo
RangeTuple: TypeAlias = tuple[Real, Real]
@spchamp
spchamp / async_httpx.py
Last active September 21, 2023 18:51
async HTTP client produces segfault on Windows, "Windows fatal exception: access violation"
## async_httpx.py - callback-based HTTP client example
## (Public Domain)
from abc import abstractmethod, ABC
from typing import Mapping, Optional
from typing_extensions import Generic, TypeVar
import asyncio as aio
import httpx
from httpx._client import BaseClient
@spchamp
spchamp / aiohttpx.py
Last active September 18, 2023 22:19
Callback-based I/O with HTTPX
## aiohttpx.py - callback-based HTTP client example
## when run, displays debugging information with a decoded
## JSON response from http://ip.jsontest.com
## requirements
## - Python 3 https://www.python.org/downloads/
## - HTTPX https://www.python-httpx.org/async/
from abc import abstractmethod, ABC
@spchamp
spchamp / deps-sort.py
Created March 11, 2023 08:57
Trivial dependency sorter (Python)
## deps-sort.py
## trivial dependency sort with stateful loop detection
class SortState():
def __init__(self, origin):
self._origin = origin
self._cache = []
@property
def origin(self):
@spchamp
spchamp / gist:92704f7040ff003ddc4e64d4c3af9724
Created November 6, 2021 09:53
Ruby I/O - capturing output of a subprocess on separate stdout and stderr descriptors
## (No Warranty)
class SHFrob02
def self.runfrob()
out_rd, out_wr = IO.pipe
err_rd, err_wr = IO.pipe
subpid = Process.spawn("ls -d /frob /etc", :in => :close, :out => out_wr, :err => err_wr )
samepid, status = Process.wait2(subpid)
@spchamp
spchamp / getent_auxgroups.sh
Last active April 20, 2020 01:28
print a list of a auxiliary groups assigned to a single user name, using getent(1)
# getent_auxgroups.sh - print auxiliary groups assigned to a single user name
#
# % Environment parameters
# WHOM
# - user name to parse for
# - If unspecified, defaults to $USER
# - Will be interpreted within a regular expression, in awk(1)
#
# % Depends On
# - getent(1)
@spchamp
spchamp / gist:4914ed654dffeff17e2e2fa431f95557
Created October 1, 2019 23:24
Build failures with newer WebKit (GTK+)
When building `webkit-gtk-2.26.1` with a GTK+3 `gtk+-3.24.10`, after some update to the webkit-gtk port, e.g
~~~~
-USE_LANGUAGES= c c++11
+USE_LANGUAGES= c c++11 c++14 c++17
~~~~
... this apparently serving to obviate some build failures, but subsequently, the following build failures may occur
~~~~
@spchamp
spchamp / Ninja.tools.mk
Created September 29, 2019 08:25
Snippet - use ninja-build in pkgsrc www/webkit-gtk
BUILD_DEPENDS+= ninja-build-[0-9]*:../../devel/ninja-build
CMAKE_ARGS+= -GNinja
do-build:
cd ${WRKSRC} && ninja
@spchamp
spchamp / docbook2X.buildlink3.mk
Created November 8, 2018 23:14
mk/docbook2x.buildlink3.mk - provides ports e.g textproc/expat with build configuration for docbook2X or xmlto
# $NetBSD$
#
# This Makefile fragment is meant to be included by ports that require
# a docbook2X implementation during build
#
# === Variables set by this file ===
#
# DOCBOOK2X_TYPE
# The name of the selected docbook2X implementation.
# One of: docbook2X, docbook2x, xmlto
@spchamp
spchamp / man2pdf.sh
Created October 30, 2016 23:49
PDF generator for manual pages in *ROFF format. runtime-depends on ports textproc/groff and print/ghostscript9-base. Public domain. No warranty.
#!/bin/sh
THIS="$(basename $(readlink -f $0))"
msg() {
echo "$THIS: $@"
}
ferr() {