Ruby China
  • Topics
  • 招聘
  • Wiki
  • 酷站
  • Gems
  • Sign Up
  • Sign In
🍡
@dorentus
Member
NO. 13700 / 2014-06-17

0 Topics / 79 Replies
0 Followers
0 Following
6 Favorites
GitHub Public Repos
  • libBPush 11

    Unofficial `Baidu Cloud Push Service ( http://developer.baidu.com/cloud/push )' iOS client SDK mi...

  • .fish 8

    .config/fish

  • nginx-spdy-indicator-ssi 5

    SSI pages + nginx configurations, provides API for client to check if itself supports SPDY protocol

  • bnet-authenticator 5

    Ruby implementation of the Battle.net Mobile Authenticator

  • resolvconf-autogen 2

    [OS X 10.6+] Every time when system network changes, write upstream DNS IPs to a file, using reso...

  • bna 2

    discontinued, see: https://github.com/dorentus/bna-swift

  • homebrew-recipes 1

    自分用のレシピ

  • coobjc 1

    coobjc provides coroutine support for Objective-C and Swift. We added await method、generator and ...

  • mruby-lolcat 1

    Rainbows and unicorns! forked to mruby

  • hermes 1

    A JavaScript engine optimized for running React Native.

More on GitHub
  • Overview
  • Topics
  • Replies
  • Favorites
  • Following
  • Followers
  • rvm 安装 ruby 之后,必须执行 /bin/bash --login 才能执行 ruby 命令 at August 28, 2014

    /bin/bash --login 是以 login shell 模式新开启一个 bash 进程而已。

    2 楼的应该就是正确/最优的解决方案。

  • 所有需要登录才能退订的邮件都是耍流氓 at August 22, 2014

    Gmail,report spam。然后发送方就哭了。

  • ISODate ("2012-12-19T06:01:17.171Z") 最后的 Z 是什么意思? at August 22, 2014

    小窍门:这种情况下翻文档不一定比 Google 快,重要的是提炼出问题的关键字:ISODate Z

  • 为什么好多工具是用 ruby 写的?而不是用 python,perl? at August 11, 2014

    Homebrew 的话,原因大致是这样(我猜的): 1) 很多 Ruby 程序员都用 Mac 2) Ruby 实现的 DSL 比较漂亮

  • IDE 速度太快,我突然莫名的失落 at August 06, 2014

    vim 慢的各位得是装了多少插件啊……

  • RVM 与 Bundler 的爱恨情仇 at August 04, 2014

    #5 楼 @xiaoronglv 因为还有人在用吧。加功能容易减功能难啊……

  • 王垠需要帮助! at August 01, 2014

    #21 楼 @jiyinyiyong “重视人才而不是急需 code monkey 的公司”和“不需要有挑战性”应该是冲突的,既然重视人才了,那肯定是需要人才创造出相应水平的价值的。

  • 大家都是技术做好多年的人了,现在还看什么深度的技术书? at July 31, 2014

    #25 楼 @ywjno 刚刚查了下,第二本的 GC 算法实战在亚马逊日本上面有二手的卖…

  • “Ruby” 这个九零后小伙儿 at July 30, 2014

    #6 楼 @yuhaidonghd 明明是拿在手里的。。。

  • 大家都是技术做好多年的人了,现在还看什么深度的技术书? at July 30, 2014

    #7 楼 @ywjno 看了你这个我忽然想起来「きつねさんでもわかる LLVM」这本我有实体书的……但是还没怎么看……

  • “Ruby” 这个九零后小伙儿 at July 30, 2014

  • Rails 做服务端,请问移动端的用户验证一般是用什么? at July 27, 2014

    我都是用 OAuth 2 Resource Owner Password Credentials Flow,登录的时候发用户名密码以及 client id、client secret 来直接获取 access token。另外很自然地,用 https 而不是 http。

    User Model 是手写的。OAuth 2 Server 用了 doorkeeper gem。

    好处是: 客户端的开发者可用用自己喜欢的 OAuth2 实现,不管是手写还是使用第三方库,都 OK。 服务端也不用去纠结 token 怎么生成怎么过期怎么认证。手写的 User Model 里面用 BCrypt 已经算是通行的 best practice 了。


    API Server 这边大致是这样(Rails 4.1.4, Mongoid 4.0.0):

    app/models/user.rb

    class User
      include Mongoid::Document
      include Mongoid::Timestamps
      include ActiveModel::MassAssignmentSecurity
    
      attr_accessible :email, :password, :password_confirmation
      attr_accessible :display_name
    
      attr_accessor :password
    
      validates :password, confirmation: true, on: :create
      validates :password_confirmation, presence: true, on: :create
      validates :email, presence: true, uniqueness: true, email: true
      validates :display_name, presence: true, length: { minimum: 2, maximum: 42}
    
      before_save :encrypt_password
    
      field :email, type: String
      field :password_hash, type: String
      field :password_salt, type: String
    
      field :display_name, type: String
    
      def self.authenticate!(email, password)
        user = find_by(email: email) rescue nil
        if user && user.password_hash == BCrypt::Engine.hash_secret(password, user.password_salt)
          user
        else
          nil
        end
      end
    
      def encrypt_password
        if password.present?
          self.password_salt = BCrypt::Engine.generate_salt
          self.password_hash = BCrypt::Engine.hash_secret(password, password_salt)
        end
      end
    end
    

    config/initializers/doorkeeper.rb

    module Doorkeeper
      class Application
        include ActiveModel::MassAssignmentSecurity
      end
      class AccessGrant
        include ActiveModel::MassAssignmentSecurity
      end
      class AccessToken
        include ActiveModel::MassAssignmentSecurity
      end
    end
    
    Doorkeeper.configure do
      # Change the ORM that doorkeeper will use.
      # Currently supported options are :active_record, :mongoid2, :mongoid3, :mongo_mapper
      orm :mongoid4
    
      resource_owner_from_credentials do
        User.authenticate! params[:username], params[:password]
      end
    
      native_redirect_uri 'urn:ietf:wg:oauth:2.0:oob'
    
      use_refresh_token
      client_credentials :from_basic
      access_token_methods :from_bearer_authorization
      grant_flows %w(password)
    end
    
  • Power - 无需配置的本地静态网站服务 at July 20, 2014

    #12 楼 @wcc526 OS X 10.10 把原来自带的 ruby 1.8 删掉了,默认使用 ruby 2.0 而已。也就是像 homebrew 这些之前使用 /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby 的才会有问题(homebrew 很快就一个补丁修正了)。

    如果满足一下两个条件的任意一个,都不会有问题: 1) 不用 ruby 1.8 2) 用 ruby 1.8 但不是用的系统自带的 /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby

  • 上海环球 iOS 的培训怎么样? at July 20, 2014

    #7 楼 @salleeshi 看了下,Training options 列表里面没有 iOS,只有 OS X(选了以后地区选 China 的话找不到培训机构) 所以这家苹果认证的应该是别的什么培训,与 OS X/iOS 开发无关……

  • 2014718 这样格式的字符串转换成日期? at July 18, 2014

    2014718 这种,假如月和日都不补全到两位的话,会有歧义的吧,比如 2014121、201411、2014110

  • "wget -O - http://foo.com",'-O' 后的'-'什么含义? at July 11, 2014

    #5 楼 @pynix wget 的这个还确实可以写成更好看的 -O- 😄

  • vc6 编译 ruby 源码出错了 at July 11, 2014

    #4 楼 @sevk 其实我是现搜的,你那个日志里的第一个错“error LNK2005: rb_file_expand_path_internal already defined in file”,Google 一下就两个结果,一个是那个 issue,一个是本帖。。。

  • vc6 编译 ruby 源码出错了 at July 11, 2014

    https://bugs.ruby-lang.org/issues/7660

    You can build ruby in any directory including the source directory, except win32 directory in the source directory.

    看起来你在外面比如 G:\ruby-2.1.2 目录下运行 nmake 就可以了吧……

  • 尝试提问:Mutablearray 和 array 如何比较数组内元素是否一样? at July 11, 2014

    NSArray#isEqualToArray: 是对每个元素用 #isEqual: 比较的,如果不行的话,那么应该是和你的 NSArray/NSMutableArray 里的元素类型有关,和数组容器是不是 mutable 无关。

  • 有朋友刚好准备启用 Dropbox 的吗?顺便帮我增加点空间好不? at July 08, 2014

    #9 楼 @chairy11 Dropbox 自己的说法是他们想鼓励用户使用、测试这功能,所以给奖励,至于之后,用户不删的话当然最好,删了的话也 OK。

  • 有朋友刚好准备启用 Dropbox 的吗?顺便帮我增加点空间好不? at July 08, 2014

    #4 楼 @chairy11 之前相机上传奖励的时候是上传得越多奖励的越多,上限是 3G。奖励是实时加的,传完就可以删掉……

  • RoR 后台改为 Swift 来写是否可以 at July 08, 2014

    #16 楼 @bydmm 直接写 socket 服务也没啥特别的优势吧,但是有个很大的缺点就是至少目前只能跑在 Mac 上……

  • 有朋友刚好准备启用 Dropbox 的吗?顺便帮我增加点空间好不? at July 08, 2014

    https://www.dropbox.com/help/287/zh_CN 启用相机上传可以再得最多 3G(而且传完删掉照片也不会有影响)

  • 怎样使的 routes.rb 在数据库可配置 at July 08, 2014

    Rei 的方法灵活性已经很高了啊,随你怎么定义 model,在 page#show 里面,都可以自己处理来实现。为啥一定要纠结在 routes.rb 里面。。。

  • 在域名 @ 记录上做 CNAME 是否有不好的影响? at July 07, 2014

    没问题。 只是按标准的话,任意的域名,设了 CNAME 之后,别的所有例如 MX、A、AAAA 等等都不要设就 OK。

    我错了,收回上面的结论。

    确实是设了 CNAME 之后,不能再设其它项不假;然后由于裸域至少会有 NS 和 SOA,所有其实是可能会有问题的。所以 github pages 是建议用裸域的话,不用 CNAME 而是设 A 到它们的 IP。

    不过实际的情况下,我没仔细试过,不知道具体会出什么问题……想上面这种除了 CNAME、NS、SOA 没其它项的,估计也问题不大吧……

    参考资料:http://superuser.com/a/264914/182908

  • RoR 后台改为 Swift 来写是否可以 at July 07, 2014

    #12 楼 @alsotang Swift 编译器有命令行版的(xcrun swift)不开 Xcode 也能直接用,不过依然需要: 1) OS X 2) Xcode 6 3) 目前因为 Xcode 6 还是 beta 2,所以可能还需要把 Xcode Command Line Tools 切换到 beta 2: sudo xcode-select -s /Applications/Xcode6-Beta2.app

  • js 文件放在 public 文件夹下第一次不能加载问题 at July 05, 2014

    #2 楼 @flowerwrong 嗯。我发现我访问错地址了。我上面访问的是登录完以后页面里那个 New Role 链接的页面。。。

    刚刚我又用全新的虚拟机里面的 Safari 试了一下: 1) 先访问 http://203.195.169.138/articles/new -浏览器跳转到登录页面 2) 登录 -浏览器跳转到 http://203.195.169.138/roles 页面 3) 在地址栏再次输入 http://203.195.169.138/articles/new -浏览器如 #2 楼 的图一样,正常显示了富文本编辑器

    所以 @flowerwrong 如果楼主你后来没改什么的话,不会也是访问错 URL 了吧……

  • js 文件放在 public 文件夹下第一次不能加载问题 at July 05, 2014

    我访问的结果是无论怎么刷新都没有 kindeditor

    页面里的 js 是:http://203.195.169.138/assets/application-442198d369fc365e53bc3c6a0fa927d8.js 里面也没看到相关的东西。

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