<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

    <title>很二很天真</title>
    <link href="https://blog.toonaive.me/atom.xml" rel="self"/>
    <link href="https://blog.toonaive.me/"/>
    <updated>2019-06-30T06:13:44+00:00</updated>
    <id>https://blog.toonaive.me</id>
    <author>
        <name>RustingSword</name>
        <email>i@toonaive.me</email>
    </author>

    
    <entry>
        <title>讲故事的套路</title>
        <link href="https://blog.toonaive.me/2019/06/30/pattern-of-storytelling.html"/>
        <updated>2019-06-30T00:00:00+00:00</updated>
        <id>https://blog.toonaive.me/2019/06/30/pattern-of-storytelling</id>
        <content type="html" xml:base="https://blog.toonaive.me">&lt;p&gt;首先一个让我感到有点恐慌的事情，是不知道该给每篇博客选择哪些标签，虽然这不是必须的，但是也反映出我悲催的概括能力，大概取不好变量名也是同样的原因。&lt;/p&gt;

&lt;p&gt;今天无意间在 YouTube 上看到一个冯内古特的&lt;a href=&quot;https://www.youtube.com/watch?v=GOGru_4z1Vc&quot;&gt;演讲&lt;/a&gt;，主题是 “Shape of Stories”，很值得一看。&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/img/Vonnegut.png&quot; alt=&quot;shape of stories&quot; /&gt;&lt;/p&gt;

&lt;p&gt;这篇博客和演讲内容无关，只是借这个主题记录一下以前的一点想法。&lt;/p&gt;

&lt;p&gt;天涯上有一篇&lt;a href=&quot;http://bbs.tianya.cn/post-free-5439941-1.shtml&quot;&gt;红楼梦考据贴&lt;/a&gt;，考证作者是傅山，里面的角色事件都有现实中的对应。这是我第一次看索隐派的文章，还觉得挺有说服力的，当然这可能是因为我不了解相关的事实，看不出文中的纰漏。抛开这篇文章的正确性不谈，看完之后我觉得类比真实事件是拟提纲的好方法。首先，这些事情已经发生过，不会有情节荒谬无稽的担心（诚然，现实生活中也有很多事情比编造的故事还让人难以置信）。其次，不用担心写跑偏，真实事件细节无限丰富，任何时候觉得写不下去了，再参照一下相关内容即可，也可以把不同事情交织起来作为一个故事，选择的余地就更多了。&lt;/p&gt;

&lt;p&gt;再举个例子，刘宝瑞的&lt;a href=&quot;https://www.ximalaya.com/xiangsheng/10103087/48311027&quot;&gt;《书迷打砂锅》&lt;/a&gt;里说《三侠五义》里的人物全是按屋子里的东西编出来的，也算一个大工程了。知乎还有人按这招编出过一个&lt;a href=&quot;https://www.zhihu.com/question/20359670/answer/501972040&quot;&gt;武侠故事大纲&lt;/a&gt;。&lt;/p&gt;

&lt;p&gt;照着这个思路再拓展一下，为了增加故事性，这个大纲最好不要由人来拟，可以发挥计算机的特长，给一堆候选元素，比如各种事件、人物，从里面随机选择，打乱顺序，再发挥人的创造性，用这些元素编一个完整的故事提纲。这一步之后，其实只剩下半机械的翻译工作，把真实事件里的人事物翻译成大纲设定里的对应元素，这个甚至也可以用机器来完成。考虑到 &lt;a href=&quot;https://openai.com/blog/better-language-models/&quot;&gt;GPT-2&lt;/a&gt; 这类模型的快速发展，想必要不了多久就能实现。最后再由人来统一润色一遍就完事，写作效率会有几个数量级的提升。&lt;/p&gt;

&lt;p&gt;1984 里真理部小说司批量生产色情文学的那一天估计也不远了。&lt;/p&gt;
</content>
    </entry>
    
    <entry>
        <title>漠然</title>
        <link href="https://blog.toonaive.me/2019/06/23/indifference.html"/>
        <updated>2019-06-23T00:00:00+00:00</updated>
        <id>https://blog.toonaive.me/2019/06/23/indifference</id>
        <content type="html" xml:base="https://blog.toonaive.me">&lt;p&gt;这几天在断断续续地写规划了很长时间的饭否客户端，测试数据来自&lt;a href=&quot;https://github.com/FanfouAPI/FanFouAPIDoc/wiki/statuses.public-timeline&quot;&gt;“随便看看”&lt;/a&gt;，因为每一刷都有新的结果，内容样式也很丰富，是很好的测试用例。&lt;/p&gt;

&lt;p&gt;以前在各个网站上都只会看自己关注的内容，生活中就更不用说了，和陌生人偶然对上眼神都会生出一丝不自在，与自己无关的人事从来都是敬而远之。这次密集地刷新几百次饭否，看了几千条各式各样的消息，有人在如火如荼地版聊，有人在形单影只地叹息，有人在坚定决绝地挥别过往，有人在小心翼翼地眷恋现在，有人的幸福溢出屏幕，有人的悲伤难以掩藏。生活的多样性突然出现在眼前，击碎一惯的冷漠，但我又能做啥呢？自顾不暇，还是只能做一个旁观者。&lt;/p&gt;
</content>
    </entry>
    
    <entry>
        <title>间歇性话痨</title>
        <link href="https://blog.toonaive.me/2019/04/27/intermittently-talky.html"/>
        <updated>2019-04-27T00:00:00+00:00</updated>
        <id>https://blog.toonaive.me/2019/04/27/intermittently-talky</id>
        <content type="html" xml:base="https://blog.toonaive.me">&lt;p&gt;人的表达欲也是会逐渐累积的，太久不说话（不管是哪种输出渠道都算）就会觉得憋得难受，总得找个地方说出来才行。&lt;/p&gt;

&lt;p&gt;以前读书的时候在网上（主要是豆瓣）灌了不少水，后来慢慢意识到自己的浅陋，就尽量不在公共场合放甚厥词，以免贻笑大方。有些憋不住的都写在了饭否，渐渐地甚至连饭否都让我有一种“暴露智商”的感觉，发饭频率也越来越低。&lt;/p&gt;

&lt;p&gt;于是又回过头翻出尘封的博客，让它再发挥一下余热吧。&lt;/p&gt;
</content>
    </entry>
    
    <entry>
        <title>最美的微笑</title>
        <link href="https://blog.toonaive.me/2017/08/05/smile.html"/>
        <updated>2017-08-05T00:00:00+00:00</updated>
        <id>https://blog.toonaive.me/2017/08/05/smile</id>
        <content type="html" xml:base="https://blog.toonaive.me">&lt;p&gt;在我看过的展览里，最美的微笑应当属于各种佛教造像。印象尤其深刻的是永宁寺的佛面和
青州龙兴寺的造像。&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/img/smile1.jpg&quot; alt=&quot;永宁寺佛面&quot; title=&quot;永宁寺佛面&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/img/smile2.jpg&quot; alt=&quot;龙兴寺造像&quot; title=&quot;龙兴寺造像&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/img/smile3.jpeg&quot; alt=&quot;龙兴寺造像&quot; title=&quot;龙兴寺造像&quot; /&gt;&lt;/p&gt;

&lt;p&gt;前者见于故宫&lt;a href=&quot;http://sino-indian-sculptures.dpm.org.cn/project_welcome.html&quot;&gt;“梵天东土并蒂莲华”&lt;/a&gt;展，此前看《洛阳伽蓝记》时已经为永宁寺的瑰丽而倾倒，在亲眼见到这个佛面之后更是心折不已。&lt;/p&gt;

&lt;p&gt;后者机缘巧合在不同场合看过几次，第一次是央美的&lt;a href=&quot;http://museum.cafa.com.cn/cn/exhibitions/smashed%20and%20reassembled/text&quot;&gt;青州龙兴寺佛教造像特展&lt;/a&gt;，后来在国博和故宫又屡次邂逅。&lt;/p&gt;

&lt;p&gt;“温柔的慈悲”，大概就是这些造像给人的感觉吧。&lt;/p&gt;
</content>
    </entry>
    
    <entry>
        <title>判断算法是否能被改进</title>
        <link href="https://blog.toonaive.me/2016/03/04/whether-your-algorithm-can-be-improved.html"/>
        <updated>2016-03-04T00:00:00+00:00</updated>
        <id>https://blog.toonaive.me/2016/03/04/whether-your-algorithm-can-be-improved</id>
        <content type="html" xml:base="https://blog.toonaive.me">&lt;p&gt;本文介绍一种根据算法产生的信息量来定性判断其是否有改进余地的方法。这个很简单的思路是前几年想到的，上周又应用了一次，找地方记录一下。&lt;/p&gt;

&lt;p&gt;举个例子：找出 \(n\) 个未排序数字中最小的 \(k\) 个，\(n \gg k\)。&lt;/p&gt;

&lt;p&gt;方法一：先排序，再取前面 \(k\) 个数，时间复杂度 \(O(n \log n)\)。&lt;/p&gt;

&lt;p&gt;这个算法是不是最优的呢？我们可以对比一下目标和结果：&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;目标：找出最小的 \(k\) 个数；&lt;/li&gt;
  &lt;li&gt;结果：最小的 \(k\) 个数，并且按照大小排序。&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;可以看到，虽然排序的方法能够解决问题，但结果相对目标而言太强了，我们还得到了额外的信息——原来的问题里并不要求结果是有序的。子曰，天下没有免费的午餐，这些额外的信息必然会带来额外的开销。这个时候就应该意识到，很可能有更高效（更经济）的算法存在。&lt;/p&gt;

&lt;p&gt;方法二：用前 \(k\) 个数字建立一个大小为 \(k\) 的 &lt;code class=&quot;highlighter-rouge&quot;&gt;max-heap&lt;/code&gt;，然后依次将剩下的 \(n-k\) 个数字 \(d_i, i \in [k+1, n]\) 和堆顶数字 \(d_{top}\) 比较，若 \(d_i\) 小于 \(d_{top}\)，将 \(d_{top}\) 替换为 \(d_i\)，并重新 &lt;code class=&quot;highlighter-rouge&quot;&gt;heapify&lt;/code&gt;；否则跳过 \(d_i\)。最后得到的 \(k\) 个数就是最小的 \(k\) 个。时间复杂度 \(O(k + (n-k) \log k)\)。&lt;/p&gt;

&lt;p&gt;比起方法一，时间复杂度降低了不少，但我们还是得到了额外的信息：我们知道了 \(k\) 个数之间的部分大小关系，比如可以在 \(O(1)\) 的时间内得到 \(k\) 个数中的最大值（堆顶的数字）。&lt;/p&gt;

&lt;p&gt;方法三：先用 &lt;a href=&quot;http://www.wikiwand.com/en/Median_of_medians&quot; title=&quot;Wiki&quot;&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;Median of medians&lt;/code&gt;&lt;/a&gt; 算法找出第 \(k\) 大的数 \(d_k\)，这一步的时间复杂度 \(O(n)\)。然后遍历数组，将小于等于 \(d_k\) 的数找出来（这里不考虑有重复数字的情况）。总的时间复杂度也是 \(O(n)\)。&lt;/p&gt;

&lt;p&gt;其实选择 \(d_k\) 的过程也会将这 \(n\) 个数字按照大小分组，但是这个额外信息比起前两种方法得到的要弱很多，所以方法三优于前两者。实际上 \(O(n)\) 的算法已经是渐进最优的，因此我们可以断定，即便还存在效率更高的算法，在渐进意义上也不可能优于方法三了。&lt;/p&gt;
</content>
    </entry>
    
    <entry>
        <title>用ydcv在Vim里查单词</title>
        <link href="https://blog.toonaive.me/2013/07/22/look-up-words-in-vim-using-ydcv.html"/>
        <updated>2013-07-22T00:00:00+00:00</updated>
        <id>https://blog.toonaive.me/2013/07/22/look-up-words-in-vim-using-ydcv</id>
        <content type="html" xml:base="https://blog.toonaive.me">&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;安装&lt;code class=&quot;highlighter-rouge&quot;&gt;ydcv&lt;/code&gt;：&lt;code class=&quot;highlighter-rouge&quot;&gt;pacman -S ydcv&lt;/code&gt;。&lt;code class=&quot;highlighter-rouge&quot;&gt;ydcv&lt;/code&gt;是有道词典的命令行版本，类似于&lt;code class=&quot;highlighter-rouge&quot;&gt;Stardict&lt;/code&gt;的&lt;code class=&quot;highlighter-rouge&quot;&gt;sdcv&lt;/code&gt;，如果一直联着网的，用这个比较方便，因为可以查整个句子。&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;在&lt;code class=&quot;highlighter-rouge&quot;&gt;.vimrc&lt;/code&gt;里添加两个函数和对应的快捷键映射（抄自&lt;a href=&quot;https://github.com/gudezhi/vimfiles/blob/master/plugin/sdcv.vim&quot;&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;Github&lt;/code&gt;上的一个脚本&lt;/a&gt;，不过我没有用split window来显示结果）：&lt;/p&gt;

    &lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt; &quot; look up current word under cursor
 function! SearchWord()
     let expr = '!ydcv -s ' .expand(&quot;&amp;lt;cword&amp;gt;&quot;)
     exec expr
 endfunction
        
 &quot; translate selected text
 function! SearchWord_v(type, ...)
     let sel_save = &amp;amp;selection
     let &amp;amp;selection = &quot;inclusive&quot;
     let reg_save = @@
            
     if a:0
         silent exe &quot;normal! `&amp;lt;&quot; . a:type . &quot;`&amp;gt;y&quot;
     elseif a:type == 'line'
         silent exe &quot;normal! '[V']y&quot;
     elseif a:type == 'block'
         silent exe &quot;normal! `[\&amp;lt;C-V&amp;gt;`]y&quot;
     else
         silent exe &quot;normal! `[v`]y&quot;
     endif
             
     let word = @@
     let expr = '!ydcv &quot;' . word . '&quot;'
     exec expr
            
     let &amp;amp;selection = sel_save
     let @@ = reg_save
 endfunction
            
 nnoremap &amp;lt;Leader&amp;gt;d :call SearchWord()&amp;lt;CR&amp;gt;
 vnoremap &amp;lt;Leader&amp;gt;d :&amp;lt;C-U&amp;gt;call SearchWord_v(visualmode(), 1)&amp;lt;cr&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;code class=&quot;highlighter-rouge&quot;&gt;:source $MYVIMRC&lt;/code&gt;&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;大功告成。查询光标下的单词或者visual模式里选中的内容，直接按&lt;code class=&quot;highlighter-rouge&quot;&gt;&amp;lt;Leader&amp;gt;d&lt;/code&gt;就行。&lt;/p&gt;

&lt;p&gt;效果图：&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/img/word.png&quot; alt=&quot;查单词&quot; title=&quot;查单词&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/img/sentence.png&quot; alt=&quot;查句子&quot; title=&quot;查句子&quot; /&gt;&lt;/p&gt;

&lt;p&gt;缺点有两个，一是可能有延迟，这个看网络情况，二是之前查询的结果会一直显示（Gvim里没这个问题，不过会显示终端下的颜色代码）。&lt;/p&gt;

&lt;p&gt;顺便说一下，还有一个更简单的方法：&lt;code class=&quot;highlighter-rouge&quot;&gt;Vim&lt;/code&gt;里有个命令是&lt;code class=&quot;highlighter-rouge&quot;&gt;K&lt;/code&gt;，会调用&lt;code class=&quot;highlighter-rouge&quot;&gt;keywordprg&lt;/code&gt;这个变量指定的程序查询光标下的单词，&lt;code class=&quot;highlighter-rouge&quot;&gt;keywordprg&lt;/code&gt;的默认值是&lt;code class=&quot;highlighter-rouge&quot;&gt;man&lt;/code&gt;，把这个改成&lt;code class=&quot;highlighter-rouge&quot;&gt;ydcv&lt;/code&gt;可以实现同样的效果（也能在visual模式使用），可参考&lt;code class=&quot;highlighter-rouge&quot;&gt;:h keywordprg&lt;/code&gt;。&lt;/p&gt;
</content>
    </entry>
    
    <entry>
        <title>蛋疼的TeXLive</title>
        <link href="https://blog.toonaive.me/2013/07/11/texlive-in-arch.html"/>
        <updated>2013-07-11T00:00:00+00:00</updated>
        <id>https://blog.toonaive.me/2013/07/11/texlive-in-arch</id>
        <content type="html" xml:base="https://blog.toonaive.me">&lt;p&gt;好久没在Arch里编译tex，Windows里后来装的那些包Arch里都没有，本来想一劳永逸地解决自动/半自动安装缺失package的问题，结果白白浪费了一上午的时间……自带的&lt;code class=&quot;highlighter-rouge&quot;&gt;tlmgr&lt;/code&gt;没法用，aur里的&lt;code class=&quot;highlighter-rouge&quot;&gt;texlive-localmanager&lt;/code&gt;也是千疮百孔，作者一年前就没有再维护了，参考&lt;a href=&quot;https://wiki.archlinux.org/index.php/TeX_Live#TeXLive_Local_Manager&quot;&gt;Arch的Wiki&lt;/a&gt;改了一下，可惜只能用一部分功能。&lt;/p&gt;

&lt;p&gt;全手动安装一个包之后实在受不了，最后决定放大招，把Windows上MiKTeX的tex文件夹拷过来，放在&lt;code class=&quot;highlighter-rouge&quot;&gt;~/texmf&lt;/code&gt;下面，然后&lt;code class=&quot;highlighter-rouge&quot;&gt;texhash ~/texmf&lt;/code&gt;，终于通过了编译。MiKTeX自带的包放在&lt;code class=&quot;highlighter-rouge&quot;&gt;%ProgramFiles%\MiKTeX 2.9\tex&lt;/code&gt;下面，编译过程中自动安装的缺失包放在&lt;code class=&quot;highlighter-rouge&quot;&gt;%AppData%\MiKTeX\2.9\tex&lt;/code&gt;下面，都复制过去就行了。&lt;/p&gt;

&lt;p&gt;其实想起来这个功能也不难实现，本地维护一个表，保存cls文件到对应package的映射，CTAN上的路径都是固定的，要自动下载也很简单，不知道为啥到现在都还没实现，等有时间了来试一下。&lt;/p&gt;
</content>
    </entry>
    
    <entry>
        <title>xkcd quotation</title>
        <link href="https://blog.toonaive.me/2013/06/07/xkcd-quotation.html"/>
        <updated>2013-06-07T00:00:00+00:00</updated>
        <id>https://blog.toonaive.me/2013/06/07/xkcd-quotation</id>
        <content type="html" xml:base="https://blog.toonaive.me">&lt;blockquote&gt;
  &lt;p&gt;Take wrong turns. Talk to strangers. Open unmarked doors. And if you see a group of people in a field, go find out what they are doing. Do things without always knowing how they’ll turn out. You’re curious and smart and bored, and all you see is the choice between working hard and slacking off. There are so many adventures that you miss because you’re waiting to think of a plan. To find them, look for tiny interesting choices. And remember that you are always making up the future as you go.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;blockquote&gt;
  &lt;p&gt;—— Randall Munroe&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;via &lt;a href=&quot;http://xkcd.com/267/&quot;&gt;Choices: Part 4&lt;/a&gt;&lt;/p&gt;
</content>
    </entry>
    
    <entry>
        <title>用AutoHotkey让Foxit Reader模拟Vim的操作</title>
        <link href="https://blog.toonaive.me/2012/05/22/foxit-ahk-script.html"/>
        <updated>2012-05-22T00:00:00+00:00</updated>
        <id>https://blog.toonaive.me/2012/05/22/foxit-ahk-script</id>
        <content type="html" xml:base="https://blog.toonaive.me">&lt;p&gt;我已经有一段时间没用过鼠标了（因为无线鼠标电池用完了懒得去买……），平时可以用小红点，但是翻文档（主要是看pdf）的时候没啥好办法。习惯了Vim的按键，再用方向键觉得很别扭，&lt;a href=&quot;http://naihe2010.github.com/apvlv/&quot;&gt;Apvlv&lt;/a&gt;功能还是弱了一点，那就用&lt;a href=&quot;http://www.autohotkey.com/&quot;&gt;AHK&lt;/a&gt;曲线救国吧。&lt;/p&gt;

&lt;p&gt;很简单粗暴的方法：&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;;在Foxit中模拟Vim的操作
#IfWinActive, ahk_class classFoxitReader
j::Down
k::Up
h::Send ^+{Tab}
l::Send ^{Tab}
^f::PgDn
^b::PgUp
g::Home
o::Send ^o
d::Send ^w
q::Send !{F4}
#IfWinActive
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;不过有时候&lt;code class=&quot;highlighter-rouge&quot;&gt;^f&lt;/code&gt;和&lt;code class=&quot;highlighter-rouge&quot;&gt;^b&lt;/code&gt;会失效，不知道为啥，往下翻页还能用空格来代替，往上翻页就只能用pageup了。&lt;/p&gt;
</content>
    </entry>
    
    <entry>
        <title>douban claim</title>
        <link href="https://blog.toonaive.me/2012/05/18/douban-claim.html"/>
        <updated>2012-05-18T00:00:00+00:00</updated>
        <id>https://blog.toonaive.me/2012/05/18/douban-claim</id>
        <content type="html" xml:base="https://blog.toonaive.me">&lt;p&gt;doubanclaim85aae8b364636cb8&lt;/p&gt;
</content>
    </entry>
    

</feed>
