Skip to content

Instantly share code, notes, and snippets.

@yszou
yszou / ng_resource.html
Created July 2, 2013 18:27
AngularJS ngResource Demo
<!DOCTYPE html>
<html ng-app="Demo">
<head>
<meta charset="utf-8" />
<title>AngularJS的Demo</title>
</head>
<body>
# -*- 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 / gist:7415192
Created November 11, 2013 15:42
sth about MySQLdb
# -*- coding: utf-8 -*-
import MySQLdb
#(1, 2, 3, 'final', 0)
print MySQLdb.version_info
'''
+--------------------+
@yszou
yszou / txt2tags
Created December 9, 2013 10:53
我修改过的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 / muttrc
Created December 9, 2013 11:17
mutt配置文件
#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 / query.py
Created December 9, 2013 11:20
LDAP的一个查询交互
# -*- 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 / fetch.py
Created December 9, 2013 11:33
获取内容的文件
# -*- coding: utf-8 -*-
'获取邮件'
import pickle
from time import time
from uuid import uuid4
import os
import sys
import re
@yszou
yszou / pop.py
Created December 9, 2013 11:35
Tornado实现的简单POP客户端
# -*- 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 / smtpclient.py
Created December 9, 2013 11:48
Tornado实现的SMTP客户端
# -*- 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 / eml_parse.py
Created December 9, 2013 11:50
邮件解析
# -*- coding: utf-8 -*-
import uuid
import base64
import datetime
import email
import email.Header
from email.utils import getaddresses, parsedate_tz, mktime_tz
from StringIO import StringIO