Skip to content

Instantly share code, notes, and snippets.

View osteele's full-sized avatar

Oliver Steele osteele

View GitHub Profile
@osteele
osteele / ble-list.py
Last active July 13, 2022 04:49
List connected BLE devices
import asyncio
import sys
from collections import Counter, defaultdict
from io import StringIO
import asyncclick as click
from bleak import BleakClient, BleakError, BleakScanner
print_device_names = False
@osteele
osteele / pb-touch-chaser.js
Created March 2, 2022 04:21
Pixelblaze pattern: a block of lights chases around a circle while the touch sensor is touched
// While the capacitive sensor is touched, a block of light chases around the
// LED strip.
timer = 0 // ms since last position update
period = 100 // ms between position updates
hue = 0
export var center = 0 // the center of the light block
export function beforeRender(delta) {
isTouching = touchRead(T4) > .6
@osteele
osteele / TrackHeldKeys_Array
Last active November 24, 2021 05:08
Demonstrate how to keep track of held keys (array version)
/*
* This sketch demonstrates how to keep track of which keyboard keys are held
* down (pressed, and not released). Multiple keys can be held at the same time
* (if a second key is pressed before the first key is released).
*
* This is an alternative implementation of https://gist.githubusercontent.com/osteele/986252244a0e7973ca3ffe92f85fef18
* See the comments in that gist for more details.
*
* This sketch uses a `char[]` array instead of an instance of `IntList`.
* This is less efficient, because it requires a new array to be created
@osteele
osteele / TrackHeldKeys.pde
Last active November 24, 2021 05:08
Demonstrate how to keep track of currently held keyboard keys in Processing
/*
* This sketch demonstrates how to keep track of which keyboard keys are held
* down (pressed, and not released). Multiple keys can be held at the same time
* (if a second key is pressed before the first key is released).
*
* The list of currently-held keys is printed to the console each time a key is
* pressed or released.
*
* Instructions:
* 1. Run the sketch.
@osteele
osteele / npm-or-yarn.bash
Last active October 21, 2021 06:18
Bash alias to run a command in npm or yarn
# Pass arguments to whichever of npm or yarn is managing the current directory's
# workspace.
alias yn=npm/yarn
function npm/yarn() {
local package_manager # this will be initialized to yarn or npm
local dir=$(pwd)
while true; do
if [[ -f "$dir/package.json" ]]; then
if [[ -f "$dir/package-lock.json" ]]; then
@osteele
osteele / README.md
Last active June 9, 2021 11:01
GitHub Pages -> GitHub Repo bookmarklet
// Collect timings for use here: https://observablehq.com/@osteele/p5-js-pixel-manipulation-timings
// The p5.js version is here: https://openprocessing.org/sketch/1159872
PImage img;
int imgWidth = 1920;
int imgHeight = 1080;
float smoothFrameRate;
float smoothFrameTime;
@osteele
osteele / index.html
Created May 11, 2021 09:28
Center a p5 canvas within the window
<style>
canvas {
margin: auto;
position: absolute;
transform: translate(0, -50%);
top: 50%;
</style>
@osteele
osteele / sketch.js
Created May 4, 2021 00:53
CCLab Spring 2021 Exercise 13.1
let HORIZONTAL = "HORIZONTAL";
let VERTICAL = "VERTICAL";
function setup() {
createCanvas(windowWidth, windowHeight);
background(100);
let whiteColor = color(255, 255, 255);
let blackColor = color(0, 0, 0);
let redColor = color(255, 0, 0);
@osteele
osteele / sketch.js
Created December 13, 2020 10:10
emojimorse
/**
* Author: Oliver Steele
*
* Graphic design adapted from image on
* https://www.offgridweb.com/preparation/morse-code-dits-dahs-dots-and-dashes/
*/
const DOT_COLOR = "orange";
const DASH_COLOR = "#4CACE9";
let rowStrings = [