Skip to content

Instantly share code, notes, and snippets.

View woodie's full-sized avatar

John Woodell woodie

View GitHub Profile
@woodie
woodie / README.rdoc
Created October 19, 2009 18:39
Using Servlets
# bundle everything into .gems (won't be uploaded)
disable_rubygems
bundle_path '.gems/bundler_gems'
gem "rack", "1.0.0"
gem "dm-appengine"
gem "sinatra"
gem "haml"
. . .
@woodie
woodie / Gemfile
Created October 27, 2009 05:06
bundle and jar up from within ruby
# Critical default settings:
disable_system_gems
disable_rubygems
bundle_path ".gems/bundler_gems"
# List gems to bundle here:
#gem "rack", "1.0.0"
gem "dm-appengine"
gem "sinatra"
@woodie
woodie / Gemfile .rb
Created November 12, 2009 09:18
Rails 3.0.pre GAE Guide
# Critical default settings:
disable_system_gems
disable_rubygems
bundle_path ".gems/bundler_gems"
# List gems to bundle here:
gem "rails", "3.0.pre", :git => "git://github.com/rails/rails.git"
gem "arel", :git => "git://github.com/rails/arel.git"
gem "i18n"
gem "dm-appengine"

Hpricot, Read Any HTML

Hpricot is a fast, flexible HTML parser written in C. It's designed to be very accommodating (like Tanaka Akira's HTree) and to have a very helpful library (like some JavaScript libs -- JQuery, Prototype -- give you.) The XPath and CSS parser, in fact, is based on John Resig's JQuery.

Also, Hpricot can be handy for reading broken XML files, since many of the same techniques can be used. If a quote is missing, Hpricot tries to figure it out. If tags overlap, Hpricot works on sorting them out. You know, that sort of

@woodie
woodie / rails_appengine.rb
Created December 5, 2009 20:15
Rails 3 on App Engine - from hg files
#!/usr/bin/ruby
require 'rubygems'
file_base = 'http://appengine-jruby.googlecode.com/hg/demos/rails/'
mod_files = %w{ app/controllers/rails/info_controller.rb
Gemfile config/application_rb config/boot.rb
config/initializers/notifications.rb config_ru }
# Install apengine gems if missing
gems_index = Gem::SourceIndex.from_gems_in('local')
@woodie
woodie / show_exceptions.rb
Created December 31, 2009 06:53
Rails 3 error logging bug
# Rails 3 needs error logging
~/rails/actionpack/lib/action_dispatch/middleware/show_exceptions.rb
private
def render_exception(env, exception)
# ------------------------------------------- #
puts exception.to_s # show me the error please!
# ------------------------------------------- #
log_error(exception)
@woodie
woodie / eager_autoload.rb
Created December 31, 2009 08:52
Rails 3 frameworks
~/rails/railties/lib/rails/application.rb
# Preload all frameworks specified by the Configuration#frameworks.
# Used by Passenger to ensure everything's loaded before forking and
# to avoid autoload race conditions in JRuby.
initializer :preload_frameworks do
ActiveSupport::Autoload.eager_autoload! if config.preload_frameworks
end
# commenting out this had no effect on unwanted frameworks
@woodie
woodie / README.rdoc
Created January 3, 2010 23:32
Rails 2.3.5 on App Engine with DataMapper

Rails 2.3.5 on App Engine (DataMapper)

Do not use rvm (or install and run from JRuby). The google-appengine gem must install into your system MRI. The appengine-sdk gem includes a complete Java app server. We bootstrap Java from MRI, then your app runs inside a servlet container (with access to all the APIs) using the version of JRuby installed into each app.

We assumed Rails 2 would never work without rubygems, and we committed to gem bunlder for JRuby on App Engine, so we were waiting for Rails 3. Fortunately, Takeru Sasaki was able to patch the Rails 2.3.x calls to rubygems, and now we have it working. Rails 2.3.x currently spins up several seconds faster than Rails 3, and just a few seconds behind Sinatra.

See the TInyDS version also: gist.github.com/gists/269075

Install the Development Environment

@woodie
woodie / README.rdoc
Created January 5, 2010 02:04
Rails 2.3.10 on App Engine with TinyDS

Rails 2.3.10 on App Engine (TinyDS)

Do not use rvm (or install and run from JRuby). The google-appengine gem must install into your system MRI. The appengine-sdk gem includes a complete Java app server. We bootstrap Java from MRI, then your app runs inside a servlet container (with access to all the APIs) using the version of JRuby installed into each app.

We assumed Rails 2 would never work without rubygems, and we committed to gem bunlder for JRuby on App Engine, so we were waiting for Rails 3. Fortunately, Takeru Sasaki was able to patch the Rails 2.3.x calls to rubygems, and now we have it working. Rails 2.3.x currently spins up several seconds faster than Rails 3, and just a few seconds behind Sinatra.

See the DataMapper version also: gist.github.com/671792

Install the Development Environment