Rails 3 提供了 match
方法供我们自定义 routes,然而我们要小心使用它以避免“跨站脚本攻击”(XSS Attack)。比如像这样的 routes:
注:(r3 代表 Rails 3,r4 代表 Rails 4)
# routes.rb
while (!done) | |
{ | |
if (SDL_WaitEvent(&event)) | |
{ | |
switch (event.type) | |
{ | |
case SDL_QUIT: | |
view.interrupt(); | |
decode.interrupt(); | |
done = 1; |
# 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" |
class Image | |
attr_accessor :width, :height, :bitmap | |
end | |
img = Image.new | |
hexmap = nil | |
File.open('font1', 'rb') do |f| | |
data = f.read | |
img.width = data[0].ord |
# 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): |
{ | |
"debug": { | |
"resourceMap": { | |
"friendlyVersion": "v1.8-HM", | |
"media": [ | |
{ | |
"defName": "PUG", | |
"file": "images/pug.png", | |
"type": "png" | |
}, |
# 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): |
$ ./waf configure | |
Waf: The wscript in 'c:\\Users\\SouthWolf\\pebble\\sdk\\watches\\segment_six' is | |
unreadable | |
Traceback (most recent call last): | |
File "c:\Users\SouthWolf\pebble\sdk\watches\segment_six\waf-1.7.0-9334f7e963be | |
e5410f4fa28728feffdd\waflib\Scripting.py", line 87, in waf_entry_point | |
set_main_module(Context.run_dir+os.sep+Context.WSCRIPT_FILE) | |
File "c:\Users\SouthWolf\pebble\sdk\watches\segment_six\waf-1.7.0-9334f7e963be | |
e5410f4fa28728feffdd\waflib\Scripting.py", line 112, in set_main_module | |
Context.g_module=Context.load_module(file_path) |
#include <string.h> | |
#include <ctype.h> | |
const uint8_t req[5] = {0x00, 0x01, 0x00, 0x11, 0x00}; | |
const uint8_t cap[17] = {0x00, 0x0d, 0x00, 0x11, 0x01, 0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32}; | |
const uint8_t ping[9] = {0x00, 0x05, 0x07, 0xd1, 0x00, 0xde, 0xad, 0xbe, 0xef}; | |
const uint8_t sms[23] = {0x00, 0x13, 0x0b, 0xb8, 0x01, 0x01, 0x41, 0x01, 0x42, 0x0d, 0x31, 0x33, 0x37, 0x36, 0x34, 0x36, 0x36, 0x36, 0x35, 0x39, 0x30, 0x30, 0x30}; | |
//uint8_t serialMessage[200]; | |
int index = 0; |