<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>jiffies</title>
    <link>https://ruby-china.org/jiffies</link>
    <description></description>
    <language>en-us</language>
    <item>
      <title>请问大家一般爬数据用什么？</title>
      <description>&lt;p&gt;是用什么库么还是自己写？&lt;/p&gt;</description>
      <author>jiffies</author>
      <pubDate>Sun, 23 Sep 2012 23:36:46 +0800</pubDate>
      <link>https://ruby-china.org/topics/5708</link>
      <guid>https://ruby-china.org/topics/5708</guid>
    </item>
    <item>
      <title>request.body 和 params 是不是一样的？</title>
      <description>&lt;p&gt;params 是不是完整的把请求主体转化为一个哈希？&lt;/p&gt;</description>
      <author>jiffies</author>
      <pubDate>Sun, 19 Aug 2012 02:36:44 +0800</pubDate>
      <link>https://ruby-china.org/topics/5023</link>
      <guid>https://ruby-china.org/topics/5023</guid>
    </item>
    <item>
      <title>中断的本质是什么</title>
      <description>&lt;p&gt;洗澡的时候不知怎么突然又想到“中断”。
以前上学的时候就听的就不是很明白，许多书里也讲的似是而非，在后来编程的时候又遇到很多名词像 addListener，bind，槽，回调，事件，消息等等似乎都跟“中断”这个词有关。所以也上网看过许多帖子的解释，过程虽然很清晰明了，但是总觉得还是哪里隔着一层膜，让人那么的不舒服。
经常性的解释就是：&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;loop {
  check A  //假设check实在检查某事件是否发生
  do B
  check C
  do D
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;在 B 执行时，如果 C 发生了，C 不能得到及时相应，或者 A 一直不发生却一直检查 A 效率很低。
用中断机制时，&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;loop {
  do B

  do D
}

&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;A，C 发生了会主动发出信号，CPU 再去处理。之前注册的两个回调
do A {}
do B {}&lt;/p&gt;

&lt;hr&gt;

&lt;p&gt;实际上，在底层，CPU 执行完每条指令时都会去检查一个中断标志位，当发现某一位置 1（可能）时，知道有中断发生（不考虑多中断），CPU 会保存现场（context），转而执行我们提前注册过的程序，即 ISR（Interrupt Service Routine），实际就是一种回调函数。ISR 会调用具体硬件驱动程序的中断例程，这里的中断例程又是一种回调（linux 会用 request_irq 注册），它会去读硬件寄存器取得事件的具体信息。&lt;/p&gt;

&lt;p&gt;之后的就不太熟悉了，猜测的，希望有高人教我
Linux 可能会是层层回调机制，最上层的应用程序注册的回调最终会被调用。
windows 可能用的事件机制（消息机制，一回事），事件从底层层层上传，windows 窗口程序有一个线程专门循环 GetMessage，检查一个事件队列。&lt;/p&gt;

&lt;p&gt;不管怎么样，检查某个事件是否发生本质都是轮询+check，它没在代码里看到，只是发生在别的地方了，比如 CPU 层级；或者换了一种方式。经常举得例子里实际是用听力代替了视力去轮询（觉得这里有什么可以挖掘，还没想到），一定范围内，听力比视力的监察范围更广。&lt;/p&gt;

&lt;p&gt;所谓的实时性，就是提高到了指令周期级别。每秒十亿次，但是在无限细分下去，仍然有无法响应的盲点，因为每一周期就是一个轮询。并行性也就是利用计算机极快的速度与人的反应的差别。并不是一直在运行，但是看上去似乎是的。&lt;/p&gt;

&lt;p&gt;光速 30 万公里每秒，人的肉眼捕捉不到 24 帧以下的空隙，当有那么快的速度时，人就可以做到分身术了&lt;/p&gt;</description>
      <author>jiffies</author>
      <pubDate>Tue, 14 Aug 2012 02:30:01 +0800</pubDate>
      <link>https://ruby-china.org/topics/4920</link>
      <guid>https://ruby-china.org/topics/4920</guid>
    </item>
    <item>
      <title>有没有什么关于浏览器的好书？</title>
      <description>&lt;p&gt;今天在微博看到有人推荐《动人的 JavaScript》（Eloquent JavaScript）时说 Javascript 是 Web 时代的 C 语言。这样的话浏览器不就是 Web 时代的操作系统么，所以想问问大家有没有什么介绍浏览器原理，组成，工作流程等内容的书？
大家推荐推荐  &lt;/p&gt;</description>
      <author>jiffies</author>
      <pubDate>Wed, 20 Jun 2012 23:58:14 +0800</pubDate>
      <link>https://ruby-china.org/topics/3916</link>
      <guid>https://ruby-china.org/topics/3916</guid>
    </item>
    <item>
      <title>我想打印 Rails gudie，求办法</title>
      <description>&lt;p&gt;想打印下来可以带到教室看，但是官网只提供 mobi 格式，不知道怎么打印？  &lt;/p&gt;</description>
      <author>jiffies</author>
      <pubDate>Wed, 06 Jun 2012 23:25:34 +0800</pubDate>
      <link>https://ruby-china.org/topics/3700</link>
      <guid>https://ruby-china.org/topics/3700</guid>
    </item>
    <item>
      <title>求助正则表达式</title>
      <description>&lt;p&gt;&lt;code&gt;/&amp;lt;a.*?href="(.*?)".*?&amp;gt;Download\s*Video&amp;lt;\/a\s*&amp;gt;/m&lt;/code&gt;
我想匹配这样一段：&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;a href="http://xxx.com/aaa" class="orange-button left_20"&amp;gt;Download Project Files&amp;lt;/a&amp;gt;
&amp;lt;a href="http://xxx.com/bbb"&amp;gt;Download Video&amp;lt;/a&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;我是这样理解的:
1.&lt;code&gt;&amp;lt;a&lt;/code&gt;开头
2.匹配任何字符直到第一个 href="
3.捕获任何字符直到第一个"
4.匹配任何字符直到第一个&amp;gt; (这里多匹配了不知道为什么)
5.Download\s*Video
我觉得会匹配到&lt;code&gt;http://xxx.com/bbb&lt;/code&gt;，但实际是&lt;code&gt;http://xxx.com/aaa&lt;/code&gt;
请问哪里出了问题？  &lt;/p&gt;</description>
      <author>jiffies</author>
      <pubDate>Wed, 30 May 2012 19:09:28 +0800</pubDate>
      <link>https://ruby-china.org/topics/3563</link>
      <guid>https://ruby-china.org/topics/3563</guid>
    </item>
    <item>
      <title>豆瓣和 720p</title>
      <description>&lt;p&gt;刚刚在豆瓣找一部电影，突然发现高清下载的按钮，顿时觉得奇怪，豆瓣不怕版权问题么，点击跳转到 720p.so，才发现这个貌似是浏览器插件，好像原生的按钮。。  &lt;/p&gt;</description>
      <author>jiffies</author>
      <pubDate>Tue, 29 May 2012 21:00:06 +0800</pubDate>
      <link>https://ruby-china.org/topics/3550</link>
      <guid>https://ruby-china.org/topics/3550</guid>
    </item>
    <item>
      <title>请问 Rails 文档中有动态生成的方法吗？</title>
      <description>&lt;p&gt;比如我想查 new_user_path 这种函数的文档，在哪能查到？  &lt;/p&gt;</description>
      <author>jiffies</author>
      <pubDate>Thu, 10 May 2012 20:08:20 +0800</pubDate>
      <link>https://ruby-china.org/topics/3201</link>
      <guid>https://ruby-china.org/topics/3201</guid>
    </item>
    <item>
      <title>请问异步 ajax 的通知是怎么实现的？</title>
      <description>&lt;p&gt;比如我发了一个消息给另一个用户，接收者的消息提示就像 ruby-china 右上角红色的，
在不刷新页面的情况下，弹出提示。是前端有 js 定时与服务器通信呢还是？  &lt;/p&gt;</description>
      <author>jiffies</author>
      <pubDate>Fri, 04 May 2012 22:49:23 +0800</pubDate>
      <link>https://ruby-china.org/topics/3080</link>
      <guid>https://ruby-china.org/topics/3080</guid>
    </item>
    <item>
      <title>关于原子性问题</title>
      <description>&lt;p&gt;在一个 action 里操作了好几个资源，如果前面几个资源都操作成功了，但是最后一个却失败了，比如我要发私信给另一个用户，先 message save 成功然后发送一个提醒却失败了，一般应该怎么处理这种情况？&lt;/p&gt;</description>
      <author>jiffies</author>
      <pubDate>Sun, 29 Apr 2012 22:10:53 +0800</pubDate>
      <link>https://ruby-china.org/topics/2985</link>
      <guid>https://ruby-china.org/topics/2985</guid>
    </item>
    <item>
      <title>View 里嵌入 ruby 代码问题</title>
      <description>&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;span class=
&amp;lt;%= current_user.notifications.size&amp;gt;0? "badge badge-important":"badge" %&amp;gt;&amp;gt;

&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;期望大于 0 的时候 class="badge badge-important",
但结果却是&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;span class="badge" badge-important=""&amp;gt;

&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;请问为什么？  &lt;/p&gt;</description>
      <author>jiffies</author>
      <pubDate>Sun, 29 Apr 2012 13:59:01 +0800</pubDate>
      <link>https://ruby-china.org/topics/2980</link>
      <guid>https://ruby-china.org/topics/2980</guid>
    </item>
    <item>
      <title>foreign_key 放在哪里？</title>
      <description>&lt;p&gt;在模型定义关系时，foreign_key 指定一个表的外键，has_many,belongs_to 好像都有这个参数，效果是不是一样的？  &lt;/p&gt;</description>
      <author>jiffies</author>
      <pubDate>Sat, 21 Apr 2012 12:45:29 +0800</pubDate>
      <link>https://ruby-china.org/topics/2788</link>
      <guid>https://ruby-china.org/topics/2788</guid>
    </item>
    <item>
      <title>这里到底要不要加 self？</title>
      <description>&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="n"&gt;before_save&lt;/span&gt; &lt;span class="ss"&gt;:create_remember_token&lt;/span&gt;
&lt;span class="kp"&gt;private&lt;/span&gt;
   &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;create_remember_token&lt;/span&gt;
     &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;remember_token&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;SecureRandom&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;urlsafe_base64&lt;/span&gt;
   &lt;span class="k"&gt;end&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;请问这里，self.remember_token 的 self 能否去掉？不加 self 好像运行不正常，但是不应该默认是 self 的么  &lt;/p&gt;</description>
      <author>jiffies</author>
      <pubDate>Tue, 17 Apr 2012 16:07:16 +0800</pubDate>
      <link>https://ruby-china.org/topics/2660</link>
      <guid>https://ruby-china.org/topics/2660</guid>
    </item>
    <item>
      <title>ruby 所谓方法和消息怎么理解呢？</title>
      <description>&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class foo
  def bar
  end
end

foo.new.bar

&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;类是方法和数据的集合，class 里定义的应该是一个 bar 方法。但是调用的时候为什么经常说是发送一个消息 bar 给 foo 的实例？  &lt;/p&gt;</description>
      <author>jiffies</author>
      <pubDate>Sun, 08 Apr 2012 23:31:12 +0800</pubDate>
      <link>https://ruby-china.org/topics/2468</link>
      <guid>https://ruby-china.org/topics/2468</guid>
    </item>
    <item>
      <title>改了模型，页面跟着改的问题</title>
      <description>&lt;p&gt;我更改了一张表的一个 column 的 name，
现在对应到之前的页面里许多地方都要改了，请问这种情况怎么办？
再 model 里对应虚拟属性还是？  &lt;/p&gt;</description>
      <author>jiffies</author>
      <pubDate>Fri, 06 Apr 2012 01:25:39 +0800</pubDate>
      <link>https://ruby-china.org/topics/2405</link>
      <guid>https://ruby-china.org/topics/2405</guid>
    </item>
    <item>
      <title>求助 Octopress 的问题</title>
      <description>&lt;p&gt;在个 github pages 试用了一下 Octopress，有点疑惑
这个程序是不是只是在本地生成静态的页面放到服务器上，然后看到一个&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class SinatraStaticServer &amp;lt; Sinatra::Base


&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;是不是用这个返回静态页面？有木有讲解一下的？
还有除了插件它的核心代码放在哪？难道都在 Rakefile 里？  &lt;/p&gt;</description>
      <author>jiffies</author>
      <pubDate>Tue, 03 Apr 2012 02:04:24 +0800</pubDate>
      <link>https://ruby-china.org/topics/2355</link>
      <guid>https://ruby-china.org/topics/2355</guid>
    </item>
    <item>
      <title>类方法和对象方法分不清，求助</title>
      <description>&lt;p&gt;在 agile rails 书中有这样一段代码 m&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Cart &amp;lt; ActiveRecord::Base
  has_many :line_items, dependent: :destroy
  def add_product(product_id)
    current_item = line_items.find_by_product_id(product_id)
    if current_item
      current_item.quantity += 1
    else
      current_item = line_items.build(product_id: product_id)
    end
    current_item
  end
end

&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;请问这里的 line_items 应该是当前调用 cart 对象的 line_item 数组吧，它也能调用 find 的函数？
不是应该 LineItem 类调用的嘛？  &lt;/p&gt;</description>
      <author>jiffies</author>
      <pubDate>Wed, 28 Mar 2012 22:20:59 +0800</pubDate>
      <link>https://ruby-china.org/topics/2220</link>
      <guid>https://ruby-china.org/topics/2220</guid>
    </item>
    <item>
      <title>mysql 5.5 是不是和 rails3.2 一起有问题？</title>
      <description>&lt;p&gt;Awdwr4 里说 mysql5.5 和 Rails3.1 有问题，但我用的是 3.2.1&lt;/p&gt;

&lt;p&gt;在 Gemfile 里加了 mysql2,&lt;/p&gt;

&lt;p&gt;执行 rake db:setup RAILS_ENV="production"时报错，&lt;/p&gt;

&lt;p&gt;&lt;code&gt;rake aborted!
Please install the mysql adapter: `gem install activerecord-mysql-adapter` (mysql is not part of the bundle. Add it to Gemfile.)
&lt;/code&gt;
mysql2 不是 adapter 嘛？  &lt;/p&gt;</description>
      <author>jiffies</author>
      <pubDate>Sun, 18 Mar 2012 20:34:05 +0800</pubDate>
      <link>https://ruby-china.org/topics/1951</link>
      <guid>https://ruby-china.org/topics/1951</guid>
    </item>
    <item>
      <title>请介绍一下 i18n 中文问题</title>
      <description>&lt;p&gt;看得教程都是英文开发，提到一点点本地化也看不大明白。有没有高手介绍一下中文显示问题啊？
对了还有个问题，ruby-china 里 model 是不是不用 ActiveRecord？看不大明白。是不是 Mongnid 的 ORM 要用其他？  &lt;/p&gt;</description>
      <author>jiffies</author>
      <pubDate>Sat, 17 Mar 2012 22:49:32 +0800</pubDate>
      <link>https://ruby-china.org/topics/1927</link>
      <guid>https://ruby-china.org/topics/1927</guid>
    </item>
    <item>
      <title>几个问题</title>
      <description>&lt;p&gt;1.能不能在 wiki 里加一些介绍 web 开发相关概念的入门。比如服务器怎么与 rails 程序协作，简单的一些流程。
2.@huacnlee 的从零开始里说写一个 blog 包括 UI，UI 方面高手们有什么想说的么，只会一些基本的 html，css。怎么能做一个看得过去的页面呢？
3.Agile Web Development with Rails, 4th Edition，有没有哪位大侠有 3.2 版本的？  &lt;/p&gt;</description>
      <author>jiffies</author>
      <pubDate>Wed, 22 Feb 2012 00:16:24 +0800</pubDate>
      <link>https://ruby-china.org/topics/1349</link>
      <guid>https://ruby-china.org/topics/1349</guid>
    </item>
  </channel>
</rss>
