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
/* From Mike Bostock | |
* https://x.com/mbostock/status/1765222176641437859 | |
*/ | |
c=new AudioContext(),g=c.createGain(),o=c.createOscillator(),G=g.gain,of=o.frequency,g.connect(c.destination),G.value=0.1,G.linearRampToValueAtTime(0,1),o.connect(g),o.type="square",of.setValueAtTime(988,0),of.setValueAtTime(1319,0.08),o.start(),o.stop(1) |
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
## Pre-requisite: You have to know your last commit message from your deleted branch. | |
git reflog | |
# Search for message in the list | |
# a901eda HEAD@{18}: commit: <last commit message> | |
# Now you have two options, either checkout revision or HEAD | |
git checkout a901eda | |
# Or | |
git checkout HEAD@{18} |
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/bash | |
# Script to sync GitHub tasks with Things locally | |
# Run this script with a cron job every hour on weekdays from 8 AM to 6 PM. | |
# Commands to make it happen: | |
# > brew install jq | |
# > chmod +x script.sh | |
# > crontab -e | |
# > 0 8-18 * * 1-5 /path/to/github_to_things.sh |
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
// Core assets | |
let coreAssets = []; | |
// On install, cache core assets | |
self.addEventListener('install', function (event) { | |
// Cache core assets | |
event.waitUntil(caches.open(coreID).then(function (cache) { | |
for (let asset of coreAssets) { | |
cache.add(new Request(asset)); |
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
# Really simple using ffmeg | |
ffmpeg -i video.mov -filter_complex "[0:v] fps=12,scale=960:-1,split [a][b];[a] palettegen [p];[b][p] paletteuse" -f gif video.gif |
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 cities = [ | |
[-79.41, 43.66], // Toronto | |
[-73.58, 45.5], // Montreal | |
[-114.08, 51.08], // Calgary | |
[-75.7, 45.41], // Ottawa | |
[-63.6, 44.65], // Halifax | |
[-64.79, 46.09], // Moncton | |
[-123.13, 49.25], // Vancouver | |
[-63.13, 46.23], // Charlottetown | |
[-106.66, 52.13], // Saskatoon |
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
/** | |
* Regular expression to test string is a proper Canadian postal code. | |
* H0H H0H, H0H0H0, H0H-H0H, and h0h0h0 formats are valid. | |
*/ | |
/^[ABCEGHJ-NPRSTVXY][0-9][ABCEGHJ-NPRSTV-Z][ -]?[0-9][ABCEGHJ-NPRSTV-Z][0-9]$/i |
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
([\w,]+) ([$\w]{1,7}[.!:\?”…"']*)</(.*)>\n |
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
// Analytics | |
dataLayer.push({ | |
'event': 'Interactive', | |
'category': 'Interactive', | |
'action': 'ACTION', | |
'label': 'LABEL' | |
}); |
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 header = document.querySelector('.header'); | |
var origOffsetY = header.offsetTop; | |
function onScroll(e) { | |
window.scrollY >= origOffsetY ? header.classList.add('sticky') : | |
header.classList.remove('sticky'); | |
} | |
document.addEventListener('scroll', onScroll); |
NewerOlder