Skip to content

Instantly share code, notes, and snippets.

View postspectacular's full-sized avatar
🎉
Celebrating 25 years of building open source tools

Karsten Schmidt postspectacular

🎉
Celebrating 25 years of building open source tools
View GitHub Profile
@postspectacular
postspectacular / blinky.S
Created December 12, 2015 23:44
ARM blink example (ASM only)
.syntax unified
.cpu cortex-m4
.thumb
// configuration values for STM32F4x
// see: http://www.st.com/web/en/resource/technical/document/reference_manual/DM00031020.pdf
#define AHB1PERIPH_BASE 0x40020000
#define RCC_BASE AHB1PERIPH_BASE + 0x3800
#define RCC_AHB1_ENR RCC_BASE + 0x30
@postspectacular
postspectacular / sdf-voxel.clj
Last active January 5, 2016 08:25
thi.ng/geom SDF voxel isosurface meshing
(ns sdf-voxel
(:require
[thi.ng.geom.core :as g]
[thi.ng.geom.core.vector :as v :refer [vec3]]
[thi.ng.geom.voxel.svo :as svo]
[thi.ng.geom.voxel.isosurface :as iso]
[thi.ng.geom.mesh.io :as mio]
[clojure.java.io :as io]))
(defn sd-nested-sphere
@postspectacular
postspectacular / barricelli-repro.clj
Created December 30, 2015 15:31
HOLO2 - Random generated Barricelli reproduction function
;; pretty printed randomly generated reproduction function
;; x = position in curr. generation
;; y = generation
;; gene = value at (x,y)
(set-cell
x y
(if (and (prob (abs-sin (* x (+ 0.70618 (/ y 4.62437)))))
(pos? (dist x y 0 (- (sq (>> y 3.39245))))))
(mod (+ (+ gene (sin (* y 0.11592)))
(* 0.05011 (+ (gene-at x y -3 0) (gene-at x y 3 0))))
@postspectacular
postspectacular / holo-ast.edn
Created January 4, 2016 09:07
HOLO2 genetic programming demo AST (unoptimized)
;; random example program AST
;; fixed target threshold 25, fixed rotation 45 deg
[[if-target 25
[[mov 15]
[mov 15]
[mov 17]
[turn 45]
[mov 17]
[turn 45]
[turn 45]]
@postspectacular
postspectacular / holo2-ast-peephole.edn
Created January 4, 2016 09:17
HOLO2 genetic programming demo AST (peephole optimization)
;; random example program AST (w/ peephole optimization)
;; fixed target threshold 25, fixed rotation 45 deg
;; unoptimized version: https://gist.github.com/postspectacular/f421037929be75ee7e4e
[[if-target 25
[[mov 47]
[turn 45]
[mov 17]
[turn 90]]
[[if-target 25
[[mov 10]
@postspectacular
postspectacular / holo-path-ast.clj
Last active January 4, 2016 16:12
HOLO2 path finding GP agent & AST generator
(ns hologp.path
(:require
[thi.ng.geom.core :as g]
[thi.ng.geom.core.vector :as v]
[thi.ng.math.core :as m]))
(def config
{:mov [10 20]
:turn [45 45]
:if-target {:non-empty 0.2
@postspectacular
postspectacular / ra.html
Last active January 11, 2016 02:12
242 chars (original author @ra) - I've done further optimizations to bring size down from 261
<canvas><script>T=Math;S=T.sin;Q=T.cos;N=(M=75)*2;C=(V=document.all[3]).getContext("2d");a=b=d=1.8;c=.3;setInterval(function(){V.height=300;x=y=i=1e4;a-=1/N;while(--i)C.fillRect((t=x,x=S(a*y)-Q(b*x))*M+N,(y=S(c*t)-Q(d*y))*M+N,1,1)})</script>
@postspectacular
postspectacular / tjunctions.clj
Last active March 4, 2016 21:24
T-Junction mesh repair for thi.ng/geom (0.0.908)
(ns tjunctions
(:require
[thi.ng.geom.core :as g]
[thi.ng.geom.core.utils :as gu]
[thi.ng.geom.line :as l]
[thi.ng.geom.gmesh :as gm]
[thi.ng.math.core :as m]))
(defn- edges-without-v
"Takes gmesh and vertex, returns lazyseq of all edges NOT related to v."
@postspectacular
postspectacular / main.c
Last active April 25, 2019 22:13
Simple double buffer manager for STM32
static Screen *screen;
int main(void) {
HAL_Init();
SystemClock_Config();
screen = ct_screen_init();
while (1) {
ct_screen_flip_buffers(screen);
// put normal drawing code here...
// particle system structs
typedef struct {
float x,y,z;
} Vec3;
typedef struct {
Vec3 pos; // 12 bytes
Vec3 vel; // 12 bytes
Vec3 col; // 12 bytes