Skip to content

Instantly share code, notes, and snippets.

View crhntr's full-sized avatar

Christopher Hunter crhntr

View GitHub Profile
package main
import (
"fmt"
"go/scanner"
"go/token"
"math"
"sync"
"time"
)
// parseArgs(os.Args)
func parsArgs(args []string) ([]string, map[string][]string) {
argMap := make(map[string][]string)
arguments := []string{}
for i := 1; i < len(args); {
if args[i][0] == '-' {
j := i + 1
argMap[args[i][1:]] = []string{}
for j = i + 1; j < len(args) && len(args[j]) > 0 && args[j][0] != '-'; j++ {
worker_processes 1;
user nobody nogroup;
# 'user nobody nobody;' for systems with 'nobody' as a group instead
pid /run/nginx.pid;
# error_log /tmp/nginx.error.log;
events {
worker_connections 1024; # increase if you have lots of clients
accept_mutex off; # set to 'on' if nginx worker_processes > 1
@crhntr
crhntr / main.go
Created March 19, 2017 21:09
An HTTP2 push example program for go
// golang http2 example
// run these before: openssl genrsa -out server.key 2048
// openssl ecparam -genkey -name secp384r1 -out server.key
// openssl req -new -x509 -sha256 -key server.key -out server.crt -days 3650
package main
import (
"log"
"net/http"
"time"
@crhntr
crhntr / id.go
Last active April 7, 2017 17:33
minimal bson ObjectID implementation mostly based/copied from implementation in https://labix.org/mgo/bson
// mostly based on https://labix.org/mgo
package id
import (
"crypto/md5"
"crypto/rand"
"encoding/binary"
"fmt"
"io"
@crhntr
crhntr / linecount.go
Last active August 17, 2017 16:59
A line counting utility in golang
package main
import (
"bytes"
"flag"
"fmt"
"io"
"log"
"os"
"path/filepath"
package main
import "fmt"
func main() {
max := 1000
for a := 0; a < 8; a++ {
for b := 0; b < 8; b++ {
func(a, b int) {
package main
import "fmt"
const Count = 3
var Goal = State{0, 0, R, ""}
func main() {
fmt.Println("breadthFirstSearch")
@crhntr
crhntr / selfSigningHttpsServer.go
Last active October 29, 2017 20:38
An HTTPS server that generates it's own cert in memory.
package main
import (
"bytes"
"crypto/ecdsa"
"crypto/elliptic"
"crypto/rand"
"crypto/rsa"
"crypto/tls"
"crypto/x509"
@crhntr
crhntr / mgocert.go
Last active June 25, 2018 08:15
autocert.Cert Implementation using mgo for MongoDB backend
package mgocert
import (
"context"
"golang.org/x/crypto/acme/autocert"
mgo "gopkg.in/mgo.v2"
)
type Cache struct {