Ruby China
  • 社区
  • 招聘
  • Wiki
  • 酷站
  • Gems
  • 注册
  • 登录
@quakewang
高级会员
第 162 位会员 / 2011-11-22

[email protected]
上海
26 篇帖子 / 752 条回帖
212 关注者
4 正在关注
22 收藏
GitHub Public Repos
  • rfcs 1

    This repository contains proposals, standards and documentations related to Nervos Network.

  • linux 1

    Linux kernel source tree

  • cfn-node 0

  • ckb 0

    CKB is a public/permissionless blockchain, the layer 1 of Nervos network.

  • ractor 0

    Rust actor framework

  • autocorrect 0

    A linter and formatter for help you improve copywriting, to correct spaces, punctuations between ...

  • ckb-vm 0

    CKB's vm, based on open source RISC-V ISA

  • ckb-auth 0

    A consolidated library featuring numerous blockchains authentication techniques on CKB-VM

  • hyprnote 0

    Privacy-first AI Notepad for back-to-back meetings

  • fiber-scripts 0

More on GitHub
  • 概况
  • 话题
  • 回帖
  • 收藏
  • 正在关注
  • 关注者
  • 都来分享下让你们觉得有成就感的程序代码吧 at 2013年04月17日

    楼上都是恶搞的。 我来装 B 一下,由于受专利和竞业禁止条款限制的缘故,无法贴出来...

  • nginx 出现大量 400 Bad Request 错误 at 2013年04月17日

    nginx 的 log 日志开启到了 info 级别?关掉就可以了。

  • 請 Linode 用戶注意,緊急情況。 at 2013年04月16日

    #17 楼 @yedingding 我在 Linode 上用的是我老婆的信用卡,问过她,说是 1 月份到期,换了新卡,还好不用麻烦去换。

  • 請 Linode 用戶注意,緊急情況。 at 2013年04月16日

    从爆出截图的文件后缀名 cfm,和 irc log 里面提到的 coldfusion 漏洞和配置问题,这个问题看上是真的。另外 irc 提到 Linode 的信用卡信息是加密的,但是 public key 和 private key 放到了一起,所以...

  • 請 Linode 用戶注意,緊急情況。 at 2013年04月16日

    冻结或者销卡,换卡不知道背后的 cvv 会不会换呢

  • 好初级的问题,rails 国际化用哪个 at 2013年04月14日

    好像每个做 locale 的都会遇到这个问题,我是这样做的,在 user model 添加一个 locale 属性,用户可以在设置界面进行修改,如果为空的话,就读取他的浏览器设置一个默认值,贴代码:

    class ApplicationController < ActionController::Base
      before_filter :set_locale
    
      private
      def set_locale
        I18n.locale =  cookies[:locale] || setup_locale
      end
    
      def setup_locale
        if user_signed_in?
          current_user.update_attribute(:locale, guess_browser_language) if current_user.locale.blank?
          return cookies[:locale] = current_user.locale
        else
          return cookies[:locale] = guess_browser_language
        end
      end
    
      def guess_browser_language
        request.accept_language.split(/,/).each{|language|
          if language =~ /zh-cn/i
            return 'zh-cn'
          else
            return I18n.default_locale
          end
        } unless request.accept_language.blank?
        return I18n.default_locale
      end
    end
    
  • I18n 当 locale 是 en 如何不翻译? at 2013年04月14日

    你可以定义一个 I18n 的 exception_handler:

    I18n.exception_handler = CustomizeI18nExceptionHandler.new
    
    class CustomizeI18nExceptionHandler
      def call(exception, locale, key, options) 
        if exception.is_a?(MissingTranslation) && locale == I18n.default_locale
          return key
        end
      end
    end
    

    不过如果是有比较多的 i18n 内容项目,我建议是将内容放到数据库或者其他存储,方便修改,有很多 i18n 的 backend,比如 redis,activerecord。你复写一下 backend 的 lookup 方法,也可以实现上面的用途,毕竟用 exception_handler 不是正途。

  • rails 单元测试里面怎么模拟并发的两个请求呢? at 2013年04月13日

    我以前有过类似的测试,是 fork 多线程,在线程里面用 IO.pipe 定义输入输出,最后断言输入输出是配对的。

  • rails 日期查询容易进入的误区 at 2013年04月13日

    获取开始和结束时间来查询,就不需要做时区转化,而且用 date 函数无法有效利用数据库索引。

    Model.where("created_at >= ? and created_at <= ?", date.beginning_of_day, date.end_of_day)
    
  • rails middleware 太多是否会有性能问题? at 2013年04月11日

    #9 楼 @edokeh 囧,你竟然还找得到那个帖子...

  • rails middleware 太多是否会有性能问题? at 2013年04月11日

    很久以前的一篇文章: http://quake.iteye.com/blog/1473073 看你的项目具体情况,这些中间件是可以考虑去掉的:

    Rack::Cache                 整页缓存
    Rack::Runtime               记录X-Runtime(方便客户端查看执行时间)
    ActionDispatch::RequestId       记录X-Request-Id(方便客户端查看请求具体在集群中的哪台执行)
    ActionDispatch::RemoteIp        防止IP伪造(可以在web server上做)
    ActionDispatch::Callbacks       设置callback
    Rack::ConditionalGet            设置If-None-Match and If-Modified-Since
    Rack::ETag              设置ETag
    ActionDispatch::BestStandardsSupport    设置X-UA-Compatiblecd(可以在web server上做)
    

    除非你的应用 GC 压力很大,一般无必要调整,特别是 Ruby 1.9.3 打过 GC patch 和 Ruby 2.0,直接用默认的吧。

  • 被豆瓣的 omniauth 的 gem 搞吐了 at 2013年04月11日

    #8 楼 @kevinhua 我们是支持一个用户同时绑定到多个服务的,比如你先用微博注册,接下去还能同时绑定 QQ 和豆瓣。

    你说的这个提示是这样一个情况:用户先用一个服务注册了(比如 QQ),再登出了当前用户,然后又用豆瓣注册一个新用户,接下去他如果想在这个新用户上绑定之前已经注册过的 QQ,那么就会提示出错。

  • 被豆瓣的 omniauth 的 gem 搞吐了 at 2013年04月11日

    我们网站就用的这个 gem,没有遇到什么问题,是你 devise 或者 omniauth 哪里配置不正确吧?

  • 被豆瓣的 omniauth 的 gem 搞吐了 at 2013年04月11日

    用 https://github.com/liluo/omniauth-douban-oauth2 这个 gem,你可能用的是 oauth 那个 douban 老的 gem

  • 数组排序求简单实现 at 2013年04月10日
    arr.sort_by {|a| a == 'mike' ? '' : a}
    
  • iOS 开发中使用 git 团队协作 nib 文件如果冲突了这修复你们怎么做的? at 2013年04月10日

    nib 是个大坑,我们现在都是直接用代码创建各种 view

  • 不知为什么总是收到 format 为 NULL 的请求 at 2013年04月07日

    都是一些弱智或者恶意爬虫,我的做法是 rescue_from ActionView::MissingTemplate,然后强制 redirect 一个 zip bomb http://en.wikipedia.org/wiki/Zip_bomb

    实践效果十分有效,对方通常是用一些第 3 方 http 库,会自动 unzip,然后就内存爆掉了 ...

  • 关于子类复用父类 before_fitler 的问题 at 2013年03月28日

    before_filter 接受 if 参数,用 proc 来处理

    class ParentController
      before_filter :x, if => proc {|controller| controller.filter_names_for_x.include?(action_name) }
    
      def filter_names_for_x
        [:A, :B, :C]
      end
    end
    
    class ChildController
      def filter_names_for_x
        super << :D
      end
    end
    
  • 被 next_week 迷惑了。。蠢蛋 at 2013年03月14日

    Time.now.since 1.week

  • 想在浏览器上和 iPad 上都可以播放,有什么好的解决方法? at 2013年03月14日

    #3 楼 @SharpX 不是,自己写的,没有找到相关类似的插件,而且要支持 ipad 和手机等移动设备。

  • 想在浏览器上和 iPad 上都可以播放,有什么好的解决方法? at 2013年03月14日

    我们是采用 mp4 格式,然后使用 videojs.com,在 ipad 上是直接用 html5 播放,对于不支持 html5 的,会自动转换成 flash,例子:

    http://chanyouji.com/trips/24694#nt/771803

  • 猜猜,这能干啥~ at 2013年03月13日

    raspberry pi + 继电器?控制电器么?

  • 做开发到底是 Linux 好 还是 Mac 好? at 2013年03月12日

    #97 楼 @jan 这地图炮轰的我是体无完肤啊...

  • Rails 中怎么组织多个页面的的 view 啊 at 2013年03月11日

    基础的方法: http://railscasts.com/episodes/217-multistep-forms

    如果项目中这种引导多步骤的表单比较多,推荐这个 gem: https://github.com/schneems/wicked

  • 想将 mac 地址转换 crc 值,有什么方法 at 2013年03月11日
    require 'zlib'
    Zlib::crc32("aa::bb::cc::dd::ee::ff")
    
  • Web 应用的缓存设计模式 at 2013年03月09日

    另外,我在微博上提到过:Rails 的 ActiveRecord 在 3.1 以后,对于 n+1 有更先进的处理,通过 Eager Loading http://t.cn/zYnMxad 会转化成 in 查询,变成 1+1,而且 in 查询可以通过 cache server 的 multiget 方式来批量命中。

    fork 了那个 cache,正在看如何改进这个。

  • Web 应用的缓存设计模式 at 2013年03月09日

    robbin 的这篇文章很赞,将 Rails 中各种 cache 的最佳实践都很详细地总结了一次,强烈推荐。

  • MariaDB or PerconaDB 你选哪种来替代 MySQL? at 2013年03月08日

    #5 楼 @ShiningRay 淘宝贡献的代码据说会在 MariaDB 10 这个版本发布,目前好像已经发布 GA 版本。

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