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
// npm init --yes && npm i -S chalk chokidar split | |
const fs = require("fs"); | |
const { stat } = require("fs").promises; | |
const { red, cyan } = require("chalk"); | |
const chokidar = require("chokidar"); | |
const split = require("split"); | |
let config = require("./config.json"); // { okPattern: string, nokPattern: string, logFile: string } | |
try { | |
config = require("./config.user.json"); | |
} catch (err) {} |
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
// first: `npm init -- yes && npm i chalk puppeteer-core` | |
// then: `node . --help` | |
const puppeteer = require('puppeteer-core'); | |
const chalk = require('chalk'); | |
// --- | |
const ifHasParam = (s = '') => process.argv.includes(s); | |
const paramValueOf = (s = '') => (process.argv.find(x => x.startsWith(`${s}=`)) || '').split('=')[1]; | |
const DEFAULT_VIDEO_ID = '5qap5aO4i9A'; // ChillCow; his other channel is "DWcJFNfaw9c" | |
const DEBUG = ifHasParam('--debug'); | |
const SHOW_HEAD = ifHasParam('--head'); |
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
Func ToggleTaskbarAutohide($hide = False) | |
; this is the message id (from nf-shellapi-shappbarmessage documentation page at microsoft.com) | |
Local Static $ABM_SETSTATE = 0xA | |
; these two are message payloads, probably defined as constants in the dll / c lib itself | |
; a list could be found here: https://stackoverflow.com/a/44746235 | |
Local Static $ABS_AUTOHIDE = 1, $ABS_ALWAYSONTOP = 2 | |
; appbardata will be filled with the results (or prefilled with the input), | |
; the SHAppBarMessage documentation tells us how it looks: |
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 fs = require('fs'); | |
const source = require('./pinboard_export.json'); | |
const uniq = (value, index, self) => self.indexOf(value) === index; | |
let text = ''; | |
source.forEach(bkm => { | |
text += `## ${bkm.description}\n`; | |
if (bkm.extended) text += `${bkm.extended}\n` | |
text += `${bkm.href}\n` | |
if (bkm.tags) { | |
const tags = bkm.tags.split(' ').map(t => { |
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 logObject(obj) { | |
let result = JSON.stringify(obj, null, 2); | |
let hr = ''; | |
for (let i = 0; i < 80; i++) { hr += '-'; } | |
const lines = result.split('\n'); | |
result = lines.map(line => line.replace(/^(\s+)"([a-zA-Z0-9_$]*)"/, '$1$2')).join('\n'); | |
console.log(`${hr}{{{\n${result}\n}}}${hr}`); | |
} | |
function stringifyComplexObjects(obj) { |
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 bash | |
function addHook() { | |
echo -e "#!/bin/sh\n# husky" > .git/hooks/$1 | |
echo '. "$(dirname "$0")/husky.sh"' >> .git/hooks/$1 | |
chmod +x .git/hooks/$1 | |
} | |
DIRNAME="$(basename "${PWD}")" | |
if [ "${DIRNAME}" = 'server' ] || [ "${DIRNAME}" = 'client' ]; then echo "Do not run this script in the server/client subdir!"; exit 1; fi | |
if [ ! -f ./node_modules/husky/package.json ]; then echo "Project has no husky?"; exit 2; 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
#!/usr/bin/env bash | |
read -p "This will RECURSIVELY process all music files and downgrade them; are you sure? " -n 1 -r | |
echo | |
if [[ ! $REPLY =~ ^[Yy]$ ]]; then | |
[[ "$0" = "$BASH_SOURCE" ]] && exit 1 || return 1 | |
fi | |
shopt -s nullglob | |
# recursively find all music files and then convert them one by one to 128k mp3 | |
find . -type f -iname "*.mp3" -o -iname "*.flac" -o -iname "*.mpc" -o -iname "*.ogg" | while read file; do | |
cd "$(dirname "${file}")" |
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 fs = require('fs'); | |
const path = require('path'); | |
const dir = path.join(__dirname, '/../locales'); | |
fs.readdir(dir, (err, files) => { | |
files.filter(fn => /\.json$/.test(fn)).forEach(fn => { | |
fs.readFile(path.join(dir, fn), (err, s) => { | |
s = s + ''; | |
let lang = {}; | |
try { | |
lang = JSON.parse(s); |
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 bash | |
NOCOLOR='\e[0m' | |
RED='\e[0;31m' | |
GREEN='\e[0;32m' | |
YELLOW='\e[1;33m' | |
CYAN='\e[0;36m' | |
command -v ffmpeg >/dev/null 2>&1 || { echo >&2 "${RED}ffmpeg not installed!${NOCOLOR}"; exit 1; } | |
echo -e "You can select a window for ${CYAN}fixed coordinates${NOCOLOR} in 3 seconds." | |
sleep 3 | |
echo "Select window!" |
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
import i18n from 'i18next'; | |
import { initReactI18next } from 'react-i18next'; | |
import resources from '../locales/translations.json'; | |
// we disable the translation texts for dev mode so that the | |
// tests would only break if an ID is missing but not | |
// if the translation has been changed by the translators. | |
const devTranslations = Object.keys(resources['en-US'].translation).reduce((acc, key) => { | |
acc[key] = key; | |
return acc; |