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

杭州
15 篇帖子 / 363 条回帖
66 关注者
31 正在关注
82 收藏
GitHub Public Repos
  • bonfire 71

    A delightful website for tracking reading state of books.

  • dockerize 48

    A small hex package for creating docker image from an Elixir project.

  • formular 24

    A tiny DSL engine for Elixir projects

  • auto_response 16

    A proxy server for debugging HTTP requests.

  • data_fetcher 11

    Simple data fetcher in Elixir

  • word-info 8

    Word information, including frequency, pronunciation and syllables.

  • formular-client 6

  • docker-elixir-runner 5

    Docker images for elixir projects

  • AdventOfCode 4

    Solving Advent Of Code

  • docker-elixir-builder 4

    Docker image for CI building of Elixir projects

More on GitHub
  • 概况
  • 话题
  • 回帖
  • 收藏
  • 正在关注
  • 关注者
  • ruby.taobao.org 为什么不好用了? at 2015年07月08日

    UPDATE:

    现在 ruby.taobao.org 已经实现了 dependencies api curl https://ruby.taobao.org/api/v1/dependencies.json?gems=rails

    速度应该比以前快很多了,大家测试一下,有问题随时 @我 吧!

  • 如何找到调用者当前方法的对象 at 2015年07月03日

    binding.receiver http://ruby-doc.org/core-2.2.2/Binding.html#method-i-receiver

  • 无需更改 Gemfile,让 bundle 使用淘宝源 at 2015年07月03日

    #3 楼 @cqcn1991 可以在部署脚本里加个 bundle config ...

  • 参与开发的 ruby gems 的下载量破五百万了... at 2015年07月03日

    slim 我 Rails 标配

  • 小数至少保留两位如何实现 at 2015年06月30日
    '%.2f' % 21999.666666
    => "21999.67"
    
    '%.2f' % 1
    => "1.00"
    

    http://ruby-doc.org/core-2.2.2/Kernel.html#method-i-sprintf

  • ruby.taobao.org 为什么不好用了? at 2015年06月24日

    #15 楼 @rei rubygems-mirror https://github.com/alibaba/rubygems-mirror

  • ruby.taobao.org 为什么不好用了? at 2015年06月23日

    主要是 API 请求现在没有实现,所以安装时会把一个 gem 的所有版本都下载下来,进行计算后得到依赖关系。 这个是能解决的,不过需要点时间(公司财务上比较麻烦)

  • 以后能用 Ruby 进行严肃的前端编程么? at 2015年06月19日

    https://github.com/voltrb/volt 这也是个 ruby 写前端的框架

  • [杭州] 阿里巴巴招聘 Ruby 工程师 2 名 at 2015年06月18日

    #16 楼 @zizhan 是的 #19 楼 @fadying 欢迎来交流

  • Rails 中自动布署工具 mina 的经验谈 at 2015年05月29日

    「一开始我是用 mina 的,但现在我要换 capistrano 了,因为要部署新机器了」

  • 关于生产环境数据库迁移正确姿势的问题 at 2015年05月26日

    migration 中是可以写 ruby 代码的

    例如这样:

    class AddKeyToUsers < ActiveRecord::Migration
    
      def self.up
        add_column :users, :key, :string, null: false
    
        User.find_each do |user|
          if user.key.blank?
            user.key = SecureRandom.hex
            user.save(validate: false)
          end
        end
    
        add_index :users, :key, uniqueue: true
      end
    
      def self.down
        remove_index :users, :key
        remove_column :users, :key
      end
    
    end
    

    这种方式的缺点是中间那段 ruby 代码导致异常时,migration 就中断了,重新 migrate 的时候得注释一些东西。 好处是逻辑简单明了,不用头疼这些一次性代码往哪里放

  • 10 个 Ruby 技巧提升你的代码 at 2015年04月29日

    #21 楼 @fbsender 是的,小心 Array(obj) 有坑:obj 是个 Hash 的时候,可能不是期望的结果

  • [make-proxy] 添加 http 代理 at 2015年04月21日

    赞,正好要用上! 谢谢~

  • 有没有汉语注音的 gem at 2015年04月21日

    https://github.com/flyerhzm/chinese_pinyin

    看错了,注音是什么?

  • Rails 开发:那些年,我们一起踩过的坑 (剧终) at 2015年03月25日

    挺多心得的,赞个,有很多问题我也还在思考,楼主给我了很多启发,谢谢!

    不明白 redirect_to 为什么会被吐槽,json format 时不能 redirect_to 难道不是任何 web 开发人员都需要遵从的准则吗?应该和 rails 没什么关系。

    我在 controllers 里面是这样用的:

    # file: app/controllers/share_dirs_controller.rb
    
    # POST /share-dirs
    def create
      create_share_dir!
    
      respond_to do |format|
        format.html { redirect_to files_path }
        format.json { render 'show' }
      end
    rescue SubDirAlreadyShared
      render_json code: -1, msg: "..."
    rescue DirLimitReached
      render_json code: -1, msg: "..."
    rescue DirLimitFileSize
      render_json code: -1, msg: "..."
    end
    

    即便是用户认证失败,json 格式也只是 render 一个失败的 json,不会 redirect:

    # file: app/controllers/application_controller.rb
    
    # 需要认证登录用户的 action 加上这个 filter
    # Usage:
    #    before_action :require_user
    def require_user
      return true if logined?
    
      if request.format.json?
        render_json({ code: 10301, msg: "用户登录,或登录信息已过期。" })
      else
        redirect_to signin_url(protocol: "https")
      end
      false
    end
    
  • 如何用正则表达式判断一个字符串的开头是否是数字? at 2015年02月12日

    #3 楼 @alsotang 其实是单行模式。ruby 的单行模式中 ^ 就是匹配「行首」,而不是「起始」。和 js 处理不同。

    实际上 ruby 的多行模式是这样的:

    # 这是单行模式
    /a.b/   =~ "aaa\nbbb"  #=> nil
    
    # 这是多行模式
    /a.b/m  =~ "aaa\nbbb"  #=> 2
    
  • 如何用正则表达式判断一个字符串的开头是否是数字? at 2015年02月12日
    /\A\d/
    

    如果不是特别需要,我会用 \A 而不是 ^,防止考虑不周带来的安全问题。 区别是:

    /\A\d/ =~ "0aa"    #=> 0
    /^\d/  =~ "0aa"    #=> 0
    
    /\A\d/ =~ "aaa\n0" #=> nil
    /^\d/  =~ "aaa\n0" #=> 4
    
  • 阿拉伯数字转简体中文的 gem at 2015年02月11日

    问题是,3015 要转换成什么?三零一五 还是 三千零一十五 ?

  • 求 ruby 视频教程 at 2015年02月03日

    https://www.youtube.com/results?search_query=ruby+programming

    删了,貌似不太适合看完就做网站

  • 一个网站 allrubybooks at 2014年12月30日

    赞,看到好多好书,已收藏!

  • 用 Ruby 开发命令行工具的一些 tips at 2014年11月24日

    #11 楼 @mogodb 有些露点的人体模特图

  • 用 Ruby 开发命令行工具的一些 tips at 2014年11月17日

    #1 楼 @robot_zhang 嗯,主要写的时候不知道大家的需求,后面可以加上 #3 楼 @flowerwrong 😄 这是我花名,哈哈

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

    :plus1: 非常赞!

  • vi 有没有什么好的方法切换 tab? at 2014年10月28日

    土方法:

    " <Alt + [1-5]> goto tab in position i
    nnoremap <M-1> 1gt
    nnoremap <M-2> 2gt
    nnoremap <M-3> 3gt
    nnoremap <M-4> 4gt
    nnoremap <M-5> 5gt
    

    如果是 Mac,可以用 CMD 键

    " <CMD + [1-5]> goto tab in position i
    nnoremap <D-1> 1gt
    nnoremap <D-2> 2gt
    nnoremap <D-3> 3gt
    nnoremap <D-4> 4gt
    nnoremap <D-5> 5gt
    
  • 求助,有没有方法快速递格式化以下代码? at 2014年10月22日

    看楼主这个帖子让我复习了一下 Tabularize,呵呵

  • 如果设置通过 IP 地址访问不出现网站 at 2014年10月19日

    http://www.oschina.net/question/12_3565

  • 找零钱问题 at 2014年10月15日

    https://ruby-china.org/topics/12837

  • 程序员的 Burnout 与 Depression 抑郁症 at 2014年10月09日

    给楼主加个油!放弃其实比坚持更难,预祝达到更高的目标!

  • 计时攻击原理以及 Rails 对应的防范 at 2014年09月05日

    涨姿势了! :plus1:

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