Skip to content

Instantly share code, notes, and snippets.

View owencm's full-sized avatar

Owen Campbell-Moore owencm

View GitHub Profile
@owencm
owencm / blob-to-image.js
Created January 12, 2019 18:01
Convert a blob to an image with JavaScript (e.g. to render blob to canvas)
const blobToImage = (blob) => {
return new Promise(resolve => {
const url = URL.createObjectURL(blob)
let img = new Image()
img.onload = () => {
URL.revokeObjectURL(url)
resolve(img)
}
img.src = url
})
@owencm
owencm / cookie-refresh-service-worker.js
Last active March 5, 2016 00:34
A service worker that refreshes out of date cookies automatically