Skip to content

Instantly share code, notes, and snippets.

View mactanxin's full-sized avatar
😆
happy coding

Xin Tan mactanxin

😆
happy coding
  • San Jose
  • 18:16 (UTC +08:00)
View GitHub Profile
# encoding: utf-8
import hashlib
import sys
if __name__ == '__main__':
i = bytes(sys.argv[1],'utf8')
k = hashlib.md5(i).hexdigest()
print(k)
<form name=f action=s>
<input type=text name=wd id=kw size=42 maxlength=100>
<input type=submit value=百度一下 id=sb>
<div id=sug onselectstart="return false">
</div>
<span id=hp>
<a href=/gaoji/preferences.html>设置</a>
<br>
<a href=/gaoji/advanced.html>高级</a>
</span>
# -*- coding:utf-8-*-
import os,sys
filename = sys.argv[1]
openfile = open(filename)
condition = str(sys.argv[2])
for i in open(filename):
i=i.strip()
data = i.split('|')[2]
if condition == data:
print i.split('|')[5]
# -*- coding:utf-8-*-
from __future__ import with_statement
import os,sys
def find_condition(filename,condition):
with open(filename) as f:
for i in f:
i = i.strip()
data = i.split('|')
if condition == data[2]:
# -*- coding:utf-8-*-
from __future__ import with_statement
import sys
def sortu(filename):
with open(filename) as f:
x = open(targetfile,"w")
for j in list(set([i.strip() for i in f])) :
print >> x,j
x.close()
import re
import os,sys
filename=sys.argv[1]
openfile=open(filename)
for i in openfile.readlines():
b = re.sub(r"<.*?>","",i)
print b
@mactanxin
mactanxin / nit.py
Created March 7, 2011 09:18
nga in terminal
# -*- coding: utf-8 -*-
import os,sys
import re
from urllib2 import build_opener
import random
def visit_page(fid,page_type="fid"):
a_link="http://bbs.ngacn.cc/thread.php?%s=%s" %(page_type,fid)
pass
#!/bin/sh
usage () {
echo "usage: $0" 1>&2
exit 2
}
if [ $# -lt 1 ] ; then
usage
fi
@mactanxin
mactanxin / itunes.awk
Created April 16, 2012 06:22
itunes.awk
#!/usr/bin/awk -f
BEGIN{
FS="\t"
OFS=","
}
{
Product_Type=$7;
App_name=$3;
Customer_mount=$8;
split($10,date_array,"/");
@mactanxin
mactanxin / TornadoRequestHandlerRewrite
Created February 17, 2013 03:30
test gist public sharing through sublime text2 addon
class RequestHandler(web.RequestHandler):
def __init__(self, application, request, status_code=None):
web.RequestHandler.__init__(self, application, request)
if status_code: self.set_status(status_code)
def get_error_html(self, status_code, **kwargs):
if status_code == 404:
return self.render_string('404.html')
elif status_code == 405:
return self.render_string('servererror.html')