Skip to content

Instantly share code, notes, and snippets.

@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 January 2, 2023 00:12
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
@stellarpower
stellarpower / Google Maps Satellie Tile Fetcher.js
Last active April 13, 2022 14:32 — forked from praeclarum/TileSticher.cs
Downloads and stitches map tiles
// For a given latitude, longitude, and zoom, returns the URL to an image for that tile.
function tileIndex(latitude, longitude, zoom){
if ((latitude === undefined) || (longitude === undefined) || (zoom === undefined))
throw("Arguments mising in tileIndex");
var lat_rad = latitude / 180 * Math.PI;
var n = 1 << zoom;
var xtile = n * ((longitude + 180) / 360);
var ytile = n * (1 - (Math.log (Math.tan (lat_rad) + 1/Math.cos (lat_rad)) / Math.PI)) / 2;