Skip to content

Instantly share code, notes, and snippets.

@luser-dr00g
luser-dr00g / xcr.c
Created August 30, 2014 09:35
xcb+cairo hello world window
//xcr.c
//cc -o xcr $(pkg-config --cflags --libs cairo xcb xcb-icccm) xcr.c -lcairo -lxcb -lxcb-icccm
#include <stdlib.h>
#include <string.h>
#include <cairo.h>
#include <cairo-xcb.h>
#include <xcb/xcb.h>
#include <xcb/xcb_image.h>
#include <xcb/xcb_aux.h>
#include <xcb/xcb_icccm.h>
@luser-dr00g
luser-dr00g / stars.ps
Created August 30, 2014 09:30
my god! it's full of stars
/starpath { % n r1 r2 x y
matrix currentmatrix 6 1 roll % [] n r1 r2 x y
translate % [] n r1 r2
10 dict begin {/r2 /r1 /n} {exch def}forall % []
/da 360 n div def
r2 0 moveto
n {
@luser-dr00g
luser-dr00g / labels.pl
Created August 2, 2014 10:11
perl/postscript csv->avery labels
#!/usr/bin/perl
# labels.pl reads csv records in the form:
# "Name","123 Street","Apt","City, ST ZIP"
# from a file named "addr.csv" and
# produces a postscript program on stdout
# suitable for piping into ps2pdf or
# even distiller, maybe
# CAVEATS: prototype produces at most
# one page. label and sheet sizes are hard-coded
# at 3 3-inch-width labels which are 4*17 points
@luser-dr00g
luser-dr00g / L.c
Last active August 29, 2015 13:57
Lukasiewicz Logic Intepreter in C.
//http://www.ams.org/journals/mcom/1954-08-046/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
enum { LOW = -10000, HIGH = 10000 };
char *P = "01";
%1 http://www.ams.org/journals/mcom/1954-08-046/
/init{
P{ %check P for validity
W 1 ne {ERROR:W_p!=1} if
}forall
/Ptab <<
P {
dup
} forall
@luser-dr00g
luser-dr00g / apl2.ps
Last active August 29, 2015 13:57
revision/simplification of apl.ps
%apply unary proc to array. ie. proc implements a monadic operator
/mop{ % A proc
1 index type /arraytype eq {
[ 3 1 roll % [ A proc
exch % [ proc A
{ % [ ... proc A_i
1 index op % [ ... proc A_i'
exch % [ ... A_i' proc
}forall
@luser-dr00g
luser-dr00g / apl.ps
Last active August 29, 2015 13:57
APL-like calculations in Postscript. Intended to help (me, a human) interpret the J and APL answers to http://codegolf.stackexchange.com/questions/12103/generate-a-universal-binary-function-lookup-table
/i{[1 1 4 3 roll {} for ]}def
%10 i == %[1 2 3 4 5 6 7 8 9 10]
/+{
dup type /arraytype eq { % ? []
1 index type /arraytype eq { % [] []
2 copy length exch length ne {
2 copy length exch length exch lt { exch } if % now nA > nB
2 copy length exch length exch sub % A B nA-nB
[ 3 2 roll % A nA-nB [ B