Rails 3 提供了 match
方法供我们自定义 routes,然而我们要小心使用它以避免“跨站脚本攻击”(XSS Attack)。比如像这样的 routes:
注:(r3 代表 Rails 3,r4 代表 Rails 4)
# routes.rb
# coding=utf-8 | |
import Image, ImageDraw, ImageFont | |
import struct | |
font_width = 16 | |
font = ImageFont.truetype("/usr/share/fonts/truetype/wqy/wqy-zenhei.ttc", font_width) | |
def get_font_data(char): |
# coding=utf-8 | |
import Image, ImageDraw, ImageFont | |
import struct | |
font_width = 16 | |
font = ImageFont.truetype("/usr/share/fonts/truetype/wqy/wqy-zenhei.ttc", font_width) | |
def get_font_data(char): |
# Usage: | |
# [sudo] gem install mechanize | |
# ruby tumblr-photo-ripper.rb | |
require 'rubygems' | |
require 'mechanize' | |
# Your Tumblr subdomain, e.g. "jamiew" for "jamiew.tumblr.com" | |
site = "doctorwho" |
project :test => :shoulda, :renderer => :haml, :stylesheet => :sass, :script => :jquery, :orm => :activerecord | |
#default routes | |
APP_INIT = <<-APP | |
get "/" do | |
"Hello World!" | |
end | |
get :about, :map => '/about_us' do | |
render :haml, "%p This is a sample blog created to demonstrate the power of Padrino!" |
project :test => :shoulda, :renderer => :haml, :stylesheet => :sass, :script => :jquery, :orm => :activerecord | |
#default routes | |
APP_INIT = <<-APP | |
get "/" do | |
"Hello World!" | |
end | |
get :about, :map => '/about_us' do | |
render :haml, "%p This is a sample blog created to demonstrate the power of Padrino!" |
require 'amqp' | |
module HiringThingEM | |
def self.start | |
if defined?(PhusionPassenger) | |
PhusionPassenger.on_event(:starting_worker_process) do |forked| | |
# for passenger, we need to avoid orphaned threads | |
if forked && EM.reactor_running? | |
EM.stop | |
end | |
Thread.new { |
package main | |
import ( | |
"context" | |
"flag" | |
"fmt" | |
"log" | |
"net/http" | |
"os" | |
"os/signal" |