Skip to content

Instantly share code, notes, and snippets.

benfoxall /
Last active Aug 8, 2022
Reset MAC address (for rejoining time-limited wifi)
# turn off wifi
sudo /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -z
# set mac address to random value
NEW_MAC=`openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//'`
sudo ifconfig en0 lladdr $NEW_MAC
View demo.html
<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
benfoxall / extract-functions.js
Last active Jan 29, 2022
Extract functions from js source code
View extract-functions.js
import { opendir, readFile } from 'fs/promises';
import { join } from 'path'
import * as parser from "@babel/parser";
import _traverse from "@babel/traverse";
const traverse = _traverse.default;
for await (const file of allFiles('javascript')) {
if (file.endsWith('.js')) {
const buffer = await readFile(file)
benfoxall /
Last active Mar 31, 2022
Generate video of satellite imagery
# Extract frames from GEOS Image Viewer to generate a video
mkdir -p images output
curl $BASE \
| grep -o -e "\".*GEOCOLOR-$DIM.jpg\"" \
View favicon.js
const set = favicon()
function favicon() {
const link = document.createElement('link')
link.rel = 'icon'
benfoxall / emoji.js
Created May 17, 2021
Function for parsing emoji sequences
View emoji.js
export function* emojiList(sequences) {
const LINES = /^[0-9A-F\.\ ]*;/mg;
const TRAILER = /\W+;$/;
const RANGE = /(.*)\.\.(.*)/;
for (const line of sequences.match(LINES)) {
benfoxall / unicorn-draw.html
Created May 15, 2021
A page for drawing on the Pi Pico Unicorn Pack over WebUSB –
View unicorn-draw.html
pico serial
body {
font-family: sans-serif;
display: flex;
View 🍅.py
## Hacky pomodoro script for pi pico
from math import floor
import picounicorn
from machine import Pin, Timer
w = picounicorn.get_width()
benfoxall / gifsize.js
Created Jan 16, 2021
Find the size of a gif by requesting only 4 bytes
View gifsize.js
await gifsize('')
// > {width: 500, height: 247}
async function gifsize (url) {
const result = await fetch(url, {headers: {Range: 'bytes=6-9'}})
const [width, height] = new Uint16Array(await result.arrayBuffer())
return {width, height}
View vis.js
class AudioVis {
constructor() {
this.analyser = = new Uint8Array()
this.frequencies = new Uint8Array()
populateArrays() {