Skip to content

Instantly share code, notes, and snippets.

@p4bl0-
p4bl0- / Pure HTML TicTacToe.md
Last active November 15, 2023 15:31
Pure HTML playable TicTacToe game (no CSS nor JavaScript) in 367KB

This is an attempt to see how small a pure HTML playable TicTacToe game can be. The first script (ttt.py) generates a 560KB HTML file.

I made it in reaction to this Hacker News post: Implementing Tic Tac Toe with 170MB of HTML – No JavaScript or CSS, because my reaction to "170MB" was "wait, WAT?".

The second script (ttt_smaller.py) is an attempt to go further, by shortening IDs to maximum 2 chars rather than using 9 characters for full board descriptions as IDs. It does so by using a custom base74, because 74 + 74 × 74 = 5550 which is just above the 5478 game states that have to be represented.

This optimization allows to get down to 412KB, that is a saving of 148Ko, i.e., a 26% size-reduction!

@p4bl0-
p4bl0- / seven_segment_display.py
Created July 16, 2022 22:37
Actual example of PLY use
### Pablo Rauzy
### Compsci bachelor / 1st semester / fundamental compsci
### Lab session 1 : Seven-Segment Display
import sys
import ply.lex as lex
import ply.yacc as yacc
import pygame
###
@p4bl0-
p4bl0- / 00_readme.md
Last active October 12, 2023 09:09
A complete compiler for a simple language (in less than 150 LoC)

This project is a tiny compiler for a very simple language consisting of boolean expression.

The language has two constants: 1 for true and 0 for false, and 4 logic gates: ! (not), & (and), | (or), and ^ (xor).

It can also use parentheses to manage priorities.

Here is its grammar in BNF format:

expr ::= "0" | "1"

@p4bl0-
p4bl0- / echosrv.c
Last active February 9, 2017 00:17
Premier programme TCP : echo server simple.
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <errno.h>
int
@p4bl0-
p4bl0- / pingue.c
Created January 29, 2017 21:31
Version simplifiée de ping pour jouer avec les protocoles IP et ICMP, et avec la programmation réseau bas niveau (raw socket).
#include <stdlib.h>
#include <stdio.h>
#include <strings.h>
#include <stdint.h>
#include <unistd.h>
#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <netinet/ip_icmp.h>