Skip to content

Instantly share code, notes, and snippets.

@garthk
garthk / LICENSE.txt
Last active March 19, 2019 22:31
Generate an AWS CloudWatch Logs event as if an AWS Lambda executed
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
@garthk
garthk / h2o2.d.ts
Created December 17, 2018 23:59
Quick and dirty typings for h2o2 version 8.1
import { BoomError } from 'boom';
import { Request, HandlerDecorations, ResponseToolkit } from 'hapi';
import { Agent, IncomingMessage } from 'http';
import { Server, PluginPackage } from 'hapi';
import { ResponseObject } from 'hapi';
export interface ProxyHandlerOptions {
host?: string;
port?: number | string;
protocol?: 'http' | 'https';
@garthk
garthk / demo.geojson
Created August 30, 2018 01:16
@turf/buffer breaking change
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@garthk
garthk / user_main.c
Last active July 25, 2018 07:55
ESP8266_RTOS_SDK PDM ESP8266 playing 512Hz sine wave over UART
#include <stdio.h>
#include <stdint.h>
#include <esp_libc.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "rom/ets_sys.h"
#include "driver/uart.h"
#include "driver/gpio.h"
#include "esp_system.h"
@garthk
garthk / RFC2119-prelude.md
Created July 1, 2018 23:57
RFC 2119 prelude in Markdown
@garthk
garthk / ksuid.py
Created June 28, 2018 04:38
KSUID generator
"Functions for generating key-sortable unique IDs (KSUIDs)."
import os
import time
import typing
EPOCH = 1400000000 # segment.io epoch (March 5th, 2014)
DIGITS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
def timestamp_bytes() -> bytes:
@garthk
garthk / README.md
Created June 27, 2017 01:57
declaration-output-mapped-types

declaration-output-mapped-types

Demonstrates bug with declaration output of mapped types in TypeScript 2.3.4.

Usage:

  • npm install
  • npm run build
  • Observe invalid syntax in dist/index.d.ts, which needs but lacks quotes around the keys in the declaration of scopes:
@garthk
garthk / pgConfig.js
Created June 27, 2016 01:55
simplistic PostgreSQL URL parser
function pgConfig(url) {
const config = {};
let { auth, hostname, port, pathname, query } = parse(url);
let { poolSize, poolIdleTimeout } = (query || {});
if (auth) {
let [user, password] = auth.split(':');
@garthk
garthk / .gitignore
Last active June 8, 2016 02:07
TypeScript Augmentation Challenge
node_modules/
typings/
dist/
@garthk
garthk / main.go
Created January 17, 2016 23:47
could not determine kind of name for C.free
package main
// #include <stdlib.h>
// #include <unistd.h>
// #include <sys/types.h>
// #include <pwd.h>
// #include <grp.h>
import "C"
import "fmt"