Skip to content

Instantly share code, notes, and snippets.

View dansanderson's full-sized avatar

Dan Sanderson dansanderson

View GitHub Profile
@dansanderson
dansanderson / whichrom.py
Created September 15, 2022 05:55
Identifies the version of a given MEGA65 ROM file
#!/usr/bin/env python
import sys
PREFIX = b'\x42\x41\x53\x49\x43\x20\x36\x35\x20'
def main(args):
if len(args) != 1:
print('Usage: python3 whichrom.py mega65.rom')
@dansanderson
dansanderson / superclean.py
Created August 15, 2022 03:28
A tool for cleaning up all build-generated files in a project (SEE NOTES)
#!/usr/bin/env python3
# READ THIS BEFORE USING
# ----------------------
#
# This cleans all git-ignored files and empty directories out of a project,
# and also deletes *all* untracked files from git submodules.
#
# Use --dry-run to print what would be deleted without actually deleting.
# python3 superclean.py --dry-run
@dansanderson
dansanderson / balloon65.bas
Created May 20, 2022 22:44
A C65 version of the balloon demo program from the Commodore 64 Programmer's Reference Guide, p181
10 print"{clr}":fori=0to63:poke8128+i,0:next
20 gosub60000
999 end
60000 data" xxxxxxx "
60001 data" xxxxxxxxxxx "
60002 data" xxxxxxxxxxxxx "
60003 data" xxxxx xxxxx "
60004 data" xxxxx xxx xxxx "
60005 data" xxxxx xxx xxxxx "
60006 data" xxxxx xxx xxxx "
@dansanderson
dansanderson / balloon64.bas
Created May 20, 2022 19:56
The balloon demo program from the Commodore 64 Programmer's Reference Guide, p181
10 print"{clr}":fori=0to63:poke832+i,0:next
20 gosub60000
999 end
60000 data" xxxxxxx "
60001 data" xxxxxxxxxxx "
60002 data" xxxxxxxxxxxxx "
60003 data" xxxxx xxxxx "
60004 data" xxxxx xxx xxxx "
60005 data" xxxxx xxx xxxxx "
60006 data" xxxxx xxx xxxx "
@dansanderson
dansanderson / circles65.bas
Created May 20, 2022 19:52
A simple BASIC 65 program that draws circles, for the MEGA65
10 screen 320, 200, 5
20 for x=0 to 31
30 pen x
40 circle x*10+10, x*10+10, x*5
50 next x
60 sleep 3
70 screen close
80 color 0
90 print "{clr}{wht}have a {cyn}nice{wht} day!"
@dansanderson
dansanderson / beefinder.py
Last active May 21, 2022 07:42
Finds New York Times Spelling Bee puzzles in a word list
#!/usr/bin/env python3
#
# A tool to generate New York Times Spelling Bee puzzles from a word list.
#
# A Bee is a set of seven unique letters that can be used to form words. One
# of the letters is required to appear at least once in every word, and each
# word must be at least four letters long. Letters can be repeated. A Bee must
# have at least one word in its word list that uses all seven letters at least
# once (a "pangram").
#
@dansanderson
dansanderson / bee_saeinrt.txt
Last active December 11, 2021 03:32
New York Times Spelling Bee answers for [S] A E I N R T
New York Times Spelling Bee answers for [S] A E I N R T
airiness
aitesis
ananas
anastasis
anastate
anatase
anenst
anes
@dansanderson
dansanderson / angletest.lua
Last active November 1, 2021 00:39
Calculating the angle formed by three points in PICO-8
-- ❎ changes selected point
-- direction keys move point
function _init()
a = {x=20,y=20}
b = {x=80,y=80}
c = {x=40,y=60}
pts = {a,b,c}
sel = 1
end
@dansanderson
dansanderson / p8_devterm_printwatcher.py
Last active June 11, 2022 23:38
Prints .lua.png files exported from PICO-8 on a DevTerm
# The PICO-8 text printer for the ClockworkPi DevTerm!
#
# This Python script allows you to print text directly from the PICO-8 source
# code editor. The script runs in the background and watches for you to execute
# the "EXPORT FILE.LUA.PNG" command. It does some light processing of the
# generated image file, then sends it to DevTerm's thermal printer.
#
# This is mostly just a joke/hack for the purposes of this tweet:
# https://twitter.com/dan_sanderson/status/1434253649266364417?s=20
#
#!/usr/bin/env python3
"""
THIS SCRIPT DELETES YOUR TWEETS FROM TWITTER. Be careful! You are solely responsible for any
unintentionally lost data!
Specifically, this reads tweets from a personal data export, then deletes them from Twitter. As written,
this script deletes 1,000 tweets at a time, writing to a log file so it can start where it left off when
you run it again. This is just how I felt comfortable doing it, deleting in batches and eventually
deleting my entire Twitter history and preserve the local export data. Edit to your taste.