摘要: import imaplibimap_host = 'imap.gmail.com'imap_user = 'youremail@gmail.com'imap_pass = 'password'## open a connection imap = imaplib.IMAP4_SSL(imap_host)## loginimap.login(imap_user, imap_pass)## get status for the mailbox (folder) INBOXfolderStatus, UnseenInfo = imap.status( 阅读全文
posted @ 2013-09-23 17:16 Functional Life 阅读(526) 评论(0) 推荐(1) 编辑
摘要: 注意:如果报找不到 OPENSSL.CNF文件的错误,可以到网上下一个,然后用 -config openssl.cnf来指定这个配置文件的位置,或放到报错时提示的指定位置1.生成根证书的KEY, 1024的意思是RSA加密位数,必须为2的N次方,一般用1024即可。openssl genrsa -out ca.key 10242.用刚刚生成的根证书的KEY来生成CSR(证书签发请求),这一步会要求填写请求的相关信息。openssl req -new -key ca.key -out ca.csr其中要注意的输入项有两个,一个Common Name(证书机构名),另一个challenge pas 阅读全文
posted @ 2013-07-03 17:27 Functional Life 阅读(649) 评论(0) 推荐(0) 编辑
摘要: 原文:http://www.rassoc.com/gregr/weblog/2013/02/16/zero-to-postgresql-streaming-replication-in-10-mins/假设主数据库IP为1.2.3.4 备份数据库IP为5.6.7.8先到主数据库创建一个新的,只有备份权限的用户psql -c "CREATE USER replicator REPLICATION LOGIN ENCRYPTED PASSWORD 'password';"修改主数据库postgresql.conflisten_address = '*&# 阅读全文
posted @ 2013-07-03 17:24 Functional Life 阅读(227) 评论(0) 推荐(0) 编辑
摘要: 1 def sim_pearson(prefs, person1, person2): 2 si = {} 3 4 for it in prefs[person1]: 5 if it in prefs[person2]: 6 si[it] = 1 7 8 n = len(si) 9 if n == 0: return 010 11 sum1 = sum([prefs[person1][it] for it in si])12 sum2 = sum([prefs[person2][it] for it ... 阅读全文
posted @ 2013-04-17 14:23 Functional Life 阅读(536) 评论(0) 推荐(0) 编辑
摘要: recommendations.pycritics = { 'Lisa Rose' : {'Lady in the Water' : 2.5, 'Snakes on a Plane' : 3.5, 'Just My Luck' : 3.0, 'Superman Returns' : 3.5, 'You, Me and Dupree' : 2.5, 'The Night Listener' : 3.0}, 'Gene Seymour' : {'Lady in t 阅读全文
posted @ 2013-04-17 11:00 Functional Life 阅读(435) 评论(0) 推荐(0) 编辑
摘要: 名称关于Perl5中引用的简短教程描述关于Perl5中一个非常重要的新功能就是引用,我们可以用引用来完成操作复杂的数据结构,比如多为数组和嵌套哈希。但是这要求我们学习一些新的语法。废话少说,开始吧。为什么Perl5里要加入引用?Perl4里,你的哈希列表里的值只能是标量,不能是列表,也就是不能嵌套。懂?不懂看下面下面有一张城市和其对应国家的文件1 Chicago, USA2 Frankfurt, Germany3 Berlin, Germany4 Washington, USA5 Helsinki, Finland6 New York, USA然后你想读取这个文件,输出如下的格式,即把国家放在 阅读全文
posted @ 2013-03-28 15:21 Functional Life 阅读(289) 评论(0) 推荐(0) 编辑
摘要: 原文地址:http://en.wikibooks.org/wiki/F_Sharp_Programming1. 声明变量1.1 值是值,变量是变量在F#里最常见的关键字就是let,用来声明变量或是函数。 举例如下:let x = 5let y = 10let z = x + y这样就声明了x,y,然后分别赋值。最后z等于x加y的值。 然后你可以再把它们打印出来printfn "x: %i" xprintfn "y: %i" yprintfn "z: %i" z最后输出的结果是什么,到FSI里试下就知道了。 记得不要忘记,在FSI里要在 阅读全文
posted @ 2013-01-28 22:24 Functional Life 阅读(187) 评论(0) 推荐(0) 编辑
摘要: 原文地址:http://en.wikibooks.org/wiki/F_Sharp_Programming2. 声明函数声明一个函数用的也是let,后面函数名和函数体,用空格间隔开来let add x y = x + ylet z = add 5 10定义一个叫add的函数,接受两个参数,然后返回相加的结果。这里z就等于15了。那如果我这样调用呢?let z = add 5 10.2也许你会说z等于15.2吧,其实这里你会得到一个错误error FS0001: This expression was expected to have type intbut here has type ... 阅读全文
posted @ 2013-01-28 22:24 Functional Life 阅读(165) 评论(0) 推荐(0) 编辑
摘要: 原文地址:http://en.wikibooks.org/wiki/F_Sharp_Programming先下载F#:http://www.microsoft.com/en-us/download/details.aspx?id=11100最低要求.NET2.0环境。安装好了以后把BIN目录加入环境变量里。两个主要的东西,一个是FSI,交互式的SHELL。一个是FSC,用来编译F#代码的。运行FSI,如下图所示。Microsoft F# Interactive, (c) Microsoft Corporation, All Rights ReservedF# Version 1.9.6.2, 阅读全文
posted @ 2013-01-28 22:20 Functional Life 阅读(196) 评论(0) 推荐(0) 编辑
摘要: Don't pity the humble programmer. He can be lord of all things.Whatever exists in the universe, he has first in his mind, and then in his hand.By his code, he may be called a grandchild of god. 阅读全文
posted @ 2013-01-28 22:19 Functional Life 阅读(169) 评论(0) 推荐(0) 编辑