Skip to content

Instantly share code, notes, and snippets.

@kurtroberts
kurtroberts / ExampleSwiftUIView.swift
Created February 27, 2024 16:16
Using a SwiftUI layout inside a UIKit View Controller
//
// ExampleSwiftUIView.swift
// Example
//
// Created by Kurt Roberts on 2/26/24.
//
import SwiftUI
struct ExampleSwiftUIView: View {
@kurtroberts
kurtroberts / README.md
Last active November 21, 2023 04:06
Understanding the math behind blend modes

Understanding the math behind blend modes

This started as a REPL session to try to understand why our Goodbeast.com colors look so much better when a friendly designer used them than when I did (other than his exceptional sense of color). I realized that he was "overlaying" them on top of themselves, effectively increasing both brightness and saturation.

This all came together as a shader, forked to start and mostly credited. https://www.shadertoy.com/view/DtKyRc

The overlay function in the javascript version can be thought of more as an "S curve" in a design program - it increases

@kurtroberts
kurtroberts / index.js
Created December 23, 2022 15:45
Create QR codes from a google sheet of URLS and save them locally
//sheet should be formatted in 2 columns: name, url
require('dotenv').config();
let { GoogleSpreadsheet } = require('google-spreadsheet'),
doc = new GoogleSpreadsheet(process.env.GOOGLE_SPREADSHEET_ID),
Bottleneck = require('bottleneck'),
limiter = new Bottleneck({
minTime: 500,
maxConcurrent: 1
}),
@kurtroberts
kurtroberts / command.sh
Created October 23, 2022 16:33
How do I make google drive stop asking to sync data from cameras and devices when I plug them in.
#!/bin/zsh
defaults write com.google.drivefs.settings PromptToBackupDevices 0
killall -v -SIGKILL Google\ Drive
open -a Google\ Drive
@kurtroberts
kurtroberts / 1-circle.js
Last active October 7, 2022 17:20
Confetti Animation Walkthrough
// Check out https://editor.p5js.org/
var a = 0,
r = 100;
function setup() {
createCanvas(600, 600);
}
@kurtroberts
kurtroberts / Splotches.fs
Created January 7, 2022 15:29
Shaders Notes
#ifdef GL_ES
precision mediump float;
#endif
uniform vec2 u_resolution;
uniform vec2 u_mouse;
uniform float u_time;
vec3 white = vec3(1.0);
@kurtroberts
kurtroberts / MySketch.vue
Created December 3, 2021 23:00
Only make vue-p5 available as a client-side component in Nuxt to avoid SSR and SSG render errors.
<!-- - components/MySketch.vue -->
<template>
<section class="sketch">
<client-only>
<VueP5
v-on="{setup, draw}">
</VueP5>
</client-only>
</section>
</template>
@kurtroberts
kurtroberts / datastoreDecorator.js
Created September 10, 2020 17:45
Amplify Datastore - Control when Sync Starts
/******
Amplify's DataStore is useful, but it is very, very immature and has some
incredibly naive implementation choices. One of those is that it will
perform synchronization on the first call to query, regardless of a call
to start.
This is an issue, because most non-trivial applications will require a
login so that the app can load appropriate content for the user in question.
@kurtroberts
kurtroberts / Bottleneck.js
Last active September 1, 2020 19:44
Strategies for meeting API Limits with Promises
const _ = require('lodash'),
Bottleneck = require('bottleneck'),
limiter = new Bottleneck({
minTime: 333,
maxConcurrent: 1
}),
Promise = require('bluebird'),
promises = [];
_.range(10).forEach(function (x) {
@kurtroberts
kurtroberts / index.js
Created July 29, 2020 17:49
Fun with browser automation
const puppeteer = require('puppeteer');
async function getLink (url, xpathExpression) {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto(url);
let link = await page.$eval(xpathExpression, anchor => { return anchor.href; });
await browser.close();
return link;
};