Programmer, Gamer, Hacker

How to Mount Disk to Linux Operation System

| Comments


I’ve bought a NAS as home server recently, so I’ve considered how to mount disk on it by using linux operating system.

I’ve got SSD and HDD, SSD is faster, but is more expensive, and write time limit. So SSD should mount at /, OS will run faster. Writing frequently location like /home, /var should mount on HDD, Temporary location /tmp should mount to file system tmpfs.

About choosing file system. SSD can use ext4 with some adjustment to reduce write, HDD can use ext4 for ordinary use, if used for file sharing and service, ZFS is a good fit: Compressed storage, higher ID throughput.

If you want setup NAS disk array, RAID0 is the simplest solution, multiple disks handle IO in the same time. If you have to store some important data, use RAID2: dual disk write the same data. But RAID1 spend too much disk space, software RAID5 can balance it well enough. If you know nothing about RAID, you can watch this demo.


| Comments






Personal Data Backup Method

| Comments

I’m thinking about how to backup personal data, we can divide them into groups which according to their importance, file size, and privacy.

  • Important, Big size, Sensitive: Computer full disk data.
  • Important, Small size, Sensitive: key information, like daily.
  • Unimportant, Middle size, Sensitive: photos.
  • Unimportant, Big size, insensitive: film, comics.

We can use different methods to backup them, vary in price, space, security, and usability:

  • Encrypted online backup service: high price, small space, secure, hard to use.
  • Online backup service: fair price, small space, insecure, easy to use.
  • NAS/Portable disk drive: low price, big space, secure, hard to use.

So, this is the method I’m using now:

  • Use timemachine to backup computer into portable disk drive.
  • Use lastpass to keep website and server password.
  • Use dropbox to save and sync notes, photos, and documents, I extended it to 20G.
  • Use portable disk drive to backup film, music and comics.


| Comments


  • 重要,文件大,私密性高:电脑全盘备份
  • 重要,文件小,私密性高:关键数据,比如日记
  • 不重要,文件中等,私密性高:图片
  • 不重要,文件大,私密性低:下载的电影,漫画


  • 加密网盘:价格高,空间小,安全性高,易用度低
  • 国外网盘:价格高,空间小,安全性中,易用度高
  • 国内网盘:价格低,空间大,安全性低,易用度高
  • 移动硬盘:价格低,空间大,安全性高,易用度低
  • NAS:价格低,空间大,安全性高,易用度低


  • 备份电脑用timemachine备份到移动硬盘里面
  • lastpass备份网站帐号密码和关键系统密码
  • dropbox备份笔记和文档
  • dropbox备份图片,因为我想办法把dropbox空间拓展到了20G。
  • 移动硬盘备份视频,漫画等

How to Use Gem

| Comments

I’m a rails developer, as a benefit of rails developer, I’ve got lots of Gems. Gem is flaring, but handle without enough care, it may cut your finger bleeding. As a jeweler, I can share some knowledge about it.


First thing to do is search the gem. search google by describe it, like rails tagging, or you can browse the list at ruby toolbox.


You should pick the right gem with enough quality. there are lots of unqualified, unmaintained shitty gems there, you don’t want to touch them. take a look at the following count on its github project page, and update activity.

You should think first before import it into your project, how its complexity level? is is stable enough? can it be extended? Other than use the whole gem, you can copy one of it’s files into your project to reduce the overhead. Some gem may change rails module, handle them with caution.


Gem version need to be fixed, accidentially upgrading it may cause unexpected bug.

You must know what you have done, read gem documents, wiki, know how to use it. I prefer figure out how gem works by read the source code, so if something goes wrong, you know how to deal with it.

When something bad happens, check the gem project issue page, or you can debug it yourself by add log to the gem source code.

You need write document about what you have learned, history repeats itself, you don’t want to solve the same issue more than once, like install issue of rmagick.


| Comments

作为rails开发者,无数好用的第三方Gem插件让工作变得更加简单。 不过东西好用,也还是有一些需要注意的问题。这里整理一下我使用Gem的经验。


第一步是寻找到想要的Gem。最基础的方法是Google搜索,输入想要实现的功能,比如:rails tagging, 也可以去ruby toolbox网站上面根据分类寻找。


找到Gem之后,需要选择质量高的Gem,不然会出现各种问题。主要看Github上面是否有很多人Follow, 以及项目近期是否有足够的更新。

不能随便引入Gem到项目里面,需要从增加的系统复杂度,拓展性,系统稳定性等方面综合考虑。 除了引入Gem,可以考虑直接拷贝需要的代码文件到项目里面。一些会修改Rails等其他模块的Gem,需要谨慎引入。




我个人偏好把Gem的实现原理弄懂,最好扫一遍源码,这样出现bug或者问题大概有一个方向, 以及可以学会别人是怎么写ruby的。

当使用Gem的时候出现了问题,可以去项目Github的Issue区块看看有没有人提交类似问题, 没有的话自己可以通过看源码来调试解决,或者提交issue给官方项目。


Country of Mask

| Comments

I was thinking, if we all wear masks, we cound decorate ourself as we want, present self as we are, to show our true character, without bothered by the nature born face.

Mask is make by ourselves, represented in a way we want to.

You can use this mask:

And that:

So how could it be, for a world like this? Let me illustrate one.

The first question is, how this could be? Tradition may come from nowhere and anywhere, As if there was a dectator, have some skin conditions maybe coming from syphilis. He wear a mask, and force all the others do so. Then dectator goes tradition remains.

For public security, all mask must marked with ID which belongs to individual, as in the condition same as car number. Steal mask is felony, because it is identity thefting and critical privacy violation. People only show their face to the relative really close.

Children’s mark are labeled with their parents’ identity, after they come of age, they should create their own. There are mask craftsman who fill people’s needs. Person with figure choose the best tailor, ordinary may buy a template and customize it by their own.

Soldier’s mask are standard by rank, for serious concern, all soldiers tatoo for proventing identity theft.

So how to eat food while wearing a mask? Mask should have a moving part on the mouth area for feeding. The way people eat will change, Food are cutting into small pieces for easy deliver. Then tools for eating are changed accordingly, with tools to clean mouth.

It is impossible to communicate with face expression, and it will not be needed, people use tone and gesture to express the subtle. For foreigners, understand the art of tones may be challenging.

There could be mask represents emotion, and those who want represent them, include women, noble, actor, will prepare lots of them, changing them rapidly in the public.

For finding the perfect wife, people seek according to how beautiful her musk is. It repesent her light hand. Women will spend lots of time on decorating mask, same as in makeup in our country.

But we know man are nature’s slave, seek for pretty, they invite girl for dinner, look through the small holes on the mouth, to find the evidence. Women has contermeasures by using hand or thin cloth to hide. And for the women who feel more comfortable about it, would protent to show more, even remove part of the cover on the mask.

There are still diversity around people. Rich one use better mask, embeded with jewel, crafted with special treatment.

And there definitly will be a festival about mask, people bring the best mask off, Mask crafter are create all kinds of strange mask to promote themself: the biggest one, smallest one, most delicate one. It will attract lots of tourists, they will buy masks and bring them home, Collector will gether all kinds of rare masks, special or from special people. Mask economy, is important for this country.

It will be fun, if there is a country with mask.


| Comments

我在想,如果大家都戴面具就好了, 可以按照自己想要的样子完全装饰自己, 不纠结长相,注重每个人的性格特质。

面具上面根据自己的想法来做, 通过面具体现自己的性格,特质。



那么如果这样设置,这个世界会变成什么样子呢? 让我来构建一下吧。

首先是为什么会产生戴面具的需求。习俗的产生可能是很无厘头的, 比如以前有一个专制国王,脸部有疾病,就戴着面具出现, 然后要求所有的臣民都戴面具。不戴面具的就杀头。之后慢慢就演变成了习俗。

为了社会安全,每个人的面具上面要有自己特殊的标识, 让别人认出来。类似于汽车必须有车牌号。 扒人面具是重罪,一般只有在自己最亲近的人面前才能摘下面具。

小孩子的面具上面有做家长的记号。成年之后就可以自己选择面具。 但是也还是会有专业的面具师做面具。地位比较高的人,会请好的面具师来订做, 普通人可能就购买模板面具,然后根据自己的要求设计面具。

军人的面具都统一形式,上面有军衔标识。不过为了防止军人间谍, 可能所有的军人都要纹身,通过纹身来达到辨识身份的目的。

戴上面具如何解决吃饭问题?面具的嘴部是有活动机关的,可以伸勺子进去。 那么餐饮习俗也会变化,吃饭就必须把食物做成小块,深入到面具嘴部递食。 然后餐具就不会是筷子,而是刀叉,勺子,甚至有专门的可以伸长到面具里面把嘴擦干净的工具。

因为面具挡着,不好通过表情来沟通,所有的人基本上都会变成面瘫, 然后通过声调和手势来表达情感,语言上面,会有很多微妙的声调区别, 对于外国人来说,理解和学习好声调会显得困难。

会出现可以做出表情的面具,一些比较在乎的人,或者女性,或者贵族, 会根据心情,准备一系列的面具,社交场合下,或者平时,会频繁换。 类似于现在女性换包包。

找老婆,就看谁的面具做得好,因为女性的面具是自己做的,做得好代表心灵手巧。 女性会花费好多时间在学习如何制作面具上面。类似于化妆。

不过男性还是会希望找到除去面具后长得好看的,就会请中意的女性去吃东西, 通过嘴部的缝隙来偷窥想了解女性长相,但是女性也有针对性的对策,有薄纱来遮挡。 但是自信一些的女性,会故意多露一些。更有大胆的女性,会尝试打破禁忌, 面具上面缺失一些遮挡,露出皮肤。

人与人之间还是有差异。有钱人就可以用好的面具, 上面会镶嵌一些贵重的宝石,或者做一些特殊工艺的效果。

每年都有一个面具节:大家把最好的面具都拿出来,游行, 各种面具师制作各种极限的面具来宣传自己,比如最华丽的面具,最大的面具,最精致的面具等。 节日也会吸引大量的外国旅游者,他们会买各种针对旅游者的面具, 一些收藏者也会想办法找到著名人物的面具进行收藏, 面具经济,是这个国家里面的一个重要的组成部分。



| Comments



  • 多台服务器任务量巨大。
  • 手动操作的话,需要连上服务器手动执行,步骤烦琐,容易操作错误和忘记事项。
  • 写脚本自动操作不能重用到其他项目里面去。

用了自动化工具,可能第一次配置比较复杂,但是配置好了之后,发布工作就简单得只需要执行一个命令,轻松愉快。 它也有学习复杂,因为有抽象出现问题难以找到原因,造成额外心智负担的问题, 这个要开发者根据项目大小和类型来做权衡。



  • 需要部署的服务器根据角色(role)区分: 比如有app,db,web,然后每个角色可以有多台服务器。
  • 针对不同角色,设置各类的任务,设置执行一些命令。
  • 可以根据阶段设置不同的stage,比如staging/production,staging用来本地测试环境的部署,production用来进行生产环境的部署。
  • 默认的一套发布流程包括了检查服务器环境,更新代码,初始化,上线等各种过程。
  • 每个过程都提供了钩子,把任务链接到钩子上面,就能够保证部署过程按照期待的状况进行。


  • 首先是去看官方文档,对于基础概念,有一定的了解。
  • 一定要实际部署一下,可以用本地环境测试,repo_url设置成本地,比如”user@localhost:/home/user/testapp”。
  • 弄清楚发布到服务器上面的文件架构。本地测试部署一次就清楚概念了。
  • 如果需要自动部署rails,可看别人整理的一份详细文档



| Comments

减肥第一步,是真正想减肥。 真正想减肥的意思是,你可以下决心放弃美食,放弃晚上舒服地躺在沙发上面看电视剧。

减肥是全身性的,不能局部减。 减肥的要义很简单,就是减少能量摄入,增大能量输出。


营养均衡保证热量摄入少,以及长时间保持血糖平衡。 保持全天的血糖平衡,就可以长时间维护好身体的能量消耗等级,保证持续的热量消耗, 不至于因为血糖少而减低热量消耗等级。 千万不能饿到肚子,因为饿肚子会减低人的能量消耗水平,反而瘦不下来。

还有就是每天保持高能量输出,这样让身体维护一个比较高的热量消耗水平。 方法是通过每天高强度运动(时间不一定很长,40分钟足够了), 高强度就是你的心率很高,可以感觉到心跳厉害。 散步,慢跑效果都不够好,要做一些快速跑跳的全身动作。