Ruby China
  • Topics
  • 招聘
  • Wiki
  • 酷站
  • Gems
  • Sign Up
  • Sign In
@reus
VIP
NO. 942 / 2012-02-07

1 Topics / 411 Replies
4 Followers
0 Following
0 Favorites
No GitHub.
  • Overview
  • Topics
  • Replies
  • Favorites
  • Following
  • Followers
  • 被调用的函数都很短小,参数却很大 at October 20, 2012

    把参数封装成对象,然后这个函数实现成方法,就可以省去打字和参数传递的开销了吧

  • 请问 ruby 能不能和 C++ 一起工作的? at October 11, 2012

    http://rice.rubyforge.org/

  • Bitbucket 这次改版后感觉比 Github 好看多了 at October 10, 2012

    私人仓库用 bitbucket,因为免费,而且也支持 git

  • 推荐个等宽字体 Adobe Source Code Pro at September 30, 2012

    不错,在用

  • image = MiniMagick::Image.read (url) at September 24, 2012

    #5 楼 @sjzg001 用 wget 可以下载吗?

  • 3 亿的 12306.cn 你说用 Rails 多少能搞定? at September 23, 2012

    要和旧系统集成的,不是纯粹的 web 系统

  • Ruby 每日一菜 at September 21, 2012

    要不就 cygwin

  • ruby 1.9.3 irb 下不能用中文?! at September 21, 2012

    ……11 楼那个图里,楼主直接输入了个中文,irb 解释成 identifier,然后出错信息是变量或方法未定义 这显然是能用中文,楼主根本就没看懂出错信息吧…………………… 在字符串内用 codepoint 的方法是"\uXXXX"或者"\u{XXXX}",小写 u,双引号,没有+

  • image = MiniMagick::Image.read (url) at September 21, 2012

    你是在提问吗?读的是远程图片吗?图片什么格式?如果是远程图片,下载到本地之后能不能打开?有没有出错信息?你的软件环境是怎样的?imagemagick 和各种 jpg png 包都装上了吗?

  • 大家能不能分享一下自己在 github 上关注的项目和用户呢? at September 19, 2012

    项目的话这是个不错的起点:https://github.com/languages

  • 如何知道 Enumerator 的当前内部指针位置和前一个元素? at September 19, 2012

    要反序遍历就用反序的遍历器 当前指针属于内部实现细节,没必要暴露,不然直接用指针就好了,何必多此一举

  • 谁能介绍款游戏手柄? at September 18, 2012

    我用着罗技 f510

  • 上传文件,用什么做为文件名好 at September 18, 2012

    用日期挺好的啊,加多几个随机字符,重复可能性极低

  • 装好 debian 基本系统后,怎样安装 openbox 桌面管理器 at September 18, 2012

    #2 楼 @chao 如果你用 arch,你根本就不需要提出这个问题,因为 wiki 里面已经有了解决方案,你只需要照着来做就行了。先装一个基本系统,然后再安装自己想用的软件,arch 会这样假定用户的使用习惯。而 debian 假定的是,用户如果想要图形界面,那就应该在安装时选上。也就是说,对于你这样的使用习惯,arch 其实更友好 安装 archlinux 可以看这份文档 https://wiki.archlinux.org/index.php/Beginners_Guide' 页面左边也有中文版的链接

    debian 的配置可以 google:debian configure xorg 或者用安装盘启动,把基本的桌面系统装上

  • 装好 debian 基本系统后,怎样安装 openbox 桌面管理器 at September 18, 2012

    xorg 没配置好吧

    如果你用的是 archlinux,我会推荐这个 https://wiki.archlinux.org/index.php/Xorg 没发现 debian 有此类文档。虽然两个系统功能一样,不过 arch 对习惯最小化安装的用户来说更加友好一些。常用软件都有专门的 wiki 页,照着做就可以了,不像其他发行版需要到处找 howto

  • 大家一般怎么使用 /dev/shm 呢? at September 13, 2012

    缓存浏览器的目录之类的 其实我没有用

  • 大家解决 rails 难题的过程是怎样的? at September 13, 2012

    google 不到答案,要么是你遇到了一个没有人遇到过的问题,要么是你关键词选得不好 不如你把问题贴出来,我们帮你 google 试试…

  • sinatra 如何判断 MIME_TYPE at September 12, 2012

    http://boonedocks.net/mike/archives/162-Determining-Image-File-Types-in-Ruby.html

    http://stackoverflow.com/questions/51572/determine-file-type-in-ruby

    https://www.google.com.hk/search?q=ruby+detect+image+file+type&sugexp=chrome,mod=1&sourceid=chrome&ie=UTF-8

  • 写了个新玩具 Ruby method decorators (类似 Python) at September 12, 2012

    如果 decorator 返回的是 callable object,还可以实现多重 decorate,比如 python 的

    @double_arguments
    @double_arguments
    @double_arguments
    def foo(a, b):
      return a + b
    
    print foo(1, 2) # => 24 八倍参数             
    

    相当于

    def foo(a, b):
      return a + b
    
    foo = double_arguments(double_arguments(double_arguments(foo)))
    
    
  • 写了个新玩具 Ruby method decorators (类似 Python) at September 12, 2012

    比如这样一个 python 的 decorator

    def double_arguments(func):                                      
      def f(*args):                                                  
        return func(*[x * 2 for x in args])                          
      return f                                                       
    
    @double_arguments                                                
    def add(a, b, c):                                                
      return a + b + c                                               
    
    @double_arguments                                                
    def mul(a, b, c):                                                
      return a * b * c                                               
    
    print add(1, 2, 3) # => 12                                       
    print mul(1, 2, 3) # => 48                                       
    

    double_arguments 会修改 add 和 mul 的定义,使传递给他们的参数都先乘以 2,再传递给原函数 如果 decorator 只能改变返回值,那是实现不了这个效果的 decorator 的实现里面,不仅可以引用到原先定义的函数/方法,也可以引用到实际调用时的参数 所以 ruby 可能可以写成这样?

    class Batman < RubyDecorator
      def call(func)
        lambda {|*args|
          func(*args).sub('world', 'batman')
        }
      end
    end
    
  • 写了个新玩具 Ruby method decorators (类似 Python) at September 12, 2012

    感觉跟 python 的 decorator 差异很大。python 里面用 class 来实现 decorator 的话,__call__方法的参数是 funtion 类型,返回另一个 function。这里的 call 方法的 this 参数,是所 decorate 的方法的返回值吧?对返回值进行修改,倒跟 golang 里用 defer 修改返回值类似。python 的 decorator 可以对方法/函数进行重新定义,而且可以引用到原方法/函数,不是修改返回值

  • Emacs 24 使用 GTK+ 经常会死机 (你们是怎么解决的?) at September 10, 2012

    #16 楼 @zw963 http://linuxtoy.org/archives/musca.html http://linuxtoy.org/archives/awesome.html http://linuxtoy.org/archives/subtle.html http://linuxtoy.org/archives/ion-2.html http://linuxtoy.org/archives/qtile.html

  • Emacs 24 使用 GTK+ 经常会死机 (你们是怎么解决的?) at September 10, 2012

    #16 楼 @zw963 tiling wm 这个东西好像是从 linuxtoy 里知道的,后来又 google 出很多来

  • Emacs 24 使用 GTK+ 经常会死机 (你们是怎么解决的?) at September 09, 2012

    #14 楼 @zw963 awesome 的依赖是很多,可以试下这个 http://i3wm.org/,或者这个 http://xmonad.org/

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