Skip to content

Instantly share code, notes, and snippets.

@chrisws
chrisws / wavefunction_collapse.bas
Created February 5, 2019 10:36
Wavefunction collapse in SmallBASIC
#
# see https://robertheaton.com/2018/12/17/wavefunction-collapse-algorithm/
# https://raw.githubusercontent.com/robert/wavefunction-collapse/master/main.py
#
const kUP = [0, 1]
const kLEFT = [-1, 0]
const kDOWN = [0, -1]
const kRIGHT = [1, 0]
const kDIRS = [kUP, kDOWN, kLEFT, kRIGHT]
rem Welcome to SmallBASIC
rem see https://github.com/anvaka/atree
nmax = 19
xScale = 6
zScale = 2.5
yScale = 16
startFrom = 0
dz = 400
redSpiralShadow = createSpiral(rgb(0x66,0,0), rgb(0x33,0,0), true, 1.01)
@chrisws
chrisws / bm25.bas
Last active May 29, 2020 08:24
BM 2.5
REM SmallBASIC
REM created: 21/09/2019
REM based on the article https://burakkanber.com/blog/machine-learning-full-text-search-in-javascript-relevance-scoring/
const stop_words = ["the", "at", "in", "on"]
func stemmer(text)
return text
end
@chrisws
chrisws / a71.sh
Created July 29, 2020 21:46
Samsung A71 bloatware cleanup
#!/bin/bash
#
# USE AT YOUR OWN RISK !
#
# Based on ideas from these articles:
# https://forum.xda-developers.com/s10-plus/how-to/s10-s10-bloatware-package-list-t4054003
# https://medium.com/@kaikoenig/samsungs-bloatware-disgrace-c7d14a298ad7
#
const a_sep = 5
const numSectors = 74
const interval = 9
const a_offs = 80
const r_offs = 1
const rings = [30, 70, 110, 150, 190]
const sectors = seq(0, 360, numSectors)
const col_off = rgb(0xf5, 0xf6, 0xbd)
const col_on = rgb(0xea, 0x9c, 0x21)
const col_stop = rgb(255, 255, 255)
@chrisws
chrisws / amiga_disc.bas
Created March 7, 2021 19:58
Why was the Amiga Kickstart 1.x "Insert floppy" graphic so bad?
rem
rem Why was the Amiga Kickstart 1.x "Insert floppy" graphic so bad?
rem
rem https://news.ycombinator.com/item?id=26369057
rem https://www.youtube.com/watch?v=gXhxE4j6dm0
rem
rem The machine-language code uses a simple program stored in an array to draw
rem the different parts of the diskette, hand, and the fingers, run-time.
rem This DSL implements three commands:
rem
@chrisws
chrisws / hitomezashi.bas
Created January 12, 2022 09:24
Hitomezashi Stitch Patterns - Numberphile (Youtube)
rem see https://youtu.be/JbfhzlMk2eY
const spacing = 18
const lineColor = rgb(120, 121, 122)
txt = "this is my secret message"
alphabet = {}
word_index = 0
bit_index = 0
@chrisws
chrisws / sqr.bas
Last active November 12, 2023 23:38
We've squared the circle
rem https://youtu.be/H3xEbpnv5fo?feature=shared
rem Up and atom - We've squared the circle
rem Made for SmallBASIC https://smallbasic.github.io/
const col1 = RGB(10,255,10)
const col2 = RGB(255,10,10)
const x1 = xmax / 2
const y1 = ymax / 2
const r = 100
const buffer = 10