Skip to content

Instantly share code, notes, and snippets.

View neilmiddleton's full-sized avatar
🏠
Working from home

Neil Middleton neilmiddleton

🏠
Working from home
View GitHub Profile
@neilmiddleton
neilmiddleton / gist:5712976
Last active December 18, 2015 02:39
Unicorn config
worker_processes ENV["RAILS_ENV"] == 'production' ? 3 : 1
timeout 30
worker_processes ENV.fetch("WORKER_CONCURRENCY", 1).to_i
timeout ENV.fetch("UNICORN_TIMEOUT", 30).to_i

Neil is the English Samurai at Heroku working as part of the Support Engineering team. Based in the UK working remotely Neil helps look after the 3 million + applications Heroku run on a daily basis whilst struggling to remember all their names.

<%
require 'cgi'
require 'uri'
begin
uri = URI.parse(ENV["DATABASE_URL"])
rescue URI::InvalidURIError
raise "Invalid DATABASE_URL"
end
$ h pg:index_usage -a bisley-production
EventMachine.run do
EventMachine::PeriodicTimer.new(15) { out << "\0" }
http = EventMachine::HttpRequest.new(url, keepalive: true, connection_timeout: 0, inactivity_timeout: 0).get
buffer = ""
http.stream do |chunk|
buffer << chunk
while line = buffer.slice!(/.+\n/)
puts line
end
def stream(url, timeout)
http.stream do |chunk|
buffer << chunk
yield buffer
end
end
stream url, 20 do |buffer|
while line = buffer.slice!(/.+\n/)
end
module HealthReport
module LogStreamer
def stream(url, timeout)
Timeout::timeout(20) do
EventMachine.run do
EventMachine::PeriodicTimer.new(15) { out << "\0" }
http = EventMachine::HttpRequest.new(url, keepalive: true, connection_timeout: 0, inactivity_timeout: 0).get
buffer = ""
http.stream do |chunk|
[
{
"name": "support.triage_paid",
"data_point": "views/26629566/count.json",
"type": "count",
"source": "zendesk"
},
{
"name": "support.triage_free",
"data_point": "views/26626052/count.json",
TUTORIAL_KEY=`(echo -n ":" ; heroku auth:token) | base64` ; echo $TUTORIAL_KEY
curl -X GET https://api.heroku.com/apps -H "Accept: application/vnd.heroku+json; version=3" -H "Authorization: $TUTORIAL_KEY"
curl -X GET https://api.heroku.com/apps/neilmiddleton/formation -H "Accept: application/vnd.heroku+json; version=3" -H "Authorization: $TUTORIAL_KEY"
$ curl -H 'Accept: application/json' http://foaas.herokuapp.com/off/cancer/everyone | prettyjson
message: Fuck off, cancer.
subtitle: - everyone