This file contains 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 | |
# ensure running bash | |
if ! [ -n "$BASH_VERSION" ];then | |
echo "this is not bash, calling self with bash...."; | |
SCRIPT=$(readlink -f "$0") | |
/bin/bash $SCRIPT | |
exit; | |
fi | |
This file contains 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
func ComputeHmac256(message string, secret string) string { | |
key := []byte(secret) | |
h := hmac.New(sha256.New, key) | |
h.Write([]byte(message)) | |
return base64.StdEncoding.EncodeToString(h.Sum(nil)) | |
} |
This file contains 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 | |
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd) | |
POSITIONAL_ARGS=() | |
while [[ $# -gt 0 ]]; do | |
case $1 in | |
# -e|--extension) | |
# EXTENSION="$2" |
This file contains 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 | |
# NOTE: assumes bsd `date` (as in mac) | |
set -euo pipefail | |
user_name="Your Name" | |
PD_TOKEN=${PD_TOKEN:-} | |
if [ -z "$PD_TOKEN" ]; then | |
PD_TOKEN=$(cat ~/.pagerduty.token) |
This file contains 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
FROM golang:1.9-alpine | |
# vi: ft=dockerfile | |
RUN apk update && apk add curl \ | |
git \ | |
protobuf \ | |
bash \ | |
make \ | |
openssh-client && \ | |
rm -rf /var/cache/apk/* |
This file contains 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
Imports Microsoft.Owin | |
Imports Microsoft.Owin.Security.OpenIdConnect | |
Imports Owin | |
Imports Microsoft.Owin.Security | |
Imports Microsoft.Owin.Security.Notifications | |
Imports Microsoft.Owin.Security.Cookies | |
Imports Microsoft.IdentityModel.Protocols.OpenIdConnect | |
Imports Microsoft.IdentityModel.Tokens | |
Imports System.Threading.Tasks |
This file contains 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 repo | |
import ( | |
"context" | |
"database/sql/driver" | |
"github.com/jmoiron/sqlx" | |
) | |
// can be either a *sqlx.DB or a *sqlx.Tx |
This file contains 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
// MultiError don't use directly, use NewMultiError | |
type MultiError map[string]error | |
// NewMultiError returns nil if all errs are nil | |
func NewMultiError(errs map[string]error) error { | |
for k, v := range errs { | |
if v == nil { | |
delete(errs, k) | |
} | |
} |
This file contains 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 pkg | |
import ( | |
"context" | |
"time" | |
) | |
// Debounce takes a channel, and will notify the output channel with the last received message at frequency min. | |
// Upon cancel or max timeout, it will check one last time for a message. | |
// Cancelling the ctx will cause the goroutine to exit. |
This file contains 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
go func(dbx *sqlx.DB) { | |
ticker := time.NewTicker(5 * time.Second) | |
defer ticker.Stop() | |
for { | |
select { | |
case <-ticker.C: | |
stats := dbx.Stats() | |
b, _ := json.Marshal(stats) | |
log.Printf("db stats: %d open, %d idle, %d in-use", stats.OpenConnections, stats.Idle, stats.InUse) |
NewerOlder