Skip to content

Instantly share code, notes, and snippets.

View pedro's full-sized avatar

Pedro Belo pedro

  • San Francisco, CA
  • X @ped
View GitHub Profile

Keybase proof

I hereby claim:

  • I am pedro on github.
  • I am ped (https://keybase.io/ped) on keybase.
  • I have a public key whose fingerprint is B3CB A84E 05B4 03FC 2506 BD8F ACF9 8F42 BA4D 4E90

To claim this, I am signing this object:

module Base
class Foo
end
end
module Base
class A
def self.test
puts Foo.object_id # this works
end
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../vendor/sinatra/lib'
require 'sinatra'
Sinatra::Application.default_options.merge!(
:run => false,
:env => :development # ENV['RACK_ENV']
)
require File.dirname(__FILE__) + '/../app/mailer.rb'
@pedro
pedro / nike.md
Last active August 29, 2015 14:09
Nike's journey to microservices

Nike's journey to microservices

  • 2011: running activity/service "barely running in production"

    • reliability issues
    • little tests
    • features deployed in months
  • 2012: their own backend

    • "deep vertical" stack
  • 9 teams on the same codebase supporting 14 products

@pedro
pedro / s3-performance.md
Created November 13, 2014 21:46
Maximizing S3 Peformance

Maximizing S3 Peformance

  • 137% increase in AWS usage in the last year

  • Factors to keep in mind when picking a region

    • Performance: Proximity to users and to other resources in AWS
    • Compliance
    • Cost
  • Naming scheme is the most important thing

@pedro
pedro / jack-white-guac.md
Last active August 29, 2015 14:14
Jack White's guacamole recipe

Jack White's guacamole recipe

Recently the tour rider for a Jack White performance was made public, and it contained a recipe for guacamole intended to be made for the artist.

Ingredients

  • 8x large ripe Haas avocados
  • 4x vine-ripened tomatoes (diced)
  • ½ yellow onion finely chopped
  • 4x Serrano pepper (de-veined and chopped)
irb(main):018:0> RestClient::VERSION
=> "1.7.3"
irb(main):019:0> RestClient.get("http://test-affinity.herokuapp.com/")
=> "1"
irb(main):020:0> RestClient.get("http://test-affinity.herokuapp.com/").to_i
=> 200
irb(main):021:0> RestClient.get("http://test-affinity.herokuapp.com/").class
=> String
irb(main):022:0> RestClient.get("http://test-affinity.herokuapp.com/") == "1"
=> true
@pedro
pedro / init.r
Last active August 29, 2015 14:22
Running R code in parallel on Heroku
# used by the R buildpack to install dependencies:
# https://github.com/virtualstaticvoid/heroku-buildpack-r
install.packages("foreach", dependencies = TRUE)
install.packages("doParallel", dependencies = TRUE)
@pedro
pedro / enqueue.r
Last active August 29, 2015 14:22
Running redis-based workers in R on Heroku
# same code used in https://gist.github.com/pedro/f931e8cd20b5770b6780
# only using doRedis instead of doParallel
library(foreach)
library(doRedis)
redis_url <- Sys.getenv("REDIS_URL")
host <- gsub("redis://.*@(.+):.*", "\\1", redis_url)
pass <- gsub("redis://.*:(.+)@.*", "\\1", redis_url)
port <- as.integer(gsub(".*:(.*)$", "\\1", redis_url))
registerDoRedis("jobs", host=host, port=port, password=pass)
@pedro
pedro / init.r
Last active August 29, 2015 14:22
R + Redis on Heroku
# used by the R buildpack to install dependencies:
# https://github.com/virtualstaticvoid/heroku-buildpack-r
install.packages("rredis", dependencies = TRUE)