Ruby China
  • Topics
  • 招聘
  • Wiki
  • 酷站
  • Gems
  • Sign Up
  • Sign In
Zete
@luikore
VIP
NO. 2880 / 2012-07-16

55 Topics / 3422 Replies
245 Followers
6 Following
32 Favorites
GitHub Public Repos
  • triez 140

    fast, efficient, unicode aware HAT trie with prefix / suffix support for Ruby

  • rsec 78

    Parser / Regexp Combinator For Ruby

  • regexp_optimized_union 11

    Regexp.optimized_union(word_list, regexp_options) generates optimized regexp for matching union o...

  • zscan 9

    Improved string scanner

  • stimulus-bind 9

    Enable simple data binding for stimulusjs

  • vscode-hypertab 3

    The Missing Tab Completion for VS Code

  • property-list 1

    Property list (plist) library with all formats support

  • keycap 1

    1.5u keycap for Kailh low profile switch

  • ffi-clang 0

    Ruby FFI bindings for libclang 3.4+.

  • llvm-node 0

    Node LLVM 4.0+ Bindings

More on GitHub
  • Overview
  • Topics
  • Replies
  • Favorites
  • Following
  • Followers
  • 更好的命令行 at May 25, 2015

    类似还有:

    更好的文件系统,存对象而不是文件 更好的集成开发工具,直接编辑对象的属性,而不是源代码文本 更好的网络协议,传输对象而不是流 ...

    smalltalk 都做过

  • 将两个数组交叉合并分享 at May 21, 2015
    a.zip(b).flatten
    

    需要性能可以写个 C extension...

  • Crystal 0.7 Released at May 21, 2015

    呃,估计没有,可否做个 crystal 的简介?以及它为什么特别?

  • ImageMagick 操作 eps 图片问题 at May 21, 2015

    eps 是 embed postscript, 所以要安装 ghostscript 支持

    brew info imagemagick 看看 ghostcript 是否勾上了,没有的话

    brew reinstall imagemagick --with-ghostscript
    
  • RubyMotion 的 一个深坑 at May 21, 2015

    你误解了 Objective-C 的语法,把它和 C++ 的语法混淆了

    foo.equalTo(bar)
    

    其实是下面的语法糖 (记住,objective-C 的点语法是 getter 的语法糖而不能代替带参数的方法!! ):

    [foo equalTo](bar)
    

    所以对应的 Ruby 是 foo.equalTo.(bar) 或者 foo.equalTo[bar] 或者 foo.equalTo.call bar

    假如 equalTo 需要一个参数,在 Objective-C 中就只能这么写:

    [foo equalTo: bar]
    
  • Ruby 中的各种稀奇古怪的关键字 at May 17, 2015

    双下划线可以这么输入:

    \_\_END\_\_
    

    千分符,heredoc 等等不算关键字

  • 新手请教一个简单的 ruby 问题——字符串输出某列 at May 15, 2015
    require 'csv'
    _, *rows = CSV.parse rs.strip, col_sep: ' '
    rows.map {|r| r.values_at 5, 6 }
    
  • 对于多进程或者多线程 Logger 类是否是安全的? at May 13, 2015

    在 Linux 一直是安全的,因为

    • Logger IO 是 sync 的不 buffer
    • Logger::LogDevice#write 用了 mutex 保证线程安全
    • Linux 的 write 函数是原子的保证进程安全

    对 log rotation, Ruby 2.1 之后是安全的,因为

    • 现在 logger 打开 log 时会调用文件锁 logdev.flock(File::LOCK_EX)

    信息来源:源代码和 http://b.hatena.ne.jp/entry/www.slideshare.net/sonots/rubylogger-rubyconf-20131109

  • Grunt 前端自动化构建工具 [方便懒得看英文文档的新同学] at May 08, 2015

    #12 楼 @lgn21st 我觉得把简单灵活的命令行参数做成一个复杂难用的插件太蛋疼...

    concat 不就是 cat 么... global command 的问题 thor 解决 streaming 就是重新发明了 shell 的 pipe orchestra 什么的依赖管理 make/rake 本来就带 watch 我们的编译工具里已经有 sass --watch, browserify --watch , 还有 listen 和 guard 等 gem 可以用

  • Grunt 前端自动化构建工具 [方便懒得看英文文档的新同学] at May 07, 2015

    #6 楼 @lips 都有,而且不需要记那么复杂的 json 配置结构

  • Grunt 前端自动化构建工具 [方便懒得看英文文档的新同学] at May 07, 2015

    其实 rake 和 thor 更好用...

  • Ruby VS Scala at May 05, 2015

    If you want brackets, use Clojure If you want verbosity, use Java If you want both, use Scala

  • 写起 Python 来各种不习惯…… at May 05, 2015

    嗯,其实 len(array) 是 array.__len__() 的语法糖... 不加括号的 print 在 python 2 是可以的,但 python 3 不行... array[start:stop:step] 挺强大的,不过哲学是只用一种方法操作,所以没有 array.first ... list comprehension 也挺好使,比较适合简化一些需要 map + filter 才能完成的操作

  • Ruby C extension 中怎么把 C wchar 类型和 ruby string 互相转换? at May 04, 2015

    请问你这个 wchar 是哪个 wchar? 可否提供更详细的信息?

    • 如果你指的是 Win32 API 的 WCHAR, 它是 UTF-16 内码,little endian (UTF-16LE).
    • 如果你指的是 wchar_t, 不同平台的 wchar_t 是不同长度的,有的是是 UTF-16 有的是 UTF-32, 还有别的,而且有 big endian/little endian 的区别 (x86 一般都是 little endian, 不过最好自己做下试验先).

    弄清楚内码以后,强转成 char* 交给 rb_enc_str_new, 然后再调用 rb_str_encode 或者在 ruby 方面用 String#encode 方法转换回 utf-8 的字符串。

    以 Win32 API WCHAR 为例,它是 UTF-16LE 内码,所以对应的字节数目是字符串长度乘以 2, 假设你有 wchar_ptr, wchar_len

    #include <ruby/encoding.h>
    
    .....
    
    volatile VALUE s;
    s = rb_enc_str_new((char*)wchar_ptr, wchar_len * 2, rb_enc_find("UTF-16LE"));
    s = rb_str_encode(s, rb_enc_from_encoding(rb_utf8_encoding()), 0, Qnil);
    

    假设你有个 Ruby 字符串 s

    s = rb_str_encode(s, rb_enc_from_encoding(rb_enc_find("UTF-16LE")), 0, Qnil);
    WCHAR* wchar_ptr = (WCHAR*)RSTRING_PTR(s);
    int wchar_len = RSTRING_LEN(s) / 2;
    

    基础知识见: http://www.rubydoc.info/stdlib/core/file/README.EXT

    找 API 只能看头文件咯: http://rxr.whitequark.org/mri/ident?i=rb_str_encode

    另外,如果你在 C++, 那个强制转换会稍微麻烦点,得用 reinterpret_cast<>

  • [ 已解决 - 更新解决方案 ] 如果在这里问大家怎么对付蚊子的,会不会被拍死? at May 01, 2015

    #16 楼 @chairy11 再 + 电热毯...

  • [ 已解决 - 更新解决方案 ] 如果在这里问大家怎么对付蚊子的,会不会被拍死? at May 01, 2015

    #14 楼 @lgn21st six god 效果很弱吧,没有驱蚊液有效...

  • [ 已解决 - 更新解决方案 ] 如果在这里问大家怎么对付蚊子的,会不会被拍死? at May 01, 2015

    空调低温抽湿 + 大被子

  • 用了 Ruby 以后,发现瓶颈已不在数据库,而在语言 at April 30, 2015

    #38 楼 @tini8 不好意思写错了...

    trees = trees.to_a
    q = trees.group_by &:parent_id
    trees.each do |t|
      t.children = q[t.id]
    end
    # 如果要选取根节点, trees.select!{|t| !t.parent_id}
    
  • Ruby 服务器对比 at April 29, 2015

    如果有 phusion passenger 5 (raptor) vs unicorn 的性能测试我就点赞

  • 用了 Ruby 以后,发现瓶颈已不在数据库,而在语言 at April 29, 2015

    time 一下这个吧... 其实楼主你的 ruby 代码和 php 代码都写复杂了

    trees = trees.to_a
    q = trees.group_by &:parent_id
    trees.each do |t|
      t.children = q[t.parent_id]
    end
    
  • 写一个 “判断没有包含某个字符串的正则 “遇到的问题 at April 28, 2015
    1. 请用 markdown 编辑帖子
    2. line1 !~ /mysql/i 就好了,另外 ^ 和 $ 其实匹配的是行首和行末,\A 和 \z 才是匹配字符串首末。普通模式 . 不匹配换行符,多行模式 . 才可以匹配换行符。
    3. 建议加个头像
  • 用了 Ruby 以后,发现瓶颈已不在数据库,而在语言 at April 27, 2015

    既然你不熟悉 Ruby 又没时间,为何不直接用 act_as_nested_set... 都不用自己写,还快很多

  • JSON VS Protobuf at April 27, 2015

    #12 楼 @yueyoum 是的,Unix 系统里就大量应用了文本协议而不是二进制协议,开发起来很方便

    自动生成代码对动态语言没用,因为用 json 你都不用生成代码... 也就静态语言操作 json 麻烦点

  • JSON VS Protobuf at April 27, 2015

    protobuf/thrift 的 ruby/python 实现非常糟糕,完全体现不出速度来,还不如用 capnp + C 绑定

    messagepack 是比 json 要快一点,但它的 js 版比 json 慢很多

    没有巨大的性能差别的话,还是选择纯文本协议比较好

  • 怎样查看 Ruby 提供的方法的用法 at April 27, 2015

    pry 里 show-doc foo_method

  • 根据实际的应用场景 Rails 其实还可以做到更极致的优化 at April 24, 2015

    把这一大段直接加 view 片段缓存,可以更简单和快一点。

    class << Rails
      attr_accessor :memory_cache
    end
    Rails.memory_cache = ActiveSupport::Cache::MemoryStore.new
    
    == Rails.memory_cache.fetch 'header' do
      = javascript_include_tag ...
      = stylesheet_link_tag ...
    

    开发模式还要禁用掉否则不能 reload

  • 使用子域名有什么不好的地方吗? at April 23, 2015

    因为支持任意子域名的 SSL 证书贵,跨子域名登录验证做起来麻烦

    不过 SaSS/PaSS 服务如果允许用户放上自己的 js, 那用子域名隔离 cookie 可能得是必须的

  • 现在可以屏蔽节点和用户了 at April 20, 2015

    #1 楼 @huacnlee 把 屏蔽 改成 折叠 ?

  • transproc 的可读性更好么? at April 18, 2015

    #3 楼 @chenge https://en.wikibooks.org/wiki/Haskell/do_notation

  • transproc 的可读性更好么? at April 18, 2015

    为什么 Haskell 有 do-notation? 就是为了不像 code 1 那么写代码而像 code 2 那么写,本末倒置了...

  • Prev
  • 1
  • 2
  • …
  • 17
  • 18
  • 19
  • 20
  • 21
  • …
  • 111
  • 112
  • Next
关于 / RubyConf / Ruby 镜像 / RubyGems 镜像 / 活跃会员 / 组织 / API / 贡献者
由众多爱好者共同维护的 Ruby 中文社区,本站使用 Homeland 构建,并采用 Docker 部署。
服务器由 赞助 CDN 由 赞助
iOS 客户端 / Android 客户端 简体中文 / English