This file contains hidden or 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
export const assignDeep = (input, regex, replacer) => { | |
const json = JSON.stringify(input) | |
return JSON.parse(json, (k, v) => | |
typeof v === "string" && regex.test(k) ? replacer(v) : v | |
) | |
} | |
export const redactDeep = (input, regex) => | |
assignDeep(input, regex, () => "[REDACTED]") |
This file contains hidden or 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 { mergeWith, isNil } from "lodash" | |
var existing = { | |
a: 1, | |
b: 2, | |
d: { | |
a: 1, | |
b: [], | |
c: { test1: 123, test2: 321 } | |
}, |
This file contains hidden or 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
#!/bash/bin | |
# Recursively find all occurences of X in all *.js files excluding node_modules | |
egrep -lir --include=*.js "X" --exclude-dir="node_modules" . |
This file contains hidden or 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
export const COUNTRY_CODES = { | |
AF: "Afghanistan", | |
AL: "Albania", | |
DZ: "Algeria", | |
AS: "American Samoa", | |
AD: "Andorra", | |
AO: "Angola", | |
AI: "Anguilla", | |
AQ: "Antarctica", | |
AG: "Antigua and Barbuda", |
This file contains hidden or 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
# recurisvely remove lines containing // @ts-check from all javascript files in current directory | |
find . -type f -name "*.js" -print0 | xargs -0 sed -i '' -e '/@ts-check/d' |
This file contains hidden or 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
redis-cli --scan --pattern "myprefix:*" | tr \\n \\0 | xargs -0 redis-cli unlink |
This file contains hidden or 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
git clone https://github.com/otherusername/some-awesome-repo.git | |
# make changes, commit as needed | |
git remote set-url origin https://github.com/myusername/myforkedrepo.git | |
git push | |
~done~ |
This file contains hidden or 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
// only one job is added despite removeOnComplete: true | |
import { Queue, QueueScheduler, Job, Worker } from "bullmq" | |
const now = () => `[${new Date().toISOString()}]` | |
const queue = new Queue("Paint", { | |
defaultJobOptions: { | |
removeOnComplete: true, | |
}, | |
}) |
This file contains hidden or 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 IORedis from "ioredis" | |
import { Queue, QueueScheduler, Job, Worker } from "bullmq" | |
const main = async (): Promise<void> => { | |
const qs = new QueueScheduler("Paint", { | |
connection: new IORedis(), | |
}) | |
const qPaint = new Queue("Paint", { | |
connection: new IORedis(), | |
defaultJobOptions: { |
This file contains hidden or 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 | |
if [[ -z "$1" || -z "$2" ]] | |
then echo -e "Usage: clone-collection.sh <db> <collection>"; exit 1 | |
fi | |
# clones a mongodb collection and its indexes into __collection__ | |
mongodump -v -d $1 -c $2 --out=- | mongorestore -v -d $1 -c __$2__ --drop --dir=- |