Ruby China
  • Topics
  • 招聘
  • Wiki
  • 酷站
  • Gems
  • Sign Up
  • Sign In
Cxg
@serco
VIP
NO. 1667 / 2012-03-31

12 Topics / 209 Replies
6 Followers
0 Following
0 Favorites
GitHub Public Repos
  • easy_ping 6

    EasyPing is an out of the box Ping++ Ruby SDK

  • rebuilding_sinatra 2

    rebuild sinatra from scratch

  • oss-ruby 1

  • memorable 1

    A Rails logging system based on actions.

  • remax-plugin-insert 0

  • react-native-local-auth 0

    React Native authentication with the native Touch ID popup.

  • fixed-data-table 0

    A React table component designed to allow presenting thousands of rows of data.

  • rails-webpack-react-re... 0

    Boilerplate for Rails, Webpack React and Redux

  • web-check-fork 0

  • react-modal 0

    React Modal without inline styles

More on GitHub
  • Overview
  • Topics
  • Replies
  • Favorites
  • Following
  • Followers
  • 10 个 Ruby 技巧提升你的代码 at March 30, 2015
    1. ||= 不等同于 a || a = b ruby a || a = 2 # NameError: undefined local variable or method `a' for main:Object a ||= 2 # returns 2
  • 写了个网站,利用 webhok 自动获取用户的 repo 的 star 信息,关注人的分布以及关注者的被 follow 的数量排名 at March 30, 2015

    @no13bus Star Recode?

  • 类似朋友圈,获取当前用户和用户所有朋友的文章的解决办法! at February 10, 2015

    可能这样子?

    Topic.join(:creator).where('creator_id' => current_user.friends.pluck(:id).push(current_user.id)).order('updated_at desc')
    
  • 问一个问题。Fixnum 中 += 和 -=是原子操作吗?有没有源码地址呢? at January 26, 2015

    #13 楼 @xu_xiang_yang 感觉你没看清楚我的内容。。。 如果你用的是 CRuby,那么不需要纠结是否原子操作,只需要考虑何时 GVL 会释放,GVL 保证不了的当然要加锁。

    a+=1其实做的事情很多,不只是你想得那么简单

    1. 如果 a 不存在,声明局部变量 a,初始值为 nil,如果存在,则取出来
    2. +=1里并非自增,Ruby 里的 + operator 实际上也是个 method call,所以支持 +=2
    3. 保存结果回 a
  • 新手问题,大家看看什么情况 at January 26, 2015

    你本地的 cache 有问题,删除 /Users/xxxx/.rvm/gems/ruby-2.1.3/cache/web-console-2.0.0.gem,重新 bundle 应该就可以

  • 问一个问题。Fixnum 中 += 和 -=是原子操作吗?有没有源码地址呢? at January 22, 2015

    #7 楼 @loong0 应该差不多的

    += 应该会分成两步

    1. 检查是否需要声明变量
    2. 运行 + 操作符
    2.1.4 :001 > a + 1
    NameError: undefined local variable or method `a' for main:Object
    2.1.4 :002 > a += 1
    NoMethodError: undefined method `+' for nil:NilClass
    2.1.4 :003 > a
     => nil
    
  • 求教关于 Ruby 的多线程问题 at January 19, 2015

    #14 楼 @rocLv 没有看过 <代码的未来>,能详细说一下嘛? 目前我的理解是,MRI 下,所有 C 实现的 Ruby 核心库部分是线程安全的,因为有 GVL 在 Ruby 实现的部分标准库,用 Ruby 写的其他项目,不一定是线程安全的

  • [译] Ruby concurrency explained at January 19, 2015

    看到译文这里,感觉不对劲,回头看一眼原文,感觉这里 lz 表述有误

    许多 C 的扩展不是线程安全的也没有 GIL, 这些 C 扩展就会出现问题。

    原文

    a lot of C extensions are not thread safe and without the GIL, these C extensions don’t behave properly.

    这里是说很多 C 扩展不是线程安全的, 没有 GIL 的话 ,这些 C 扩展就不能正确工作

  • Sidekiq:导致 Frozen Worker 的两个风险 at January 16, 2015

    #1 楼 @xiaoronglv 我猜第一种情况应该已经不会发生了

    2.16.1 (sidekiq changelog)
    Revert usage of resolv-replace. MRI's native DNS lookup releases the GIL.
    
  • 求教关于 Ruby 的多线程问题 at January 16, 2015

    #6 楼 @rocLv 应该倒过来说吧,MRuby 是本身是 thread safe, 个人写的代码不管是 MRuby 还是 JRuby 都需要自己注意 thread safe

  • Sidekiq:导致 Frozen Worker 的两个风险 at January 15, 2015

    #1 楼 @xiaoronglv

    多线程都需要注意一些 C Extensions 的 GIL block 住整个进程。

  • Array 迭代给 Hash 赋值的问题 at January 12, 2015

    不知道你的真实需求,按照你原帖的代码,你为什么不写成这样?

    [1,2,3,4].map {|num| {number: num-1, index: num}}
    
  • Array 迭代给 Hash 赋值的问题 at January 12, 2015

    因为你的 su 里面实际只是同一个 data 的引用 而已。 而且你实际需要的方法也应该是 map

  • [已解决] link_to 背后有很多黑魔法 at January 09, 2015

    #8 楼 @zhutingting 抛开 Ruby,有哪个实际的项目是在不停不停更新自己用的前端 library? 即使 gem 更新速度 跟原生前端项目一样快,光那些 Library 的 API 变化就该改死人了

    另外,没有人说过,用 Rails 的话,前端就必须要用 gem,用 bower 也完全没问题,再粗糙点直接复制粘贴都行。

  • 我发现 macbook 一旦开始使用虚拟内存就没那么流畅了 at January 07, 2015

    从 lion 一路升级到 yosemite,每次都是升级不是全新安装,完全没感觉到卡。。。

  • 关于 Redmine 源码中一个方法的定义与调用....没看懂 T^T at January 07, 2015

    你调用的是另一个同名方法

    def safe_attributes(*args)
      @safe_attributes ||= []
      if args.empty?
        if superclass.include?(Redmine::SafeAttributes)
          @safe_attributes + superclass.safe_attributes 
        else
          @safe_attributes
        end
      else
        options = args.last.is_a?(Hash) ? args.pop : {}
        @safe_attributes << [args, options]
      end
    end
    
  • 为啥 Mac 上 safari 开 ruby china 页面渲染会卡住的 at January 07, 2015

    safari 8.02 开很多页面会卡住,可能是 safari 的 bug

  • 阅读 Sinatra 源码的感悟 (水平不高,纯属纪录) at January 07, 2015

    做过类似的事情,按照 sinatra 源码的组织方式,一个 commit 一个 commit 的重新搭建 sinatra https://github.com/serco-chen/rebuilding_sinatra

  • 能否推荐一款支持 Markdown + wysiwyg 的编辑器 at January 05, 2015

    #1 楼 @Rei 推荐看一下 http://realmacsoftware.com/typed 几乎是可视化的 markdown 编辑器

  • 12月20日 上海线下活动 PPT 分享: Ruby on Rails 开发遇到的问题 at January 04, 2015

    @lotus 我来回答你第一个问题吧。

    这个是 Arel 的一个问题,https://github.com/rails/arel/pull/262 但是 MySQL 并不支持在 update syntax 里使用 offset,http://dev.mysql.com/doc/refman/5.5/en/update.html

    所以 Arel 的维护者,包括这个 issue 的提交者觉得这个并不应该是个合理的行为,毕竟你用 MySQL 调用的时候自动会忽略 offset,用 PG 则会加上 offset 就会很奇怪。

  • 请问这段代码什么意思? at December 27, 2014

    方括号用来访问 hash,取得的值是一个 lambda,所以用 call 来调用

  • [上海][2014年12月20日] 上海及长三角年度聚会 (12 月 19 日 求借移动投影屏幕) at December 20, 2014

    #87 楼 @as181920

    一个 CI 工具,他提到是 Travis-CI,很多开源项目在用,商用收费。团队内部可以用 jenkins 搭建 另一个代码检查,说的是一个第三方服务,CodeClimate。同样,如果穷人版可以选择 metric_fu, brakeman

  • 关于多选数据修改 at December 18, 2014

    #16 楼 @gerry1004 或者字典的解释已经跟我们上学的时候不一样了,哈哈

  • unicorn.sh 问题请教 at December 17, 2014

    #1 楼 @xiaoronglv 我觉得应该是多余的,从定义上来看。

    Exit immediately if a pipeline (see Pipelines), which may consist of a single simple command (see Simple Commands), a subshell command enclosed in parentheses (see Command Grouping), or one of the commands executed as part of a command list enclosed by braces (see Command Grouping) returns a non-zero status. The shell does not exit if the command that fails is part of the command list immediately following a while or until keyword, part of the test in an if statement, part of any command executed in a && or || list except the command following the final && or ||, any command in a pipeline but the last, or if the command’s return status is being inverted with !. A trap on ERR, if set, is executed before the shell exits.
    
    This option applies to the shell environment and each subshell environment separately (see Command Execution Environment), and may cause subshells to exit before executing all the commands in the subshell.
    
  • lambda binding 的一些行为 at December 12, 2014

    如果只是想复用一些代码,可以使用 UnboundMethod

    module A
      def test(a)
        puts a + 1
      end
    end
    
    un_test = A.instance_method(:test)
    
    class B
    end
    new_test1 = un_test.bind(B)
    new_test1.call(5)
    

    另外关于为什么 eval 不能定义局部变量

    locals are bound at compile-time since 1.9

  • 写了一个 Ping++ Ruby SDK at December 03, 2014

    #1 楼 @a167651202

    官方当然可以,我重新写一个是觉得官方的部分方法我觉得太复杂了。 比方我不想每次创建 charge 都设置一次 app_id 等等

    另外就是我自己按照喜好加了一些 helper

  • 作为开发者,你喜欢 markdown 还是所见即所得的编辑器 at November 29, 2014

    #26 楼 @kgen 我个人认为 很多人不是觉得 markdown 方便,而是没有适合的所见即所得编辑方式。 其实像 medium 已经改变了很多人对所见即所得编辑方式的看法。

  • Coding PaaS 平台自定义域名正式开放! at November 28, 2014

    #13 楼 @Peter 这个不都已经烂大街了嘛? http://alvarotrigo.com/fullPage/examples/navigationV.html

  • 龟速的测试, 求解救 at November 27, 2014

    是不是 feature specs, 用了 capybara cucumber 之类的?

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