When executing Python natively:
$ python pystone.py
Pystone(1.1) time for 50000 passes = 0.129016
This machine benchmarks at 387549 pystones/second
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 |
## 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] |
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 |
"""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"; | |
... |
// 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 = '🔔' // :bell: emoji |
# 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=()): |
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/" */ |