This file contains 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
## Hacky pomodoro script for pi pico | |
from math import floor | |
import picounicorn | |
from machine import Pin, Timer | |
picounicorn.init() | |
w = picounicorn.get_width() |
This file contains 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
await gifsize('https://media.giphy.com/media/3ornjZLITGcFQVRbxK/source.gif') | |
// > {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} |
This file contains 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
class AudioVis { | |
constructor() { | |
this.analyser = … | |
this.data = new Uint8Array(…) | |
this.frequencies = new Uint8Array(…) | |
} | |
populateArrays() { |
This file contains 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
# Requires: | |
# a) `jq` to be installed | |
# b) A Bearer token (you can grab this from the healthgraph debug console) | |
export BEARER=MY_TOKEN_FROM_THE_CONSOLE | |
curl https://api.runkeeper.com/fitnessActivities?pageSize=100 -H "Authorization: Bearer $BEARER" > page1.json | |
curl https://api.runkeeper.com/fitnessActivities?pageSize=100&page=2 -H "Authorization: Bearer $BEARER" > page2.json | |
curl https://api.runkeeper.com/fitnessActivities?pageSize=100&page=3 -H "Authorization: Bearer $BEARER" > page3.json |
This file contains 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
if(typeof document !== 'undefined') { | |
// normal script tag | |
console.log("Hello #1") | |
navigator.serviceWorker.register( | |
document.currentScript.src | |
) | |
} else { | |
// running as a service worker |
This file contains 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
importScripts('https://unpkg.com/sw-toolbox@3.6.0/sw-toolbox.js') | |
toolbox.router.get('/:path*', toolbox.cacheFirst, { | |
origin: /fonts\.(gstatic|googleapis)\.com/, | |
cache: { | |
name: 'fonts-v1', | |
maxEntries: 10 | |
} | |
} | |
) |
This file contains 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
let delayed = new Promise(r => setTimeout(r, 500, 'hello')) | |
let element = Object.assign( | |
document.createElement('div'), | |
{textContent: 'hello'} | |
) | |
Object.assign(element.style, { | |
background: 'red' | |
}) |
This file contains 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(root) { | |
Object.assign(document.body.style, { | |
'transform': 'perspective(500px) rotateY(12deg) rotateX(9deg) rotateZ(-4deg) translate3d(56%, 26%, -516px)', | |
'transform-origin': '0 0', | |
'transform-style': 'preserve-3d' | |
}) | |
const node_style = { | |
'outline': '3px solid rgba(255,0,150,0.5)', | |
'transform-style': 'preserve-3d', |
This file contains 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 data = [ { lat: -28, lng: -55, count: 38 }, | |
{ lat: 29, lng: 38, count: 2 }, | |
{ lat: 36, lng: 117, count: 2 }, | |
{ lat: -22, lng: -48, count: 511 }, | |
{ lat: 41, lng: 133, count: 1 }, | |
{ lat: 51, lng: 13, count: 88 }, | |
{ lat: -25, lng: 158, count: 1 }, | |
// .....5k lines | |
{ lat: -18, lng: -44, count: 47 }, | |
{ lat: 30, lng: 35, count: 40 }, |
This file contains 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
// includes regression | |
// https://unpkg.com/regression@1.4.0/build/regression.min.js | |
var canvas = document.createElement('canvas') | |
var ctx = canvas.getContext('2d') | |
document.body.appendChild(canvas) | |
Object.assign(canvas.style, {border:'1px solid #ccc', margin:0}) | |
var m = 1 |