Skip to content

Instantly share code, notes, and snippets.

@bgv
bgv / dgraph-1.1.0-rc3-test.go
Created August 28, 2019 21:02
dgraph-1.1.0-rc3-test.go
package main
import (
"context"
"encoding/json"
"fmt"
"log"
"github.com/dgraph-io/dgo/v2"
"github.com/dgraph-io/dgo/v2/protos/api"
### Keybase proof
I hereby claim:
* I am bgv on github.
* I am bgv (https://keybase.io/bgv) on keybase.
* I have a public key ASCrQUJ1ocq0NFs7mfOSomWzJRz3bELbcGNZiKRkYajFkAo
To claim this, I am signing this object:
@bgv
bgv / hmac-sha256.go
Created June 22, 2016 03:02
Create base64 hash using HMAC SHA256
package main
import (
"crypto/hmac"
"crypto/sha256"
"encoding/base64"
"fmt"
)
func ComputeHmac256(message string, secret string) string {
@bgv
bgv / apache-log-json
Last active June 11, 2016 01:13
Apache configuration to forward structured JSON formatted log to syslog facility
# Create a log format called 'log_json' that emits, in json, the parts of an http
# request I care about. For more details on the features of the 'LogFormat'
# directive, see the apache docs:
# http://httpd.apache.org/docs/2.2/mod/mod_log_config.html#formats
LogFormat "{ \"@timestamp\": \"%{%Y-%m-%dT%H:%M:%S%z}t\", \"@message\": \"%m %H %U%q %s\", \"@fields\": { \"client\": \"%a\", \"duration_usec\": %D, \"status\": %s, \"request\": \"%U%q\", \"method\": \"%m\", \"protocol\": \"%H\", \"referrer\": \"%{Referer}i\", \"user-agent\": \"%{User-agent}i\" } }" log_json
# Apache 2.4 add sub-second precision logging
# http://httpd.apache.org/docs/2.4/mod/mod_log_config.html#formats
LogFormat "{ \"@timestamp\": \"%{%Y-%m-%dT%H:%M:%S}t.%{msec_frac}t%{%z}t\", \"@message\": \"%m %H %U%q %s\", \"@fields\": { \"client\": \"%a\", \"duration_usec\": %D, \"status\": %s, \"request\": \"%U%q\", \"method\": \"%m\", \"protocol\": \"%H\", \"referrer\": \"%{Referer}i\", \"user-agent\": \"%{User-agent}i\" } }" log_json