Skip to content

Instantly share code, notes, and snippets.

@stellarpower
stellarpower / Test Gradients Logging Keras v3 and v2.py
Last active May 8, 2024 21:33
Tests for W&B Gradients Callback for Keras v3
# Hide GPU to help with reproducibility between Keras versions
import os
os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID" # see issue #152
os.environ["CUDA_VISIBLE_DEVICES"] = ""
# Copilot says these apparently reduces the chances or reproducibility issues; treat with caution
os.environ["TF_DETERMINISTIC_OPS"] = "1"
@stellarpower
stellarpower / Directory Structure
Created April 25, 2024 13:50
Brief and Messy Script for Comparing KEras Soft-DTW against Torch pysdtw
.
├── Common.py
├── pysdtw
│   ├── ... Rest of checkout here
│   ├── Test Arrays -> /Some/Common/Path
│   ├── test.py
├── pytorch-softdtw
│   ├── ... Rest of checkout here
│   ├── Test Arrays -> /Some/Common/Path
│   └── test.py # Test script is very similar but not identical; these two are already tested as identical so not necessarily needed
@stellarpower
stellarpower / xtconcatenate.hpp
Last active April 5, 2024 22:15 — forked from jf99/xtconcatenate.hpp
A way to concatenate a vector of xt::xarrays
#ifndef XTCONCATENATE_HPP
#define XTCONCATENATE_HPP
#include <cstddef>
#include <stdexcept>
#include <vector>
#include <xtensor/xarray.hpp>
template <typename S>
struct ShapeIndex
@stellarpower
stellarpower / AntiBoilerplate.cpp
Created August 9, 2023 21:20
Brace Initialisation with Custom Logic
// WIP
// For half-baked related ideas in a situation when this won't work or be acceptable, see:
//
// https://initialiser.godbolt.org/z/esqeYf98W
// https://initialiser.godbolt.org/z/hzqzfsarz
// https://initialiser.godbolt.org/z/a53ojboYd
// https://initialiser.godbolt.org/z/G3nExT9ba
//
struct Foo {
@stellarpower
stellarpower / ConstructorPreInitialisation.hpp
Last active August 2, 2023 17:34
Use of a private struct to jimmy in arbitrary code before the submember initialisation of a class. we don't even need operator comma!
// Inherit from me privately.
struct ConstructorPreInitialisation{
// Pass in an arbitrary lambda function here, it will simply be discarded
// This remoes the need for a comma operator and importantly avoids cluttering your
// real initialisation of member subobjects.
inline ConstructorPreInitialisation( [[maybe_unused]] const auto λ ){ λ(); }
};
// WARN: This may increase the size of your class using it
// The compiler can probably elide this but from memory objects with zero length are not permitted
#!/usr/bin/env python3
import random, sys, time
from pythonosc import dispatcher, osc_server, osc_message_builder, udp_client
MessageAddress = "/test"
TimeToCutStream = 10 # seconds
#!/usr/bin/env python3
import argparse
from pathlib import Path
import sys
from packaging.utils import parse_wheel_filename
import platform
def diagnose_unsupported(p: Path) -> str:
p = Path(p)
@stellarpower
stellarpower / Earthfile
Created January 11, 2023 23:36
OpenVibe Earthfile
# From: https://gist.github.com/jfrey-xx/ed0a8d5d881a7a5734064e6ad89beccd
VERSION --use-cache-command 0.6
build:
# FROM custom:focal
# I originally used a custom image here, with compilers installed.
# Using stock ubuntu may have some steps missing, but it should be easy to add (e.g. standard buildtools)
@stellarpower
stellarpower / JavascriptDoneOnce.js
Last active May 18, 2024 00:59
Javascript is rather nasty. And there are loads of examples online that don't quite do what you need. Do everything once, document it, hopefully get it right, and re-use it.
// Demped from usecase script. Tidy-up to follow.
// To include this fromn Greasemonkey
// @require https://gist.githubusercontent.com/stellarpower/0e1600b78bb7e478ab9679f5c8213f41/raw/04fdf048d7870e5f655140cc4c4a08a59aaf9b8a/JavascriptDoneOnce.js
const ThisScript = "...";
function log(args){
#!/usr/bin/fish
# Instal;ls some rust CLI tools, as documented here: https://zaiste.net/posts/shell-commands-rust/
# Make the shell slightly less hellish and bring it kicking and screaming into the early 2000s.
pushd /tmp
mkdir rustyShell && cd rustyShell
# Debian packages