Skip to content

Instantly share code, notes, and snippets.

@sirisian
sirisian / uiinput.interface.ts
Created March 18, 2025 18:31
input web component interface
type Option<T> = {
label: string;
value: T;
}
type Options<T> =
| Record<string, T>
| Option<T>[]
| (() => Option<T>[]);
@sirisian
sirisian / webworker.js
Created January 26, 2023 06:08
web worker examples
async function SingleWorkerExample(data, param1, param2) {
return new Promise(resolve => {
const blobURL = URL.createObjectURL(new Blob(['(', function() {
onmessage = e => {
const { data, param1, param2 } = e.data;
// Do work with data which is a SharedArrayBuffer
postMessage('done');
};
}.toString(), ')()'], { type: 'application/javascript' }));
const worker = new Worker(blobURL);
@sirisian
sirisian / Shaders.hlsl
Created June 9, 2022 07:25
part of a box model shader system
cbuffer worldMatrix : register(b0)
{
matrix worldmat;
};
cbuffer viewMatrix : register(b1)
{
matrix viewmat;
};
@sirisian
sirisian / IntersectionFunctions.hpp
Created March 14, 2020 02:21
IntersectionFunctions.hpp
#pragma once
#include <vector>
#include <cmath>
#include "Vector2.hpp"
namespace IntersectionFunctions
{
struct IntersectionObject
@sirisian
sirisian / FreeList.cs
Created March 4, 2020 06:08
C# FreeList
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace FreeListClass
{
public class FreeList<T>
{
private class FreeListItem<T>
// See the paper "Implementation of a method for hydraulic erosion" by Hans Theobald Beyer (http://www.firespark.de/resources/downloads/implementation%20of%20a%20methode%20for%20hydraulic%20erosion.pdf) which has examples for all the parameter values
// particleCount number of particles to drop on the terrain
// particleInertia 0 to 1 defines how much changes in the gradient change the direction of the particle. Values near 0.1 work best
// particleCapacity 0 to 100 ish, defines how much sediment each particle can hold onto. Larger values erodes mountains more
// particleDeposition 0 to 1 limits the sediment that is dropped if the sediment carried by the drop exceeds the drops carry capacity
// particleErosion 0 to 1 determines how much of the free capacity of a drop is filled with sediment in case of erosion
// particleEvaporation 0 to 1 defines how fast the particle's waterAmount decreases. Values less than 0.1 work best
// particleRadius, 1 to 10 ish Used during erosion to decide how far away from the part
@sirisian
sirisian / Log.cpp
Created January 17, 2016 08:25
C++ Logger
#include "Log.hpp"
Section::Section(const char* name) : Name(name)
{
}
LogProxy::LogProxy(const char* level) : message(new std::stringstream)
{
*message << level;
}
@sirisian
sirisian / Packet.js
Last active December 2, 2022 05:20
Type Proposal Example
/**
* A binary bit-based writer and reader designed for packets.
* @class
*/
export class Packet {
/**
* The byte buffer for the packet.
*/
#buffer:[]<uint32>
/**
#include "Log.hpp"
#include <windows.h>
Section::Section(const char* name) : Name(name)
{
}
LogProxy::LogProxy(const char* level) : message(new std::stringstream)
{
/// <var>A binary bit-based writer and reader used for packets.</var>
var Packet =
{
Create: function()
{
/// <signature>
/// <summary>Constructor.</summary>
/// <returns type="Packet" />
/// </signature>
/// <signature>