国内访问奇慢。
弓虽
看 git log
if defined? 改成 if not defined? 才有实际意义。
加载文件超过 3 万个时,load 性能要更好一些
ruby 里面的 iconv, 第二个参数是 -f
class String
def code_a2b(a,b)
if RUBY_VERSION > '1.9.2' and defined? Encoding::Converter
tmp = Encoding::Converter.new(a,b, :universal_newline => true)
tmp.convert self rescue self
else
Iconv.conv("#{b}//IGNORE","#{a}//IGNORE",self)
end
end
end
puts "xxx".code_a2b("gb2312","utf8")
如果车速可能达到 50 码,必须系。
#20 楼 @bullockzhou 有多敏感啊。如果跑步喘气,说明氧气不足。
空气这么差,能跑吗?我喜欢在树林里跑,绿色植物多 氧气多
Watir.com | Web Application Testing in Ruby
ruby 的 mixin 算不算?
require 'time'
arr = [['2013-07-05', 12], ["2013-07-01", 24], ["2013-06-30", 34]]
h = {}
h.default = 0
arr.each{|x| h[Time.parse x[0]] = x[1] }
arr.clear
8.times{|i| arr << h[h.keys.min +86400*i] }
p arr
用 Vim 的人飘过...
gimp +1 wine +1
vim +1 罗技 +1
只要建造房子的成本降下来就 OK, 但是很多房子都空着,没人住啊,浪费啊。有木有。
'a'..'z' , '1'..'9' , 35 个字符 35.to_s(2) => "100011" 6 位
8 位的数据用 6 位存放,可以再压缩 75%
ubuntu server
好多坑阿...
要求登陆,不然就加限制。锁 ip. 登陆的人也要限制。
["11.0", "0.1", "1.2", "1.3", "0.2"]
.group_by{|s| s.match(/\d+\./)[0] }
嗯,可以再加个扔鸡蛋,扔钱什么的,送积分什么的...
你可以使用 http://www.sinatrarb.com/intro.html
get '/post.*' do
t = %w[text/css text/html application/javascript]
request.accept # ['text/html', '*/*']
request.accept? 'text/xml' # true
request.preferred_type(t) # 'text/html'
request.body # request body sent by the client (see below)
request.scheme # "http"
request.script_name # "/example"
request.path_info # "/foo"
request.port # 80
request.request_method # "GET"
request.query_string # ""
request.content_length # length of request.body
request.media_type # media type of request.body
request.host # "example.com"
request.get? # true (similar methods for other verbs)
request.form_data? # false
request["some_param"] # value of some_param parameter. [] is a shortcut to the params hash.
request.referrer # the referrer of the client or '/'
request.user_agent # user agent (used by :agent condition)
request.cookies # hash of browser cookies
request.xhr? # is this an ajax request?
request.url # "http://example.com/example/foo"
request.path # "/example/foo"
request.ip # client IP address
request.secure? # false (would be true over ssl)
request.forwarded? # true (if running behind a reverse proxy)
request.env # raw env hash handed in by Rack
end
数据都在 request.body
如果服务器的磁盘是内存盘,估计接收到了马上写入文件,而不是等接收完了再一次写入。 万一上传的文件有 1G, 难道要占用 1G 内存?
找个新的更好的。
可以自己覆盖 stdlib
ruby 代码可以自己替换说有的变量名为 a,b,c,d 这种不?也算是混淆了