Skip to content

Instantly share code, notes, and snippets.

making dreams

Alex Evans mmalex

making dreams
Block or report user

Report or block mmalex

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View midi2osc.cpp
quick midi 2 osc hack by @mmalex, use at your own risk etc
reads midi messages, forward them to osc messages on your network.
barely tested but works for me in windows 7, compiled with msvc 2015 sp2
stick a midi2osc.ini file in the same folder as the exe to configure it, with lines like these:
mmalex / base85_test.cpp
Created Jul 28, 2015
example for @ocornut of encoding groggy clean as a base85 string
View base85_test.cpp
const char *font_85 =
View gist:7917083
the redis feedback thread has been interesting, and I share many of antirez's 'tastes' when it comes to wanting to create pragmatic software that is 'robust enough' for many use cases. OTOH I do think that redis is in an interesting place regarding how its users view (and potentially misinterpret) its data 'promises' , especially in cluster
I just wanted to give an example in case it is a useful datapoint in the spectrum being discussed for redis (pure memory store vs evolving into a disk cluster that might or might not make CP claims...)
TL;DR difference from redis cluster: I basically wanted not to have the distinction of master vs slave, and all the complexity that brings (having to do elections, split brain, etc) and instead build everything around merging between symmetrical peers - ie every node is equal, and they merge their differences on (re)connection. I think it's a really powerful paradigm, and not one that I've seen antirez talk much about with respect to redis. if you're interested in
View gist:7663290
// sillycocg.cpp : disgusting test code. loads a 320x180 rgb image from input.raw
// writes out a (fixed) photoshop-style 3 bytes per index palette file to ycocg.act
// you can load this in photoshop via image/mode/index then image/mode/color-table.../load...
// then it writes out an 8bpp indexed image to output.raw
// its kinda a hindsight is 2020 thing, the old 'fake truecolor' demos that did RGB stripes/
// patterns - I wondered what it would be like to do something like
// but 15 years ago in 256 color mode, so you compute 2 channels per pixel instead of 3,
// and those channels are Y and one of Co or Cg; then you alternate Co/Cg in a checkerboard
// and pack 4 bits y, 3 bits chroma, 1 bit checkerboard switch.
mmalex / gist:2660905
Created May 11, 2012
notes on symmetric 3x3 matrix maths
View gist:2660905
// symmetric matrix stuff
// not heavily tested but should be about right
// hlsl notation
// thanks to @rygorous @m1k3 and mark adami for help
// mostly just a big geek out :)
// multiply e by the 3x3 symmetric 3x3 matrix fromed from d on the diagonal and u in the upper triangle
float3 mul_sym3x3(float3 d, float3 u, float3 e)
return float3(dot(e,float3(d.x,u.z,u.y)), // u=(yz,xz,xy) in the case of covariance matrix
mmalex / gist:1219860
Created Sep 15, 2011
untest implementation of @deplinenoise's amiga checksum
View gist:1219860
#include <stdio.h>
#include <arpa/inet.h> // for htonl
int main(int argc, char **argv){
unsigned int c=0,d,i,block[256]={0};
for (i=0;i<256;++i)
if (c > (d=c+htonl(block[i]))) c=d+1; else c=d;
return 0;
mmalex / pngencode.cpp
Created Apr 7, 2011 — forked from anonymous/pngencode.cpp
bug fix png encoder
View pngencode.cpp
// by alex evans, 2011. released into the public domain.
// based on a first ever reading of the png spec, it occurs to me that a minimal png encoder should be quite simple.
// this is a first stab - may be buggy! the only external dependency is zlib and some basic typedefs (u32, u8)
// VERSION 0.02! now using zlib's crc rather than my own, and avoiding a memcpy and memory scribbler in the old one
// by passing the zero byte at the start of the scanline to zlib first, then the original scanline in place. WIN!
// more context at
// follow me on twitter @mmalex
You can’t perform that action at this time.