Running PDFKit on Heroku

If you try to run PDFKit on Heroku you will run into a problem with starting a request to the stylesheets from within a request - thin can’t handle that.

Instead of running the PDFKit middleware, you’ll need to add a pdf format in your respond_to block.

First, register PDF as a mime-type in config/initializers/mime_types.rb:

Mime::Type.register "application/pdf", :pdf

Next, create the responder. The trick is to render the view you want to use to a string, create a PDFKit object from that, and add stylesheet paths instead of loading them through the problematic separate request.

format.pdf do
  kit = PDFKit.new(render_to_string(:template => "controller/view.html",
                                    :layout => "layout.html"))
  # stylesheets in tmp because I'm using compass
  kit.stylesheets << Rails.root.join('tmp', 'stylesheets', 'style.css').to_s
  render :text => kit.to_pdf
end

Next, you need to make sure that all partials are called as render :partial => 'partial.html' since render_to_string doesn’t know the proper format then.

ZeroMQ: Modern & Fast Networking Stack - igvita.com →

Wouldn’t it be nice if we could abstract some of the low-level details of different socket types, connection handling, framing, or even routing? This is exactly where the ZeroMQ (ØMQ/ZMQ) networking library comes in: “it gives you sockets that carry whole messages across various transports like inproc, IPC, TCP, and multicast; you can connect sockets N-to-N with patterns like fanout, pubsub, task distribution, and request-reply”. That’s a lot buzzwords, so lets dissect some of these concepts in more detail.

Simplicity Is Highly Overrated | Don Normand →

mnmal:

This is a fantastic article.

“Why can’t products be simpler?” cries the reviewer in the New York Times, the Wall Street Journal, the local newspaper. “We want simplicity” cry the people befuddled by all the features of their latest whatever. Do they really mean it? No.