Skip to content

Instantly share code, notes, and snippets.

View rfletchr's full-sized avatar
🦝
racoons are cool

rfletchr

🦝
racoons are cool
View GitHub Profile
@rfletchr
rfletchr / pyside_double_slider.py
Last active June 12, 2024 22:51
A PySide slider for floating point values.
from PySide6 import QtWidgets
"""
This is a simple "trick" that uses "scaled integer arithmatic" to internally represent floating point values as integers.
Using this coversion it makes it extremely simple to use the standard interger slider to work on floating point numbers.
given a spinner with 2 decimal places.
rounded = round(1.1111, 2)
@rfletchr
rfletchr / download_playlist.py
Last active February 20, 2024 12:12
download the movies from a shotgrid playlist
import tank
import os
auth = tank.authentication.ShotgunAuthenticator()
user = auth.get_user()
sg = user.create_sg_connection()
playlist_ids = [23024]
@rfletchr
rfletchr / calculate_inset_transform.py
Last active June 12, 2024 22:55
calculate the transform required to transform a plate to match its edit ref.
"""
This is a cobbled together "copy paste" abomination which finds the bounding box of one image inside another.
Useful for matching compositions.
"""
import numpy as np
import cv2 as cv
import matplotlib.pyplot as plt
@rfletchr
rfletchr / example.py
Last active June 12, 2024 22:57
mvc, threads, progress
"""
A minimal example of MVC in PySide utilising a ThreadPollExecutor to offload work to a thread.
"""
import time
from PySide2 import QtGui, QtWidgets, QtCore
from concurrent.futures import ThreadPoolExecutor
@rfletchr
rfletchr / export_shaders.py
Last active May 5, 2023 03:03
Maya Shader Exporter
"""
This is an attempt to make a poor man's version of Katana's look files.
We record any shader assignments on the descendants of a given group, each location is recorded as a relative path along
with the shading engine that is assigned to it.
Encoding:
given the following nodes:
@rfletchr
rfletchr / annotation.py
Last active June 12, 2024 23:19
Annotation WIP
"""
A very basic example of a image annotation tool using a QWidget as a viewport.
This implements
- Viewport panning
- Viewport zooming (maintaing Point Of Interest)
- Basic draggable handles / gizmos
"""
from PySide6 import QtCore, QtGui, QtWidgets
@rfletchr
rfletchr / capture_screen.py
Created March 28, 2023 22:25
screen capture using pyside2
"""
This example shows how to capture a screenshot of a specific area of the screen.
Warning: This has not been tested with multiple monitors.
Example:
to capture the entire the current screen::
from PySide2 import QtCore, QtWidgets
@rfletchr
rfletchr / validation.py
Created February 24, 2023 11:17
Simple Validation Framework
import enum
import time
import textwrap
import qtawesome
from PySide2 import QtCore, QtWidgets, QtGui
__ICONS = {}
@rfletchr
rfletchr / Makefile
Last active June 29, 2021 11:13
record all open system calls of a program by shimming the open function via LD_PRELOAD
CC=gcc
all: src/shim.c
$(CC) -shared -fPIC -o shim.so src/shim.c -ldl
@rfletchr
rfletchr / decompile_guide.md
Last active June 6, 2019 06:26
Decompile a 'compiled' python api.

Setup

Ensure that uncomplye6 and black are installed. use conda, venv or just pip install to user..

pip install --user black uncompyle6

Decompile

cd