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 | |
/*使用imagick在动态GIF上打文字水印*/ | |
$draw = new ImagickDraw(); | |
$draw->setFont('simsun.ttc'); | |
$draw->setFontSize( 12 ); | |
$text = iconv('GB2312', 'UTF-8', '网易'); | |
$image=new Imagick(); | |
$animation = new Imagick(); |
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 | |
# coding=utf-8 | |
def getNewId(oldid): | |
# 将输入的oldid参数拆分成元组 | |
a=[] | |
for i in oldid: | |
a.append(int(i)) | |
# 在第6和7位(从0开始计算)填入1和9,组成长度为17的元组 | |
a.insert(6,1) |
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
public static function shorturl($input) | |
{ | |
$base32 = array ( 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5' ); | |
$hex = md5($input); | |
$hexLen = strlen($hex); | |
$subHexLen = $hexLen / 8; | |
$output = array(); | |
for ($i = 0; $i < $subHexLen; $i++) | |
{ | |
$subHex = substr ($hex, $i * 8, 8); |
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 | |
function getmicrotime(){ | |
list($usec, $sec) = explode(" ",microtime()); | |
return ((float)$usec + (float)$sec); | |
} | |
//例子 | |
//开始 | |
$time_start = getmicrotime(); |
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()); |
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
#用正则简单过滤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
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
#! /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
<?php | |
/** | |
* | |
* This class for execute the external program of svn | |
* | |
* @auth Seven Yang <[email protected]> | |
* | |
*/ | |
class SvnPeer | |
{ |
OlderNewer