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
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
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
$ 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
<% | |
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
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 |
Ideas are cheap. Make a prototype, sketch a CLI session, draw a wireframe. Discussions around concrete examples, not handy-waving abstractions. Don't say you did something, provide a URL that proves it.
Nothing is real until it's being used by a real user. This doesn't mean you make a prototype in the morning and blog about it in the evening. It means you find one person you believe your product will help and try to get them to use it.
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
class Person | |
attr gender | |
def male? | |
@gender == 'male' | |
end | |
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 ActiveRecord | |
class Base | |
def read_only? | |
ENV["AR_READ_ONLY"] ||= false | |
end | |
def before_destroy | |
raise ActiveRecord::ReadOnlyRecord if read_only? | |
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 heavy_decimal_count(a,b) | |
(a..b).select do |number| | |
chars = number.to_s.split('').collect{|x| x.to_i} | |
get_avg(chars) > 7 | |
end | |
end | |
def get_avg(arr) | |
arr.inject{|sum,x| sum + x }.to_f / arr.size | |
end |