Skip to content

Instantly share code, notes, and snippets.

💪
I write code with my bare hands

Matt Holt mholt

💪
I write code with my bare hands
Block or report user

Report or block mholt

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mholt
mholt / keybase.md
Created Mar 29, 2014
Self-verifying on keybase is a little like talking to yourself in the mirror :)
View keybase.md

Keybase proof

I hereby claim:

  • I am mholt on github.
  • I am mholt (https://keybase.io/mholt) on keybase.
  • I have a public key whose fingerprint is 7C5D 8989 09D4 E407 20B8 1FF3 1DAA D2EB EC55 EA33

To claim this, I am signing this object:

@mholt
mholt / interface_spider.go
Created Aug 4, 2014
Crawls golang.org/pkg for interfaces and writes them to a file.
View interface_spider.go
package main
import (
"log"
"os"
"strings"
gq "github.com/PuerkitoBio/goquery"
)
@mholt
mholt / everything.go
Last active Dec 17, 2019
Implements 103 of the 114 Go 1.3 standard library interfaces
View everything.go
package interfaces
import (
"bufio"
"crypto/elliptic"
"crypto/tls"
"database/sql/driver"
"debug/dwarf"
"encoding/xml"
"fmt"
@mholt
mholt / stringscontext.go
Last active Jan 25, 2020
Functions from the 'strings' package as template actions. Feel free to copy+paste into your project as a starting point.
View stringscontext.go
// Functions from Go's strings package usable as template actions
// with text/template.
//
// This approach assumes you have some context type as a receiver,
// but if you just need the functions check out the FuncMap variant
// below.
//
// Commented functions are not deemed useful in template actions.
// Haven't actually used this, but this is one possible way of doing it.
// Another option is to fill a FuncMap with most of the strings package.
@mholt
mholt / comcast.js
Created Nov 19, 2015 — forked from Jarred-Sumner/comcast.js
Comcast injects this into webpages to show copyright notices
View comcast.js
// Comcast Cable Communications, LLC Proprietary. Copyright 2014.
// Intended use is to display browser notifications for critical and time sensitive events.
var _ComcastAlert = (function(){
return {
SYS_URL: '/e8f6b078-0f35-11de-85c5-efc5ef23aa1f/aupm/notify.do'
, dragObj: {zIndex: 999999}
, browser: null
, comcastCheck: 1
, comcastTimer: null
, xmlhttp: null
@mholt
mholt / runit-caddy.md
Created Dec 2, 2015 — forked from tgulacsi/runit-caddy.md
Using runit as a supervisor for Caddy
View runit-caddy.md

Supervisors

A supervisor's main task, is to start a specified process (in a specified environment), watch it running, and do something when it ends - usually based on the exit code.

Systemd

From my experience, the environment setup can be a complex task (consult some config management for the required ports, actualize the config file from the central config management...), and this is where the most featureful supervisor (systemd, AFAIK) falls short:

  • it can setup & manage the listening sockets, and pass it to your app (if it can accept it - not hard, just have to be ready for it),
View CLA_LinuxFoundationDCO.txt
Developer Certificate of Origin
Version 1.1
Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
660 York Street, Suite 102,
San Francisco, CA 94110 USA
Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.
@mholt
mholt / Caddyfile
Created Jan 17, 2016 — forked from j-mcnally/Caddyfile
Caddyfile - Example
View Caddyfile
config_server "https://etcd.local:2379"
service users {
endpoint: "/users",
proxy: "{{services.users.ip}}:{{services.users.port}}"
}
# In this example 'services.users' would be a directory with a json key for every user service container / application.
# Using this we could template the proxy and any other information in the services block, and it would just work with caddy.
@mholt
mholt / transcript
Created Feb 26, 2016
Is it necessary to consume response body before closing it (net/http client code)?
View transcript
mholt [9:10 AM]
When using http.Get(), is it really necessary to read the full response body just to close it later?
[9:10]
The docs keep saying `Caller should close resp.Body when done reading from it.` and I keep seeing code like this:
```
io.Copy(ioutil.Discard, resp.Body)
resp.Body.Close()
```
@mholt
mholt / Caddyfile
Created Mar 28, 2016 — forked from phred/Caddyfile
A+ grade on securityheaders.io with this: https://securityheaders.io/?q=https%3A%2F%2Ffff.red
View Caddyfile
fff.red {
header / {
Strict-Transport-Security "max-age=31536000; includeSubDomains"
Content-Security-Policy "default-src https:*"
Public-Key-Pins "pin-sha256=\"ckOIjdimiwD3mfMmkmCh7uiJCBtXvoqoBoKKB1K5UIM=\"; pin-sha256=\"QiTyymM4e635OgWkx9d7nq5xvEuqmgV7HiDjIIGyymo=\"; max-age=2592000"
X-Frame-Options SAMEORIGIN
X-XSS-Protection "1; mode=block"
X-Content-Type-Options nosniff
}
}
You can’t perform that action at this time.