Skip to content

Instantly share code, notes, and snippets.

View tlbdk's full-sized avatar

Troels Liebe Bentsen tlbdk

View GitHub Profile
@tlbdk
tlbdk / throws.ts
Created January 25, 2023 21:29
Test out how stack traces are formed
/* eslint-disable no-console */
const promise = new Promise<void>((resolve, reject) => {
reject(new Error())
})
async function throwsFromPromiseOutside(): Promise<void> {
return await promise
}
const zlib = require('zlib')
const fs = require('fs')
if (process.argv.length < 3) {
console.error('./unpack.js filename')
process.exit(255)
}
let filePath = process.argv[2]
@tlbdk
tlbdk / yarncache.sh
Last active June 16, 2017 14:51
node_modules folder caching on build servers
#!/bin/bash
# set ACCESS_TOKEN with gcloud auth print-access-token
UPLOAD_URL="https://storage.googleapis.com/<project>-npmcache"
SCRIPT_PATH=$(cd `dirname ${0}`; pwd)
YARN_LOCK_HASH=`cat yarn.lock package.json|sha1sum|cut -d' ' -f1`
if [ ! -d "node_modules" ]; then
echo "Trying to extract cached yarn dump"
@tlbdk
tlbdk / mongoexport-parser.js
Last active May 16, 2017 13:08
Parse mongoexport dumps in an memory efficient way
var fs = require('fs');
// Dump your collection with: mongoexport --collection collectionname --db dbname --out output.json --query '{ "myprop": "test" }'
var stream = fs.createReadStream("output.json", {flags: 'r', encoding: 'utf-8'});
var buf = '';
var count = 0;
stream.on('data', function(data) {
buf += data.toString();
@tlbdk
tlbdk / stripNullDeepTest.js
Last active November 21, 2016 09:19
Non-recursive deep stripping on null values in two version clone/non-clone
var obj = {
a: 1,
b: null,
c: [
{
d: null,
e: 'something'
}
]
};
@tlbdk
tlbdk / keybase.md
Created November 3, 2016 17:17
keybase.md

Keybase proof

I hereby claim:

  • I am tlbdk on github.
  • I am tlbdk (https://keybase.io/tlbdk) on keybase.
  • I have a public key ASAB_oFgFvmbAFHKJIQ5SlTtdcKSJhOw2qMitqe_fQDvkQo

To claim this, I am signing this object: