SSL/HTTPS for Passenger in development on Ubuntu Jaunty

Making a certificate

sudo mkdir /etc/apache2/ssl
sudo /usr/sbin/make-ssl-cert /usr/share/ssl-cert/ssleay.cnf /etc/apache2/ssl/apache.pem
sudo a2dissite default-ssl
sudo a2enmod ssl
sudo /etc/init.d/apache2 restart

Configure passenger

<VirtualHost *:80>
 ServerAlias *.something.com
 RailsEnv development
 DocumentRoot /apps/something/public
</VirtualHost>
<VirtualHost *:443>
 SSLEngine on
 SSLCertificateFile /etc/apache2/ssl/apache.pem
 ServerAlias *.something.com
 RailsEnv development
 DocumentRoot /apps/something/public
</VirtualHost>

host

descriptive raise — tired of exception class/object expected ?

# descriptive raise
# normale: raise 1 == TypeError: exception class/object expected
# now: raise 1 == RuntimeError: 1
class Object
  def raise_with_helpfulness(*args)
    raise_without_helpfulness(*args)
  rescue TypeError => e
    raise_without_helpfulness args.first.inspect if ['exception class/object expected', 'exception object expected'].include?(e.to_s)
    raise_without_helpfulness e
  end
  alias_method_chain :raise, :helpfulness
end

Switching to RubyMine from Netbeans on Ubuntu

I recently did the switch and it was fun, and now I finally got everything working, here are the steps I took:

  • Install rubymine and make a shortcut
  • Use Textmate style shortcuts (so I can work with all the evil textmaters out there :> )
  • Correct Meta key behaviour:
    keyboard > layout options
    choose meta is mapped to left win
  • fuzzy autocomplete / Textmate Esc autocomplete is called “cyclic completion”, find it in keymap and replace it with Esc
  • add ctrl+c/v/x/z/… shortcuts so rubymine behaves like all the other apps

Benefits:

  • great fuzzy file search e.g. “ba/us/in” -> app/backend/users/index.erb
  • Fast autocompletion
  • Nice refactoring with preview
  • Warnings / hints on local / global / unused variables and sane spellchecking
  • Tons of options for whitespace/editor layout
  • Integrated git with visible history
  • “click something and got to its definition” works great

Drawbacks

  • Startup takes ~30s for large app (initial indexing took ~ 4min)
  • To many menu entries, but they can be customized out…

Speeding up Slow Spork Startup for Rails 2.3+

If you noticed spork startup getting slower when switching to Rails 2.3, your not alone 😉

  • Views are eager loaded
  • app/ is eager loaded (when config.cache_classes is on)

Without hack: 18s startup
With hack: 2s startup 😀

Try it

#spec/spec_helper.rb
require 'spork/app_framework/rails'
Spork::AppFramework::Rails::NinjaPatcher.class_eval do
  # views are preloaded  spork must be restarted for view changes
  def delay_eager_view_loading
    puts "removed because i am too slow..."
  end

  # do not preload application files
  # alternatively urn off config.cache_classes
  def delay_app_preload
    ::Rails::Initializer.send(:define_method, :load_application_classes){}
  end
end


Spork.prefork do
  ...