Skip to content

Instantly share code, notes, and snippets.

View traverseda's full-sized avatar

traverseda traverseda

  • Halifax, Nova Scotia, Canada
View GitHub Profile
#Playbook to quickly and easily set up your canon camera as a webcam.
# Run with `ansible-playbook dslr-webcam.yaml --ask-become-pass`
# Tested with an old digital rebel XS, a lot of other pixel formats threw errors not sure what cameras
# this will work with.
- hosts: localhost
connection: local
tasks:
- name: set up video loopback device on boot
become: True
@traverseda
traverseda / gist:8a416ac2165e591a90d67bd61759ac67
Created August 7, 2023 18:47
Disable keyboard and mouse under wayland using evdev
#!/bin/env python3
from pathlib import Path
import os, time, signal
import evdev
pid_file=Path("/tmp/tablet_mode")
devices = [evdev.InputDevice(path) for path in evdev.list_devices()]
print(devices)
boundinputs = (
@traverseda
traverseda / ansi2html.py
Created January 6, 2023 22:51
Convert ansi escape sequences to html tags
import re
ansi_escape =re.compile(r'(\x9B|\x1B\[)[0-?]*[ -\/]*[@-~]')
def replace_ansi(text):
"""Quick hack, not expected to work in all cases but works for basic loguru cases.
"""
text = text.replace("\x1b[0m","</span>")
text = text.replace("\x1b[1m",'<span style="font-weight: bold;">')
text = text.replace("\x1b[3m",'<span style="font-style: italic;">')
text = text.replace("\x1b[8m",'<span style="text-decoration: line-through;">')
@traverseda
traverseda / README.md
Last active May 28, 2022 19:33
My customizations for the stem-minds eduponics mini

image

This is my customized eduponics mini firmware, it might not be compatible with the official app.

The main change I made is to use asyncio for the main loop. I did this so that I can more easily turn on water for just a few seconds.

The other main change is instead of generating a unique UUID I use the device's unique MAC address. Every device as a unique MAC address at creation, so this will still be globally

import whois
import string
import time
from itertools import combinations_with_replacement
from tqdm import tqdm
domains = list(combinations_with_replacement(string.ascii_lowercase+string.digits,3))
domains.reverse()
pbar = tqdm(domains)
for i in pbar:

QueryPerms

Qperms is an authentication system for django that lets you use SQL queries as a row-level permission system. This has a number of advantages over something like django-gaurdian, the main one being that there's a single source of truth. Normally with row-level permissions you need to explicitly set what users are allowed to access an object, and keep that list up to date whenever the situation changes. Keeping those permissions up to date when the situation changes is generally done using signals, and is generally fragile. You're essentially running code to make your permissions match your ideal state.

"""Generate books from a list of urls in tabletop simulator
"""
import sys, json, os, copy
bookBag={"SaveName":"","GameMode":"","Date":"","Gravity":0.5,"PlayArea":0.5,"GameType":"","GameComplexity":"","Tags":[],"Table":"","Sky":"","Note":"","Rules":"","TabStates":{},"ObjectStates":[{"Name":"Bag","Transform":{"posX":57.0064,"posY":1.26014686,"posZ":-2.550843,"rotX":1.26331825e-05,"rotY":-2.48861652e-05,"rotZ":6.62508e-06,"scaleX":1,"scaleY":1,"scaleZ":1},"Nickname":"Book Bag","Description":"","GMNotes":"","ColorDiffuse":{"r":0.7058823,"g":0.366520882,"b":0},"Locked":False,"Grid":True,"Snap":True,"IgnoreFoW":False,"MeasureMovement":False,"DragSelectable":True,"Autoraise":True,"Sticky":True,"Tooltip":True,"GridProjection":False,"HideWhenFaceDown":False,"Hands":False,"MaterialIndex":-1,"MeshIndex":-1,"LuaScript":"","LuaScriptState":"","XmlUI":"","ContainedObjects":[]}],"LuaScript":"","LuaScriptState":"","XmlUI":"","VersionNumber":""}
books=bookBag["ObjectStates"][0]["ContainedObjects"]
bookBase = {
import pyglet
import inspect
import mahi_gui
from mahi_gui import imgui
def redirect_pyglet():
import pyglet
# Do not create a hidden window and opengl context
pyglet.options['shadow_window'] = False
# Trick pyglet into using an external context
"""
Horrible hacks to allow context managers to exit early, *not* running
whatever code they're wrapping. I'm not sure if this is a reasonable
thing to do or not....
"""
import sys
class ExitEarlyException(Exception):
"""This is an exception that python
"""Tree objects that support the `with` statement.
A bit of an OOP mess though.
"""
import contextvars
defaultParent = contextvars.ContextVar('defaultParent', default=None)
treeSessionStack=[]
from collections import UserList
import weakref