Skip to content

Instantly share code, notes, and snippets.

Pedro Belo pedro

View GitHub Profile
View keybase.md

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:

View wtfnamespaces.rb
module Base
class Foo
end
end
module Base
class A
def self.test
puts Foo.object_id # this works
end
View rackup.ru
$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 Aug 29, 2015
Nike's journey to microservices
View nike.md

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 Nov 13, 2014
Maximizing S3 Peformance
View s3-performance.md

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 Aug 29, 2015
Jack White's guacamole recipe
View jack-white-guac.md

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)
View gist:9232897015a43400c041
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 / enqueue.r
Last active Aug 29, 2015
Running redis-based workers in R on Heroku
View enqueue.r
# 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 Aug 29, 2015
R + Redis on Heroku
View init.r
# used by the R buildpack to install dependencies:
# https://github.com/virtualstaticvoid/heroku-buildpack-r
install.packages("rredis", dependencies = TRUE)
@pedro
pedro / init.r
Last active Aug 29, 2015
Running R code in parallel on Heroku
View init.r
# 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)
You can’t perform that action at this time.