Skip to content

Instantly share code, notes, and snippets.

View ayuusweetfish's full-sized avatar

Ayu ayuusweetfish

View GitHub Profile
@ayuusweetfish
ayuusweetfish / image.twee
Last active April 26, 2026 14:13
Twine/Harlowe image area link template
:: StoryTitle
Untitled Story
:: StoryData
{
"ifid": "60E6E4FF-3324-4605-AB97-AB2421AE42BC",
"format": "Harlowe",
"format-version": "3.3.9",
"start": "开始",
@ayuusweetfish
ayuusweetfish / vt.c
Last active December 6, 2025 09:37
(🚧) Plain virtual terminal with a border
/*
cc % -lncurses -O2 -o /tmp/vt && /tmp/vt
*/
#include <ncurses.h>
#include <pty.h>
#include <unistd.h>
#include <sys/select.h>
#include <sys/wait.h>
#include <signal.h>
#include <stdlib.h>
@ayuusweetfish
ayuusweetfish / krita_number_layers.py
Last active September 13, 2025 07:11
Animation frame sequence packer utility
from krita import *
def rename_layers_by_index():
doc = Krita.instance().activeDocument()
if not doc:
print('No active document')
return
def traverse(i, is_root, node):
for child in node.childNodes():
@ayuusweetfish
ayuusweetfish / buf-stdin.c
Last active November 21, 2025 17:44
(🚧)
// cc buf-stdin.c -o buf-stdin -Wall -O2
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/mman.h> // memfd_create
#define bail_out(s) (perror(s), exit(1))
@ayuusweetfish
ayuusweetfish / csc_module.cc
Last active December 1, 2024 03:33
C++ subroutines for reading bicycle speed & cadence (CSC) sensor through BLE onto a computer
/*
C++ subroutines for reading bicycle speed & cadence (CSC) sensor through BLE onto a computer.
This has been integrated into an Unreal Engine 5 project to implement movement through a spinning bike.
- `csc_start()`: Global initialisation. This only needs to be called once throughout execution. Automatically discovers devices, connects, and reconnects. Internally threaded.
- `csc_get_movement(float dt)`: Gets movement for a given amount of delta time (`dt`, in seconds).
Reference / further reading:
https://learn.adafruit.com/bluetooth-bicycle-speed-cadence-sensor-display-with-clue
@ayuusweetfish
ayuusweetfish / OPTED.sh
Last active August 15, 2024 17:23
Experiments with auto-generated word games
# for c in {a..z}; do echo $c; curl https://www.mso.anu.edu.au/~ralph/OPTED/v003/wb1913_$c.html >> OPTED.html; done
# cat OPTED.html | grep "<P>" | perl -pe 's/<P><B>(.+?)<\/B> \(<I>(.*?)<\/I>\) (.*)<\/P>/$1\t$2\t$3/g' > OPTED.txt
cat OPTED.html | grep "<P>" | perl -pe 's/<P><B>([A-Z])(.*?)<\/B> \(<I>(.*?)n\.(.*)<\/I>\) (.*)<\/P>/\L$1$2/g' | grep -v "^<P>" | uniq > OPTED.txt
@ayuusweetfish
ayuusweetfish / CircuitBuilder.cs
Last active April 19, 2024 15:54
Layout of fluidic logic gates on a triangular grid. Ref: Lu, et al. "Fluidic Computation Kit: Towards Electronic-free Shape-changing Interfaces".
// nuget install Newtonsoft.Json
// cp Newtonsoft.Json.13.0.3/lib/net40/Newtonsoft.Json.dll .
// csc CircuitBuilder.cs -r:Newtonsoft.Json.dll && mono CircuitBuilder.exe
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
@ayuusweetfish
ayuusweetfish / 1.fs
Created March 2, 2024 11:26
F# library test
// Testrun: fsharpc 1.fs && mono 1.exe
// Build: fsharpc --target:library 1.fs
module Add
let f(a: int)(b: int): int =
a + b
[<EntryPoint>]
let main argv =
let printGreeting name =
@ayuusweetfish
ayuusweetfish / fft_test.c
Last active February 28, 2024 17:25
Recording LÖVE animations into a video file
// cc % -O2 -I../kissfft-131.1.0 ../kissfft-131.1.0/libkissfft-float.a
#include <math.h>
#include <stdio.h>
#include "kiss_fftr.h"
int main()
{
float x[100];
@ayuusweetfish
ayuusweetfish / date2drp2.c
Last active September 4, 2023 14:08
Reconstruction of the `date2drp2` algorithm found in the "VOCALOID5 Libraries Installer", bundled with VOCALOID5 ESV for macOS by SilverFox (https://4download.net/209-yamaha-vocaloid-full-version.html)
#include <stdio.h>
#include <string.h>
const char *shifttable = "23456789ABCDEFGHKLMNPRSTWXYZ";
const char *convtable[] = {
"BELKCFHDGA27SZT8M9W43N6XR5YP",
"ABCDEFGHKLMNPRSTWXYZ23456789",
"E8AF2B93D46K7H5CGYPNWZRTLXMS",
"BK5C6HD2A7F43E89LZGYMNXRWPST",