Skip to content

Instantly share code, notes, and snippets.

async function streamToString(readable: Readable) {
return new Promise((resolve, reject) => {
const chunks: string[] = [];
readable.on('data', (chunk) => {
chunks.push(chunk);
});
readable.on('end', () => {
resolve(chunks.join(''));
@robcresswell
robcresswell / .eslintrc.json
Last active July 18, 2020 21:09
TypeScript setup
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "./tsconfig.json"
},
"plugins": ["@typescript-eslint"],
"extends": [
"plugin:@typescript-eslint/recommended",
"prettier",
"prettier/@typescript-eslint"
@robcresswell
robcresswell / colors.ts
Last active June 23, 2019 07:46
Node CLI colours
export const reset = '\x1b[0m';
export const bright = '\x1b[1m';
export const dim = '\x1b[2m';
export const underscore = '\x1b[4m';
export const blink = '\x1b[5m';
export const reverse = '\x1b[7m';
export const hidden = '\x1b[8m';
export const fgBlack = '\x1b[30m';
export const fgRed = '\x1b[31m';
@robcresswell
robcresswell / ts-format.sh
Last active July 18, 2020 21:03
ts-format
#! /bin/sh
npx --quiet prettier --print-width 80 --single-quote --trailing-comma all --arrow-parens always --loglevel warn --write "**/*.ts"
@robcresswell
robcresswell / tags-field.vue
Last active May 30, 2018 11:04
An example of a "tag" form field in Vue
<template>
<div class="tags-field">
<input ref="input"
:disabled="disabled"
:id="id"
type="text"
class="form-control mb-2"
@keypress.enter.prevent
@keydown.188.prevent
@keydown.space.prevent
@robcresswell
robcresswell / clean_docker.sh
Last active April 6, 2018 10:38
Wipe Docker env
#!/bin/sh
docker stop $(docker ps -a -q) && docker system prune -af