Ruby China
  • Topics
  • 招聘
  • Wiki
  • 酷站
  • Gems
  • Sign Up
  • Sign In
马陆骋
@teddy
VIP
NO. 599 / 2011-12-27

薄荷科技
上海
13 Topics / 510 Replies
3 Followers
0 Following
0 Favorites
Reward
GitHub Public Repos
  • sliders 20

    自用的 slider 创建和演示工具, 具有一定通用性

  • github-comment 10

    a static page comment hosting service

  • dotfiles 5

    may the dotfiles be with me

  • geeknote 4

    yet another evernote command line client

  • how-to-learn-emacs-chi... 3

    如何学习emacs中文版

  • send-to-gitlab-issue 2

    a chrome extension to create current tab's title and url as a gitlab issue

  • guard-asciidoctor 2

    Watch asciidoc files with guard

  • tdd-ruby-template 0

  • teddy-ma.github.io 0

    编程青年的个人网站

  • refactoring-card 0

More on GitHub
  • Overview
  • Topics
  • Replies
  • Favorites
  • Following
  • Followers
  • 分享一个自己的 awesome list, 顺便问几个问题... at June 16, 2016

    #12 楼 @cqcn1991 两者都可以,个人觉得 submodule 比较合适,两者区别可以看这里

  • 分享一个自己的 awesome list, 顺便问几个问题... at June 16, 2016

    #9 楼 @cqcn1991 就是最基本的 erb 使用方式,ruby 基本库就支持,你找的那个是 chef 这个工具的做法,找错地方了

  • 分享一个自己的 awesome list, 顺便问几个问题... at June 15, 2016

    #7 楼 @cqcn1991 对的,另外你一样写脚本了,可以顺便生成一下 html 版本并提交到 gh-pages 分支上,这样就有了一个完全同步的 html 网页了

  • 分享一个自己的 awesome list, 顺便问几个问题... at June 15, 2016

    #4 楼 @cqcn1991 ci 是持续集成的意思,一般 GitHub 的开源项目都使用这个

  • 分享一个自己的 awesome list, 顺便问几个问题... at June 15, 2016

    可以让提 PR 的人直接修改 yml 文件,然后用 ci 自动生成 README 文档啊

  • 更新代码后本地代码丢失 at December 07, 2015

    按照你的描述,貌似是你的本地修改被 stash 了,可以试试 git stash pop 看看能不能找回来

  • rvm use 2.1.2@your_gemset 请问这里的 your_gemset 应该怎么写?什么意思? at October 28, 2015

    就是一个名字而已,一般和项目同名

  • git commit -m "Fixed interface issues." at July 28, 2015

    这不是适配器模式吗

  • 有没有命令行能启动的 ruby 静态文件服务器 at July 23, 2015

    https://github.com/ddfreyne/adsf 这个 gem 也行

  • Vagrant 搭建 Rails 开发环境,宿主机无法访问虚拟机中的 Rails 程序。 at July 11, 2015

    试试看 bundle exec rails server -b0.0.0.0

  • Learn to Build a Ruby Gem at July 07, 2015

    http://rubybookbundle.com/ 这里有一套 ruby 书籍的合集卖,其中包含楼主提到的这本

  • 小数至少保留两位如何实现 at June 30, 2015

    楼主是要这个效果吗?

    def format_number(a)
        array = a.to_s.split(".")
        array.first + "." + array.last.to_s.ljust(2,'0')
    end
    
    puts format_number(3.1415926) # => 3.1415926
    puts format_number(111.1) # => 111.10
    
  • Producter —— 一本关于设计,iOS,营销的书 at June 11, 2015

    #13 楼 @hbin selfstore.io 会发邮件的啊

  • Producter —— 一本关于设计,iOS,营销的书 at June 11, 2015

    已入手,早上刚收到新版本更新,加油!

  • 元编程中的环绕别名 (around Alias) 使用场景是什么? at June 10, 2015

    我在阅读 thor 的源代码时发现这个 gem 大量使用了 alias, 不过作者自己说只是为了 backward compatible . 这算一个应用场景吧。

    至于用新方法调用老方法那肯定是不一样的,alias 的方法相当于把旧方法复制了一份。

    class Foo
      def bar
        puts "bar"
      end
    
      alias biz bar
    end
    
    class Foo
      def bar
        puts "not bar"
      end
    end
    
    puts Foo.new.bar
    puts Foo.new.biz
    
    

    面对这种覆盖的情况,如果采用新调旧的方式是无法实现上面的效果的。

    回到 thor 的例子,根据那个 pr 的说明,作者觉得使用 command 这个术语要比 task 要好。 那么使用 alias 之后,就相当于这些方法都有了一份自己的拷贝,那么要添加 deprecated message 就很容易了 @etnl 。 下面是例子

    class Foo
      def command_method
        puts "run method"
      end
    
      alias task_method command_method
    
      def self.call_before_all_methods
        all_instance_methods = instance_methods - Class.instance_methods
        all_instance_methods.each do |x|
          # 名字包含 task 的方法会输出一个 deprecated message
          # 如果我想法变了,只要把"task"改成"command"就行了
          if x.to_s.include? "task"
            class_eval <<-END
              alias old_#{x} #{x}
              def #{x}
                puts "method: #{x} is deprecated"
                old_#{x}
              end
            END
          end
        end
      end
    
      private_class_method :call_before_all_methods
      call_before_all_methods
    end
    
    foo = Foo.new
    foo.command_method
    foo.task_method
    

    注意那段 aop 的元编程也使用了 alias 方法,但是和我要说明的 alias 的特性没任何关系,仅仅把它当做一种 aop 的实现来理解就行了。

  • Rack 就是一个接口 at June 09, 2015

    这里有一篇类似的文章,创建一个自己的 Rack Server

  • 看 PDF 电脑和手机如何同步阅读进度呢? at May 20, 2015

    kindle 帐号有一个对应的邮箱的,只要把书发送给这个邮箱它就会出现在你的 kindle 里了

  • Emacs Ruby 开发环境,怎么配置比较好? at April 23, 2015

    #8 楼 @lips 对啊,这玩意本来就是一个大的插件,你照做就是了,启动 emacs 配置就生效了

  • Emacs Ruby 开发环境,怎么配置比较好? at April 22, 2015

    #6 楼 @lips git clone --recursive http://github.com/syl20bnr/spacemacs ~/.emacs.d 这不就是 .emacs.d 吗,就是配置文件

  • Emacs Ruby 开发环境,怎么配置比较好? at April 22, 2015

    最近这份 emacs 配置挺火的 https://github.com/syl20bnr/spacemacs

  • 重新思考找回忘记密码解决方法 at April 10, 2015

    这篇文章的思路和楼主类似,可以参考下 https://neosmart.net/blog/2015/using-hmac-signatures-to-avoid-database-writes/

  • 初学 Rails, Ruby China 的源码在哪部分处理发帖权限的啊 at April 06, 2015

    应该是 verified 这个字段,然后逻辑不就在模型里么 https://github.com/teddy-ma/ruby-china/blob/master/app/models/user.rb#L147-L151

  • 初学 Rails, Ruby China 的源码在哪部分处理发帖权限的啊 at April 06, 2015

    我记得 user 表中有一个 is trusted 字段,设置成 true 就可以了

  • UCloud API 开发大赛在 RubyChina 的特别抽奖送书活动,截止日期 3 月 24 日 at March 22, 2015

    26

  • Vagrant 需要在本地访问虚拟机中的项目,按照教程步骤访问不了,问题出现在哪里? at March 03, 2015

    不清楚你的网络环境如何,不过可以尝试使用不一样的 ip,比如 config.vm.network "private_network", ip: "33.33.33.10" 这样的配置 就可以通过 33.33.33.10:3000 来访问了

  • Emacs 最右下角多了一个空格 at February 08, 2015

    #5 楼 @xu_xiang_yang 本来不知道的,现在被你一说我过年都过不好了...

  • Emacs 最右下角多了一个空格 at February 07, 2015

    你这么一说我发现我也是这样的 ...

  • 开发 RoR & PHP Project,测试环境、生产环境部署相关问题 at December 28, 2014

    第一个问题的答案是可行的,我使用过 nginx 配 Php-fpm 可以和 rails 共存

  • 乐享圣诞,喜迎新年抽奖活动(截止日期:2015.1.2) at December 24, 2014

    24764

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