These are my solutions to Advent of Code 2022. They are not meant to be readable, these are just the quickest-to-write solutions I found with plain ol' Javascript.
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
inkscape --actions "select-all;fit-canvas-to-selection;export-do;file-close" *.svg |
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
alacritty --working-directory $(DIR=$(xprop -id $(xprop -root '\t$0' _NET_ACTIVE_WINDOW | cut -f 2) 8t '\t$0' _NET_WM_NAME | cut -f 2 | grep -Po '(?<=:).*(?=")' | sed "s|^~|$HOME|"); if [ -d "$DIR" ]; then echo $DIR; else echo $HOME; fi) |
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
alias clipboard='xclip -selection c' |
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
/* System Fonts as used by GitHub */ | |
body { | |
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; | |
} | |
/* System Fonts as used by Medium and WordPress */ | |
body { | |
font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif; | |
} |
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 cursor = (() => { | |
const cursorEventTarget = Object.assign(document.createDocumentFragment(), {x: 0, y: 0}); | |
let changed = false; | |
const onmove = (e:MouseEvent) => { | |
if(cursorEventTarget.x !== e.x || cursorEventTarget.y !== e.y){ | |
cursorEventTarget.x = e.x; | |
cursorEventTarget.y = e.y; | |
changed = true; | |
} | |
}; |
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
find . -exec ffmpeg -i {} -acodec libopus -b:a 64k -n -vbr on -compression_level 10 ~/Documents/opus/{}.opus \; |
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 waitFrame = () => new Promise(requestAnimationFrame); |
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
twoExp = n => eval('0b1' + Array(n - 1).fill(0).join('')); |
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
/** Wait for the given key; if key is omitted, any key will trigger. It resolves the event. */ | |
function waitForKey(key){ | |
return new Promise(resolve => { | |
var onkeydown = e => { | |
if(typeof key === 'undefined' || e.key === key){ | |
document.removeEventListener('keydown', onkeydown); | |
resolve(e); | |
} | |
}; | |
document.addEventListener('keydown', onkeydown); |
NewerOlder