Skip to content

Instantly share code, notes, and snippets.

package none
import "io"
func min(a int, b int) int {
if a < b {
return a
}
return b
}
@rbranson
rbranson / kill-fdb-master.sh
Created May 4, 2020 17:47
Bash script to kill FoundationDB FDB master process
#!/bin/bash
status_json=$(fdbcli --exec 'status json')
master_addr=$(echo $status_json | jq -r '.cluster.processes[] | select(.roles[].role == "master") | .address')
# extra status json stuff workaround to bug in 6.0 where an immediate exit causes the command to not be sent
fdbcli --exec "status json; kill; kill $master_addr; status json"
@rbranson
rbranson / main.go
Last active April 29, 2020 03:29
P99 across all metrics ~= avg of P99 reported by every host
package main
import (
"fmt"
"sort"
"math/rand"
)
func p(in []int, x float64) int {
ints := make([]int, len(in))
@rbranson
rbranson / gist:007f989da12ba912ae7ec5859d4d732a
Last active January 16, 2019 16:40
MySQL re-orders commits
Schema
==========================================
CREATE TABLE locks (
name VARCHAR(191) PRIMARY KEY,
clock BIGINT
);
CREATE TABLE ledger (
seq BIGINT AUTO_INCREMENT PRIMARY KEY,
package stupid
import (
"fmt"
"reflect"
"unsafe"
)
type iptr struct {
@rbranson
rbranson / interface_slice.go
Created April 26, 2018 19:12
I'm not advocating this particularly idea.
// Converts args to an interface slice using the following rules:
//
// - Returns empty slice if no args are passed
//
// - For a single argument which is of a slice type, the slice
// is converted and returned.
//
// - For a single argument which is not a slice type, the value is
// returned within a single-element slice.
//
@rbranson
rbranson / intbloat-ca-cert-test.js
Created February 22, 2017 19:27
Demonstrates additional memory / CPU usage when forcing use of the OS-provided root certificates
// run this in bash with 'time' and it'll show CPU usage totals at the end
var totalCycles = 250;
var concurrencyLevel = 25;
var useOSCerts = true;
var requestOptions = {
hostname: 'www.google.com',
port: 443,
path: '/',
client_id operation key value
0 BEGIN
1 BEGIN
0 READ 100
0 COMMIT
0 BEGIN
1 READ 100
0 WRITE 100 0
0 READ 100
1 COMMIT
@rbranson
rbranson / leaving-hound.md
Created April 25, 2016 17:58
Stepping Down

Hey friends,

I wanted to let you know what's up with myself and Hound. I have left the company. There were fundamental conflicts among the founding team that were not reconcilable in any timeframe that would have made sense for an early-stage company.

Though it has certainly been a painful process, I still think the world of my co-founders, Charity and Christine. These are two immensely capable, hard-working, and genuinely caring people. I give my highest recommendation to anyone who would consider working with them in the future.

As for myself, I'll be spending the next few months spending time with friends and family as well as working on some side projects.

~ Rick

type Q interface {
Hello() string
}
type A struct {
}
func (x *A) Hello() {
return "Hello!"
}