Skip to content

Instantly share code, notes, and snippets.

@discretegames
discretegames / ElementaryCellularAutomata.py
Last active February 9, 2022 03:01
All 256 elementary cellular automata
# Generates an image of all 256 1-dimensional cellular automata.
from PIL import Image # from `pip install Pillow`
def ca1d(rule=90, size=5):
w, h = 2**size - 1, 2**(size - 1)
ca = [[0] * w for _ in range(h)]
ca[0][w//2] = 1
rules = [(rule >> b) % 2 for b in range(8)]
@discretegames
discretegames / default_vscode_syntax_colors.py
Last active September 15, 2021 06:19
VSCode's default "editor.tokenColorCustomizations" colors
# List and examples of the default VSCode "editor.tokenColorCustomizations" colors (in dark mode at least).
# This example is in Python but the same colors apply to any language.
# Save as a Python (.py) file in VSCode with Dark+ (default dark) color theme to view properly.
# #. Key: textMateRules scope
# 1. comments: 'comment'
# 2. strings: 'string'
# 3. keywords: 'keyword'
# 4. numbers: 'constant.numeric'
# 5. types: 'entity.name.type'
@discretegames
discretegames / TypingPractice.py
Last active April 8, 2021 20:07
Typing Practice
# Simple typing practice program where you can choose the keys to focus on. Set FOCUS on line 17.
import string
import random
import keyboard
numbers = string.digits
number_symbols = ')!@#$%^&*('
lowercase = string.ascii_lowercase
uppercase = string.ascii_uppercase
unshifted_symbols = r"`-=[]\;',./"