Skip to content

Instantly share code, notes, and snippets.

@jamesWalker55
jamesWalker55 / copy-screenshot.js
Created August 28, 2025 12:15
Script for MPV to copy screenshot to clipboard. Requires `cb.exe` tool in PATH, from https://github.com/Slackadays/Clipboard
// copy-screenshot.ts
var COMMAND_NAME = "screenshot-to-clipboard";
var path = mp.utils.get_user_path("~/AppData/Local/Temp/mpv-screenshot-clipboard.png");
function main() {
print("Saving screenshot to " + path);
mp.commandv("osd-msg", "screenshot-to-file", path, "video");
mp.commandv("run", "cb", "cp", path);
}
mp.add_key_binding(undefined, COMMAND_NAME, main);
@jamesWalker55
jamesWalker55 / logging_demo.py
Last active July 18, 2025 06:45
Opinionated setup for Python's logging module.
# Get a logger, put this in the beginning of every file:
import logging
log = logging.getLogger(__name__)
del logging
# Function to set up logging
def setup_logging():
import datetime
@jamesWalker55
jamesWalker55 / audvis_visualizer_generator.py
Last active March 20, 2024 18:19
A Python script for Blender Audvis. This generates an audio visualizer that looks similar to Monstercat's early visualizers.
import bpy
import math
def delete_object_if_exists(name):
if name in bpy.data.objects:
bpy.data.objects.remove(bpy.data.objects[name], do_unlink=True)
def get_or_create_empty(name):
@jamesWalker55
jamesWalker55 / show_img.py
Last active October 23, 2023 11:32
Open and show an image in a Python notebook, using `IPython`, `PIL`, and `numpy`.
def open_image(path):
from PIL import Image
import numpy as np
img = Image.open(path)
return np.asarray(img)
# Using PIL and IPython
def show_img(img):
@jamesWalker55
jamesWalker55 / gen_buckets.py
Created September 5, 2023 19:38
A single function for NovelAI aspect ratio bucketing. No need for classes or objects.
def gen_buckets(
min_dim: int = 256,
base_res: tuple[int, int] = (512, 512),
max_size: tuple[int, int] = (768, 512),
dim_limit: int = 1024,
divisible=64,
):
"""
Adapted from:
https://github.com/NovelAI/novelai-aspect-ratio-bucketing/blob/main/bucketmanager.py
@jamesWalker55
jamesWalker55 / image_importer.py
Created September 3, 2023 19:06
Substance Painter script to drag-and-drop images to import to project.
import datetime
import substance_painter.resource as res
import substance_painter.ui
from PySide2 import QtWidgets
def now():
return datetime.datetime.now().timestamp()
@jamesWalker55
jamesWalker55 / curve_to_mesh_preserving_modifiers.py
Last active May 11, 2023 12:07
Blender addon to convert a curve to a mesh while preserving modifiers. Tested on Blender 3.5.
from typing import Any, NamedTuple
import bpy
class ModifierSpec(NamedTuple):
name: str
type: str
properties: dict[str, Any]
model:
base_learning_rate: 5.0e-03
target: ldm.models.diffusion.ddpm.LatentDiffusion
params:
linear_start: 0.00085
linear_end: 0.0120
num_timesteps_cond: 1
log_every_t: 200
timesteps: 1000
first_stage_key: image
@jamesWalker55
jamesWalker55 / config.json
Last active December 13, 2022 03:19
Default config files generated after installing Automatic1111's WebUI, obtained at 2022-12-13 02:02 UTC
{
"samples_save": true,
"samples_format": "png",
"samples_filename_pattern": "",
"save_images_add_number": true,
"grid_save": true,
"grid_format": "png",
"grid_extended_filename": false,
"grid_only_if_multiple": true,
"grid_prevent_empty_spots": false,
@jamesWalker55
jamesWalker55 / Remove_Keyboard_Layout_en-US.ps1
Created July 24, 2022 16:01
This is a powershell script that automatically adds then removes "en-US" from the keyboard input methods list.
# This script solves the issue in this stackoverflow question:
# https://superuser.com/questions/1092246/how-to-prevent-windows-10-from-automatically-adding-keyboard-layouts-i-e-us-ke
# This method adds the en-US layout then removes it, ensuring that the layout is always removed from the taskbar
# I don't have a high enough reputation so I can't post this there, so here is the script:
# define the language to be removed
$LanguageToRemove = "en-US"
# get the current language list
$LangList = Get-WinUserLanguageList