This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/*************************************************************************** | |
* | |
* Copyright (c) 2012 Baidu.com, Inc. All Rights Reserved | |
* | |
**************************************************************************/ | |
/** | |
* @file ip.php | |
* @author dn([email protected]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib | |
import urllib2 | |
import os | |
picurl="http://images.51cto.com/files/uploadimg/20100630/104906665.jpg" | |
save_path="d:\\" | |
imgData = urllib2.urlopen(picurl).read() | |
# 给定图片存放名称 | |
fileName = save_path + "\\ddd.jpg" | |
# 文件名是否存在 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# encoding: utf-8 | |
""" | |
tb1.py | |
Created by dn on 2011-07-24. | |
Copyright (c) 2011 shubz. All rights reserved. | |
""" | |
import os | |
import sys | |
import re |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
x = u'床前明月光 疑是地上霜 举头望明月 低头思故乡' | |
print '\n'.join(' '.join(x) for x in zip(*map(list, x.split(' ')))) #这个写法还有点问题,有空再来研究 | |
--- | |
低举疑床 | |
头头是前 | |
思望地明 | |
故明上月 | |
乡月霜光 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* | |
* This class for execute the external program of svn | |
* | |
* @auth Seven Yang <[email protected]> | |
* | |
*/ | |
class SvnPeer | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
""" | |
Script to copy all bookmarks from Read It Later to Instapaper. | |
See also http://readitlaterlist.com/api/docs/#get | |
and http://www.instapaper.com/api/simple | |
""" | |
import urllib, urllib2, json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
youtube_url_pattern = re.compile(r'youtube.com/.*?v[/=](?P<video_id>[\w-]+)') | |
def get_video_id(url): | |
result = youtube_url_pattern.search(url) | |
if result: | |
return result.group('video_id') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#用正则简单过滤html的<>标签 | |
import re | |
str = "<img /><a>srcd</a>hello</br><br/>" | |
str = re.sub(r'</?\w+[^>]*>','',str) | |
print str |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#‘ignore’ (just leave the character out of the Unicode result) | |
#replace | |
unicode('\x80abc', errors='ignore') | |
text = "第二十集神兵天降 第七章 旦雅之危" | |
text.decode('gb2312',errors='ignore') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo "<input name='rft' type='hidden' value='".random_form_token()."' />"; | |
if(random_form_token($_POST['rft'])){ | |
// | |
} | |
else{ | |
// | |
} | |
function random_form_token($value=NULL){ | |
if($value == NULL){ | |
$token = hash("sha256","tanzmal".microtime()); |