Skip to content

Instantly share code, notes, and snippets.

@yszou
yszou / smtpclient.py
Created Dec 9, 2013
Tornado实现的SMTP客户端
View smtpclient.py
# -*- coding: utf-8 -*-
'参考smtplib,以tornado的IOStream实现的SMTP客户端'
import socket
import re
import email.utils
import tornado.ioloop
import tornado.iostream
import tornado.gen
@yszou
yszou / pop.py
Created Dec 9, 2013
Tornado实现的简单POP客户端
View pop.py
# -*- coding: utf-8 -*-
import logging
import socket
import uuid
import tornado.ioloop
import tornado.iostream
import tornado.gen
IL = tornado.ioloop.IOLoop.instance()
@yszou
yszou / fetch.py
Created Dec 9, 2013
获取内容的文件
View fetch.py
# -*- coding: utf-8 -*-
'获取邮件'
import pickle
from time import time
from uuid import uuid4
import os
import sys
import re
@yszou
yszou / query.py
Created Dec 9, 2013
LDAP的一个查询交互
View query.py
# -*- coding: utf-8 -*-
import sys
import ldap
ldap.set_option(ldap.OPT_REFERRALS, 0)
con = ldap.initialize('ldap://ldap.example.com:389')
con.simple_bind_s( 'xxx@sohu-inc.com', '***' )
@yszou
yszou / muttrc
Created Dec 9, 2013
mutt配置文件
View muttrc
#FROM http://stevelosh.com/blog/2012/10/the-homely-mutt/
#sidebar patch: http://www.lunar-linux.org/mutt-sidebar/
set sendmail="python /home/zys/Dropbox/AceSend/sendmail.py"
set from="YS.Zou <xxx@gmail.com>"
set charset="utf-8"
set send_charset="utf-8"
set weed=yes
set text_flowed=yes
charset-hook ^gb2312$ gb18030
@yszou
yszou / txt2tags
Created Dec 9, 2013
我修改过的txt2tags
View txt2tags
#! /usr/bin/python
# -*- coding: utf-8 -*-
# txt2tags - generic text conversion tool
# http://txt2tags.org
#
# Copyright 2001-2010 Aurelio Jargas
#
# License: http://www.gnu.org/licenses/gpl-2.0.txt
# Subversion: http://svn.txt2tags.org
@yszou
yszou / gist:7415192
Created Nov 11, 2013
sth about MySQLdb
View gist:7415192
# -*- coding: utf-8 -*-
import MySQLdb
#(1, 2, 3, 'final', 0)
print MySQLdb.version_info
'''
+--------------------+
View ng_resource.py
# -*- coding: utf-8 -*-
import os
if os.access('bottle.py.cache', os.F_OK):
with open('bottle.py.cache', 'r') as f:
code = f.read()
else:
import urllib2
print 'Loading bottle ...'
res = urllib2.urlopen('http://bottlepy.org/bottle.py')
@yszou
yszou / ng_resource.html
Created Jul 2, 2013
AngularJS ngResource Demo
View ng_resource.html
<!DOCTYPE html>
<html ng-app="Demo">
<head>
<meta charset="utf-8" />
<title>AngularJS的Demo</title>
</head>
<body>