Ruby China
  • 社区
  • 招聘
  • Wiki
  • 酷站
  • Gems
  • 注册
  • 登录
david
@davidqhr
高级会员
第 654 位会员 / 2012-01-02

[email protected]
DDEX
北京
10 篇帖子 / 157 条回帖
5 关注者
0 正在关注
0 收藏
博观而约取,厚积而博发
GitHub Public Repos
  • elixir-captcha 35

    This is a Elixir lib for generating captcha. It drawing captcha image with C code. No dependencies.

  • immutable 1

    Immutable collections for Go

  • go-openai 0

    OpenAI ChatGPT, GPT-3, GPT-4, DALL·E, Whisper API wrapper for Go

  • color-thief 0

    Grab the color palette from an image using just Javascript. Works in the browser and in Node.

  • mixpanel-tracking-proxy 0

    One-click configuration to proxy tracking requests to Mixpanel's API

  • grpc-mtls-example 0

    grpc mTLS example

  • spree-api-v2-js-sdk 0

    Spree Storefront API JavaScript / TypeScript SDK

  • grpc-multi-resolver 0

    Multiresolver allows you to Dial to multiple hosts/IPs as a single ClientConn.

  • go-ethereum-hdwallet 0

    Ethereum HD Wallet derivations in Go (golang)

  • isomorphic-git 0

    A pure JavaScript implementation of git for node and browsers!

More on GitHub
  • 概况
  • 话题
  • 回帖
  • 收藏
  • 正在关注
  • 关注者
  • 个推微服务网关架构实践 at 2019年03月08日

    @gazeldx https://konghq.com/ 社区版本已经足够好用了

  • Whenever 每 20 秒执行任务 at 2018年05月25日

    直接起个进程,死循环 + sleep。

  • 求教,不知道这个语句有没有更简便的写法呢,看着太丑了。 at 2016年10月17日

    http://stackoverflow.com/questions/325933/determine-whether-two-date-ranges-overlap

  • 本人自行删除 at 2015年12月09日

    #11 楼 @rei 有道理,学习了,那以后就用多数据库来区分项目,而不是 namespace 吧

  • 玩转 React 服务器端渲染 at 2015年12月09日

    #5 楼 @serco 多谢,我研究一下

  • 本人自行删除 at 2015年12月09日

    我的做法是全局变量

    $redis = Redis.new
    

    但是在使用多线程服务器的过程中,这样的做法出现了一些弊端。如果在多线程的服务器中使用 redis,并且用到了事务,那多个这种多个线程之间共享一个 client 的做法就出问题了。这时候就加上了ConnectionPool,每次使用 redis 都从连接池里拿独立的连接。

    create_redis_proc = ->() {
      Redis::Namespace.new("mtx_api/#{Mtx.env}", redis: Redis.new(url: Mtx::SETTINGS[:redis]))
    }
    $redis = ConnectionPool.new size: 16, timeout: 5, &create_redis_proc
    

    当数据量大之后,redis 分布在多台机器上,这时候的 redis client 就采用 Redis::Distributed,内部提供一致性 hash 来处理负载,不过需要牺牲一些命令,例如 bitop。同样也是根据需求来决定是不是需要加上 connectionPool

    redis_config = YAML.load_file(::Rails.root.to_s + '/config/redis.yml')
    instances = Redis::Distributed.new(redis_config[Rails.env], driver: :hiredis)
    $redis = Redis::Namespace.new("kecheng/#{Rails.env}", redis: instances)
    
  • 玩转 React 服务器端渲染 at 2015年12月09日

    其实这才是原文吧:

    英文: http://rackt.org/redux/docs/recipes/ServerRendering.html

    中文: http://camsong.github.io/redux-in-chinese/docs/recipes/ServerRendering.html

    一个完整的项目会有 js/css/images 等等的静态文件,比起介绍这些服务端渲染的 demo,更期待一个真实的服务端渲染的部署心得。开发的时候使用 webpack 来加载处理静态资源文件,那请问在做服务器端渲染的时候,静态文件是如何处理的?

    例如在开发过程中引入 css

    require('xx/xx/xx.css') //可以这样引入css,在服务端渲染的时候,这行可能需要根据NODE_ENV来跳过
    

    但是图片没有找到合适的解决办法

    <img src={require('xx/xx.png')} alt="xx" /> //这样的代码出现在render函数中,请问服务端渲染是怎么解决的?
    
  • Ruby 程序在运行过程中,能将已经 require 的 rb 文件从环境变量中剔除吗? at 2015年11月23日
    class A
    end
    
    Object.send(:remove_const, :A)
    
  • [北京] 课程格子-招聘 Ruby 后端工程师 / 运维工程师 /iOS 工程师,12K 起 at 2015年09月07日

    @lgn21st @huacnlee,#16 楼 #17 楼 #18 楼这种搭车招聘的,账号是不是可以枪毙了。

  • [北京诚聘] [互联网 | 旅游 | 创业] 一条大鱼在等你,工程师们是时候在春天活动活动啦 at 2015年01月30日

    @zamia 现在多少人啦?

  • 一般你们需要多长时间熟悉公司的项目然后参加开发? at 2014年11月18日

    10 个 table 估计也就一上午

  • 多条件查询怎么写语句 at 2014年11月04日

    二楼 + 三楼就是解决方案

  • 求 rack,rackup 的教程资料 at 2014年11月04日

    rack 是 frameworks 与 server 之间的一个 gem,依赖 rack 开发的任何 favmework 可以跑在任何 rack 支持的 server 上。

    rack is ruby make,是一个脚本执行工具。

  • 定时任务 rufus-scheduler 小记 at 2014年11月04日

    多谢分享,不过我知道更多人在用 whenever,与其贴上这些配置,楼主不妨给大家讲讲这个 gem 优于其他类似 gem 的地方?

  • 写完了,天快亮了,81 页 at 2014年11月01日

    这样的干货听着很过瘾,感谢分享

  • Happycasts: 网站改版了,求骂求夸奖 at 2014年10月30日

    期待响应式布局

  • 当 self.attr.nil? 时 self.attr ||= 和 self.attr = 的区别 at 2014年10月30日

    #5 楼 @serco 其实不是什么 bug 错就错在 private 的 attr_writer

  • 为啥社区显示一百多页,有内容的却只有前二十页? at 2014年10月29日

    bug

  • 当 self.attr.nil? 时 self.attr ||= 和 self.attr = 的区别 at 2014年10月29日

    private method 调用时是不允许明确的使用对象的,即使是 self

    class Foo
      def b
        self.a
      end
    
      def c
        a
      end
    
    private
      def a
        puts 'a invoked'
      end
    end
    
    f = Foo.new
    
    f.a
    f.b
    f.c
    
    # edit private -> protected, and try again
    

    self.address= 和 self.timezone= 都被我重新定义过并且设置为 private 一般不会有人这么干

    如果不想暴漏修改属性的接口

    • 如一楼 protected,类内 self.address= 没问题
    • 直接修改实例变量(如果你用了的话)
  • [远程] Rails 兼职招聘 at 2014年10月29日

    听起来感觉不错

  • Ruby 赋值中的一个坑 at 2014年10月29日
    user = User.find(1),
    school = School.find(1)
    

    你猜猜 user 是啥?

    看到逗号没有?

  • 拒绝自己拼凑查询条件 at 2014年10月28日

    这些做法纯粹是瞎折腾。用 scope 的话,名字起得不好都看不懂,更何况弄一堆约定似的 hash?

    莫不如查查有没有 n+1,如果用 mysql,explain 一下,看看索引用的怎么样,这些貌似更实际点。

  • Rails 重构: 利用 Service 优化 Fat Model at 2014年10月23日

    #7 楼 @limkurn

    感觉这些东西都是细枝末节~~~~(需求天天大变,还重构个毛)

    +1

  • rescue 里可否获得各层栈里局部变量? at 2014年09月27日

    这种事情我第一反应是有没有人做过

    我记着 better error 中可以回到某个堆栈,然后查看 binding。 也许你应该去翻翻 better_error

  • 编写 Ruby 的 C 扩展 at 2014年09月23日

    这个必须顶

  • 如何理解 form_for 和 form_tag at 2014年09月15日

    /Users/david/.rvm/gems/ruby-2.0.0-p481@xxx/gems/actionpack-3.2.19/lib/action_view/helpers/form_helper.rb

    def form_for(record, options = {}, &block)
            raise ArgumentError, "Missing block" unless block_given?
    
            options[:html] ||= {}
    
            case record
            when String, Symbol
              object_name = record
              object      = nil
            else
              object      = record.is_a?(Array) ? record.last : record
              object_name = options[:as] || ActiveModel::Naming.param_key(object)
              apply_form_for_options!(record, options)
            end
    
            options[:html][:remote] = options.delete(:remote) if options.has_key?(:remote)
            options[:html][:method] = options.delete(:method) if options.has_key?(:method)
            options[:html][:authenticity_token] = options.delete(:authenticity_token)
    
            builder = options[:parent_builder] = instantiate_builder(object_name, object, options, &block)
            output  = capture(builder, &block)
            default_options = builder.multipart? ? { :multipart => true } : {}
            form_tag(options.delete(:url) || {}, default_options.merge!(options.delete(:html))) { output }
          end
    

    form_for 无非就是处理了下参数,然后最后调用 form_tag

  • 如何理解 form_for 和 form_tag at 2014年09月15日

    form_for 中有 object 的概念,block 中需要有一个参数 t,t.object 为 form_for 第一个参数对象

    form_tag 就是普通的 html form

  • Sunspot 学习笔记 at 2014年09月11日

    给大神跪了!

  • 貌似 BAE 跑 Rails 速度还可以 at 2014年04月30日

    #17 楼 @cxh116 能给说说具体步骤么,我也想去试试

  • 貌似 BAE 跑 Rails 速度还可以 at 2014年04月30日

    敢问楼主,bae ruby 需要邀请码么?

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