Skip to content

Instantly share code, notes, and snippets.

View nst's full-sized avatar

Nicolas Seriot nst

View GitHub Profile
@nst
nst / fibo_tiny.ps
Last active October 1, 2025 07:49
PostScript sample obfuscation / minimisation
% PostScript sample obfuscation / minimisation
% gs -dNODISPLAY fibo_tiny.ps
% Nicolas Seriot, 2025-09
% Based on an idea from Takashi Hayakawa
% see https://seriot.ch/projects/postscript_tiny_ray_tracer.html
/if % a
/exch % b
/dup % c
/gt % d
@nst
nst / emp_viz_1142.ps
Last active October 2, 2025 16:19
gs -sDEVICE=png16m -r300 -o emp_viz.png emp_viz_1142.ps
/!{def}def/?[(A0grBP)(B0pBPg)(C0bgBR)(D0pGRb)(E0RpgP)(F0brGP)(G0rGRb)(H0gbPR)(I0pgRP)]!/`{11}!/Helvetica findfont 16 scalefont setfont/O{( )}!/'{O " 0 4 3 d h}!/:<</R[1 0 0]/G[0 1 0]/B[0 0 1]/P[1 0 1]>>!/P{/D}!/Q{/C}!/R{/G}!/S{/B}!/T{/A}!/V{/F}!/X{/E}!/Z{aload z}!/@{repeat}!/&{dict begin}!/${count}!/+{add}!/-{sub}!/#{rectstroke}!/"{dup}!/;{div}!/*{mul}!/~{neg}!/^{gt}!/={eq}!/_{not}!/,{end}!/.{showpage stop}!/|{cvi xor}!/ifelse/moveto/lineto/roll/idiv/stroke/get/put/false/exp/for/if/translate/fill/mod/setgray/exch/rectfill/setrgbcolor/grestore/gsave/closepath/getinterval/show/rotate/pop ${O " 0 $ 93 + put exch cvx !}@/H{putinterval}!/W[128{{' cvn}}@]! W 48[10{{' cvi}}@]H W 123{z[}h W 125{z]}h/Y[9{0}@]!/U[9{i}@]!({0"`2*`2*~}{0"b``2*~c`2*0cv}{q"1g68*-32d+4o2+g}{25j|}{Pq!018{Qq!uC3o`8**C3e`8*~*mDCgRq!0"`8*`8*#`4*`-`4*6-bG02wx013{Sq!u`4*`4*mG1g68*-B-9""*+*yG2B+g":q"9""*+^{84*-}lO"043dhgZs`~`4*m9""*+^{Hr0pH#}{In0pIf}at}kt}k}{0&Pq!D9={YL.}{018{Sq!UBg_{013{Tq!X?Bg!E1A68*+hVi_!D3o0^{E3JKYD1-g1J=_{Vi!}l}lD2^{E0JKYD3-g2
@nst
nst / emp_viz_full.ps
Last active September 30, 2025 15:45
% Edge-matching puzzle solver for 3x3 grid
% Usage: gs emp_viz_full.ps
% Define 9 puzzle pieces with their edge colors
% Format: ID + rotation + 4 edge colors (top, right, bottom, left)
% Colors: lowercase/uppercase pairs must match (g matches G, p matches P, etc.)
/pieces
[(A0-grBP) % Piece A: green(top), red(right), Blue(bottom), Purple(left)
(B0-pBPg) % Piece B: purple, Blue, Purple, green
@nst
nst / emp_full.ps
Created September 18, 2025 20:40
Edge-matching puzzle solver for 3x3 grid
% Edge-matching puzzle solver for 3x3 grid
% Usage: gs -q -dNODISPLAY emp.ps
% Define 9 puzzle pieces with their edge colors
% Format: ID + rotation + 4 edge colors (top, right, bottom, left)
% Colors: lowercase/uppercase pairs must match (g matches G, p matches P, etc.)
/pieces
[(A0-grBP) % Piece A: green(top), red(right), Blue(bottom), Purple(left)
(B0-pBPg) % Piece B: purple, Blue, Purple, green
(C0-bgBR) % Piece C: blue, green, Blue, Red
% gs -q -dNODISPLAY emp_mini.ps
/d{def}def/t[(A0-grBP)(B0-pBPg)(C0-bgBR)(D0-pGRb)(E0-RpgP)(F0-brGP)(G0-rGRb)
(H0-gbPR)(I0-pgRP)]d/B[9{null}repeat]d/U[9{false}repeat]d/c{dup 97 ge{32 sub}{32
add}ifelse}bind d/gs{exch dup 1 get 48 sub 3 -1 roll add 4 mod 3 add get}d/s{0
dict begin/u exch d u 9 eq{B{0 2 getinterval print(,)print}forall stop}{0 1 8{
/i exch d U i get not{0 1 3{/r exch d/rp t i get d rp 1 r 48 add put/f true d u
3 mod 0 gt{rp 3 gs c B u 1 sub get 1 gs ne{/f false d}if}if u 3 ge{rp 0 gs c B u
3 sub get 2 gs ne{/f false d}if}if f{B u rp put U i true put u 1 add s B u null
put U i false put}if}for}if}for}ifelse end}def 0 s
@nst
nst / pk.php
Last active August 23, 2025 18:00
PassKeys demo
<?php
session_start();
$users_file = 'users.json';
$pending_file = 'pending.json';
function loadData($file) {
if (!file_exists($file)) {
return [];
}
%PDF-1.4
%ASCII
1 0 obj
<<
/Pages 2 0 R
/Type /Catalog
/Version /1.4
>>
endobj
% Nicolas Seriot, seriot.ch
% 2025-06-25
% inspired by https://nedbatchelder.com/blog/202506/math_factoid_of_the_day_63.html
/E 28 def % cube edge
/O 6 def % cube offset % g 2 mul
/S 32 def % world edge size
/space [ S S S mul mul {0} repeat ] def
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PostScript Operators</title>
<style>
body {
font-family: sans-serif;
margin: 20px;
@nst
nst / poly.ps.pdf
Last active April 6, 2025 11:27
A simple PostScript and PDF polyglot file
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.