Rails 3 提供了 match
方法供我们自定义 routes,然而我们要小心使用它以避免“跨站脚本攻击”(XSS Attack)。比如像这样的 routes:
注:(r3 代表 Rails 3,r4 代表 Rails 4)
# routes.rb
server { | |
listen 80; | |
server_name xxxxxxxxxxx; | |
access_log /var/log/nginx/nagios.access.log; | |
error_log /var/log/nginx/nagios.error.log info; | |
expires 31d; | |
root /usr/share/nagios3/htdocs; |
//= require jquery | |
//= require jquery_ujs | |
$(function() { | |
var source = new EventSource('/stream'); | |
source.addEventListener('counter', function(e) { | |
$('body').after(e.data + '<br />'); | |
}); | |
}); |
-- (p - 1) / (t + 2)^1.5 | |
CREATE FUNCTION SP_POINTS(P SMALLINT(5), CREATED TIMESTAMP) | |
RETURNS TINYINT(3) | |
RETURN (P - 1) / POW(TIMESTAMPDIFF(HOUR, CREATED, NOW()) + 2, 1.5); |
module EventMachine | |
# A simple iterator for concurrent asynchronous work. | |
# | |
# Unlike ruby's built-in iterators, the end of the current iteration cycle is signaled manually, | |
# instead of happening automatically after the yielded block finishes executing. For example: | |
# | |
# (0..10).each{ |num| } | |
# | |
# becomes: | |
# |
#!/usr/bin/env ruby | |
# Please read http://otobrglez.opalab.com for more information about this code. | |
class Book < Struct.new(:title) | |
def words | |
@words ||= self.title.gsub(/[a-zA-Z]{3,}/).map(&:downcase).uniq.sort | |
end |
@charset "utf-8"; | |
/*! | |
* @名称:base.css | |
* @功能:1、重设浏览器默认样式 | |
* 2、设置通用原子类 | |
*/ | |
/* 防止用户自定义背景颜色对网页的影响,添加让用户可以自定义字体 */ | |
html { | |
background:white; | |
color:black; |
…. | |
send_data = “aaaaaaaaaaaaa”; | |
i = 0; | |
begin | |
t = TCPSocket.new("127.0.0.1", 80); | |
t.send(send_data, 0); | |
begin | |
recv_data = t.recv_nonblock(100); #也可用read_nonblock代替 | |
recv_data.strip!; | |
rescue IO::WaitReadable |
str.scan(/../).map(&:hex).map(&:chr).join |