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 / rot_(5+3+8)
Last active August 29, 2015 14:02
quick sketch to figure out a general solution the rot_(5+3+8) email address type problem.
/*
index 1 2 3 4 5 6 7 8 9 1011121314151617181920212223242526
input a b c d e f g h i j k l m n o p q r s t u v w x y z
output k l m n o p q r s t u v w x y z a b c d e f g h i j
*/
void setup() {
int range = 26;
int offset = 16;
for (int indx = 0; indx < range; indx++) {
int output = (indx + offset) % range;
size(1100, 1000);
background(255);
float x, y, dia;
color c1, c2;
noStroke();
for (int i = 0; i<550; i++) {
dia = random(25, width/10);
x = random(width-dia/2+dia/2);
y = random(height-dia/2+dia/2);
c1 = color(random(20, 255), random(20, 255), random(10, 255),random(200,255));
@sspboyd
sspboyd / Angled Dashes
Last active August 29, 2015 14:24
Drawing a dashed line on an angle - when seemingly simple things turn out to be hard, math to the rescue!
// Processing is a fantastic prototyping tool for me, but every once in a while I come across something that I think should be
// super simple and turns out to be surprisingly hard. For example, drawing a dashed line. Or, drawing a dashed line on an angle!!
PGraphics angDashes;
float boxW = 300;
float boxH = boxW;
float angLineLen, angLineBuff;
int angledDashCount = 12;
void setup() {
size(500, 500);
### Keybase proof
I hereby claim:
* I am sspboyd on github.
* I am sspboyd (https://keybase.io/sspboyd) on keybase.
* I have a public key ASBQaniLXuzD1pXx9nXXVo_0EUSJ0H9-8TDSjZLm0GMkigo
To claim this, I am signing this object:
@sspboyd
sspboyd / OrderOfMagnitudeRounding.pde
Created June 5, 2019 20:11
Rounding up and rounding down to the nearest order of base 10 magnitude.
// Some example code for rounding up and rounding down to the nearest order of base 10 magnitude.
// Thanks to this thread for pointing me in the right direction
// https://stackoverflow.com/questions/7906996/algorithm-to-round-to-the-next-order-of-magnitude-in-r
void setup() {
int i = 1200;
println("i = "+ i);
println("---");
println("log(i): "+log(i));
Note Midi Frequency
C1 0 8.1757989156
Db1 1 8.6619572180
D1 2 9.1770239974
Eb1 3 9.7227182413
E1 4 10.3008611535
F1 5 10.9133822323
Gb1 6 11.5623257097
G1 7 12.2498573744
Ab1 8 12.9782717994
CREATE TABLE `user` (
`twitter_id` int(10) unsigned NOT NULL,
`created_at` timestamp NOT NULL default '0000-00-00 00:00:00',
`name` varchar(80) NOT NULL,
`screen_name` varchar(30) NOT NULL,
`location` varchar(120) default NULL,
`description` varchar(640) default NULL,
`profile_image_url` varchar(400) NOT NULL,
`url` varchar(100) default NULL,
@sspboyd
sspboyd / TotalExpenditureByAgency-2015.csv
Created July 17, 2020 14:06
UNArcTest Jupyter Notebook
Agency description Year Expenditure
Department of Peacekeeping Operations 2015 8759159000
United Nations 2015 5613139904
United Nations Children’s Fund 2015 5077601656
United Nations Development Programme 2015 5057413898
World Food Programme 2015 4893472393
Office of the United Nations High Commissioner for Refugees 2015 3278871762
World Health Organization 2015 2738660315
International Organization for Migration 2015 1594121668
Pan American Health Organization 2015 1379321927
@sspboyd
sspboyd / sketch.js
Last active October 26, 2020 13:59
P5.js Instance Mode Template
const s = (p55) => {
const PHI = (Math.sqrt(5) + 1) / 2; // I use PHI for layout ratios
const sketch_name = "sspboyd"; // put this in the index.html canvas div too!
let canvasW = 400;
let canvasH = 400;
// let copy_font;
p55.preload = () => {
// copy_font = p55.loadFont('assets/fonts/Georgia.ttf');
@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 = () => {