Ruby China
  • Topics
  • 招聘
  • Wiki
  • 酷站
  • Gems
  • Sign Up
  • Sign In
ian
@doitian
VIP
NO. 186 / 2011-11-23

皮匠科技
杭州
22 Topics / 849 Replies
42 Followers
1 Following
13 Favorites
GitHub Public Repos
  • live2dviewer 76

    Live2D 模型批量查看器

  • dotfiles-public 14

    My configurations

  • knowledge-base 5

  • ckb-sdk-python 2

  • readwise-scripts 2

  • zotero-actions-tags-sc... 2

    Scripts for the Zotero plugin windingwind/zotero-actions-tags

  • lnd-grpc-tonic-client 2

    Rust lnd client using tonic and tonic-openssl.

  • http-inspector 1

  • dotfiles 1

    dotfiles managed using saltstack

  • userstyles 0

More on GitHub
  • Overview
  • Topics
  • Replies
  • Favorites
  • Following
  • Followers
  • 让你的 OSX 拥有完整的 Emacs Binding. at July 13, 2013

    把差不多所有 Option + 字母的组合都拿来做全局快捷键了,今天看了这个,又折腾着空出了 f, b, v。其它用得不多就不绑定了。普通键盘布局,Option 都很难按,不大适用于常用快捷键。

  • ruby 获取 model 名字 at July 13, 2013

    include C 的时候,A 的子类还不存在呢。如果不考虑子类的子类,可以用 #1 楼 的方法,覆盖 A 的 inherited 方法。

    module C
      extend ActiveSupport::Concern
    
      included do
        def self.inherited(sub_class)
          sub_class.send :include, SubMixin
        end
      end
    
      module SubMixin
        ...
      end
    end
    

    另外,如果所有子类都差不多,为什么不在父类中直接 mixin 呢?如果有些东西需要子类的特定信息,可以用类似 Template Method 的方式,在运行时的时候代理给子类

    感觉你把最重要的信息给隐藏掉了,你是需要在 included 里判断 model 类型,然后根据类型去添加一些方法,或者是调用一些 class macros 吧。

  • 求 Sublime Text 2 操作技巧 at July 12, 2013

    #18 楼 @JohnLu Mac 用 end 到文件末尾了,ctrl + a 到行首 ctrl + shift + e 选择到行尾

  • 求 Sublime Text 2 操作技巧 at July 12, 2013

    看菜单 Selection 下有很多用于多选的。比较简单的一种方案就是选中所有行,然后用 Split into Lines (⇧⌘L);或者用 Select Next Line (⌃⇧↓)。选好后每行都有 Cursor 了,行首行尾分别加下 ",再移到行尾把回车删掉

  • 请推荐入门 CSS 类书籍 at July 10, 2013

    http://learn.shayhowe.com/html-css/

  • 今天才发现 ruby 的标准库有个 un at July 08, 2013

    #4 楼 @hooopo twitter 上还有人挖出了 1.8 时代的 ubygems.rb 所以命令行下可以用 -rubygems

  • Mac 下 sublime 怎么调出顶部菜单栏? at June 28, 2013

    ⌘+? 可以搜索菜单,很方便的,还可以用来学习快捷键

  • [上海] 上街吧网 --- 寻找 Ruby 大牛 (目前公司女性人数大于男性!) at June 18, 2013

    团队中有两位前同事,在数据挖掘和机器学习方法都有很深的造诣,非常靠谱。顶一下

  • 如何查看那些文件被合并过 at June 18, 2013

    #2 楼 @coolesting git log 也是可以的,用 -m 显示 merge commit 的 stat

    git log --merges -m --name-only

  • [南京][2013年06月29日] 第一次 Ruby 聚会召集 at June 18, 2013

    虽然在江苏,不过到南京实在太远了。呆在没高铁的城市,出行还真是不方便。

  • 如何查看那些文件被合并过 at June 18, 2013

    找到 merge commit 的 SHA1

    git show --stat SHA1

  • 关于 jquery-uploader 和 masonry 的一个问题 at June 17, 2013

    你要传给 DOM collection,这样 masonry 才能对上号。如果 j render(@photo) 返回的只有一个根结点可以用 $ 先转成 DOM

    el = $("<%= j render(@photo) %>");
    $('#masonary').append(el);
    $('#masonary').masonary('appended', el);
    

    如果不只一个根结点,可以用个临时的 div

    el = $(document.createElement('div')).html("<%= j render(@photo) %>").children();
    ...
    
  • 关于 jquery-uploader 和 masonry 的一个问题 at June 17, 2013

    http://masonry.desandro.com/methods.html

    用 appended 或者 layout 方法。注意如果用图片需要图片加载完再重排,不然高度会是错误的。可以找个 jquery onload 的插件

  • 请问 rake 可以用于写 c/c++ 的项目的 makefile 吗? at June 16, 2013

    C/C++ 还是推荐 CMake

  • 手贱升了小牛,遭遇各种 crash at June 14, 2013

    maverick -> 牲口

  • 有用 wice-grid 搭配其他 select 的 js (select2、chosen) 组成表格的么 at June 14, 2013

    加下 CSS,把 select 弄宽点

  • 今年的 RubyConf China at June 12, 2013

    @jasl 这个很 cool

  • 初学 Coffee 脚本,请教 function 定义问题! at June 12, 2013

    #3 楼 @saillee coffee 自己给变量加 var ,而且每个文件都在一个匿名函数里执行,所以上面那些相当于 JavaScript (自己多看看编译后的 JavaScript 就清楚了

    (function() {
    
        var search = function () {
            ...
        };
    
    }).call(this)
    

    全局变量是不推荐的,实在需要的化,可以显示的定义为 window 对象的属性:

    window.search = search

    如果是在 CoffeeScript 文件的 top level 的话也可以写成

    @search = search

    不过推荐你加个全局的 Object 作为 namespace 来组织这些函数。

    App = @App ||= {} App.search = search

    // onclick="App.search()"

    就你的情况来说,完全没有必要暴露这个函数,你可以直接用 js 来绑定,而不是在 HTML 里混用 JavaScript。当然你需要加些 class, id 方便 jQuery 来选取

    $('body').on 'click', 'a.search-button', search

  • session 結束時,怎麼自動刪除 shopping cart? at June 11, 2013

    已经登录的用户可以和用户绑定吧

  • session 結束時,怎麼自動刪除 shopping cart? at June 11, 2013

    记下上次访问时间,定时清理

  • 我是否应该使用 mongodb?(即 mongodb 能比 mysql 更好的解决我面临的问题吗?) at June 10, 2013

    这种应用场景算是 mongodb 非常适用的,可以试试。可以在插入的统计,即插入的时候同时插入 N 张表。也可以在后台定时做 mapreduce

  • 免费 JavaScript / Python 电子书 at June 09, 2013

    http://hackershelf.com/search/?q=ruby&calling_url=%2Fbrowse%2F

  • 字符串压缩,有木有更优雅方式? at June 09, 2013

    或者用带 block 的 gsub。用 /(.)\1+/ 去匹配

  • 字符串压缩,有木有更优雅方式? at June 09, 2013

    @see Enumerable#chunk

  • 请教生产环境 rake assets:precompile at June 09, 2013

    简单说,所有你在 view 里点了名的 js 和 css 文件都需要加到 precompile 里。图片等资源在 4.0 之前默认全部,所以不用管。

  • heroku run rake db:migrate 执行后出错 at June 06, 2013

    可以运行 heroku run "rake db:migrate --trace" 拿到完整的错误

  • heroku run rake db:migrate 执行后出错 at June 06, 2013

    有加 gem pg 吗?

  • 前端假如有这样的工具就好了 at June 05, 2013

    mv x.css x.scss

  • 分享下较新的把 Guard 加入 Gemfile 的正确做法 at June 05, 2013

    确实方便很多。以前要用都是用 development_linux development_mac 这个 group,然后根据自己的系统去 without。

    比较烦人的其实是 emacs 和 tmux 的 notifier,这货检测到就使用,颜色配置需要通过 add_notification 时修改,但用了 add_notification 就不会自动检测可用的 notifier 了,后来找到个办法就是用 ~/.guard.rb 去覆盖默认的配置。

    require 'guard/notifier'
    
    notifiers_options = {
      :emacs => {
        :fontcolor => "#8fb28f",
        :default => "#2b2b2b",
        :success => "#013009",
        :failed => "#310602",
        :pending => "#534626"
      },
      :tmux => {
        :success                => 'colour64',
        :failed                 => 'colour124',
        :pending                => 'colour136',
        :default                => 'colour239',
        :display_message        => false,
      }
    }
    
    ::Guard::Notifier::NOTIFIERS.each do |group|
      group.map { |n| n.first }.find { |notifier|
        ::Guard::Notifier.add_notification(notifier,
                                           notifiers_options[notifier] || {},
                                           true)
      }
    end
    
  • 想在武汉招满 14 个搞 ror 的,是不是 mission impossible? at June 05, 2013

    #11 楼 @knwang 👍

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