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
  • 感觉自己已经成了 alias 的奴隶了. at March 31, 2012

    除了 ll 用的最多的是 psg,基本登录上某个服务器,首先加上这个 alias

    psg='ps auxw | grep -i'

  • Emacs 按键之乾坤大挪移 at March 31, 2012

    M-c不好按,推荐M-s,在 home row 大拇指按住 alt 其它手指不用动,本身键位上只在某些 mode 里 bind 到 search history forward,但一般我们只会用到 search history backward

  • 按一定的概率随机给出键,怎么实现好 at March 31, 2012

    #11 楼 @FenRagwort 2 分搜索的比较好实现,只要算出 accumulated prop (cumulative distribution function CDF) 就行了,像你例子就是算出平行数组

    [:a, :b, :c, :d] [0.5, 0.65, 0.85, 1]

    sample 个(0,1]然后在第二数组里二分查找,找出 index 从第一个数组取值,accumulate 就是到当前位置为止所有概率之和

    alias method 的构造有些小复杂,以前写过个分析的文章 不过 ruby 实现搜了下没找到。其实用二分足够了吧,几千也就 10~14 下。

  • 感觉自己已经成了 alias 的奴隶了. at March 31, 2012

    ohmyzsh 很多插件就是加一堆 alias,估计用 ohmyzsh 然后 enable 一堆插件的 alias 都比较多

  • 感觉自己已经成了 alias 的奴隶了. at March 31, 2012

    我才 88 个

  • 按一定的概率随机给出键,怎么实现好 at March 31, 2012

    @ miloyip 这篇 博客 有很详细的说明和比较。

  • 按一定的概率随机给出键,怎么实现好 at March 31, 2012

    google Alias Method O(1) 时间

  • instance_exec 和 instance_eval 有啥区别啊? at March 31, 2012

    #12 楼 @hhuai 确实,例子举得不够好

  • Back to Emacs at March 31, 2012

    #43 楼 @nil System Preferences -> Keyboard ->Modifier Keys 就可以改了,不过我交换 option 和 command 后,键盘右边那两个键盘经常就全部分变成 command 了

  • Back to Emacs at March 31, 2012

    #43 楼 @nil #44 楼 @hisea 我把 mac 的全局键盘的 option 和 command 交换了,caps lock 映射 ctrl,C-space 也留出来给 Emacs 的 set-mark-command 用

  • instance_exec 和 instance_eval 有啥区别啊? at March 30, 2012

    #10 楼 @xds2000 比如你要把 block 注入成一个 method

    class App def self.helper(name, &block) define_method(name) do |*args| instance_exec(*args, &block) end end end

    App.helper(:foo) {|bar| p bar} App.new.foo('bar')

  • Yard doc at March 30, 2012

    还可以跑个 server 查看 gems 的文档

    yard server -g -s thin

  • 坛子里使用 Git 的朋友,请教一下 Git-Subtree 如何使用。 at March 30, 2012

    能用 advice 就 advice,不能 advice 就重新定义函数,大部分库不需要去修改源代码

  • 坛子里使用 Git 的朋友,请教一下 Git-Subtree 如何使用。 at March 30, 2012

    https://gist.github.com/2181511 写了个小脚本删除 submodules,手动删除很麻烦

  • [翻译] Emacs 改变了我的人生 (发生在 Emacs 和 Ruby 之间的故事) at March 30, 2012

    #17 楼 @lgn21st 打开在scratch里就可以玩 lisp 了,C-j 执行代码并且插入结果

  • [翻译] Emacs 改变了我的人生 (发生在 Emacs 和 Ruby 之间的故事) at March 30, 2012

    #25 楼 @hbin helm-config 的 autoloads 不全,如果想像以前 anything 一样自己加 sources 需要手动 require 一堆,我用到下面这些

    (require 'helm-mode) (require 'helm-match-plugin) (require 'helm-buffers) (require 'helm-files) (require 'helm-locate) (require 'helm-w3m)

    my helm config

  • Back to Emacs at March 30, 2012

    minor modes 好少啊,记得有个 plugin 是隐藏 minor modes 名字的,忘记叫什么了。modes 多了太占地方了

    mode-line

  • 类名转化为符号最便捷的方法 at March 30, 2012

    :"#{self}"

  • [翻译] Emacs 改变了我的人生 (发生在 Emacs 和 Ruby 之间的故事) at March 30, 2012

    #2 楼 @poshboytl #1 楼 @lgn21st

    可以在 Emacs 里 M-x term,然后再开个 vim。也可以用 M-x viper-mode

  • 发点牢骚! 真的觉得日本人好牛~~ at March 29, 2012

    #15 楼 @zw963 anything +1,主要用来找 file 和 buffer,原来改名字了,我还是用的原来的 anything-config 的 git repo

  • each 的疑惑 at March 29, 2012

    @cqpx @lgn21st 我发现你的抄答案 http://www.ruby-doc.org/core-1.9.3/Enumerable.html#method-i-find_all

  • each 的疑惑 at March 29, 2012

    Enumerable的方法也要多熟悉,我怎么感觉这题是要诱导使用 find_all

  • each 的疑惑 at March 29, 2012

    多看看Array的方法,尤其跟 delete 相关的

  • each 的疑惑 at March 29, 2012

    然后 list 初始话看着太难受了

    list = (1..100).to_a

  • 能不能用表单的方式不经过查询直接跳转到 show 页面? at March 29, 2012
    1. 加个路由 match 'resources/show' =>'resources#show', via: :get
    2. 表单里的 text field 用 id 做 name

    然后你表单提交后就到了 /resources/show?id=10,因为url里的params和query都会merge到params里,所以show方法不用做任何改动

  • 这两种删除写法为什么效果相同呢? at March 29, 2012

    see http://apidock.com/rails/ActionDispatch/Routing/PolymorphicRoutes/polymorphic_url

  • markdown 避免显示 input,button 等元素.怎么做? at March 29, 2012

    也可以继承 html render 然后重写 block_html(raw_html) 和 raw_html(raw_html) 方法,前面一个是 block 级,后面一个是 span 级

  • markdown 避免显示 input,button 等元素.怎么做? at March 29, 2012

    redcarpet HTML render 有个选项是过滤所有 html: filter_html

  • [求推荐] 写 open api 的工具 at March 29, 2012

    现在一个项目是直接用 yard 生成,代码注释在一起,更新都来方便,部署的时候跑个 yard 直接就可以在线查看。缺点是文件 80% 都是注释。当然这种方法需要你有东西可以注释,我是直接用的 rails 写的 API,每个 API 对应一个 action,每个 controller 对应一个 resource。至于 json 数据格式,用的 rabl,用了些 trick,其实就是每个 rabl 文件外面套个 class,让 yard 可以提取文档。

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