Skip to content

Instantly share code, notes, and snippets.

View hilleer's full-sized avatar

Daniel Hillmann hilleer

View GitHub Profile
@hilleer
hilleer / dynamic-object-types.ts
Last active March 12, 2024 15:08
Typescript dynamic typeof object key with type definitions for key values example
const GAMES = Object.freeze({
CSGO: {
skillLevel: 'good'
},
WOW: {
skillLevel: 'average'
}
});
type GameKey = keyof typeof GAMES;
@hilleer
hilleer / index.js
Last active October 7, 2020 14:07
Express middleware
const express = require('express');
const createHttpError = require('http-errors');
const app = express();
app.get('/foo',
middlewareOne,
middlewareTwo,
fooHandler
);
@hilleer
hilleer / addNewSecret.js
Last active May 22, 2021 11:19
Fuck up story; rotating Heroku app serets using their CLI tool
const childProcess = require('child_process');
const { promisify } = require('util');
const exec = promisify(childProcess.exec);
const DRY_RUN = true; // set to false when you want to execute it
const { NEW_SECRET } = process.env; // do not end up committing the new secret :-)
(async () => {
const { stdout: apps } = await exec('heroku apps -A --json');