Skip to content

Instantly share code, notes, and snippets.

var x, y, z, a, b, c, dt;
var points;
function setup(){
createCanvas(600, 600, WEBGL);
points = [];
x = 0.01;
y = 0;
@jrc03c
jrc03c / arrangements.js
Last active February 9, 2017 15:50
A JS function to enumerate all arrangements of some letters
function arrangements(letters){
if (letters.length == 1){
return [letters];
}
else if (letters.length == 2){
return [letters[0] + letters[1], letters[1] + letters[0]];
}
else {
@jrc03c
jrc03c / spiro.js
Created February 26, 2017 16:00
A Spirograph
var n = 4;
var angles;
var speeds;
var lengths;
function setup(){
createCanvas(window.innerWidth, window.innerHeight);
stroke(0, 10);
fill(0);
frameRate(99999999999);
@jrc03c
jrc03c / spiro2.js
Last active February 27, 2017 00:48
More spirographs.
var n = 7;
var angles, speeds, lengths;
function setup(){
createCanvas(window.innerWidth, window.innerWidth);
background(255);
fill(0, 20);
frameRate(9999);
angles = [];
@jrc03c
jrc03c / high-dpi-canvas.js
Last active March 7, 2021 23:51
Create a high-DPI-compatible canvas element
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
}
@jrc03c
jrc03c / get-scrollbar-width.js
Created July 31, 2021 21:03
Get the width of a browser scrollbar
// from: https://davidwalsh.name/detect-scrollbar-width
function getScrollbarWidth() {
const div = document.createElement("div")
div.style = `
width: 100px;
height: 100px;
overflow: scroll;
position: absolute;

Modifiers

Description Code
Reset \x1b[0m
Bright \x1b[1m
Dim \x1b[2m
Underscore \x1b[4m
Blink \x1b[5m
Reverse \x1b[7m
@jrc03c
jrc03c / working-with-luks.sh
Created May 10, 2022 17:14
working with LUKS
# assuming a partition already exists, apply LUKS formatting to it
sudo cryptsetup luksFormat /dev/whatever
# open it
sudo cryptsetup luksOpen /dev/whatever mapping_name
# format it to ext4 (or whatever)
sudo mkfs.ext4 /dev/mapper/mapping_name
# mount it
@jrc03c
jrc03c / rsync-alt-port.sh
Created June 1, 2022 12:47
Use `rsync` with alternate port
# from: https://stackoverflow.com/a/4630407
rsync -rvz -e "ssh -p <PORT>" --progress /source/path user@host:/target/path
@jrc03c
jrc03c / keybase.md
Created June 10, 2022 13:46
keybase.md

Keybase proof

I hereby claim:

  • I am jrc03c on github.
  • I am jrc03c (https://keybase.io/jrc03c) on keybase.
  • I have a public key whose fingerprint is 1033 6973 7373 5FD5 7AE9 5114 ED23 C1F4 B19A C886

To claim this, I am signing this object: