Skip to content

Instantly share code, notes, and snippets.

import secrets
from pathlib import Path
def hex_to_argb(hex_string: str) -> tuple[int, int, int, int]:
"""Convert hexidecimal color information in ARGB order to tuple of binary values."""
_hex = int(hex_string, 16)
a = _hex >> 24 & 0xFF
r = _hex >> 16 & 0xFF
g = _hex >> 8 & 0xFF
@bob-ross27
bob-ross27 / download.py
Last active February 10, 2023 08:39
FastAPI Background downloading with SSE progress streaming
import asyncio
import uuid
from dataclasses import dataclass
from dataclasses import field
from time import sleep
from fastapi import Request
@dataclass
@bob-ross27
bob-ross27 / renderDialogExample.js
Created November 23, 2021 13:13
Example of using QProgressDialog with the render class in Toon Boom Harmony.
/**
* Example of using a QProgressDialog with the render class in Harmony.
*/
function renderDialogExample() {
/**
* Create the progress dialog
* @param {int} frames - Number of frames to use as the maximum value
* @returns {QProgressDialog} progressUI - The created QProgressDialog
*/
function createUI(frames) {
@bob-ross27
bob-ross27 / Toggle-Webcam.ps1
Created January 16, 2021 04:14
Toggle the Windows device status for the provided webcam.
<#
.SYNOPSIS
Enable or Disable a webcam.
.DESCRIPTION
Toggle the Status of a Webcam by disabling the PnPDevice. Useful for completely disabling an unneeded device
without physically disconnecting it.
Can also be used to output the current status of the provided webcam.
Webcam name is sourced from the -WebcamName parameter, trying the WEBCAM_NAME env var if no parameter used.
@bob-ross27
bob-ross27 / setArtLayersToBitmap.js
Created January 15, 2021 03:02
Set the drawing art layers to Bitmap for all selected read nodes.
/**
* Set the drawing art layers to Bitmap for all selected read nodes.
*/
scene.beginUndoRedoAccum("Set Layers to Bitmap");
var readNodes = selection.selectedNodes().filter(function(selNode) {
return node.type(selNode) === "READ";
}
)
readNodes.forEach(function(n) {
@bob-ross27
bob-ross27 / setVideoOn2s.js
Created January 12, 2021 14:36
Change the first selected node to 2's, presuming frame naming matches the default import values.
scene.beginUndoRedoAccum("Set Video on 2s");
var col = node.linkedColumn(selection.selectedNode(0), "drawing.element");
var keys = column.getDrawingTimings(col);
keys.forEach(function(key) {
if (parseInt(key) % 2 === 0) {
column.setEntry(col, 1, parseInt(key), parseInt(key) - 1);
}
});
@bob-ross27
bob-ross27 / renameDrawingsByFrame.js
Last active January 16, 2021 04:18
Rename drawings to their first exposed frame number.
Moved, see: https://github.com/bob-ross27/toonboom/blob/main/scripts/renameDrawingsByFrame.js
@bob-ross27
bob-ross27 / progressbar.js
Last active November 25, 2020 04:41
Example QTProgressBar
/**
* Example QTProgressBar.
*/
function progressbar() {
/**
* Sleep for a duration.
* @param {*} sleepDuration
*/
this.sleepFor = function (sleepDuration) {
var now = new Date().getTime();
@bob-ross27
bob-ross27 / mergeDuplicateTimings.js
Last active January 16, 2021 04:16
Script for Toonboom Harmony to change exposure of duplicate drawings to the first detected instance. Matching is done via MD5 hash.
Moved, see: https://github.com/bob-ross27/toonboom/blob/main/scripts/mergeDuplicateTimings.js
@bob-ross27
bob-ross27 / NC_Find_And_Replace.js
Created November 23, 2020 03:13
Added scene undo/redo accum to avoid clobbering undo history.
/* ---------------------------------------------------------------------------------
* NC_Find_And_Replace.js
*
* Jason Schleifer / 26 October 2018
* Latest Revision: v2.0 - 25 Nov 2018, 10:04 AM
* License: GPL v3
*
* Description:
* -----------
* Finds and replaces text in the selected nodes.