Skip to content

Instantly share code, notes, and snippets.

View corentinbettiol's full-sized avatar

Corentin Bettiol corentinbettiol

View GitHub Profile
@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!

#!/usr/bin/env bash
# journal.sh
# ==========
#
# One daily text file to rule them all.
#
# Copyright: 2022 Tyler Cipriani <tyler@tylercipriani.com
# License: GPLv3
set -euo pipefail
@pmoranga
pmoranga / .pre-commit-config.yaml
Last active February 28, 2024 11:14 — forked from skwashd/pre-commit
Git pre-commit hook that blocks commits for files that contain swear words.
## Example using https://pre-commit.com/
repos:
- repo: local
hooks:
- id: dontship
name: DONTSHIP check - Block words
entry: '\bdie\b'
language: pygrep # https://pre-commit.com/#pygrep
types: [php]
@frabert
frabert / COPYING
Last active December 21, 2023 13:35
Favicons for HN
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
@huytd
huytd / wordle.md
Last active March 17, 2024 20:51
Wordle in less than 50 lines of Bash

image

How to use:

./wordle.sh

Or try the unlimit mode:

@cb109
cb109 / visualize_django_template_include_hierarchy_with_graphviz.py
Last active December 21, 2021 17:06
Visualize Django Template Include Hierarchy with Graphviz
"""Point script at Django template name and output DOT text describing the includes.
Starting template name must be something relative like
'myapp/mysubfolder/template_1.html'. The script will follow the inputs and output a text like:
digraph G {
node [shape="rectangle"];
"myapp/mysubfolder/template_1.html" -> "myapp/mysubfolder/template_2.html";
"myapp/mysubfolder/template_2.html" -> "myapp/mysubfolder/template_3.html";
...
@cherrerajobs
cherrerajobs / README.md
Last active January 12, 2024 15:46 — forked from rebane2001/README.md
Tiny js code that will simulate a 3D view of your elements, like firefox used to do.

The original and fork did not work in Brave. Every year we stray further from the light of 3D visualized DOMs. Use the new modified,minified, and fixified code below.

Explanations

This script will get the computed background color of your body, and then will create shadows darker than your background (if you have a light background), or lighter than your background (if you have a dark background). If the body does not have a background, the script will take 160 as the default value for red, green and blue.

It will then add a border, a box-shadow, a padding and a margin to each element of your page, and will use the cool rotate3d css function to tilt your website.

Install

@linkdd
linkdd / hackernews-new-comms.js
Last active September 20, 2021 22:52
Add a bell emoji to unread comments on HackerNews
// Can be used with https://github.com/xcv58/Custom-JavaScript-for-Websites-2
// This snippet is released under the terms of the CC0 license: https://creativecommons.org/publicdomain/zero/1.0/deed.en
const cache_key = 'hn_comments_views'
const cache = JSON.parse(localStorage.getItem(cache_key) || '{}')
document.querySelectorAll('.athing.comtr').forEach(comm => {
if (!cache[comm.id]) {
const span = document.createElement('span')
span.innerHTML = '&#x1f514;' // :bell: emoji
@michalc
michalc / sqlite.py
Last active April 3, 2024 17:26
Use libsqlite3 directly from Python with ctypes: without using the built-in sqlite3 Python package, and without compiling anything
# From https://stackoverflow.com/a/68876046/1319998, which is itself inspired by https://stackoverflow.com/a/68814418/1319998
from contextlib import contextmanager
from collections import namedtuple
from ctypes import cdll, byref, string_at, c_char_p, c_int, c_double, c_int64, c_void_p
from ctypes.util import find_library
from sys import platform
def query(db_file, sql, params=()):
@kepano
kepano / obsidian-web-clipper.js
Last active April 18, 2024 20:47
Obsidian Web Clipper Bookmarklet to save articles and pages from the web (for Safari, Chrome, Firefox, and mobile browsers)
javascript: Promise.all([import('https://unpkg.com/turndown@6.0.0?module'), import('https://unpkg.com/@tehshrike/readability@0.2.0'), ]).then(async ([{
default: Turndown
}, {
default: Readability
}]) => {
/* Optional vault name */
const vault = "";
/* Optional folder name such as "Clippings/" */