@quakewang 求教
$ mtr --report api.weibo.com HOST: vienna Loss% Snt Last Avg Best Wrst StDev 1.|-- 106.187.33.2 0.0% 10 5.7 4.1 0.4 22.7 7.1 2.|-- 124.215.199.121 0.0% 10 1.6 5.6 0.5 13.3 4.6 3.|-- 59.128.4.121 0.0% 10 1.6 1.7 1.6 2.7 0.3 4.|-- tr-ote124.kddnet.ad.jp 0.0% 10 2.0 2.1 1.8 2.2 0.1 5.|-- 118.155.194.178 0.0% 10 182.1 171.3 160.0 182.1 6.1 6.|-- 202.97.33.6 0.0% 10 184.5 171.8 162.7 184.5 6.5 7.|-- 202.97.35.97 0.0% 10 183.1 172.8 161.7 183.1 6.1 8.|-- 202.97.33.9 0.0% 10 184.8 173.4 166.2 184.8 6.2 9.|-- 202.97.34.133 0.0% 10 221.8 199.5 191.8 221.8 9.1 10.|-- 180.149.128.26 0.0% 10 204.5 201.3 189.4 212.3 7.9 11.|-- 180.149.128.46 0.0% 10 205.5 199.0 191.2 211.0 6.2 12.|-- 180.149.129.10 10.0% 10 208.6 196.4 190.5 208.6 5.2 13.|-- 180.149.135.230 10.0% 10 205.1 195.8 188.0 205.1 4.9
此问题已经解决,具体请看我 blog: http://larryzhao.com/blog/bundler-gemnotfound-deploying-with-capistrano-and-rvm-to-a-jruby-enviroment/, 或是这个 github issue: https://github.com/wayneeseguin/rvm-capistrano/issues/20
#1 楼 @HungYuHei 都用到了,我之前信息可能给的不够,现在编辑了,信息都在主贴的 gist 里
回完发现@Rei 之前已经提到了,spammer 了..
我觉得楼主可以查看一下twitter-text-rb
这个项目https://github.com/twitter/twitter-text-rb
之前用到过一下,里面 twitter 计算混合字符长度是用ActiveSupport::Multibyte::Chars
来做的,
项目之余简单做了一下实验,不知道如下是不是可以帮助到楼主 (ActiveSupport::Multibyte::Chars
这个类的 truncate 自动添加了...
):
jruby-1.6.7 :019 > text1 = "\u6c34some??\u6d52\u4f20"
=> "水some??浒传"
jruby-1.6.7 :020 > text2 = ActiveSupport::Multibyte::Chars.new(text1).normalize(:c)
=> #<ActiveSupport::Multibyte::Chars:0x458176ff @wrapped_string="水some??浒传">
jruby-1.6.7 :021 > text2.length
=> 9
jruby-1.6.7 :022 > text2.truncate(5)
=> #<ActiveSupport::Multibyte::Chars:0x4717e412 @wrapped_string="水s...">
可以看到中英混在一起可以正确的计算出长度,然后按照你给出的长度进行截取后会自动补全...
,还是挺方便的吧
一直在 subl 的怀抱中
@rubyonme 那看来可以猜出来哪个是你了~
Rails 倒是不必了,一直希望可以有个 local 的 irb, 在外面可以玩玩...穷人版只有 wifi..
我自己还没有用过,不过通过最近 mongoid 邮件组里,Durran 回答别人的邮件可以大致看出来应该怎么做:
You need to define a session for each one you want in your mongoid.yml, and then you can tell the models which session to persist to or at runtime you can change it.
The basics are here:
http://mongoid.org/en/mongoid/docs/persistence.html#custom
A session represents your connection to the server (or servers in the case of a replica set). If you want to change the session at runtime you use with #with method:
Model.with(session: "main").create
If you want a model to always persist to a specific session use .store_in:
class Model
include Mongoid::Document
store_in session: "secondary"
end
但是根据他后续的邮件,疑似这个还有些问题。你可以注册 mongoid 邮件组来关注进展。