Skip to content

Instantly share code, notes, and snippets.

@mediocregopher
mediocregopher / panic_test.go
Last active February 4, 2019 19:53
this benchmark panics on arm64
package panicker
import (
"runtime"
. "testing"
"github.com/mediocregopher/radix/v3"
)
func BenchmarkPanic(b *B) {
package main
import (
"log"
"time"
"github.com/mediocregopher/mediocre-go-lib/mrand"
radix "github.com/mediocregopher/radix.v3"
)
0xC34976Ee7A9dAD5d4F1802C190B0967E58b137F0
@mediocregopher
mediocregopher / brainfuck.rs
Created June 16, 2016 04:36
Simple implementation of a brainfuck interpreter in rust
/*
[dependencies]
clap = "2"
*/
extern crate clap;
use clap::{Arg, App};
use std::num::Wrapping;
use std::io::Read;
@mediocregopher
mediocregopher / brpc.go
Created June 15, 2016 23:40
An RPC system from Go inspired by the http.Handler system
// Package brpc, stands for better-rpc. It's better than normal RPC, because it
// allows for saner chaining of rpc handlers
package brpc
import (
"encoding/json"
"net/http"
"golang.org/x/net/context"
)
@mediocregopher
mediocregopher / client.go
Last active June 8, 2016 17:39
Example of a TLS echo server and client which also use the PROXY protocol
package main
import (
"crypto/tls"
"fmt"
"io"
"log"
"net"
"os"
)
@mediocregopher
mediocregopher / go-deps-refs.sh
Created February 1, 2016 21:11
Prints out the revisions of all checked out dependencies of a go project that can be found in GOPATH
#!/bin/sh
function printDep {
dep="$1"
if [ "$dep" == "." ]; then return 0; fi
cd "$GOPATH/src/$dep"
if [ -d ".git" ]; then
echo "$dep (git) - $(git log --abbrev-commit --oneline -n 1)"
return 0
@mediocregopher
mediocregopher / main.go
Last active September 10, 2015 19:34
Demonstrating a simple wrapper around gorilla's json2 rpc abstraction
package main
import (
"bytes"
"log"
"math/rand"
"net/http"
"time"
"github.com/gorilla/rpc/v2"
~ ▻ gem install --debug chef
NOTE: Debugging mode prints all exceptions even when rescued
Exception `ArgumentError' at /home/mediocregopher/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/1.9.1/resolv.rb:2318 - IPv6 address must be 16 bytes
ERROR: While executing gem ... (ArgumentError)
IPv6 address must be 16 bytes
/home/mediocregopher/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/1.9.1/resolv.rb:2318:in `initialize'
/home/mediocregopher/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/1.9.1/resolv.rb:2058:in `new'
/home/mediocregopher/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/1.9.1/resolv.rb:2058:in `decode_rdata'
/home/mediocregopher/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/1.9.1/resolv.rb:1556:in `block in get_rr'
/home/mediocregopher/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/1.9.1/resolv.rb:1457:in `get_length16'

Keybase proof

I hereby claim:

  • I am mediocregopher on github.
  • I am mediocregopher (https://keybase.io/mediocregopher) on keybase.
  • I have a public key whose fingerprint is 27AB 502A 9EA8 96F6 4A27 4970 95C4 6FA6 A411 48AC

To claim this, I am signing this object: