Skip to content

Instantly share code, notes, and snippets.

type Message struct {
type string
midiData [3]byte
sysexData[255]byte
sysexLen int
}
func NewBoard() *Board {
b := &Board{}
// Start the message loops
@alexaltair
alexaltair / Today's Learning.md
Last active December 18, 2015 17:38
An exploration of infinite lists.

The first thing that really surprised me today was the flexibility of Ruby's shovel operator, <<. A student in the class had tried the following:

a = [0]
a << a

What do you think a is now? I was sure it would be [0, [0]]. But lo and behold, Ruby sparkles;

a = [0]
a &lt;&lt; a
@tangentstorm
tangentstorm / objpas-lexer.txt
Created February 27, 2013 19:35
Lexer DFA for object pascal
[[a[nd
|rray
|s
|sm]
|b[egin]
|c[ase
|lass
|onst[
|ructor]]
|d[e[structor
@tangentstorm
tangentstorm / FORLOOP.rx
Last active December 11, 2015 11:18
Talk about "build one to throw away"
## OBERON SYNTAX TO COMPILE:
FOR x := start TO goal BY step DO
block
END;
## StringTemplate ( generating retro code ):
for_stmt(id, beg, end, step, block) ::= <<
( FOR ) <id>
@tangentstorm
tangentstorm / likstromsnat.hs
Last active October 9, 2015 02:08
a little electronics problem
{-
| a dumb little circuit simulator in haskell
| by tangentstorm, 2012/08/22
|
| This basically just calculates values using Ohm's law.
| it (probably?) only works for simple circuits where there
| is a single path from the power source to each node, and
| from each node back to the power source.
|
| many thanks to quicksilver and Axman6 on #haskell for advice
@adrian17
adrian17 / whence.ijs
Last active August 29, 2015 14:20
whence for J
whence =: verb define
select. 4!:0 < y
case. _2 do. 'invalid name'
case. _1 do. 'name not defined'
case. 0;1;2;3 do.
index =. 4!:4 < y
select. * >: index
case. 0 do. 'name defined locally'
case. 1 do. > index { 4!:3''
end.
@adrian17
adrian17 / collatz.ijs
Last active August 29, 2015 14:17
collatz fractal in J
load 'viewmat'
gen_table =: 4 : '(0j1*(i: x)) +/ i: y'
fractal =: 1 : 0
:
x u"0 (y +~ 30000 %~ 150 gen_table 150) NB. resolution and scale, not sure how to decouple them
)
collatz =: 4 %~ 2 + (7*]) - (2+5*])* 2 o. o.
is_bounded_c =: 4 : '((0: collatz^:x) :: 1:) y' NB. collatz
@adrian17
adrian17 / sudoku.ijs
Created March 5, 2015 09:24
sudoku in J (translation of APL algorithm)
s44 =: 4 4 $ 0 0 0 0 0 0 2 1 3 0 0 4 0 0 0 0
box =: (] #"1 ] # ([: i. 2 # ]))
indices =: 3 : 0
yy =. {. y
a =. yy #"0 i. yy
b =. |: a
c =. a ,/"0 b
)
@Twinklebear
Twinklebear / fragment.glsl
Last active August 29, 2015 14:00
Instanced textured quads, produces this render: https://i.imgur.com/opgHu0x.png
#version 330 core
//Sampler defaults to unit 0 which is where our texture is bound
uniform sampler2D tex;
in vec2 fuv;
out vec4 color;
void main(void){