Skip to content

Instantly share code, notes, and snippets.

View nickvanw's full-sized avatar

Nick Van Wiggeren nickvanw

View GitHub Profile
@nickvanw
nickvanw / snmp.yml
Created March 24, 2018 22:41
SNMP Exporter for EdgeRouter
default:
auth:
community: thisisasecret
walk:
- 1.3.6.1.2.1.1.3
- 1.3.6.1.2.1.2
- 1.3.6.1.2.1.31.1.1
metrics:
- name: sysUpTime
oid: 1.3.6.1.2.1.1.3
package main
import (
"encoding/json"
"fmt"
"net"
"net/http"
)
type IPResponse struct {
package main
import (
"encoding/json"
"fmt"
"net"
"net/http"
"sync"
)
# rados lspools
rbd
test-pool-1446740062-eeddb785027bf960
test-pool-1446740062-d0a10528b0307445
blah
# rados mkpool lol
successfully created pool lol
# rados --pool rbd create blah
2015-11-05 16:16:33.254545 7f9ef15da700 0 -- 127.0.0.1:0/1001947 >> 127.0.0.1:6800/197 pipe(0x34dc2b0 sd=4 :0 s=1 pgs=0 cs=0 l=1 c=0x34d1cd0).fault
@nickvanw
nickvanw / key.go
Created October 21, 2015 20:49
Generate SSH Keys
package whatever
import (
"crypto/rand"
"crypto/rsa"
"crypto/x509"
"encoding/base64"
"encoding/pem"
"fmt"
@nickvanw
nickvanw / main.go
Last active August 29, 2015 14:21
Web Example
package main
import (
"database/sql"
"net/http"
"github.com/gorilla/mux"
)
func main() {
// WithUUID returns a new Context that carries a uuid. If the UUID
// already exists, nothing is done. Otherwise a new one is created.
func WithUUID(c context.Context) (context.Context, string) {
if u, ok := c.Value("request.id").(string); ok {
return c, u
}
uuid := uuid.New()
return context.WithValue(c, "request.id", uuid), uuid
}
package cbzip2
/*
#cgo CFLAGS: -Werror=implicit
#include "bzip2/bzlib.h"
*/
import "C"
nick@nick-mbp ~/.g/s/g/n/cbzip2 (master) [2]> go build -work -x
WORK=/var/folders/fz/80y95njs0wb4hyd9b3j84zd40000gn/T/go-build955903386
mkdir -p $WORK/github.com/nickvanw/cbzip2/_obj/
mkdir -p $WORK/github.com/nickvanw/
cd /Users/nick/.gopath/src/github.com/nickvanw/cbzip2
CGO_LDFLAGS="-g" "-O2" /usr/local/Cellar/go/1.4.2/libexec/pkg/tool/darwin_amd64/cgo -objdir $WORK/github.com/nickvanw/cbzip2/_obj/ -- -I $WORK/github.com/nickvanw/cbzip2/_obj/ -Werror=implicit -Werror=implicit reader.go writer.go
/usr/local/Cellar/go/1.4.2/libexec/pkg/tool/darwin_amd64/6c -F -V -w -trimpath $WORK -I $WORK/github.com/nickvanw/cbzip2/_obj/ -I /usr/local/Cellar/go/1.4.2/libexec/pkg/darwin_amd64 -o $WORK/github.com/nickvanw/cbzip2/_obj/_cgo_defun.6 -D GOOS_darwin -D GOARCH_amd64 $WORK/github.com/nickvanw/cbzip2/_obj/_cgo_defun.c
clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common -print-libgcc-file-name
clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -
@nickvanw
nickvanw / datastore.go
Created November 20, 2014 22:41
Go SQL Queries
package datastore
import (
"database/sql"
)
const (
createUser = `
INSERT INTO users (name, email)
VALUES(?,