Skip to content

Instantly share code, notes, and snippets.

View Teggy's full-sized avatar
💯
100% busy shooting lecture videos...

Torsten Grust Teggy

💯
100% busy shooting lecture videos...
View GitHub Profile
@Teggy
Teggy / README.md
Last active November 21, 2022 21:30
Simple cellular-automata-based liquid flow simulation, implemented in SQL

Simple cellular-automata-based liquid flow simulation, implemented in SQL

Loosely based on https://www.reddit.com/r/cellular_automata/comments/6jhdfw/i_used_1dimensional_cellular_automata_to_make_a/. The SQL code in fluid.sql should work with any contemporary version of PostgreSQL.

  1. In fluid.sql, uncomment one of the few initial fluid container scenarios (they start with \COPY input(cells) FROM stdin). A sample container has already been uncommented for you. Feel free to create your own.

  2. Run the SQL code, e.g., via

-- A custom base type 'wildcard' that returns true on < comparisons,
-- no matter what. Otherwise acts like a 4-byte integer.
DROP TYPE IF EXISTS wildcard CASCADE;
CREATE TYPE wildcard;
CREATE FUNCTION wildcard_in(s cstring) RETURNS wildcard
LANGUAGE internal IMMUTABLE AS 'int4in';
CREATE FUNCTION wildcard_out(d wildcard) RETURNS cstring
LANGUAGE internal IMMUTABLE AS 'int4out';
@Teggy
Teggy / bricks.alg
Last active January 17, 2020 16:35
U Tübingen LEGO database in RelaX format
group: LEGO database
description[[The U Tübingen LEGO database]]
bricks = { piece:string, type:string, name:string, cat:number, weight:number, img:string, x:number, y:number, z:number
"87749","B","Lower Body with Tentacles","20","4.07","http://www.bricklink.com/PL/87749",NULL,NULL,NULL
"wampa","B","Wampa, Complete Assembly","147","31.33","http://www.bricklink.com/PL/wampa",NULL,NULL,NULL
"90981","B","Spider Web, Hanging","86","1.51","http://www.bricklink.com/PL/90981",NULL,NULL,NULL
}
@Teggy
Teggy / NaSchl.sql
Last active February 18, 2019 14:20
Traffic flow simulation based on a simple cellular automaton
-- Traffic flow simulation based on a simple cellular automaton
--
-- Based on a 1992 model by Kai Nagel and Michael Schreckenberg (NaSch),
-- also see:
-- http://www.christophschuette.com/blog/?p=50
-- http://www.thp.uni-koeln.de/~as/Mypage/traffic.html
-- Car model:
-- - ID: c
-- - position: x
-- Tupper's self-referential formula
--
-- Plot points x ∈ [0,106), y ∈ [k, k+17) for which
-- ½ < ⌊mod(⌊y/17⌋ × 2^(-17 × ⌊x⌋ - mod(⌊y⌋, 17), 2)⌋
-- holds.
--
-- The plotted image contains a representation of the formula itself:
--
-- █ █ █ ██ █ █ █ █ █ █ █ ██ █ █ █
-- █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █
@Teggy
Teggy / diagram-vs-Unicode.md.html
Created May 23, 2017 14:22
Unicode characters beyond the BMP confuse Markdeep's diagrams
The bold capital Sigma (U+1D6BA) in the diagram below will not
be rendered. Since it occupies two indices in the extracted
diagram string, grid width computation is off by one (see the
spurious `*` rendered in the resulting document):
*******
* x𝚺x *
* xxx *
*******
@Teggy
Teggy / regression.md.html
Created May 12, 2017 14:58
SVG regression in Markdeep v0.19?
************
* o *
* / *
* / *
* o *
************
@Teggy
Teggy / four-solutions-to-a-trivial-problem.hs
Last active September 23, 2022 21:44
A Haskell "transcript" of Guy Steele's talk "Four Solutions to a Trivial Problem" (https://www.youtube.com/watch?v=ftcIcn8AmSY)
{-# LANGUAGE TypeSynonymInstances #-}
import Data.Monoid
import Data.Maybe
-- How much water does a "histogram" hold?
--
-- Inspired by Guy Steele's talk "Four Solutions to a Trivial Problem"
-- https://www.youtube.com/watch?v=ftcIcn8AmSY

Keybase proof

I hereby claim:

  • I am Teggy on github.
  • I am teggy (https://keybase.io/teggy) on keybase.
  • I have a public key whose fingerprint is A3B0 BC48 CA26 C3C1 0666 2837 E60A A49E 46AF 1FDF

To claim this, I am signing this object:

@Teggy
Teggy / init.js
Created October 9, 2012 11:17
Live LaTeX previewing with Chocolat and Skim.app
/*!
* Experimental Chocolat mixins
* Copyright(c) 2012 Torsten Grust <torsten.grust@gmail.com>
*/
var fs = require('fs');
var path = require('path');
var spawn = require('child_process').spawn;
var flashLaTeX = require('./tex.js').flashLaTeX;