In my last blog post about Middleman on Heroku, Middleman was configured to be served via the Puma application server.

By following this guide, you can setup your middleman site to be served by Nginx, which should be a lot more robust for static sites. If you already have a Middleman site in a git repo, you can skip the first few steps.

Install Middleman (if you haven’t already):

gem install middleman

Create a new Middleman site (and change into that directory):

middleman init beer_catalogue
cd beer_catalogue

Initialise the git repository and commit everything:

git add .
git commit -am "Everything"

Create a new Heroku app (if you omit the name Heroku will generate one for you):

heroku create beer-catalogue

Configure Heroku to use the multi-buildpack (with the Nginx and Ruby buildpacks):

Logs on your development machine can quickly grow to a silly size, especially if you have long running projects.

An easy cure for this is to set-up logrotate (newsyslog on OS X) to rotate the logs once they grow past a certain point (1MiB in the example below), after all most of the time you’ll only be interested in the last few lines of your logs…

Create a new file in /etc/newsyslog.d called dev-logs.conf with the following contents:

MockSMTP (€8,99) and MailCatcher (open-source) are great tools when you’re trying to debug emails, but not everyone on your team necessarily has one of them installed (or maybe you just don’t have one of them running constantly).

In case you don’t know what MockSMTP and MailCatcher do: they’re essentially SMTP servers for development. Instead of sending emails to their intended recipients, they collect them and give you a nice UI where you can inspect them at your leisure.

Using MailCatcher or MockSMTP conditionally in development is actually pretty easy and only requires you to add a few lines of code to your development.rb file:

require"net/smtp"ThanksForAllTheFish::Application.configuredo# … other settings redacted …# Try to sniff out if MockSMTP or MailCatcher is runningbeginsmtp=Net::SMTP.start"localhost",1025ifsmtp.started?smtp.quitputs">> WARNING: Found an SMTP server on port 1025"puts" Assuming that it is MockSMTP or MailCatcher..."puts">> Emails WILL be sent to the SMTP server on port 1025"config.action_mailer.delivery_method=:smtpActionMailer::Base.smtp_settings={address: "localhost",port: 1025}endrescueErrno::ECONNREFUSEDend# … other settings redacted …end

What does this code do? First of all we require NET::SMTP so that we can use it to detect whether there is a server on port 1025 (luckily both MockSMTP and MailCatcher use port 1025 by default).

Secondly we try to start an SMTP connection to port 1025. If the connection starts, we know that there’s an SMTP server running there and thus we can configure Rails to use it to send emails. If the connection doesn’t start, we don’t need to do anything.

Port 1025 isn’t a standard port for SMTP, so there’s little danger that we’d end up sending real emails to people from our development machine. If someone has a live SMTP server running on a non-standard port on their development machine we can assume that they know what they’re doing and can deal with the consequences.

If you’d like to see your actual signal strength (in dBm) on your iPhone instead of the normal little signal strength baubles, this is possible (though it’s a bit of a hack).

1. Enter Field Test Mode

Open up the Phone app and dial in *3001#12345#*, then hit Call .

Field Test Mode will open up immediately and you’ll see the signal strength in dBm in the upper left corner of the screen. Tapping the number (or baubles) will toggle between dBm and little baubles.

2. Make it stick

If you hit the home button and return to the home screen, the baubles will return, so don’t do that.

To make the signal strength stick:

Hold the power button until the “Slide to power off” overlay appears, then:

Release the power button and then hold the home button until the Field Test Mode quits

The signal strength should remain visible in the upper left corner of your screen, though I had to go through the whole procedure a few times before I got this to work (the first couple of times Field Test Mode just restarted instead of quitting).