SagerXiao's Blog

Restart of an old programmer

My First Octopress Test Page

Sager’s HTML5 presentations

Discover if a number is prime Source Article
1
2
3
4
5
class Fixnum
  def prime?
      ('1' * self) !~ /^1?$|^(11+?)\1+$/
  end
end
Discover if a number is prime Source Article
1
$ sudo make me a sandwich
Login to 163 email 163邮件系统
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
class Login163:
   #伪装browser
    header = {'User-Agent':'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.6)\
        Gecko/20091201 Firefox/3.5.6'}
    username = ''
    passwd = ''
    cookie = None #cookie对象
    cookiefile = './cookies.dat' #cookie临时存放地
    user = ''

    def __init__(self,username,passwd):
        self.username = username
        self.passwd = passwd
        #cookie设置
        self.cookie = cookielib.LWPCookieJar() #自定义cookie存放
        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(self.cookie))
        urllib2.install_opener(opener)
Javascript Array Syntax MDN Documentation
1
2
var arr1 = new Array(arrayLength);
var arr2 = new Array(element0, element1, ..., elementN);

We made 1 million dollars this year

rake new_post[“My New Post”]

edit my-new-post.markdown with text editor

jekyll markup

Preview&Deploy
1
2
3
rake preview
rake generate
rake deploy
Commit source
1
2
3
git add .
git ci -am 'your message'
git push origin source

Bacon ipsum dolor sit amet exercitation ball tip consectetur tempor. Biltong exercitation aliqua, ribeye consequat veniam consectetur.

Aliquip nulla do tempor, ball tip dolore anim esse strip steak nisi nostrud. Tri-tip mollit deserunt ut duis, commodo brisket short loin est hamburger sunt consequat rump meatloaf. Exercitation enim aliqua tempor dolore. Non eu venison, officia boudin tri-tip enim beef ribs flank cupidatat in aute. Tail voluptate fugiat aute flank, venison sint.

Brisket quis velit bresaola. Pork loin pork chop beef duis. Short loin fugiat officia short ribs magna. Ullamco eu proident jerky, fugiat chuck nostrud ham rump meatloaf eiusmod adipisicing. Qui et reprehenderit, magna biltong consequat short ribs pancetta. Tail tenderloin sausage, hamburger corned beef drumstick ad. Eu labore enim velit.

An image of a very cute kitten Filler text courtesy of Bacon Ipsum, Images courtesy of Place Kitten.

Last night I lay in bed looking up at the stars in the sky and I thought to myself, where the heck is the ceiling.

那么一个极客眼中的博客应该具备哪些要素?

1. 基于文本的编辑

作为极客,你必须很在意 Vim, Emacs 之流,你应该鄙视一切在 Office,Web 里的文字工作,Office 之流很方便使用,但是实在没有什么效率。即便在我们这个行业里,很多人至今没有弄清楚方便不等于高效这个道理。所以我个人只认同使用 Vim 方式处理任何文本工作,包括代码和博客。

2. 方便的书写和阅读格式

假设你承认上述第一点的理念,那么我们还是在写博客,仍然需要格式化的文字使得文字本身在网络上更富表现力,方便读者阅读。但是 html 是一种很冗余的格式存在,既不方便书写也不方便对编辑的源码直接阅读。同时纯文本的格式又走上了另一个极端,书写和阅读基本没有任何代价,坏处在于纯文本几乎又没有任何表现力,除了可以分出段落,它不能粗体,不能斜体,不能更改字号,不能列表。所以结论是:我们需要一种介于 html 和纯文本之间的格式来书写博客,它有不那么大的书写和阅读的成本,又兼顾一定的文字表现力。答案就是 Markdown,再送一份红利就是在线的 Markdown Editor

3. 灵活的备份和恢复

这是一条足以放弃 WordPress 的重要理由。我们无非是在码字而已,没有理由引入数据库,基于文本的保存是最安全的保存,它便于检索(grep),容易导入,导出,不依赖于任何第三方软件或者操作系统。几百年后,这篇文档仍然可以被那时的计算机打开,这很重要,好比我们今天仍然有机会看到前人的青铜器,但是我们的后人只能从图片上看看今天的各类一次性制品。如果要求更高一些,我们还希望有类似管理代码的方式来管理我们的博客,同样是文本,Version Control System 不应该是代码的专有权利。中央服务器也可以保证在任何地方,任何时候检出,更新,提交你的博客,并且也不妨碍除你以外的人这么做。

4. 基于命令行的操作方式

极客的重要特征是远离 Windows,所以我们甚至应该幻想一个 Windows 不友好的方式来写博客。它应该尽量基于命令行,在 Linux 系统上运行良好,羞啥那些 Windows 上的普通青年和 Mac 上的文艺青年,这不是说我很大度的表示我就是2B青年,只是我实在不愿意诸君承担2B青年的包袱,只好自己大度的承担罢了。

5. 支持代码片段的显示

偶尔想秀个小代码也是装2的内在诉求和外在表现之一,所以我们的博客应该是可以这样子的:

Code Snips to test code blocks link test
1
2
3
4
5
class TestCode:
    def __init__(self):
        pass
    def testCode(self):
        print 'hello world!'

6. 最后的最后,不缩水的博客

好处不能都被你这个2B青年占完了不是吗?你要这个要那个,都满足你了,末了扔给你一个缩水的博客,你不由自主的和那些个不入你法眼的新浪博客,不讨巧的 WordPress 做比较了,于是你又开始不满意了。好吧,我们折中一下,RSS 导出不能少,分享到 Facebook,Twitter,甚至于新浪微博也不能落下,还要能访客留言,搜索过往,提示最近的博客,标注 tag。于是是除了你那些个蛋疼的特殊癖好,别人有的也全都要满足。。。

Mou

1. 真的没什么
2. 其实有意思的

Mou, the missing Markdown editor for web developers.

Python’s print function Test code
1
2
def main():
    print 'Hello octopress'
Login to 163 email 163邮件系统
1
2
def main():
    print 'Hello octopress'
Backup system configuration files
1
2
echo $SHELL
tar cvfz /home/sager/bakup/etc.tar.gz /etc/ *
echo $SHELL
tar cvfz /home/sager/bakup/etc.tar.gz /etc/ *

Comments