Skip to content

Instantly share code, notes, and snippets.

View jwreagor's full-sized avatar

J R jwreagor

  • New Gillington, WI
View GitHub Profile
@jwreagor
jwreagor / sshd.go
Created September 30, 2019 14:42 — forked from jpillora/sshd.go
Go SSH server complete example - Read more here https://blog.gopheracademy.com/go-and-ssh/
// A small SSH daemon providing bash sessions
//
// Server:
// cd my/new/dir/
// #generate server keypair
// ssh-keygen -t rsa
// go get -v .
// go run sshd.go
//
// Client:
{
consul: "consul:8500",
logging: { level: "INFO" },
jobs: [
{
name: "job1",
exec: "tail -F"
}
]
}
@jwreagor
jwreagor / containerpilot.json5
Created October 18, 2017 03:51
debugging a possible memory leak
{
consul: "consul:8500",
jobs: [
{
name: "pjob",
port: 8080,
exec: "/bin/pjob start",
restarts: "unlimited",
health: {
exec: "curl --fail -s http://127.0.0.1:8080",
@jwreagor
jwreagor / README
Created August 21, 2017 17:05 — forked from louiscryan/README
GRPC - Curl, HTTP/1.1 & nghttp misc
# Build the GRPC Java server which is used for interop testing.
# Interface defined here
# https://github.com/grpc/grpc-java/blob/master/interop-testing/src/main/proto/io/grpc/testing/integration/test.proto
./gradlew :grpc-interop-testing:installDist
# Run it with TLS turned on so ALPN is enabled. Uses a dummy cert
./interop-testing/build/install/grpc-interop-testing/bin/test-server --port=8080 --use_tls=true
# Run the awesome nghttp2 as a proxy in front of it.
# See https://nghttp2.org/documentation/package_README.html#building-from-git
// packageList returns the list of packages in the dag rooted at roots
// as visited in a depth-first post-order traversal.
func packageList(roots []*Package) []*Package {
seen := map[*Package]bool{}
all := []*Package{}
var walk func(*Package)
walk = func(p *Package) {
if seen[p] {
return
@jwreagor
jwreagor / flock.go
Created July 24, 2017 04:11 — forked from ericchiang/flock.go
Golang Flock
package main
// #include <sys/file.h>
import "C"
import (
"fmt"
"os"
"os/exec"
)
@jwreagor
jwreagor / goarena.go
Created April 20, 2017 14:12 — forked from ecin/goarena.go
Dtrace probes in your Golang code
package main
/*
Ping vs Pong: A Gladiatorial Match
Two goroutines enter, only one leaves...
*/
/*
#cgo LDFLAGS: -lprobes -L/usr/local/lib
#include "probes.h"
@jwreagor
jwreagor / fakeresponse.go
Created March 27, 2017 18:57 — forked from karlseguin/fakeresponse.go
A fake http.ResponseWriter class, used for testing. See http://openmymind.net/Testing-In-Go/
package fakeresponse
import (
"testing"
"net/http"
)
type FakeResponse struct {
t *testing.T
headers http.Header
@jwreagor
jwreagor / no_compute_resources_available.md
Created March 20, 2017 00:40 — forked from bahamat/no_compute_resources_available.md
Diagnosing "No Compute Resources Available" messages in Triton.

No Compute Resources Available

This error is somewhat ambiguious because there is seemingly no indication which resource is exhausted.

Triton chooses compute nodes with a subcomponent called sdc-designation (also refered to as , DAPI). The full DAPI log for a provision job is embedded in the CNAPI log file and can be extracted with the workflow job uuid and the following script.

#!/bin/bash

if [[ -n "$TRACE" ]]; then 
@jwreagor
jwreagor / create-jwt-using-unix-commands-on-mac.md
Created February 15, 2017 18:27 — forked from indrayam/create-jwt-using-unix-commands-on-mac.md
Create JWT Token Header Using Unix Command line tools ONLY!

Pseudocode:

Y = Base64URLEncode(Header) + ‘.’ + Base64URLEncode(Payload)
JWT = Y + ‘.’ + Base64URLEncode(HMACSHA256(Y))

The steps called out here should work on a Mac as well. The only thing that might be different is the sed command used below. Instead of using -E, you will have to use -r to run sed with extended regular expression support

Use data from this tutorial:

scotch.io