This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bytes" | |
"crypto" | |
"crypto/rsa" | |
"crypto/sha256" | |
"encoding/base64" | |
"encoding/binary" | |
"encoding/json" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<style> | |
.chart div { | |
font: 10px sans-serif; | |
background-color: green; | |
text-align: right; | |
padding: 3px; | |
margin: 1px; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// CountRequests is middleware for standard handler functions | |
func (vc *VascoClient) CountRequests(handler http.HandlerFunc) http.HandlerFunc { | |
return func(rw http.ResponseWriter, req *http.Request) { | |
// we use a recorder as our response writer so we can inspect it | |
recorder := httptest.NewRecorder() | |
// now call the original handler with our recorder | |
handler(recorder, req) | |
// switch on the result | |
code := recorder.Code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ChkTok is middleware that validates that the required | |
// security token is present. | |
func ChkTok(handler http.HandlerFunc) http.HandlerFunc { | |
return func(rw http.ResponseWriter, req *http.Request) { | |
sessionid := req.Header.Get(AUTHTOKEN) | |
if sessionid == "" { | |
util.WriteNewWebError(rw, http.StatusForbidden, "U-107", "x-anet-token is required.") | |
return | |
} | |
handler(rw, req) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This file isn't really needed but I'm not ready to delete it yet. | |
package main | |
import ( | |
"bytes" | |
"crypto" | |
"crypto/rsa" | |
"crypto/sha256" | |
"encoding/base64" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SanitizeHTML strips html tags, replace common entities | |
func SanitizeHTML(s string) string { | |
output := "" | |
// Shortcut strings with no tags in them | |
if !strings.ContainsAny(s, "<>") { | |
output = s | |
} else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Data struct { | |
Data []struct { | |
Data struct { | |
Stimulus string `json:"stimulus,omitempty"` | |
Template string `json:"template,omitempty"` | |
Type string `json:"type,omitempty"` | |
Validation struct { | |
ScoringType string `json:"scoring_type,omitempty"` | |
ValidResponse struct { | |
Score int `json:"score,omitempty"` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################################################################# | |
# Here's a bunch of stuff to do prompts that are sensitive to git and svn | |
WHT='\e[22;37m' | |
TEAL='\e[22;36m' | |
BLK='\e[22;30m' | |
RED='\e[22;31m' | |
GRN='\e[22;32m' | |
YEL='\e[22;33m' | |
BLU='\e[22;34m' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this is extra bash stuff to make things easier to manage | |
shopt -s histappend | |
HISTFILESIZE=2000 | |
HISTSIZE=1000 | |
export TERM=xterm-256color | |
export CLICOLOR=1 | |
export LSCOLORS=ExFxCxDxBxegedabagacad |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# Provisioning script for a mongo-backed go server on a vagrant box | |
echo "install basic requirements" | |
apt-get --quiet -y update | |
DEBIAN_FRONTEND=noninteractive apt-get --quiet -y upgrade | |
apt-get --quiet -y install build-essential mercurial git curl libssl-dev pkg-config tree mongodb bison make gcc binutils | |