Skip to content

Instantly share code, notes, and snippets.

#include <cstdio>
#include <cmath>
#include <string>
#include "raylib.h"
#include "waterpool.hpp"
const int WIDTH = 160;
const int HEIGHT = 160;
using PoolType = Sapphire::WaterPool<WIDTH, HEIGHT>;
@cosinekitty
cosinekitty / vcvbuild.sh
Last active July 11, 2024 02:36
Script for building VCV Rack 2.4.1 with my improved (low-latency) PulseAudio anti-glitching fix applied.
#!/bin/bash
Fail()
{
echo "vcvbuild.sh: $1"
exit 1
}
CloneVcv()
{
@cosinekitty
cosinekitty / glitchfix.sh
Created November 27, 2022 00:23
Build VCV Rack with and without audio glitch fix
#!/bin/bash
#-------------------------------------------------------------------------------
#
# glitchfix.sh - Don Cross <[email protected]>
#
# Script that builds two copies of VCV Rack 2.2.0,
# one from original source code, another with the
# following fix for a glitching issue when sending
# output audio to PulseAudio on Linux:
#
@cosinekitty
cosinekitty / randomvector.py
Created July 19, 2020 19:37
Python function for generating unbiased direction unit vectors
import math
import numpy
def randomvector(n):
components = [numpy.random.normal() for i in range(n)]
r = math.sqrt(sum(x*x for x in components))
v = [x/r for x in components]
return v
function abs(x) {
return Math.abs(v(x));
}
function v(x) {
if (typeof x !== 'number') {
console.trace();
throw `Not a numeric type: ${x}`;
}
if (isNaN(x)) {
console.trace();
throw 'NAN result';
}
#include <stdio.h>
#include <math.h>
double Distance(double x, double y)
{
/* Intentional bug for illustration... */
return sqrt(-1.0);
}
int main()
function Polar(x, y) {
return {
angle: Math.atan2(y, x),
radius: Math.sqrt(x*x + y*y)
};
}
@cosinekitty
cosinekitty / oops1.js
Created June 10, 2020 00:19
The NaN trap illustrated
function UnitTest() {
const polar = Polar(3.0, 4.0);
const expected_distance = 5.0;
const diff = polar.distance - expected_distance;
if (Math.abs(diff) > 1.0e-12) {
console.error('ERROR: Excessive distance error: ', diff);
return 1;
}
console.log('PASS');
return 0;
int main()
{
/*... blah blah blah ...*/
if (error1)
goto handle_error; /* YUCK! */
if (error2)
{
handle_error: