May 252016
 
def wait_for_ajax
 counter = 0
 while page.evaluate_script(“typeof($) === ‘undefined'”)
  counter += 1
  print “^”
  $stdout.flush
  sleep(0.1)
  raise “Jquery not initialized after 10 seconds.” if counter >= 100
 end

 counter = 0
 while page.evaluate_script(“$.active > 0”)
  counter += 1
  print “_”
  $stdout.flush
  sleep(0.1)
  if counter >= 100
   msg = “AJAX request took longer than 10 seconds.”
   if page.driver.respond_to?(:console_messages)
    msg << ” console messages at time of failure: ” + page.driver.console_messages.inspect
   end
   raise msg
  end
 end
end

May 212016
 

First, on Heroku, you’ll need to add a special buildpack to your slug:

(note that all of the following commands you may need to append with -a if you manage more than one Heroku app)

heroku buildpacks:add -i 1 https://github.com/jasonfb/heroku-buildpack-cedar14-imagemagick695

(Here -i 1 tells the command you want the buildpack at index 1. It’s important that you include this flag or else the Heroku API will add your buildpack before the default build, which is known simply as heroku/ruby)

(If you’d prefer to use ImageMagick 7.0.24, I’ve also made a buildpack for that available here: https://github.com/jasonfb/heroku-buildpack-cedar14-imagemagick704)

You can and should examine what you just added with:

To examine what you just did:

heroku buildpacks

You should see the response:

$ heroku buildpacks:add -i 1 https://github.com/jasonfb/heroku-buildpack-imagemagick695

Buildpack added. Next release on app-xyz will use:
 1. https://github.com/jasonfb/heroku-buildpack-imagemagick695
 2. heroku/ruby
Run git push heroku master to create a new release using these buildpacks.

To undo what you just did

heroku buildpacks:remove https://github.com/jasonfb/heroku-buildpack-imagemagick695

Then push your app to your repo. You will notice it takes a few minutes to compile the new ImageMagick binary and install it into the slug.

You can set the :convert_options in your paperclip definitions, or to make a global change to all your definitions use a monkeypatch like so:

Create a file for paperclip init if you don’t already have one

config/initializers/paperclip_defaults.rb

Monkeypatch the Paperclip processor with the resize filter of your choice.

module Paperclip
 class Processor
def convert(arguments = “”, local_options = {})
 if (arguments =~ /-resize/)
  arguments.sub!(“-resize”, “-filter Lanczos -resize”)
 end
 Paperclip.run(‘convert’, arguments, local_options)
end
 end
end

You can read all about the kinds of filters here.