Skip to content

Instantly share code, notes, and snippets.

View mholt's full-sized avatar
💪
I write code with my bare hands

Matt Holt mholt

💪
I write code with my bare hands
View GitHub Profile
@hantuo
hantuo / gist:3073832
Created July 9, 2012 02:07
golang dynamic type
package main
type I interface {
Foo()
}
type A struct {
}
@kennwhite
kennwhite / starttls_example.go
Created November 30, 2015 23:03
Simple example of sending email with StartTLS in Go
/*
Simple example of sending an email with StartTLS in Go
See: https://golang.org/pkg/net/smtp/#SendMail for TLS defaults
*/
package main
import (
"log"
"net/smtp"
@purohit
purohit / LevenshteinDistance.go
Last active December 28, 2015 15:00 — forked from athiwatc/LevenshteinDistance.go
Updating this to work with Go v1
package LevenshteinDistance
import "math"
func compare(a, b string) int {
var cost int
d := make([][]int, len(a)+1)
for i := 0; i < len(d); i++ {
d[i] = make([]int, len(b)+1)
}
apt-get update
apt-get install -y curl git mercurial make binutils bison gcc build-essential
git clone https://go.googlesource.com/go go14
git clone go14 go15
git clone go14 go16
#build all go versions
cd go14/src
@hlandau
hlandau / rough-design.md
Last active April 24, 2016 19:00
Rough design for acmed

This is a rough sketch I've put together in my mind of how an 'ACME daemon' might end up looking.

API

acmetool is designed for batch operation which works well for small use cases but large scale deployments will work better with a daemon. This will probably expose a service via an HTTP API, so that arbitrary parts of a service provider's stack can request certificates.

This API will need to be asynchronous as it may take arbitrarily long for 'acmed'

@j-mcnally
j-mcnally / Caddyfile
Created January 14, 2016 20:02
Caddyfile - Example
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.
@AGWA
AGWA / ocsp_stapling_robustness.md
Last active October 31, 2016 20:33
OCSP Stapling Robustness in Apache and nginx

Date: Mon, 5 Oct 2015 16:34:03 -0700

Apache caches an OCSP response for one hour by default. Unfortunately, once the hour is up, the response is purged from the cache, and Apache doesn't attempt to retrieve a new one until the next TLS handshake takes place. That means that if there's a problem contacting the OCSP responder at that moment, Apache is left without an OCSP response to staple. Furthermore, it caches the non-response for 10 minutes (by default), so for the next 10 minutes, no OCSP response will be stapled to your

@phred
phred / Caddyfile
Created March 28, 2016 18:41
A+ grade on securityheaders.io with this: https://securityheaders.io/?q=https%3A%2F%2Ffff.red
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
}
}
@icholy
icholy / goi.md
Last active August 31, 2017 03:17

Interfaces

Let's imagine a very simple table

CREATE TABLE people {
  id bigserial,
  name character varying
}
@caesaneer
caesaneer / gen.go
Last active August 16, 2019 06:12
// Handler that calls generate
func ok(w http.ResponseWriter, r *http.Request) {
// res := make([]int64, 0, 100000)
var res [100000]int64
fibonacci.Generate(&res)
// fmt.Println(suc)
// fmt.Printf("%T", res)
// fmt.Println(res[50])
fmt.Fprintf(w, "OK")