Engineering notes since 2011

Blog posts

Zero copy in Linux

In many applications such as web servers, it is a common task to read disk file and write to the network interface directly without any modification. Zero copy frees the CPU from copying data from one memory area to another. This note is a brief on zero copy in Linux.

Read the full post

Git 推送到多个仓库

Github 现在支持无限私有仓库了,所以我把之前保存在 Bitbucket 上的一些仓库转移到了这里来。 不过原来 Bitbucket 上的仓库也没有删掉,我是想可以做一个备份仓库来用。

刚开始我是想这样做: 把仓库转移到 Github 上,origin 的 fetch 的 push 都设置为 Github 仓库; 然后 Bitbucket 作为另一个 remote,每次更新了 origin 之后再 push 到这里来。

不过后来我看到 Git 的 remote 是可以设置多个 URL 的,于是就改成了下面这个做法。

Read the full post

程序员 Git 技能进阶

最近为一个 Git 课程写了一套将近七万字的教案,正在由我们的设计师同学制作视频课程。 尽管是做一套初等水平的课程,但是本着"取乎其上,得乎其中"的精神,我通读了一些 Git 的书系统学习。 因此,写完这套教案稿子,我自己也对 Git 的方方面面有了更深入的理解。

作为一个程序员,我使用 Git 已经有很多年了,自认为水平也不差,能够解决日常开发中各种各样的问题。 然而写完这个课程我才意识到,如果不是这次写课的契机,可能我还会长期保持掌握点 Git 皮毛的状态了。

如果你和我一样长期使用 Git,但还没有去深入了解过它,这里我列出几个技能进阶的方向,可以找资料学习一下。

Read the full post

推荐一个 YouTube 频道: Explanimator

最近在做编程教育相关的工作,写了一些在线视频的稿子,也顺便看了不少别人的视频。 今天发现一个很有意思的 YouTube 频道叫 Explanimator, 是 New Scientist 出品的,看了几集,感觉很不错。

这上面的视频都比较短小,但是主题涉及宇宙、信息、人工智能、拓扑、社会、历史、考古等方方面面, 语言通俗,内容有趣。看了以后感到非常高兴。 另外,New Scientist 的主频道也很棒,我就是在这里看到 Explanimator 的。

越过长城,你就能得到一切。

一分钟 ICO 教程

最近有个标题是《10 分钟搞定 ICO》的文章很火, 介绍了如何用 Ethereum 官方 Wallet 程序以及官方 Demo 代码, 来发行一个新数字代币的方法。 当然文章并不是真让大家都去发行自己的数字货币。 通过揭示创建新代币可以几乎无成本这件事,作者给大家揭露了一些当前区块链领域的乱象。

不过 10 分钟文没有涉及太多原理知识,本文我来写一写技术,希望能用简单通俗的描述, 帮助大家多了解新技术,提高辨识力。

BTW,如果你确实想创造一个数字代币,后面我介绍一个一分钟搞定的办法。

Read the full post

用 Parity 作为 Ethereum 客户端

最近几天看了很多关于 Ethereum 的资料,学习了一下 DAPP 开发相关的知识。 感觉区块链还是很有意思的,我打算再深入学习学习,看看有什么有趣的应该可以参与开发开发。 要搞事情,第一步还是得把客户端搭建起来,我试了试官方 Ethereum Wallet 和 Parity, 感觉这个 Parity 非常好用,值得推荐,所以今天先记叙一下客户端的事情。

Read the full post

切换到了美区 Apple ID, iCloud 和 App Store

最近贵州一个公司火了。 本人多年网络难民,不翻墙不算上网,之前眼看着 VPN APP 越封越少,虽然早就有放弃国区的想法, 但因为自己用的翻墙工具还健在,就一直在拖延。 这次贵州事件消息出来之后,出于不想把私人数据交给党的初心,我才终于下定决心搞了。 “干”。 于是今晚我发挥了一下折腾精神,把自己的 Apple ID 成功切换到了美区。 我并不是新注册了一个美区帐号,而是把国内帐号切换到了美区。

我切换成功主要依赖手中这张招行全币种信用卡(VISA 卡)和 Paypal,其他也有一些便利条件, 比如我有个开通多年的 Google Voice 美国电话号码,但不知道是不是必须的。 总之折腾起来挺麻烦的,感谢贵州,感谢党,感谢库克。

Read the full post

实践 GTD 的一些心得

从 2014 年 10 月正式购买 doit.im 服务开始,到现在已经续了两次年费了。 正好今天是 2016 年最后一天,坐在家里没什么事情,趁机回顾一下这两年实践 GTD 的心得,总结经验吸取教训,希望 2017 年能够完成更多事情,实现更多目标。

向着自由。

Read the full post

Docker 开发环境

Docker 开发环境就建在 Docker 容器里,比较容易搭建。 本地搞一个 Docker 开发环境比较方便代码阅读、修改和调试, 尽管官方文档 中的指引已经很详细,我还是记一个符合国情的流水账。

要理解下面文章写的内容,需要熟悉 Docker,并熟悉 Docker 开发环境构建的官方文档

Read the full post

吴哥,吴哥

这个草稿放在 _drafts 目录下已经很久了,当年从吴哥窟回来打算写一篇文章,但是没有写出来。

现在估计也写不出来了。

COVID-19 这么久了,很久没有出去玩儿,很想念自由的时光。

Read the full post

Dremel 论文中的列式存储

Dremel 论文中,Google 介绍了将嵌套 Schema 的数据使用列式方式存储的方法,提供了一个高效的列式存储格式模板。 我觉得论文中的介绍方式并不太直接,因此本文尝试重新阐述一下这个方法, 希望有一个更清晰的解释。

Read the full post

Hadoop MapReduce 任务设计的几个常用技术

MapReduce 计算模型简单而有效,很多常见的计算问题都可以使用 Input -> Map -> Shuffle & Sort -> Reduce -> Output 这样简单的流程来实现,并在 Hadoop 这样的系统上进行大规模、分布式的数据处理。 尽管目前 Spark 这样较新的大数据处理模型/框架日益流行, 然而新计算模型的出现并不意味着 MapReduce 会被立刻取代, 而是意味着我们解决问题的时候有了更多的思路和方法, 也意味着一个数据工程师有了更多的工具需要学习、掌握和选择。

Read the full post

友盟数据平台 -- 从 MapReduce 说到 Spark

友盟数据平台承担了大量 APP 的统计分析任务,为开发者计算 APP 的新增/活跃用户、用户留存/沉默、用户访问路径、自定义事件等丰富、多维、 精准的统计分析指标,并在友盟的海量数据上进行深度挖掘。 由于友盟服务的开发者众多,很多优秀的 APP 也用户量巨大,为了能够全面、准确 并且及时的为开发者提供数据,数据平台面临了很大的挑战。

Read the full post

我为什么爱存不存

刚才我司最漂亮的薪酬福利专员同学告诉我这个月要补发年终奖了, 于是我兴冲冲的打开工商银行的手机银行想查一下余额,输入密码之后,我惊愕了。

Read the full post

用 Github Webhook 自动更新 Jekyll

昨天买了个 DigitalOcean (这是我的 Refcode),用优惠码 ALLSSD10 换了 $10,然后迅速创建了一个 $5/mo 的节点,连夜把博客迁移过来了。 前阵子换了 Jekyll 以后,我就一直把博客的源代码放在 Github 上,而站点本身还是放在了之前 WordPress 的 Web Root,用原来的 Apache 来做服务。 由于之前我只在笔记本上搭建了 Jekyll 环境,所以有新文章和新修改时候,我需要在本地 jekyll build,打包上传 _site 目录,然后替换到线上更新站点, 使 Github 沦落成了一个保存代码的地方。

Read the full post

失去写作的能力了

刚才突然有些想法,感觉想写下来,但是好像已经失去了写作的能力了似的,不知道如何下笔。 感慨来感慨去,只能拿年龄来搪塞,说成熟了就收敛了,不再外露和抱怨,于是也写不出东西了。

Read the full post

最近在看 BBC 的纪录片

最近网上罗到一份 BBC 纪录片的目录,想到自己目前的文化水平这么令人捉急, 决定工作之余拿万恶的资本主义好片充实一下自己,为以后约会相亲聊妹子时假装有文化打下坚实的基础。 最初我是打算每篇都整理一些槽点出来,以便约会前随时温习的。 可是这么看片速度确实太慢,加上昨晚(20140929)找了两部《恐龙星球》和《宇宙的奇迹》, 饕餮之余想到还是光看不写痛快,于是决定就写这么多了,后面的就不一定继续写了。

Read the full post

从 Wordpress 迁移到 Jekyll

虽然只有二十多篇文章,但是这次迁移仍然耗时巨长,从最初 jekyll new gnailuy.com 到现在终于替换掉 WP 已经俨然一个多月过去。 一方面是 Jekyll 这个新东西我要花时间学习,除去工作、学习其他东西以及四处浪的时间,留给 Jekyll 的业余时间确实不多; 另一方面直接从 WP 导出(导出工具在此)的 Markdown 实在不忍直视,强迫症指使下我还要一篇一篇手打成’纯’ Markdown。

Read the full post

Hello World!

Well, this is my new blog powered by Jekyll.

And again: Hello world!

Play only the audio in a movie file with Mplayer

I have a piece of beautiful music in an MP4 video file, so good that I wanted to loop it for this whole afternoon. With Mplayer, I could single cycle this file with an option -loop 0. Moreover, I wanted to play only the sound without the video, so I searched the ‘man page’ of mplayer and found this:

Read the full post

Net-installing CentOS without CD-ROM and USB

There was an old PC in our lab, and one day I wanted to use it as a node in our Hadoop cluster. There was a Fedora 8 on it. But I’d like to change it to a new CentOS 5.7. The problem I met, was that this PC was too old, that neither the CD-ROM nor the USB ports worked well.

Read the full post

无光驱、无 USB,网络安装 CentOS

实验室有台非常老的机器,今天被我翻出来打算当作我们 Hadoop 集群中的一个节点。这台机器上原有一个 Fedora 8 可以用,不过我还是想给它安装一个全新的 CentOS 5.7。 只有一个问题,就是这台机器太老了,光驱和 USB 接口竟然全都坏掉了。

Read the full post

Spoofing MAC address in Archlinux

The first issue I met after I logged in to my newly installed Arch Linux, was that I had to change the MAC address to gain access to our campus network. I have a short post here about how to spoof the MAC address in Linux. In that article, I introduced how to change the MAC address temporarily using ifconfig, and how to edit the network configure file in Red Hat/CentOS/Fedora or Debian/Ubuntu. But I found no ifconfig available in my new Arch Linux (I must had missed some essential package that provides ifconfig during the installation.). So I had to find another method, and fortunately, there is an Arch Way.

Read the full post

Archlinux 中伪装 MAC 地址

装好 Archlinux 以后,我遇到的第一个麻烦就是如何修改 MAC 地址来接入校园网。 之前我写过一篇短文,里面介绍 Linux 下如何修改 MAC 地址(在这里)。 那篇文章介绍了如何使用 ifconfig 程序临时修改 MAC 地址,以及在 Red Hat/CentOS/Fedora 或 Debian/ubuntu 中如何修改网络配置文件来修改 MAC 地址。 但是我发现我新装的 Archlinux 没有 ifconfig 程序(我安装系统时选择的包很少)。所以我得找个其他的方法,幸好,Arch 有自己的 Arch Way。

Read the full post

Setting up SSH Public Key Authentication

Compared to the password authentication, it’s more convenient and more secure to log into a remote Linux box over SSH by the public key authentication. With this technique, we can perform an automatic login without entering any password. It is very useful when we call ssh from a shell script. In this post, we show how to setup SSH public key authentication between two Linux hosts.

Read the full post

Wordpress 添加 Google Adsense 代码

今天 Google 批准了我的 Adsense 计划申请,所以下午我花了点时间看了些相关的文章,想找个比较好的方法把 Adsense 代码添加到这个小站上。 我找到不少插件都可以向 Wordpress 添加广告代码,其中口碑比较好的应该是 Adsense DeluxePost Layout 这两个。 不过我只需要添加一点点的广告代码,这些插件显得有些大材小用了。而且我已经安装了不少插件,为了避免降低网站访问速度,也为了避免插件冲突, 我就采用直接修改 Wordpress 代码的方法,本文为就这件事做个小结。

Read the full post

Add Google Adsense code to Wordpress

Google approved my Adsense application today. I read a lot of articles to find an easier way to add Adsense code to my blog this afternoon. There are quite a few plugins doing this. It seems like the Adsense Deluxe and the Post Layout have the best reputation. But I prefer to have no more plugins. There are already a lot of plugins installed on my site, so I’m afraid that too many plugins may slow down my site or cause conflicts. I choose to edit the source code of Wordpress directly and it turns out to be not that hard. Here is a small summary.

Read the full post

Troubleshooting: wordpress can't login

I keep cookies in my browsers all the time, so it had been long since the last time I perform a Login action to my Wordpress site. But today, when I tried to log into my dashboard on another computer, a problem arose.

Read the full post

GNU Screen 使用入门

前些天开始学习使用 GNU Screen 程序,发现这个工具在管理服务器时候确实挺方便的,于是写一篇文章总结一下,顺便介绍 Screen 的基本使用方法。

Read the full post

又一个 VIM 配置文件

这篇文章记录我的 VIM 配置,包括带注释的配置文件 .vimrc,和几个很好玩的插件。 VIM 可以依照个人习惯进行很多有趣的配置,因此每个人的配置多多少少都不太一样,这也是这个编辑器的强大与灵活所在。 我在配置自己的 VIM 时,也是参考了许多其他人的配置文件,再依照自己的使用习惯增删修改。 因此虽然网上已经有很多配置 VIM 的文章,我也不介意增加一篇,希望本文的内容能够成为众多有价值的参考之一。

Read the full post

GSL 科学计算库、随机变量的 Erlang 分布与 Weibull 分布

本文首先简要介绍了 GNU 科学计算库 GSL 和随机变量的 Erlang 分布与 Weibull 分布,然后说明了 GSL 库如何生成服从 Erlang 分布或 Weibull 分布的随机数,以及在编程中如何使用 GSL 库。 对计算机生成的一系列随机数,可以有许多方法测试它们的分布,一个常见的测试是 Kolmogorov-Smirnov 测试,也称作 K-S Test。 云师姐的这篇文章中有使用 Matlab 进行 K-S Test 的示例以及代码。

Read the full post

CentOS VPS 上搭建 PPTP VPN

本文介绍在安装 CentOS 操作系统的 Xen VPS 上,如何搭建 PPTP VPN 服务。 包括 PPTP 的安装、配置,以及相应的 iptables 规则。 本文暂时不涉及 PPTP 流量控制的部分,等抽空学明白了 FreeRADIUS 再来写续篇。 2011 年 7 月 20 日更新:在安全建议这一部分,增加了使用不同的 IP 地址,分别提供 VPN 服务和 Web 等其他常规服务,以及使用不同 IP 地址时如何书写 iptables 规则的内容。

Read the full post