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
class CustomOverlay { | |
constructor() { | |
this.overlay = new google.maps.OverlayView(); | |
this.overlay.onAdd = () => this.onAdd(); | |
this.overlay.onRemove = () => this.onRemove(); | |
this.overlay.draw = () => this.draw(); | |
} | |
onAdd() { /* ... */ } | |
onRemove() { /* ... */ } | |
draw() { |
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
console.clear(); | |
const DAY = 16; | |
const DEBUG = false; | |
const INPUT_URL = `https://adventofcode.com/2021/day/${DAY}/input`; | |
const testInput = `A0016C880162017C3686B18A3D4780`.trim(); | |
const tests = { | |
literal: () => { |
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> | |
<body><script src="index.js" type="module"></script></body> |
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
LAST_PWD="" | |
LAST_NPM_BIN="" | |
# find the npm binary path for a given directory ($1). | |
# Mostly equivalent to calling `npm bin` (except it doesn't report | |
# non-existing directories), but around 40x faster. | |
function fastNpmBin() { | |
local dir="${1}" | |
local candidate="" |
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
function extractScriptContent(root) { | |
return Array.from(root.querySelectorAll('script:not([src])')) | |
.filter(el => !el.type || el.type.endsWith('javascript')) | |
.reduce((result, el) => { | |
el.parentNode.removeChild(el); | |
return result + el.textContent; | |
}, ''); | |
} | |
function extractCssContent(root) { |
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
LAST_PWD="" | |
LAST_NPM_BIN="" | |
# find the npm binary path for a given directory ($1). | |
# Mostly equivalent to calling `npm bin` (except it doesn't report | |
# non-existing directories), but around 40x faster. | |
function fastNpmBin() { | |
local dir="${1}" | |
local candidate="" | |
while [ "${dir}" != "/" ] ; do |
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
/** | |
* A fivetwelve-driver for the enttec usbopen-interface. | |
* | |
* @example | |
* import fivetwelve from 'fivetwelve'; | |
* import Serialport from 'serialport'; | |
* import EnttecUsbOpenDriver from 'fivetwelve-driver-enttec-usbopen'; | |
* | |
* // I read somewhere that connection settings like baudrate etc are not | |
* // required as it's just a virtual serialport or something like that |
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
# add this to your .bashrc to add `npm bin` dynamically to your path (works with bash > 4): | |
function command_not_found_handle() { | |
npmBinDir=`npm bin` | |
if [ -x "$npmBinDir/$1" ] ; then | |
"$npmBinDir/"$@ | |
else | |
echo "$1: command not found" >&2 | |
( exit 127 ) | |
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
function makeLessCrappy(crappyData) { | |
const entries = crappyData.feed.entry; | |
const data = []; | |
const tmp = entries.map(entry => ({ | |
address: entry.id.$t.replace(/.*\/R(\d+)C(\d+)$/, '$1,$2').split(',').map(Number), | |
content: entry.content.$t | |
})); | |
tmp.forEach(({address, content}) => { |
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 DEFAULT_OPTIONS = { | |
universeMapping: {1: 1, 2: 2} | |
}; | |
const API_KEY = 0xC8D088AD; // taken from qlc+ | |
const labels = { | |
SEND_DMX_PORT1: 0x06, | |
SEND_DMX_PORT2: 0xA9, | |
SET_API_KEY: 0x0D, | |
SET_PORT_ASSIGNMENT: 0xCB |
NewerOlder