Skip to content

Instantly share code, notes, and snippets.

View nst's full-sized avatar

Nicolas Seriot nst

View GitHub Profile
@nst
nst / PostScript.plist
Last active January 24, 2024 09:39
BBEdit Language Module for PostScript
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<!--
Nicolas Seriot
2024-01-24
https://gist.github.com/nst/56744072a0f8c298f6426d7a98803e9f
-->
@nst
nst / tiny_bf.ps
Last active December 5, 2023 12:18
A tiny Brainfuck interpreter in PostScript
% A Brainfuck interpreter written in PostScript
% 2023-12-05 Nicolas Seriot https://github.com/nst/bfps
% ps2pdf bf_tiny.ps && open bf_tiny.ps
/P(+[-[<<[+[--->]-[<<<]]]>>>-]>-.---.>..>.<<<<-.<+.>>>>>.>.<<.<-.)def
/Courier findfont 12 scalefont setfont 32 740 moveto
/p 0 def/M 30000 string def/m 0 def/V{M m get}def/j P length array def 0 1 P
length 1 sub{/i exch def/c P i 1 getinterval def c([)eq{i}if c(])eq{/x exch def
@nst
nst / ttm.c
Last active May 7, 2023 19:49
A tiny Turing machine for 2-symbols Busy Beavers. No variable for state. Program is kept on input string.
// Tiny Turing machine in C
// for 2-symbols Busy Beavers
// Nicolas Seriot, 2023-05-07
#include <stdlib.h>
#include <stdio.h>
#define TAPE_LEN 50000
#define MAX_COUNT 100000000
@nst
nst / wang.py
Last active April 3, 2023 08:09
#!/usr/bin/env python3
# Nicolas Seriot
# 2023-03-31
# https://gist.github.com/nst/f9269ff6b8cadd619b9c3058868da70f
# https://seriot.ch/visualization/wang_pipes.png
import random
import cairo
%!PS
<< /PageSize [780 600] >> setpagedevice
/S 5 def % step height
% draw one face of a brick
/f {
/M exch def
/C exch def
<</PageSize[800 600]>>setpagedevice/S 5 def/f{/M exch def/C exch def/h exch def
/w exch def gsave M concat C setgray 0 0 w h rectfill 0 setgray 0 0 w h
rectstroke grestore}def/b{/H exch def/W exch def gsave W H 2 div 0.8[1 0 -1 1 0
S]f W S 1[1 0 0 1 0 0]f H 2 div S 1[-1 1 0 1 0 0]f grestore}def/U{/H2 exch def{
H 2 div neg H 2 div S add translate W H2 b}repeat}def/D{/H exch def{H 2 div H 2
div neg S sub translate W H b}repeat}def/L{/W2 exch def{W2 neg S neg translate
W2 H b}repeat}def/R{/W2 exch def{W S translate W2 H b}repeat}def/s{save}def/r{
restore}def/W 60 def/H 60 def 100 200 translate 2 30 L 2 30 D s 12 5 D 1 60 D 1
265 R 9 10 R 4 5 R r 2 30 R 1 30 U 1 60 U 1 60 R 1 60 U 5 10 R 1 30 R 1 60 R s
5 20 D s 10 5 L r s 18 5 D r 10 5 R r 10 10 R 1 60 R s 20 10 D 1 60 D 10 5 R 1
%!PS
200 200 translate/W 300 def/H 200 def/w 150 def/h 100 def/P{1 setgray 0 0 W H
rectfill 0 setgray 0 0 W H rectstroke 0 10 W{dup 0 moveto H lineto}for stroke}
def/A[1 0.6 -1 0.6 50 60]def/B[0 1 1 0.6 0 0]def/C[1 -0.6 0 1 -50 200]def/p{
gsave concat exec P grestore}def 1 0 0{}A p 0 1 0{}B p 1 0 0{0 0 W h rectclip}A
p 0 0 1{}C p 1 0 0{0 0 w H rectclip}A p 0 1 0{w 0 w h rectclip}B p showpage
@nst
nst / sq_logo.ps
Last active September 28, 2022 12:54
%!PS Swissquote logo in 3 lines 2022-09-28 Nicolas Seriot https://seriot.ch/
2.5 2.5 scale /l { lineto } def 1 0.4 0.2 setrgbcolor
(0.33# D636.:.=3# D@3@.D.D:,:,.,>8$!884 h) { 32 sub 5 mul } forall
arc fill setgray rectfill moveto l l l l l arc l l l arc l fill showpage
@nst
nst / schotter_golf.ps
Last active September 27, 2022 10:29
197 bytes one-liner version of schotter.ps https://gist.github.com/nst/696c31566a283588b7933415b3bd6aae
%!PS
100 770 translate 1 -1 scale /j{rand r mod 2 mul r sub 1 add}def 1 1 12{/c exch def 1 1 24{/r exch def gsave c 28 mul r 28 mul translate j rotate j j 28 28 rectstroke grestore}for}for showpage
%!PS
% Postscript implementation of Georg Nees "Schotter"
% Nicolas Seriot, 2022-09-20
% https://collections.vam.ac.uk/item/O221321/schotter-print-nees-georg
/COLS 12 def
/ROWS 24 def
/SIZE 28 def