Skip to content

Instantly share code, notes, and snippets.

View ayuusweetfish's full-sized avatar

Ayu ayuusweetfish

View GitHub Profile
@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",
@ayuusweetfish
ayuusweetfish / README.md
Last active June 13, 2023 09:57
bga_compo: BMS (Be-Music Source) background animation to video encoder

BGA Compo

bga_compo produces videos from Be-Music Source (BMS) files. It takes a BMS file, reads its accompanying images and sounds, and outputs the video and audio streams in raw formats that can be easily encoded into common video formats.

To compile:

cc bga_compo.c bmflat.c stb_vorbis.c -O2 -o bga_compo

# Test. Should print a few lines and a few pixels.
./bga_compo -v twinklesky/_tsky_5_3.bms | od -N 10
@ayuusweetfish
ayuusweetfish / DragController.cs
Created November 3, 2022 05:58
Unity script for object pick-up with hand (2021.3.12f1)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DragController : MonoBehaviour
{
public GameObject HandModel;
public Camera Camera;
public float MaxDetectDistance = 50;
public float GrabbedCloseUpDistance = 4;
@ayuusweetfish
ayuusweetfish / wlxt.js
Last active July 31, 2022 15:38
清华大学网络学堂课件爬虫
// Assignments
import { copy, readAll, writeAll } from 'https://deno.land/std/streams/conversion.ts';
import cred from './cred.js';
const { csrfToken, cookies } = cred;
const globalReqRecords = await Deno.open('requests.log', { append: true, create: true });
const req = async (url, method, body) => await fetch(
'https://learn.tsinghua.edu.cn' +
@ayuusweetfish
ayuusweetfish / temperature_convert.html
Last active November 23, 2021 14:52
Celsius ↔ Fahrenheit converter
<html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
</head>
<body>
<style>
html, body {
height: 100%;
margin: 0;
overflow: hidden;
@ayuusweetfish
ayuusweetfish / translate.js
Created November 22, 2021 14:47
Extract text for editing, and patch back to original source
// deno run --allow-read translate.js > 1.txt
// deno run --allow-read --allow-write translate.js 1.txt
const files = [];
const readDir = (path) => {
for (const entry of Deno.readDirSync(path)) {
if (entry.isFile && entry.name.endsWith('.js')
&& entry.name !== 'translate.js' && entry.name.indexOf('jquery') === -1) {
files.push(path + '/' + entry.name);
@ayuusweetfish
ayuusweetfish / neteasemusic.rs
Created September 25, 2021 15:50
NetEase Music cache uc! → mp3
// rustc neteasemusic.rs -O
use std::io::{Read, Write};
fn main() {
let args = std::env::args().collect::<Vec<_>>();
if args.len() == 1 {
println!("Usage: {} <uc file> [<uc file> ...]", args[0]);
return;
}