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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% | |
require 'cgi' | |
require 'uri' | |
begin | |
uri = URI.parse(ENV["DATABASE_URL"]) | |
rescue URI::InvalidURIError | |
raise "Invalid DATABASE_URL" | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ h pg:index_usage -a bisley-production |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"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"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ curl -H 'Accept: application/json' http://foaas.herokuapp.com/off/cancer/everyone | prettyjson | |
message: Fuck off, cancer. | |
subtitle: - everyone |