Upload
itszero
View
444
Download
0
Embed Size (px)
DESCRIPTION
This is a slide of lightning talk session of OSDC.tw 2009. In this slide, we'll show you some example, and deployment tips & tricks on passenger(mod_rails), heroku and Google AppEngine.
Citation preview
SinatraZero & XDite
惡搞、惡搞、惡搞
Make Ur Calendar Icon
Yes, Make our own!
秘技
上上下下左右左右BA
UUDDLRLRBA
自我介紹
itsZero• Full-time student
• Works in hypo
• http://itszero.org/
• http://twitter.com/itszero
山寨傑洛我不會說日文也不會兩段跳...
這可以幹嘛?
Sinatra + RMagick
#!/usr/bin/rubyrequire 'rubygems'require 'sinatra'require 'RMagick'include Magick FONTPATH = File.dirname(File.expand_path(__FILE__)) + "/Aller/Aller_Bd.ttf" get '/' do open('public/index.html').readend get '/gen_icon' do headers['Content-Type'] = 'image/png' [some nasty RMagick code...] canvas.format = 'png' canvas.to_blobend
http://makeyourcalicon.heroku.comhttp://tr.im/j9DH
Another Example
Oh, Dear Mr IE6...
PHP / CodeIgniter
無法顯示中文
?
幾千行 debug 個鬼啊...by XDite
require ‘twitter_search’
require 'rubygems'require 'sinatra'require 'twitter_search'get '/' do @client = TwitterSearch::Client.new 'politweets' @results = @client.query :q => '@MrIE6' erb :homeend
10 行搞定 !
db & paginate
activerecord will_paginate
多寫了 40 行
Deployment!
Passenger
• (可以想成) Ruby 的 mod_php
• Supports Rack!
Rack
Handler Adapters
• Mongrel• WEBrick• FastCGI• Passenger
• Camping• Sinatra• Merb•...•...
Sinatra on Passenger
1 require 'rubygems' 2 require 'sinatra' 3 4 Sinatra::Application.default_options.merge!( 5 :run => false, 6 :environment => :production 7 ) 8 9 require 'make_your_cal_icon.rb' 10 run Sinatra::Application 11
=> config.ru
Java on GAE
JRuby + Sinatra + GAE
URLFetchingBumbleWill_paginate