Skip to content

Instantly share code, notes, and snippets.

@shiffman
shiffman / sketch.js
Created May 18, 2023 15:53
Gist from VSCode Stream
let stars = [];
let factor = 100;
let speedSlider;
function setup() {
createCanvas(windowWidth, windowHeight);
speedSlider = createSlider(0, 20, 2, 0.1);
for (let i = 0; i < 500; i++) {
stars[i] = createVector(
random(-width*factor,width*factor),
@shiffman
shiffman / coding-train-2024.md
Last active May 29, 2024 20:40 — forked from dipamsen/coding-train-2023.md
Coding Train 2023 Goals and Plans

Coding Train 2024 Goals (as of May 29, 2024)

  • Nature of Code Additional videos (as challenges?)
    • Elastic Collisions (Chapter 6 reference)
    • Exercise 5.8 - image flow field
    • Exercise 5.13 - group path following
    • Dragon Curve (unfoloding) - chapter 8
    • Exercise 8.9 and 8.10 - animating / physics trees?
    • Slime Mold (related to chapter 5?)
  • ml5.js new tutorials
@shiffman
shiffman / cube3D.a
Last active August 29, 2023 15:57
AppleSoft BASIC 3D Cube
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
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
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
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 March 30, 2024 05:02
Guide for pushing p5.js sketch to GitHub

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 protected]

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
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
// 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
function pickOne(list) {
var index = -1;
var r = random(1);
while (r > 0) {
index++;
r = r - list[index].prob;
}
return list[index];
}