Skip to content

Instantly share code, notes, and snippets.

@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"
@garthk
garthk / README.md
Last active August 21, 2022 04:26
Fixing Docker on QNAP
$ export DOCKER_HOST=tcp://fnord.local:2376 DOCKER_TLS_VERIFY=1
$ docker ps
An error occurred trying to connect: Get https://fnord.local:2376/v1.21/containers/json: x509: certificate is valid for fnord, 192.168.23.23 , localhost, not fnord.local
$ ssh [email protected]
# /sbin/setcfg global realm local -f /etc/config/smb.conf
# /etc/init.d/network.sh restart
# hostname -f
fnord.local
# cd $(dirname $(readlink /etc/init.d/container-station.sh))