Skip to content

Instantly share code, notes, and snippets.

@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 admin@fnord.local
# /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))
@garthk
garthk / luasnmp-1.0.6-2.rockspec
Last active October 29, 2015 22:06
Rockspec for luasnmp 1.0.6-2 and Lua 5.1; works with LuaJIT
package = "luasnmp"
version = "1.0.6-2"
source = {
url = "https://github.com/hleuwer/luasnmp/archive/1.0.6-2.zip",
dir = "luasnmp-1.0.6-2"
}
description = {
summary = "LuaSNMP is a binding to the netsnmp library.",
@garthk
garthk / make-supervisor-wheels.sh
Created October 8, 2015 23:47
Generate wheels for supervisord
#!/bin/sh
# Build meld3 and supervisor wheels on CentOS
# Ship wheels/*.whl
#
# Installation doc then becomes:
#
# yum install -y epel-release
# yum install -y --enablerepo=epel python-pip
# pip install meld*.whl supervisor*.whl
#
@garthk
garthk / console.log
Last active September 10, 2015 08:06
nodejs.org/dist CDN for HTTP misconfigured to redirect to the blog
[ec2-user@hostname tmp]$ sudo rm -rf node_modules/
[ec2-user@hostname tmp]$ npm install sleep
/
> sleep@3.0.0 install /tmp/node_modules/sleep
> node-gyp rebuild
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: incorrect header check
gyp ERR! stack at Zlib._binding.onerror (zlib.js:295:17)
@garthk
garthk / README.md
Last active August 29, 2015 14:27
CentOS cleanup prior to taking AMI

A CentOS image straight off the marketplace shelf boots with the instance key loaded into authorized_keys for root. We prefer ec2-user. This new /etc/rc.d/rc.local helps, along with the pre-image procedure in ready.sh.

@garthk
garthk / profile
Created June 21, 2015 23:51
boot2docker 1.7.0 cert fix
wait4eth1() {
CNT=0
until ip a show eth1 | grep -q UP
do
[ $((CNT++)) -gt 60 ] && break || sleep 1
done
sleep 1
}
wait4eth1