Skip to content

Instantly share code, notes, and snippets.

@shiffman
shiffman / cube3D.a
Last active October 1, 2022 17:59
AppleSoft BASIC 3D Cube
View cube3D.a
10 REM POKE 230,32 : REM page 1
20 REM POKE 230,64 : REM page 2
30 REM POKE 49236,0 : REM display page 1
40 REM POKE 49237,0 : REM display page 2
100 HGR:HGR2
105 W = 140 : H = 90 : SL = 50
110 TH = 0
120 SCR = 0
125 GOSUB 1000
@shiffman
shiffman / sketch.js
Created April 29, 2022 19:39
Picked via random.org
View sketch.js
function setup() {
createCanvas(400, 400);
const url = 'https://www.random.org/integers/?num=10&min=2&max=1316&col=1&base=10&format=plain&rnd=new';
loadStrings(url, gotData);
function gotData(data) {
console.log(data);
}
}
@shiffman
shiffman / wheel.txt
Last active March 4, 2022 18:12
Current list of wheel ideas
View wheel.txt
Falling Sand
K-d Tree
Fast Blur
Slime Mold
Spider Web
K-means
image stippling
Wave collapse function
Skyline Viz
Dancing Skeleton
@shiffman
shiffman / sketch.js
Created October 31, 2020 19:26
Coding Challenge 80 update
View sketch.js
function setup() {
noCanvas();
let button = createButton('start');
button.mousePressed(function() {
let speech = new p5.Speech();
let speechRec = new p5.SpeechRec('en-US', gotSpeech);
let continuous = true;
let interim = false;
speechRec.start(continuous, interim);
@shiffman
shiffman / p5-github-tutorial.md
Last active February 9, 2023 20:30
Guide for pushing p5.js sketch to GitHub
View p5-github-tutorial.md

Guide for pushing p5.js sketch folder to a new GitHub repo

If you have never used git before on your computer!

$ git config --global user.name username
$ git config --global user.email email@email.com

Commands once you create a empty repo ("skip this step") on GitHub

@shiffman
shiffman / mandelbrot.pde
Last active March 14, 2019 23:07
PI Day
View mandelbrot.pde
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.MathContext;
int digits = 11;
MathContext mc = new MathContext(digits*digits + 1);
BigDecimal c = new BigDecimal(0.25);
BigDecimal hundred = new BigDecimal(100);
BigDecimal e = BigDecimal.ONE.divide(hundred.pow(digits-1), mc);
BigDecimal z = BigDecimal.ZERO;
@shiffman
shiffman / promises.js
Last active March 28, 2018 03:51
Working on demonstrating Promises
View promises.js
// Without Promises
setTimeout(function() {
console.log('first thing');
setTimeout(function() {
console.log('then second');
setTimeout(function() {
console.log('and now the third')
}, 1000);
}, 1000)
}, 1000);
@shiffman
shiffman / poolselection.js
Created May 1, 2017 20:43
Pool Selection
View poolselection.js
function pickOne(list) {
var index = -1;
var r = random(1);
while (r > 0) {
index++;
r = r - list[index].prob;
}
return list[index];
}
View earthquake.js
// https://api.mapbox.com/styles/v1/mapbox/streets-v8/static/0,0,2/600x600?access_token=pk.eyJ1IjoiY29kaW5ndHJhaW4iLCJhIjoiY2l6MDJ0Mjk5MDQ1dzJ3bzRiM29zaW16ayJ9.guiqnHMGUq196Zxa1d3UPg
var mapimg;
var zoom = 1;
var data;
var ww = 900;
var hh = 900;
var clat = 0; //37.7749;
var clon = 0; //-122.4194;
@shiffman
shiffman / mapbox_test.js
Created December 13, 2016 22:20
Mapbox test
View mapbox_test.js
var mapimg;
var bounds;
function setup() {
createCanvas(800, 600);
angleMode(RADIANS);
var size = [800, 600];
//var center = [2.3522, 48.8566];
var center = [2.3522, 48.8566];