Skip to content

Instantly share code, notes, and snippets.

001

Love the way the light shines through it like that

002

The General Prototype

003

@tripzilch
tripzilch / quadtree.js
Last active December 5, 2023 21:59 — forked from L-A/quadtree.js
Basic quadtree implementation in JS
const CAPACITY = 8;
class QuadTree {
constructor(x, y, w, h) {
// the rect (x,y,w,h) defines the product of two half-open intervals: [x, x+w) × [y, y+h)
this.x = x; this.xe = x + w;
this.y = y; this.ye = y + h;
this.w = w;
this.h = h;
this.pts = [];
@tripzilch
tripzilch / prng-xorshift128.js
Last active July 9, 2020 11:49
Seedable Xorshift128 PRNG
// RNG = Math.random
RNG = xorshift128
function nonsense() {
// if all you need
// is a random seed
// of type string
// then this thing
// does the deed, hey
xorshift128_seed(Date.now() + '');

Pasta en champignon en crème fraiche en broccoli

Voor 2 personen.

  • 1 bakje champignons
  • 1 broccoli (of 2 kleintjes)
  • 2-3 uien, 3-4 dikke tenen knoflook
  • 1 bekertje creme fraiche
  • zonnebloempitjes (optioneel)
  • verse zwarte peper
@tripzilch
tripzilch / mogelijk de beste vega chili ooit.md
Created April 18, 2017 19:11
mogelijk de beste chili ooit (vegetarisch)

Mogelijk de beste chili ooit (vegetarisch)

  • 2-3 medium uien, halve ringen
  • 3 dikke tenen knoflook, gesnipperd
  • 1 zoete aardappel (paarse schil), blokjes
  • 1 chilipeper, pitjes verwijderd, fijngesnipperd (2 was achteraf beter denk ik)
  • halve winterpeen, kleine blokjes / gesnipperd
  • genoeg olijfolie

in stevige grote pan aanbakken/fruiten tot het bruin begint te worden. ondertusen oven voorverwarmen. daarna toevoegen:

Some quick notes about PRNGs

If the docs don't specify the cycle length, IMHO better not use it in situations where it matters.

65**5 is about 30 bits. if the PRNG-state is 32 bits, and the PRNG algorithm doesn't cycle through the full state, that may already be too little.

In many languages the default PRNG is implemented as a LCG, which are just 2-3 lines of code, and just not very good on their own. Computational science has found much, much better algorithms that are (almost) just as tiny to implement. Maybe 4-5 lines, see PCG-random.org.

I recently used a Java port of CMWC4096 from StackOverflow, for a numerical simulation in Java (where the default Math.random() has a stupid-bad cycle length, and the Java crypto-PRNG might have been too slow). It worked great. Not quite as tiny as PCG-random, but still short and it was ready-to-use Java-code that fit my needs.

#ifdef GL_ES
precision mediump float;
#endif
#define PROCESSING_TEXTURE_SHADER
uniform sampler2D texture;
uniform vec2 C;
uniform vec2 P;
uniform vec2 M;
@tripzilch
tripzilch / blobs_simple.pde
Created April 24, 2015 16:03
Simple 2D Blobs (metaballs / implicit surface)
import java.lang.Math; // de functies in java.lang.Math zijn een stuk sneller
// dan die van Processing zelf.
class Blobs {
int N;
int[] rrr;
float[] cx, cy, cr;
private float time;
Blobs(int N) {
@tripzilch
tripzilch / blobs_aa.pde
Last active August 29, 2015 14:19
Processing: 2d implicit metaballs surface with anti-aliasing
import java.lang.Math; // de functies in java.lang.Math zijn een stuk sneller
// dan die van Processing zelf.
class Blobs {
int N;
int[] rrr;
float[] cx, cy, cr;
private float time;
Blobs(int N) {
this.N = N;
@tripzilch
tripzilch / game-loop.md
Last active April 18, 2017 22:08
Timing en de gameloop

Timing en de game-loop

lol, sam snapt mijn gameloop niet ofzo :P "die while loop is niet goed ofzo" stel je pc loopt vast dan zou ie oneindig veel updates kunnen krijgen

http://gameprogrammingpatterns.com/game-loop.html hmm ik zie toch echt dat ze t hier ook doen XD

Ah nice dus ik had het goed onthouden? :-) Volgens mij was dat ook precies het artikel waar ik dit uit geleerd heb.