Ruby China
  • Topics
  • 招聘
  • Wiki
  • 酷站
  • Gems
  • Sign Up
  • Sign In
Cantin
@cantin
VIP
NO. 353 / 2011-12-01

广州
3 Topics / 213 Replies
1 Followers
0 Following
3 Favorites
GitHub Public Repos
  • dotfiles 2

  • mtouch 2

  • cantin.github.com 1

    cantin's blog

  • cap_deployer 1

    cap deploy helper

  • d-render.js 1

    A lightweight hotwired-compatible lib with directive programming in HTML

  • merit 1

    Reputation system Rails engine.

  • floatThead 1

    Fixed table headers, without custom html/css

  • shu 1

    something just for practice

  • vim-closer 0

    Closes brackets

  • animegan2-pytorch 0

    PyTorch implementation of AnimeGANv2

More on GitHub
  • Overview
  • Topics
  • Replies
  • Favorites
  • Following
  • Followers
  • 用 100 行 Ruby 代码模拟 JavaScript 的 Eventloop at August 19, 2022

    这个 marco task 跟 JS 的 marco task 还是有些许不同。JS 每一次 event loop 只会处理当前已经在 queue 里面的 tasks,之后新加的只会等到下一次 loop 再处理。

    From MDN:

    When executing tasks from the task queue, the runtime executes each task that is in the queue
    at the moment a new iteration of the event loop begins.
    Tasks added to the queue after the iteration begins will not run until the next iteration.
    
    Each time a task exits, and the execution context stack is empty, each microtask in
    the microtask queue is executed, one after another. The difference is that execution
    of microtasks continues until the queue is empty—even if new ones are scheduled
    in the interim. In other words, microtasks can enqueue new microtasks and those
    new microtasks will execute before the next task begins to run, and before the end 
    of the current event loop iteration.
    

    如果把楼主 repo 里的 sample.js 改成这样,就能比较清晰看到 task 跟 mirco task 的不同了

    settimeout_macro_task("macro 1", () => promise_micro_task("macro1-micro1"))
    settimeout_macro_task("macro 2")
    settimeout_macro_task("macro 3")
    
    console.log("第一个出现")
    
    promise_micro_task("micro 1", () => settimeout_macro_task("micro1-macro1", () => promise_micro_task("micro1-macro1-micro 1")))
    promise_micro_task("micro 2")
    promise_micro_task("micro 3")
    
    
  • Ruby | Rails - 浅拷贝 | 深拷贝 at October 29, 2014

    #15 楼 @hiveer taint 的确会被拷贝。

    我只看了clone的文档,没看dup的。其实文档里面都有提到。

    dup copies the tainted state of obj. http://ruby-doc.org/core-2.1.3/Object.html#method-i-dup

  • Ruby | Rails - 浅拷贝 | 深拷贝 at October 29, 2014

    #12 楼 @hiveer

    [7] pry(main)> hash.frozen? => true

    应该是 hash2.forzen 吧。

  • Ruby | Rails - 浅拷贝 | 深拷贝 at October 25, 2014

    ruby 的 dup 跟 clone还有一个不同是 clone 会保存 object 的 state。 Copies the frozen and tainted state of obj.

    拷贝还有一个 initialize_copy method 可以了解一下,相关文章 http://www.jonathanleighton.com/articles/2011/initialize_clone-initialize_dup-and-initialize_copy-in-ruby/

  • Enumerator 的一个问题 at September 19, 2014

    据说是利用Fiber来实现的

  • Rails 中如何自定义 Error Pages at September 10, 2014

    这里是另外一种作法,https://gist.github.com/wojtha/8433843 默认的 exceptions_app 是ActionDispatch::PublicExceptions的一个实例,它会在 ShowExceptions 这个 middleware 中被通过 call 来调用。 所以我们可以将其替换成一个 lambda 或者是直接一个 rack 的 middleware。

  • [广州][2014年5月30日] GZRUBY 第 18 次聚会 - 19:00 at May 30, 2014

    可惜今晚有事去不了,玩的开心!😆

  • 电子书五折优惠 at May 30, 2014

    👍

  • 又发现一个好玩的游戏~ XSS Game~ at May 30, 2014

    http://zhuanlan.zhihu.com/wooyun/19756127

  • 有木有生产模式下的性能日志 gem 丫,求推荐 at April 23, 2014

    https://github.com/wvanbergen/request-log-analyzer

  • 写了个 播报"xx 宝"收益的命令行工具 (Ruby 版) at April 20, 2014

    一个中文字符好像是占了两个英文字符的位置,比如 "测试"的显示长度跟'test'的是一样的 所以 printf 的时候可能要将中文字符串的 length *2

  • Ruby 2.1 现在稳定吗? at March 31, 2014

    小步升级,升到 ruby1.9.3,然后升级到 rails 3 如果客户还不满意,再升级到 ruby 2,rails 4

  • [广州][2014年3月26日] GZRUBY17 - 19:00 at March 19, 2014

    😄

  • [广州] 酷德软件招聘 web 工程师 (已招满,感谢支持) at January 24, 2014

    去年去菲律宾一个小岛旅游的照片 😄

  • 2014 Rails Girls 广州站 Ruby 教练招募! at January 07, 2014

    :thumbsup:

  • 如何在一个 haml 中去插入另一个 haml 呢? at November 05, 2013

    render partial 不行?

  • 关于 vim 中 nerdtree 和 ctrl-p 加载文件的问题 at November 05, 2013

    c-p 下按 F5 刷新就好了

  • gemspec 中条件依赖问题 at November 04, 2013

    😄 就弄成 factory_girl => factory_girl_rails, rspec => rspec-rails 这种吧

  • 有关 Array #join 的 encoding at November 02, 2013

    #9 楼 @046569 这种情况应该是对所有用户的输入都进行编码转换吧。 如果用 Rails 的话,本身应该就有强制转换了吧。

    #10 楼 @ywjno 2.0 是源代码改用 utf-8 编码,数据编码还是要我们自己来处理的

  • [广州] 赋为呼唤 Rails 集成项目经理 :自由女神每天都欢迎您,而五月花号首航只有一次 - 广州首航仅余一席 at October 28, 2013

    支持👍

  • [广州] 招聘 Ruby 程序员 at October 23, 2013

    👍

  • [UCloud 开源接力]#[email protected]#RubyConf China at September 24, 2013

    我是来打酱油的

  • 我们不应该为开源项目提供特别支持么?赠送 Ruby Conference VIP 门票如何? at September 23, 2013

    👍

  • [广州] 招聘 Ruby/Rails 开发人员 at September 23, 2013

    nice 👍

  • 精华贴功能上线 at August 30, 2013

    👍

  • 新手发个纯 ruby 写的 tarball 解压程序,希望大家帮忙改进,谢谢! at August 30, 2013

    #2 楼 @shane51 我不生产代码,我是 SO 的搬运工。 😄

    entry 应该可以拿到内容,然后用写文件的方法将它的内容写到硬盘里?

  • 新手发个纯 ruby 写的 tarball 解压程序,希望大家帮忙改进,谢谢! at August 30, 2013

    http://stackoverflow.com/questions/856891/unzip-zip-tar-tag-gz-files-with-ruby/11505644#11505644 这个不行?

  • 有一句话,能让苹果手机隔屁,大家要见识下不?(进来的后果自负哈) at August 30, 2013

    Mac 下的 chrome 也会中招......

  • 哈希中默认值为数组,使用变量作为 key,出现查找不到的情况 at August 28, 2013

    没插入,hash 取不到值时才会返回默认值的

    1.9.3p429 :001 > a = Hash.new([])
     => {}
    1.9.3p429 :002 > a['asd'].push(1,2)
     => [1, 2]
    1.9.3p429 :003 > a
     => {}
    1.9.3p429 :006 > a['123']
     => [1, 2]
    

    要插入的话在要在 new 后面加上 block http://ruby-doc.org/core-1.9.3/Hash.html#method-c-new

  • Google Reader 挂了,用什么? at August 27, 2013

    要善用 ruby-china 的搜索,搜一下就有了

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