Skip to content

Instantly share code, notes, and snippets.

@ryansmith3136
ryansmith3136 / log.rb
Last active December 15, 2015 23:49
A simple ruby logger that emits l2met conventional data
def log(data)
result = nil
if data.key?(:measure)
name = data.delete(:measure).insert(0, ENV["APP_NAME"] + ".")
end
if block_given?
start = Time.now
result = yield
elapsed = (Time.now.to_f - start.to_f) * 1000
data.merge!("measure.#{name}" => elapsed.round)
@ryansmith3136
ryansmith3136 / timer.rb
Last active December 15, 2015 00:19
Time rack requests and print heroku request id
class RackTimer
def initialize(app)
@app = app
end
def call(env)
start_request = Time.now
status, headers, body = @app.call(env)
elapsed = (Time.now - start_request) * 1000
$stdout.puts("request-id=#{env['HTTP_HEROKU_REQUEST_ID']} measure.rack-request=#{elapsed.round}ms")
@ryansmith3136
ryansmith3136 / predictable-failure.md
Last active December 14, 2015 06:39
Predictable Failure - Waza 2013

Predictable Failure

Building systems that fail in predictable ways promote safety and sanity.

Original Audience: Heroku Waza 2013

About

@ryansmith3136
ryansmith3136 / hack-reactor.md
Last active November 24, 2022 07:01
Hack Reactor Talk

Tales From a Heroku User

Here are some things I have learned along the way.

Last Updated: 2013-02-08

Original Audience: Hack Reactor

About

@ryansmith3136
ryansmith3136 / komrade-api.md
Last active December 11, 2015 18:28
Komrade's HTTP API

Komrade

Komrade is a message queue for your workers. Komrade will help you manage background jobs for web applications.

HTTP based queueing service.

  • PUT Job
  • POST Job's Heartbeat
  • PUT Job Failure
  • GET Jobs
@ryansmith3136
ryansmith3136 / agg.sql
Created January 23, 2013 05:19
Postgres array concatenation aggregate function.
CREATE AGGREGATE array_accum (anyarray)
(
sfunc = array_cat,
stype = anyarray,
initcond = '{}'
);
@ryansmith3136
ryansmith3136 / l2met-client.go
Created January 16, 2013 01:46
l2met Go client
package main
import (
"encoding/json"
"fmt"
"net/http"
"strconv"
"sync"
"time"
"io/ioutil"
@ryansmith3136
ryansmith3136 / pq-array.go
Created January 4, 2013 03:41
Simple postgres array parsing in Go.
package main
import (
"database/sql"
"fmt"
_ "github.com/bmizerany/pq"
"strconv"
"strings"
)
@ryansmith3136
ryansmith3136 / service-visibility.md
Created December 14, 2012 22:36
Defining service visibility

Service Visibility

The purpose of service visibility is to reconcile the execution of software with the agreement between the provider & customer of the service. Thus, the service must have customers who are aware that they are in fact customers of the service and furthermore are aware of the expected level of performance. In the case of an e-commerce site, the customers of the service are the visitors to the site and the agreed level of service is such that the customer views pages at some small epsilon + the speed of light. The service level agreement is arbitrary and can be estimated by the service provider. (e.g. 100ms)

Service providers need tools to help reconcile each customer's interaction with the service to understand if there are any breaches in agreement. When the agreement is breached, visibility tooling should provide help in debugging the violating component that lead to the breach. Surfacing information to service operators with the least amount of paing is a challenge accepted by makers

@ryansmith3136
ryansmith3136 / mem-lower-bound.md
Created November 27, 2012 16:06
Memory Lower Bound: Go vs. C

Have you ever wondered about the least amount of memory a C or Go program will use on a 64bit Linux machine? Kr & I have, here is the results of our curiosity:

A simple C program:

void
main()
{
  for (;;) {
 }