Skip to content

Instantly share code, notes, and snippets.

View nst's full-sized avatar

Nicolas Seriot nst

View GitHub Profile
@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.
%!PS
% Nicolas Seriot
% 2025-03-24
<< /PageSize [300 300] >> setpagedevice
/datetime (%Calendar%) currentdevparams def
/H datetime /Hour get def
/M datetime /Minute get def
%!PS
<< /PageSize [320 240] >> setpagedevice
/Courier findfont 12 scalefont setfont
/sleep { 100000 mul {} repeat } def
/x 100 def
/y 50 def
/r 15 def
@nst
nst / cube.ps
Last active March 20, 2025 10:45
/Sleep {5000000 {} repeat } def
/P 50 def
/X 250 def
/Y 200 def
% rotation angles
/a 0 def
/b 0 def