Skip to content

Instantly share code, notes, and snippets.

View dgieselaar's full-sized avatar

Dario Gieselaar dgieselaar

View GitHub Profile

Keybase proof

I hereby claim:

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

To claim this, I am signing this object:

import t from 'io-ts';
import { Request } from 'hapi';
import { PathReporter } from 'io-ts/lib/PathReporter';
import { fold } from 'fp-ts/lib/Either';
import { pipe } from 'fp-ts/lib/pipeable';
import { identity } from 'fp-ts/lib/function';
interface Params {
path?: t.HasProps;
query?: t.HasProps;
import t from 'io-ts';
import { Request } from 'hapi';
import { PathReporter } from 'io-ts/lib/PathReporter';
import { isLeft } from 'fp-ts/lib/Either';
interface Params {
path?: t.HasProps;
query?: t.HasProps;
body?: t.Any;
}
const route = createRoute({
url: '/api/metrics/:type',
method: 'GET',
params: {
path: t.type({
type: t.string
}),
query: t.type({
start: t.string,
end: t.string
import { pipe } from 'fp-ts/lib/pipeable';
import { fold } from 'fp-ts/lib/Either';
import codec from './codec.ts';
const input = {
title: 'Title of this article',
content: 'Content of this article',
options: {
private: true
}
import * as t from 'io-ts';
/*
This codec represents the following TypeScript type:
{
title: string,
content: string,
options: {
private?: boolean
}
const response = await fetch({
url: `http://localhost:5601/api/metrics/cpu`,
query: {
start: new Date().getTime() - 1000 * 60 * 60,
end: new Date().getTime() - 1000 * 60 * 60
},
method: 'GET'
});
server.route({
url: '/api/metrics/:type',
method: 'GET',
handler: ( request ) => {
const { type } = request.params;
const { start, end } = request.query;
return getMetrics({ type, start, end });
}
});
const fs = require('fs');
const path = require('path');
const { uniq, groupBy, pickBy } = require('lodash');
const beautifiedJsFile = fs.readFileSync(path.join(__dirname, './build.js'), 'utf-8');
const nodeModulesRegex = /"(.*?\/node_modules\/.*?)"/;
const findNodeModules = ( str ) => {
const lines = str.split('\n');
const RawSource = require('webpack-sources').RawSource;
class SplitCssByMediaPlugin {
apply(compiler) {
// wait until compilation becomes available
compiler.hooks.compilation.tap(
'SplitByCssMediaPlugin',
(compilation) => {
// hook into additionalAssets phase
compilation.hooks.additionalAssets.tap(