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
// Adapted from, | |
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/loadedmetadata_event | |
async function getBlobDuration(blob) { | |
const buffer = document.createElement('video') | |
const result = new Promise((resolve, reject) => { | |
buffer.onerror = reject | |
buffer.onloadedmetadata = () => { | |
resolve(buffer.duration) | |
} | |
}) |
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
#!/usr/bin/env node --use-strict | |
const path = require('path') | |
const { exec, execSync } = require('child_process') | |
const { readdir } = require('fs') | |
const bento4 = require('bento4-installer') | |
const assets = path.join(__dirname, './assets') | |
readdir(assets, async (error, filesMaybe) => { |
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
const assert = require('assert'); | |
// Produce random (signed) integers from min inclusive to max exclusive | |
function randint(min = 0, max) { | |
let lo = min; | |
let hi = max; | |
if (typeof max === 'undefined') { | |
hi = lo; | |
lo = 0; |
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
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="description" content="Select all to reveal page content"> | |
<title>Select all</title> | |
<style> | |
html { | |
color: white; | |
display: flex; |
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
{ | |
"background_color": "#fff", | |
"description": "Web dev job gone south.", | |
"display": "fullscreen", | |
"icons": [ | |
{ | |
"purpose": "maskable", | |
"sizes": "192x192", | |
"src": "icon.png", | |
"type": "image/png" |
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
const assert = require('assert') | |
// I'm trusting R's built in helper for calculating expected values | |
// https://repl.it/repls/IroncladLightpinkBookmark | |
const samples = [ | |
{ | |
input: [187], | |
expected: 187, | |
}, | |
{ |
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
'use strict' | |
const { exec } = require('child_process') | |
const assert = require('assert') | |
const fs = require('fs') | |
const path = require('path') | |
const util = require('util') | |
const { minify } = require('terser') | |
const readFile = util.promisify(fs.readFile) |
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
// "1.2" -> 1.2 | |
console.assert(convert('1.2') === 1.2) | |
// " " -> " " (not a number) | |
console.assert(isNaN(convert(' '))) | |
console.assert(isNaN(convert(''))) | |
// "12a" -> "12a" (not a number) | |
console.assert(convert('12a') === '12a') | |
console.assert(isNaN(convert('12a'))) | |
// null -> null (not a number) | |
console.assert(convert(null) === null) |
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
/* | |
const run = async () => { | |
await sleep(1000) | |
console.log("One") | |
await sleep(1000) | |
console.log("Two") | |
} | |
run() | |
*/ |
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
#!/bin/sh | |
# The goal is to construct a table out of two files of an equal | |
# number of lines, one for the urls and one for the titles, which are then | |
# merged together in pairs via paste(1) and converted to JSON via python. | |
# Copy Safari's bookmarks plist somewhere temporary. | |
cp ~/Library/Safari/Bookmarks.plist /tmp/Bookmarks.plist | |
# Use the property list utility to convert the copy from binary to XML text. |