Skip to content

Instantly share code, notes, and snippets.

View MagnusThor's full-sized avatar
🏠
Working from home

Magnus 'Bagzy' Thor MagnusThor

🏠
Working from home
  • Freelancer & member of coloquium
  • Sweden
View GitHub Profile
@MagnusThor
MagnusThor / index.html
Last active December 5, 2025 15:35
CSS Houdini - Fiddling
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Hello World</title>
<style>
body {
display: flex;
justify-content: center;
align-items: center;
class SierpinskiTriangle {
static get inputProperties() {
return [
'--sierpinski-iterations',
'--zoom-factor',
'--fractal-opacity',
'--rotation-angle'
];
}
paint(ctx, size, props) {
/**
* A custom array class that provides additional query-like methods for filtering, mapping, and manipulating arrays.
* @template T - The type of elements in the array.
*/
export class QueryableArray<T> extends Array<T> {
/**
* Skips the specified number of elements and returns the remaining elements.
* @param count - The number of elements to skip.
* @returns A new QueryableArray containing the remaining elements.
*/
@MagnusThor
MagnusThor / archipelago.wgsl
Created July 16, 2025 15:36
This shader raymarches a stylized landscape with fractal terrain, dynamic lake shading, procedural clouds, and post-processing effects like god rays, lens flares, and sun glow. It uses screen-space techniques to simulate lighting, reflections, and atmosphere, creating a rich, animated scene with depth and color variation.
struct Uniforms {
resolution: vec3<f32>,
time: f32
};
struct VertexOutput {
@builtin(position) pos: vec4<f32>,
@location(0) uv: vec2<f32>
};
@MagnusThor
MagnusThor / DOMUtils.ts
Created February 26, 2025 17:54
Utils functions that i used regularly, i not that keen to use massive framework for tiny web app, less is more!
export class DOMUtils {
static value<T>(selector: string, value?: any) {
const element = DOMUtils.get<HTMLInputElement>(selector);
if (value && element) element!.value = value;
return element ? element.value as T : null;
}
static get<T extends HTMLElement>(selector: string, parent?: Element | DocumentFragment | null): T | null { // Allow null
if (!parent) {
@MagnusThor
MagnusThor / greenscreenmshitfix.ts
Last active May 26, 2021 19:09
Snapshot , dump of virtual-bg example broski dosiki, kushki khleb
import { GreenScreenStream, GreenScreenMethod } from "../../src/GreenScreenStream";
document.addEventListener("DOMContentLoaded", () => {
const bgfile = location.hash.length > 0 ? location.hash.replace("#", "") : "beach.jpg"
navigator.getUserMedia({ video: { width: 640, height: 360 }, audio: false }, (ms: MediaStream) => {
let instance = GreenScreenStream.getInstance(true, `../assets/${bgfile}`, undefined, 640, 360);
instance.onReady = () => {
const fps = 60;
instance.initialize().then(result => {
instance.start(GreenScreenMethod.VirtualBackground);
@MagnusThor
MagnusThor / p.json
Created August 12, 2020 21:11
Points 5x5 ( 25 joints )
let pp =
[[0,4],[0,3],[0,2],[0,1],[0,0],[1,0],[2,0],[3,0],[4,0],[4,1],[4,2],[4,3],[4,4],[3,4],[3,3],[3,2],[3,1],[2,1],[1,1],[1,2],[1,3],[1,4],[2,4],[2,3],[2,2]]
@MagnusThor
MagnusThor / client.ts
Created July 30, 2020 12:53
thor.io.client-vnext tiuny example
import { ClientFactory, WebRTCFactory, BinaryMessage, TextMessage, Controller } from 'thor-io.client-vnext'
export class TestClient{
factory: ClientFactory;
controller: Controller;
constructor(){
this.factory = new ClientFactory("ws://localhost:1337",["example"],{});
this.factory.onOpen = (controller: Controller) => {
this.controller = controller;
@MagnusThor
MagnusThor / Server.ts
Created July 30, 2020 12:52
Set up a ThorIO Server on Express
import path from "path";
import fs from "fs";
import http from "http";
import https from "https";
import express from "express";
import webSocket from "ws";
import { ExampleController } from "./controllers/ExampleController";
import { BrokerController } from "../src/Controllers/BrokerController/Broker";
import { ThorIO } from "..";
@MagnusThor
MagnusThor / ExampleController.ts
Created July 30, 2020 12:50
thor-io.vnext ExampleController
import { CanSet } from '../../src/Decorators/CanSet';
import { CanInvoke } from '../../src/Decorators/CanInvoke';
import { ControllerProperties } from '../../src/Decorators/ControllerProperties';
import { ControllerBase } from "../../src/Controller/ControllerBase";
import { BinaryMessage } from 'thor-io.client-vnext';
import { Connection } from '../../src/Connection/Connection';
interface IMyModel{
age:number;