Skip to content

Instantly share code, notes, and snippets.

View nickvanw's full-sized avatar

Nick Van Wiggeren nickvanw

View GitHub Profile
@nickvanw
nickvanw / dd.sh
Last active August 29, 2015 13:57
#!/bin/bash
# Save this script somewhere (chmod it 777) and add this to cron:
# 0 */2 * * * cd ~; dd.sh
#
# There are some configuration variables to change below these comments
#
# You'll want to set where the dd command prints to, as well as what command it runs
#
types {
text/html html htm shtml;
text/css css;
text/xml xml;
image/gif gif;
image/jpeg jpeg jpg;
application/javascript js;
application/atom+xml atom;
application/rss+xml rss;
@nickvanw
nickvanw / dotdeb.sh
Last active August 29, 2015 14:00
Dotdeb Install Script
#!/bin/bash
OFFICIAL_DOTDEB="http://packages.dotdeb.org"
APT_FOLDER="/etc/apt/sources.list.d/"
DOTDEB_FILE="dotdeb.list"
# Make sure we're running this as root!
if [[ $UID -ne 0 ]]; then
echo "$0 must be run as root"
exit 1
### Keybase proof
I hereby claim:
* I am nickvanw on github.
* I am nickvanw (https://keybase.io/nickvanw) on keybase.
* I have a public key whose fingerprint is 9549 9ACC 64DE 7476 0624 2871 67A9 7259 F9FC 4628
To claim this, I am signing this object:
@nickvanw
nickvanw / main.go
Created August 18, 2014 00:13
FiSH DH1080 in Go
package main
import (
"crypto/cipher"
"crypto/rand"
"crypto/sha1"
"encoding/base64"
"errors"
"fmt"
"math/big"
@nickvanw
nickvanw / main.go
Created August 23, 2014 01:52
Parallel URL Fetcher
package main
import (
"encoding/csv"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"strings"
"sync"
@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(?,
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 -
package cbzip2
/*
#cgo CFLAGS: -Werror=implicit
#include "bzip2/bzlib.h"
*/
import "C"
// 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
}