Ruby China
  • Topics
  • 招聘
  • Wiki
  • 酷站
  • Gems
  • Sign Up
  • Sign In
李华顺
@huacnlee
Admin
NO. 2 / 2011-10-28

[email protected]
长桥证券 (Longbridge)
成都
502 Topics / 9058 Replies
959 Followers
53 Following
105 Favorites
Reward
GitHub Public Repos
  • autocorrect 1410

    A linter and formatter to help you to improve copywriting, correct spaces, words, and punctuation...

  • rails-settings-cached 1101

    Global settings for your Rails application.

  • rucaptcha 696

    Captcha Gem for Rails, which generates captcha image by Rust.

  • zed-theme-macos-classic 95

    A macOS native style theme for Zed, let it same like native app in macOS.

  • vscode-macos-classic.t... 21

    macOS Classic theme for Visual Studio Code

  • zed-extension-action 19

    GitHub Action for automatically bump Zed Extensions version after a release.

  • autocorrect-action 11

    GitHub action for use AutoCorrect as lint

  • zed-autocorrect 6

    AutoCorrect for Zed

  • gpui-workspace 4

    Dock layout UI component for GPUI, that extracted from Zed project.

  • zed-lalrpop 3

    LALRPOP parser grammar support for Zed.

More on GitHub
  • Overview
  • Topics
  • Replies
  • Favorites
  • Following
  • Followers
  • 有人使用 redis-store 来做 cache store 吗? at November 25, 2011

    @nowazhu Redis 是长久存放的,很多数据不便于放里面,尤其是用了 redis-objects 将一些重要的数据也放 Redis 里面的时候,放到 Memcached 里面会变得放心些。 把握点就是不重要的 Cache 或 数据就扔 Memcached,重要的放 Redis 现在 Ruby China 也已经从之前的 redis-store 撤回到了 Memcached

  • 好奇 wget 那种百分比的进度是如何打印出来的 at November 25, 2011
    100.times do |i|
      print ("="*i).ljust(100) + "#{i}%\r"
      $stdout.flush
      sleep 1
    end
    
  • 好奇 wget 那种百分比的进度是如何打印出来的 at November 25, 2011

    哈哈,会了,谢啦

  • Code smell in Ruby-China code base at November 24, 2011

    #42 楼 @xdite 这个还是碍于对于 MongoDB 的一些机制不够了解,还有目前 Mongoid 的某些 Bug 也可能是带来性能问题的原因,比如 N+1 的问题

  • Code smell in Ruby-China code base at November 24, 2011

    新的机制: https://github.com/huacnlee/ruby-china/blob/bed5d21cf82d51e01c36778abece8c2af9665a39/app/models/user.rb

    原理: 用 user_id + topic_id 作为 key,长期没有被访问的冷数据将会被 Memcached 自动挤掉,仅留下访问比较频繁的那些,此外存放只有一个 last_reply_id 有更新自动就过期了,无需手动清除

  • Code smell in Ruby-China code base at November 24, 2011

    #21 楼 @nowazhu 刚刚想了想,现在已经可以简化成两行来实现这项功能。 @fredwu

  • 有什么办法可以让 MongoDB 在 Mac OS X 下开机启动 at November 24, 2011

    Redis 和 MongoDB 是同样的,Homebrew 这个神器可以搞定!

  • 求 Textmate 推荐配色 Theme at November 24, 2011

    我一直喜欢用 TextMate 默认的 Mac Classic 不过目前家里面用的是 Sunburst 的改进版(无意中改出来的)

  • Code smell in Ruby-China code base at November 24, 2011

    #36 楼 @Rei 其实这个 cache 还是负担得起的,你不觉得回家看到的阅读状态和公司一样,还有当你有 iPad 访问的时候,是一件很爽的事情么

  • 有什么办法可以让 MongoDB 在 Mac OS X 下开机启动 at November 24, 2011

    MongoDb 用 Homebrew 安装好以后会这么一段

    ➜  ~  brew install mongodb
    mongodb 2.0.0-x86_64
    http://www.mongodb.org/
    /usr/local/Cellar/mongodb/2.0.0-x86_64 (17 files, 120M)
    
    If this is your first install, automatically load on login with (这段就是用来设置 MongoDB for Mac 的服务的,会开机自启动):
        mkdir -p ~/Library/LaunchAgents
        cp /usr/local/Cellar/mongodb/2.0.0-x86_64/org.mongodb.mongod.plist ~/Library/LaunchAgents/
        launchctl load -w ~/Library/LaunchAgents/org.mongodb.mongod.plist
    
    If this is an upgrade and you already have the org.mongodb.mongod.plist loaded:
        launchctl unload -w ~/Library/LaunchAgents/org.mongodb.mongod.plist
        cp /usr/local/Cellar/mongodb/2.0.0-x86_64/org.mongodb.mongod.plist ~/Library/LaunchAgents/
        launchctl load -w ~/Library/LaunchAgents/org.mongodb.mongod.plist
    
    Or start it manually:
        mongod run --config /usr/local/Cellar/mongodb/2.0.0-x86_64/mongod.conf
    MongoDB 1.8+ includes a feature for Write Ahead Logging (Journaling), which has been enabled by default.
    To disable journaling, use --nojournal.
    
    http://github.com/mxcl/homebrew/commits/master/Library/Formula/mongodb.rb
    
  • 有什么办法可以让 MongoDB 在 Mac OS X 下开机启动 at November 24, 2011

    用 Homebrew 安装

    brew install mongodb
    # 安装完成后会有一段提示,执行提示那几个命令就可以了
    
  • Code smell in Ruby-China code base at November 24, 2011

    #32 楼 @nowazhu 现在这些 cache 都是需要的,论坛首页已经慢了

  • Code smell in Ruby-China code base at November 24, 2011

    #30 楼 @fredwu 这个地方除了用 cache 还能用什么方法(V2EX 用的是 :hover 设置样式,这个的缺点是换浏览器或是换电脑以后就没有效果了)

  • Code smell in Ruby-China code base at November 24, 2011

    #25 楼 @dotnil method? 返回 Boolean 不动原始数据 method! 直接修改原数据

  • 求 Gem,有没有支持发 attachment 的 Amazon SES 服务的 Gem at November 24, 2011

    #6 楼 @fredwu 这个 @nowazhu 也一直在用的,他说的不太明白,但他想要的肯定不是这个

  • 求 Gem,有没有支持发 attachment 的 Amazon SES 服务的 Gem at November 24, 2011

    #4 楼 @fredwu 是 SES, Carrierwave 能支持么?

  • Code smell in Ruby-China code base at November 24, 2011

    #22 楼 @quakewang ^^ 我都忘了当初设定的原因了,看起来确实用不上

  • Code smell in Ruby-China code base at November 24, 2011

    以前我一直觉得我有代码洁癖,看了 @fredwu 和 @xdite 的几个提交以后才发现,还有更厉害的,哈哈哈

  • Code smell in Ruby-China code base at November 24, 2011

    #13 楼 @quakewang 赞,不过这样还有那个绿色(2 最后是用户的回复)的状态无法实现

    class User
      def read_topic?(last_reply_id)
        reply_ids = Rails.cache.read("user:#{self.id}:topic_read")
        reply_ids.include?(last_reply_id)
      end
    
      def read_topic(last_reply_id)
        reply_ids = Rails.cache.read("user:#{self.id}:topic_read")
        reply_ids = [] if reply_ids.blank?
        reply_ids.dup
        reply_ids << last_reply_id
        Rails.cache.write("user:#{self.id}:topic_read",reply_ids)
      end
    end
    
  • Code smell in Ruby-China code base at November 24, 2011

    #7 楼 @fredwu 这段代码的逻辑要搞清楚哦

  • Code smell in Ruby-China code base at November 24, 2011

    再改进点应该,不过这个或许太过头了:

    def user_readed?(user_id)
      uids = Rails.cache.read("Topic:user_read:#{self.id}")
      return [self.last_reply_user_id,self.user_id].include?(user_id) == true ? 2 : 1 if uids.blank?
      return 0 if uids.include?(user_id)
      return 2 if [self.last_reply_user_id,self.user_id].include?(user_id)
      1
    end
    
  • Code smell in Ruby-China code base at November 24, 2011

    我的做法,拆解成多个 if,以上面代码为例

    def user_readed?(user_id)
      uids = Rails.cache.read("Topic:user_read:#{self.id}")
    
      if uids.blank?
        if self.last_reply_user_id == user_id || self.user_id == user_id
          return 2
        else 
          return 1
        end
      end
    
      if uids.index(user_id)
        return 0
      end
    
      if self.last_reply_user_id == user_id || self.user_id == user_id
        return 2
      end
      1
    end
    
  • [北京] Red Hat 招 Ruby Developer-Update Mar 30 at November 24, 2011

    哈哈,看来该出个招聘栏目了

  • Code smell in Ruby-China code base at November 24, 2011

    汗!昨天 @xdite 也这么说我代码很多地方乱。 其实这个是以前的老代码,一直没去重构,大家多多海涵

  • RubyC 2011 视频 at November 24, 2011

    #15 楼 @lgn21st 哦,这样啊

  • RubyC 2011 视频 at November 24, 2011

    纳妮!居然没杭州和成都的

  • Twitter Bootstrap 出来以后,网站 UI 都同质化了 at November 24, 2011

    或许楼主是应为之前看了 rubybbs.com put.im 和 现在这里,才会这么觉得,应为都是出自同一个项目 Homeland 其实其他 Bootstrap 做出来得不是这个样,比如: http://www.githire.com/ 就连 Bootstrap 和这里差别还是很大的,除了那些控件和头部

  • RubyC 2011 视频 at November 24, 2011

    #11 楼 @lgn21st 就是不够专注,照片早上上了,Slide 早该收集起来放到官网了,视频早该放出来了

  • Unicorn 怎才做才能正确的无缝重启? at November 24, 2011

    谁之前用得熟悉的,看看 ruby-china 的 unicorn.rb 写得对不对 https://github.com/huacnlee/ruby-china/blob/master/config/unicorn.rb

  • RubyC 2011 视频 at November 24, 2011

    用 Linode 东京翻的表示很流畅,哈哈

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