Skip to content

Instantly share code, notes, and snippets.

@thewhodidthis
thewhodidthis / snippet.sh
Created Feb 15, 2022
Retouch image files to reflect EXIF dates
View snippet.sh
find ./*.jpg -exec sh -c 'touch -d $$(date -j -f "%Y:%m:%d %H:%M:%S" "$$(identify -format "%[EXIF:DateTimeOriginal]" {})" +%Y-%m-%dT%H:%M:%S) {}' \;
View README.md

Poor man's static site builder

Basic,

\
redcarpet content.md |          # 1. Parse markdown
mustache - data.yaml.mustache | # 2. Save as unescaped HTML in proxy template
mustache - layout.mustache |    # 3. Fill in page layout
tidy # 4. Fix indentation
@thewhodidthis
thewhodidthis / links
Last active Feb 15, 2022
Helps extract Bookmarks.plist data into JSON
View links
View sleep.js
/*
const run = async () => {
await sleep(1000)
console.log("One")
await sleep(1000)
console.log("Two")
}
run()
*/
@thewhodidthis
thewhodidthis / index.js
Last active Aug 8, 2021
Numerical string to number convert
View index.js
// "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)
@thewhodidthis
thewhodidthis / index.js
Last active Aug 8, 2021
Super basic text diff probe via terser
View index.js
'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)
@thewhodidthis
thewhodidthis / index.js
Last active Aug 8, 2021
Find the median value in array of numbers
View index.js
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,
},
{
@thewhodidthis
thewhodidthis / index.html
Last active Apr 4, 2022
This site is down
View index.html
<!DOCTYPE html>
<html prefix="og: http://ogp.me/ns#" lang="en">
<head>
<meta charset="utf-8">
<meta name="description" content="Keep scrolling to the end of the page. ████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████">
<title>This site is down</title>
<meta property="og:image" content="https://thewhodidthis.net/000/screenshot.jpg">
<meta property="og:site_name" content="thissiteisdown.com">
<meta property="og:type" content="website">
<style>
View index.html
<!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;
@thewhodidthis
thewhodidthis / randint.js
Last active Aug 8, 2021
Towards a NumPy inspired bound random integer producer
View randint.js
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;