Skip to content

Instantly share code, notes, and snippets.

@gorsuch
gorsuch / gist:4436860
Created January 2, 2013 18:53
String#scan is awesome.
line = "measure=foo.bar value=0.123123 timestamp=1231235"
line.scan(/(\S+)=(\S+)/i).map { |x| Hash[*x] }.inject({}) { |h,x| h.merge(x) }
@gorsuch
gorsuch / gist:4381806
Last active December 10, 2015 04:28
Measurements from event streams

[WIP] Measurements from event streams

If logs are thought of as living event streams that are meant to be processed in near-realtime, things get interesting. Rich data flows out of your app and on to various processors that take care of actions such as long term archival to S3 or populating search indexes in elasticsearch.

If you adopt a key=value convention like below, they can be more easily parsed by machines and filtered by tools like grep:

app=foo a=1 b=2 c=3
@gorsuch
gorsuch / gist:4377690
Last active December 10, 2015 03:58
Exploring application manifests

[WIP] Exploring application manifests

Phase 1: Config management

Lean on Chef recipes or Puppet manifests to describe your application. If you are here, you are doing awesome. The most clear downside is almost the system's strength: everything is coupled to the configuration management system and is therefore limited by it. It's a monolith.

When your customers want to run an application on your platform, they have to use a DSL and write recipes or manifests as well as corresponding templates.

Phase 2: Containerize / Normalize

@gorsuch
gorsuch / gist:4377677
Created December 26, 2012 03:35
Who needs a blog engine when you have gists?

I recently scrapped by blog (then powered by the excellent Jekyll) in favor of a simple index that links to gists. With the advent of the new Gist release one has about all that is needed to maintain and publish technical notes.

Here is to experimentation.

check_http: A Small Part of the Modern Monitoring Pipeline

[note: this was originally published on 08/27/2012. Other writing can be found here.]

Monitoring tooling has been a fascination of mine since I began hacking on computing systems. Every ops engineer wants to write their own. I get that. I'm one of those guys, too.

However, these endeavours always end up spitting out large, monolithic applications that just aren't as good as the already existing (and somewhat crappy) monolithic applications. I'd prefer to avoid that approach, if only to make it a point that the monitoring story can never be finalized. We will never reach an end state, but the more flexible our tooling the better.

Traditional Unix philsophy gives us something to go on here. What if, instead of writing large applications, we just wrote a bunch of tiny tools. AND - rather than writing each of these tiny tools as sexy network daemons (which

@gorsuch
gorsuch / gist:4267067
Created December 12, 2012 11:22
Simple Bash Prompt
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ $(__git_ps1 "(%s)")'
@gorsuch
gorsuch / gist:4178165
Created November 30, 2012 20:00
streaming go server example
package main
import "fmt"
import "net/http"
import "os"
import "time"
func handler(w http.ResponseWriter, r *http.Request) {
for {
fmt.Fprintf(w, "hi\n")
@gorsuch
gorsuch / gist:4013795
Created November 4, 2012 21:11
parse key value pairs
package main
import "fmt"
import "strconv"
import "strings"
import "regexp"
// extracts key=value pairs out of a string
var exp = regexp.MustCompile(`([a-zA-Z0-9\_\-\.]+)=(([a-zA-Z0-9\.\-\_\.\:\/]+)|(\"([^\"]+)\"))`)
@gorsuch
gorsuch / gist:3946737
Created October 24, 2012 15:26
cargo-culted sshd
// largely cargo-culted from http://go.pkgdoc.org/code.google.com/p/go.crypto/ssh#_example_Listen
package main
import "fmt"
import "io/ioutil"
import "code.google.com/p/go.crypto/ssh"
import "code.google.com/p/go.crypto/ssh/terminal"
func main() {