Skip to content

Instantly share code, notes, and snippets.

View dobesv's full-sized avatar

Dobes Vandermeer dobesv

View GitHub Profile
{
"presets": [
"@babel/preset-typescript",
[
"@babel/preset-env",
{ "ignoreBrowserslistConfig": true, "targets": { "node": true } }
],
"@babel/react"
]
}
@dobesv
dobesv / babel-generic-func-bug_.babelrc
Last active March 6, 2019 19:23
Reproduce babel typescript bug
{
"presets": [
"@babel/preset-typescript",
[
"@babel/preset-env",
{ "ignoreBrowserslistConfig": true, "targets": { "node": true } }
],
"@babel/react"
]
}
@dobesv
dobesv / csvAsyncIterator.ts
Created February 20, 2019 19:43
Async iterator wrapper for papaparse
import Papa, { ParseConfig, Parser } from 'papaparse';
export type CsvAsyncIteratorOptions = Exclude<
ParseConfig,
'step' | 'chunk' | 'complete' | 'error'
>;
/**
* Helper to allow async iteration over the contents of
* a CSV input.
@dobesv
dobesv / dev_cert.sh
Created May 28, 2018 17:38
Script to create a local certificate authority and TLS certificate for a given domain name.
#!/usr/bin/env bash
set -x
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
NAME=${1:-localhost}
CA_KEY=$DIR/dev_cert_ca.key.pem
[ -f $CA_KEY ] || openssl genrsa -des3 -out $CA_KEY 2048
@dobesv
dobesv / dev_signed_cert.sh
Last active November 9, 2025 02:36
Script to create (1) a local certificate authority, (2) a host certificate signed by that authority for the hostname of your choice
#!/usr/bin/env bash
#
# Usage: dev_signed_cert.sh HOSTNAME
#
# Creates a CA cert and then generates an SSL certificate signed by that CA for the
# given hostname.
#
# After running this, add the generated dev_cert_ca.cert.pem to the trusted root
# authorities in your browser / client system.
#
@dobesv
dobesv / positionSuggestions.js
Created January 5, 2018 02:59
Code to position draft-js emojis plugin popup in way that it is more likely to be on-screen
const getRelativeParent = element => {
if (!element) {
return null;
}
const position = window
.getComputedStyle(element)
.getPropertyValue('position');
if (position !== 'static') {
return element;
@dobesv
dobesv / recenter-png-files.sh
Created January 27, 2017 03:25
Re-center all the pngs in the current folder using ImageMagick
#!/usr/bin/env bash
# Re-center all the pngs in the current folder using ImageMagick
for F in *.png ; do
convert -size $(identify -format '%wx%h' $F) xc:white \( $F -trim \) -gravity center -compose copy -composite $F
done
@dobesv
dobesv / gulpfile.js
Last active June 30, 2016 06:39 — forked from anonymous/gulpfile.js
Reproduce RegularExpression condition bug with new version of node (6.2.2)
var gulp = require('gulp');
var plugins = require('gulp-load-plugins')();
var del = require('del');
var merge = require('merge-stream');
var path = require('path');
var RevAll = require('gulp-rev-all');
var runSequence = require('run-sequence');
var os = require('os');
src = [
#!/usr/bin/env bash
PROJECT_DIR=$(git rev-parse --show-toplevel)
BASE_COMMIT='upstream/develop'
OLD_ERRS=$(mktemp)
NEW_ERRS=$(mktemp)
# Clean up temp files on interrupt/exit
trap "rm -f $NEW_ERRS" EXIT SIGINT