This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// from: https://davidwalsh.name/detect-scrollbar-width | |
function getScrollbarWidth() { | |
const div = document.createElement("div") | |
div.style = ` | |
width: 100px; | |
height: 100px; | |
overflow: scroll; | |
position: absolute; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 🚨 🚨 🚨 | |
// NOTE: According to MDN, `document.execCommand()` is deprecated. See: | |
// https://developer.mozilla.org/en-US/docs/Web/API/document/execCommand | |
// Instead, use the Clipboard API: | |
// https://developer.mozilla.org/en-US/docs/Web/API/Clipboard_API | |
// 🚨 🚨 🚨 | |
function copy(text) { | |
const input = document.createElement("input") | |
input.type = "text" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function createHighDPICanvas(width, height){ | |
let dpi = window.devicePixelRatio || 1 | |
let canvas = document.createElement("canvas") | |
canvas.width = width * dpi | |
canvas.height = height * dpi | |
canvas.style.width = width + "px" | |
canvas.style.height = height + "px" | |
canvas.getContext("2d").scale(dpi, dpi) | |
return canvas | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function downloadText(filename, text){ | |
const a = document.createElement("a") | |
a.href = "data:text/plain;charset=utf-8," + encodeURIComponent(text) | |
a.download = filename | |
a.dispatchEvent(new MouseEvent("click")) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function downloadCanvasAsImage(canvas, filename){ | |
let a = document.createElement("a") | |
a.href = canvas.toDataURL() | |
a.download = filename | |
a.dispatchEvent(new MouseEvent("click")) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################## | |
Basic Git Commands | |
################## | |
git init = turns the current working directory into a repository | |
git clone = downloads a remote repository to your machine | |
Syntax: git clone <source> <destination> | |
Example: git clone https://github.com/willfind/uplift-website /home/josh/projects/uplift.app |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var n = 7; | |
var angles, speeds, lengths; | |
function setup(){ | |
createCanvas(window.innerWidth, window.innerWidth); | |
background(255); | |
fill(0, 20); | |
frameRate(9999); | |
angles = []; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var n = 4; | |
var angles; | |
var speeds; | |
var lengths; | |
function setup(){ | |
createCanvas(window.innerWidth, window.innerHeight); | |
stroke(0, 10); | |
fill(0); | |
frameRate(99999999999); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function arrangements(letters){ | |
if (letters.length == 1){ | |
return [letters]; | |
} | |
else if (letters.length == 2){ | |
return [letters[0] + letters[1], letters[1] + letters[0]]; | |
} | |
else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var x, y, z, a, b, c, dt; | |
var points; | |
function setup(){ | |
createCanvas(600, 600, WEBGL); | |
points = []; | |
x = 0.01; | |
y = 0; |
NewerOlder