Skip to content

Instantly share code, notes, and snippets.

@tedsuo
tedsuo / example_data.js
Created September 15, 2011 02:21
hailstorm example
module.exports = test_data = {
defaults:{
protocol: 'http',
host: 'target-site.com',
port: 80
},
requests:[
{method:'get', path:'/test', weight:200},
{method:'post', path:'/foo', body:'bar=false', weight:5},
{method:'post', path:'/bar', body:'foo=true', weight:10},
function combinator(func,data,args){
new_args = [data].concat(args);
return function(cb){
new_args.push(cb);
func.apply(this,new_args);
}
}
function getCell(data,row_id,col_id,cb){
@tedsuo
tedsuo / gist:6466787
Last active December 22, 2015 11:38
Go failed to build on 10.8.4 with --cross-compile-common
○ → brew install -v go --cross-compile-common
==> Downloading https://go.googlecode.com/files/go1.1.2.src.tar.gz
Already downloaded: /Library/Caches/Homebrew/go-1.1.2.tar.gz
tar xf /Library/Caches/Homebrew/go-1.1.2.tar.gz
==> ./make.bash --no-clean
./make.bash --no-clean
# Building C bootstrap tool.
cmd/dist
# Building compilers and Go bootstrap tool for host, darwin/amd64.
@tedsuo
tedsuo / gist:11262905
Last active August 29, 2015 14:00
Cloud Foundry Logging Proposal

Cloud Foundry Logging Proposal

Log Format

Each log line corresponds to a line of JSON. This is backward compatible with the existing steno output.

Common among all log-level formats:

{
  timestamp: TIMESTAMP, // formatted as fmt.Sprintf("%.9f", time.Now().UnixNano()) / 1e9)
@tedsuo
tedsuo / struct_migrations.md
Last active August 29, 2015 14:01
Migrating Go structs

Decouple Compare and Swap from the serialized Value

if we modify storeadapter#compareAndSwapByIndex to return the new index, we can use this mechanism for our lifecycle/state machines:

type StoreAdapter interface {
  CompareAndSwapByIndex(prevIndex uint64, newNode StoreNode) (newIndex uint64, err error)
}

This would allow our state machines to continue, even if the values changed (provided all versions of the model have a StoreIndex field that we can use). Doesn't solve the issue of our processes expecting the data to be in a different format that the model they currently have, but it does prevent model changes from messing up the state machine.

@tedsuo
tedsuo / gist:aaa87ece6caa94b3f3cf
Created August 5, 2014 22:12
loopback for inigo
#!/bin/bash
set -e -x
apt-get install aufs-tools
pushd $GOPATH_ROOT/src/github.com/cloudfoundry-incubator/warden-linux
make # compile wshd/etc.
export WARDEN_BINPATH=$PWD/linux_backend/bin
popd
@tedsuo
tedsuo / gist:c7627828a97bdebe22ee
Last active August 29, 2015 14:06
Dropsonde in Diego

Metrics

Questions

  • where is time recorded?
  • how do we unit test what values we have recorded?

Notes

  • instrumentedResponseWriter does not support the http.CloseNotifier interface

This is a minimal-ish set of instruction to set up a freshly imaged OS X workstation for working on Diego. If you've already used the Pivotal sprout recipes to provision your machine, you might have a bad time.

Pivotal Workstation Conveniences

These are nice for the core developer team, feel free to skip this section:

  • Download Chrome using Safari, and install it.
  • Download Wraparound from the web.
  • Download ShiftIt.zip from github.com/onsi/shiftit.
  • Get Flycut from the App Store.
@tedsuo
tedsuo / main.go
Created December 9, 2014 21:51
CancellableCopy wants to stop an in-progress io.Copy, but suffers from a race
package main
import (
"bytes"
"errors"
"io"
"io/ioutil"
"os"
)
type Range interface {
Add(low, high int)
Remove(low, high int)
Contains(int) bool
Lowest() int
Highest() int
Each(func(int, int) bool)
Union(Range) Range