Skip to content

Instantly share code, notes, and snippets.

View sspboyd's full-sized avatar
🎯
Focusing

Stephen Boyd sspboyd

🎯
Focusing
View GitHub Profile
@sspboyd
sspboyd / math_constants.js
Created August 9, 2022 17:04
The following are a collection of mathematical constants I use in my coding/art practice. The constants are typically used to modulate the relationships between visual elements on screen or bias the selection between different options.
// Stephen Boyd, @sspboyd
// August 2022.
// The following are a collection of mathematical constants I use in virtually
// all of my coding/art practice.
// The constants are typically used to modulate the relationships between
// visual elements on screen or bias the selection between different options.
const SQR_2 = 1.4142135623730951;
const TWO_PI = 6.283185307179586;
I am attesting that this GitHub handle sspboyd is linked to the Tezos account tz1W5Mxj2FooGscWVFxfnu3tow9djuCdtndA for tzprofiles
sig:edsigtf6kii9tghrKaxC74E9BQ2BZfyyozXizVp7AxkmG9CfBWTpgrqT9XHGhSHL8TYijQaJnvq9VU9RqLRYUQkJ3fD76gk164s
@sspboyd
sspboyd / Calculate Fibonacci Sequence
Created March 19, 2022 20:53
Calculate fibonacci sequence based on two given starting numbers and up to a specified number of entries.
let fib_num = function (n0, n1, fib_idx) {
let next_num;
for (let i = 0; i <= fib_idx; i++) {
next_num = n0 + n1;
n0 = n1;
n1 = next_num;
}
console.log(`fibonacci number is: ${next_num}.`);
return next_num;
};
@sspboyd
sspboyd / Export a P5.js Canvas to an Image
Created December 10, 2021 21:51
This code makes it simple to export a lot of versions of a canvas without having to manually change the downloaded file's name so you don't overwrite it
// This code makes it simple to export a lot of versions of a canvas without having to manually
// change the downloaded file's name so you don't overwrite it.
const export_canvas = function () {
const file_name = "sspboyd"; // change this to whatever you'd prefix your image file name with
const dt = new Date(); // create a new date object representing the current time
// Parse the date object to get strings for year, month, day, hour, minute, seconds
const year = dt.getFullYear();
@sspboyd
sspboyd / .block
Created May 10, 2021 17:42 — forked from mbostock/.block
Beeswarm
license: gpl-3.0
height: 200
redirect: https://observablehq.com/@d3/beeswarm
@sspboyd
sspboyd / NHL_Player_Bios.py
Last active April 30, 2021 03:48
Python + NHL API to gather stats on every skater since 1917
import json
import time
import random
import requests
from requests.exceptions import HTTPError
api_request_limit = 100
# total_num_players = 7274 # skaters
total_num_players = 201 # only using 201 for now so that we aren't hammering the api while testing
start_index = 0
@sspboyd
sspboyd / .block
Created April 19, 2021 20:42 — forked from netzwerg/.block
D3.js Simple Template
license: apache-2.0
border: no
height: 550
@sspboyd
sspboyd / .block
Created April 18, 2021 14:04 — forked from widmerin/.block
D3.js Life in Weeks
license: apache-2.0
border: no
height: 900
Player Pos GP G A P
Nikita Soshnikov R 70 7 7 14
Wayne Primeau C 59 3 5 8
Michael Grabner L 80 9 9 18
Keith Aulie D 57 2 2 4
Richard Panik R 76 11 6 17
Andrew MacWilliam D 12 0 2 2
Roman Polak D 240 12 33 45
Mason Raymond L 82 19 26 45
Nick Spaling C 35 1 6 7
@sspboyd
sspboyd / sketch.js
Created October 28, 2020 19:51
Minimal P5.js Instance Mode template
const s = (p55) => { // using p55 to refer to the sketch - throwback to Processing megabucket era :)
// Declare some globals
let canvasW = 521;
let canvasH = 521;
p55.preload = () => {
// load any fonts, data, etc...
};
p55.setup = () => {