Skip to content

Instantly share code, notes, and snippets.

View rfletchr's full-sized avatar
:shipit:
Code

Rob rfletchr

:shipit:
Code
View GitHub Profile
@rfletchr
rfletchr / shadow_effect.py
Last active June 18, 2024 01:53
A subclass of QtWidgets.QGraphicsDropShadowEffect which accounts for view scaling.
from PySide6 import QtWidgets, QtCore
class SceneSpaceShadowEffect(QtWidgets.QGraphicsDropShadowEffect):
"""
A drop shadow effect which takes the scene space size into account.
"""
def __init__(self, parent=None):
super().__init__(parent=parent)
@rfletchr
rfletchr / callable_weak_ref.py
Last active September 19, 2024 17:44
Generate a weak ref to a python callable accounting for loose functions, bound methods and callable classes.
"""
Generate a weak ref to a python callable accounting for loose functions, bound methods and callable classes.
This allows creating references to python functions without increasing their reference countm and creating
circular dependencies.
"""
import typing
import weakref
import types
@rfletchr
rfletchr / prompt.py
Last active July 4, 2025 14:01
Python Console Prompt
#!/usr/bin/env python3
"""
wget https://gist.githubusercontent.com/rfletchr/3cb7987b4f636b6eb226c14bc141587e/raw/13d126a43f449204aa5d50635d6a517efa3f1620/prompt.py -O ~/.local/bin/prompt
chmod ug+x ~/.local/bin/prompt
echo 'export PROMPT_COMMAND=prompt' >> ~/.bashrc
"""
import sys
import os
@rfletchr
rfletchr / rez-venv.py
Last active July 4, 2025 13:54
make the current virtual environment aware of the a rez packages requirements.
#! /usr/bin/python3
"""
This script parses a `package.py` file add adds its dependencies to a virtual environment.
- find package.py in the current directory or any parent directory
- extract the 'requires' variable from package.py
- build the environment using `rez env`
- get the site-packages path for venv's Python interpreter
- create a rez.pth file in the site-packages directory
- write the paths from the built environment to rez.pth
@rfletchr
rfletchr / generic_table_model.py
Created March 19, 2026 02:00
Generic QT model with undo integration, and batch editing
"""
A collection of classes for working with MVC in QT, including a generic table model, and an example of integrating undo via a proxy model.
"""
import typing
from qtpy import QtCore, QtGui, QtWidgets
T = typing.TypeVar("T")
class SchemaColumn(typing.Generic[T]):
@rfletchr
rfletchr / main.go
Created April 8, 2026 17:23
asset management server
package main
import (
"fmt"
"log"
"github.com/pocketbase/pocketbase"
"github.com/pocketbase/pocketbase/core"
)