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
# -*- coding: utf-8 -*- | |
import os,time | |
import threading | |
rlock = threading.RLock() | |
curPosition = 0 | |
class Reader(threading.Thread): | |
def __init__(self, res): | |
self.res = res |
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
-- Resource: https://github.com/timotta/wrk-scripts/blob/master/multiplepaths.lua | |
-- Initialize the pseudo random number generator | |
-- Resource: http://lua-users.org/wiki/MathLibraryTutorial | |
math.randomseed(os.time()) | |
math.random(); math.random(); math.random() | |
-- Shuffle array | |
-- Returns a randomly shuffled array | |
function shuffle(paths) |
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
function throttle( fn, time ) { | |
var t = 0; | |
return function() { | |
var args = arguments, ctx = this; | |
clearTimeout(t); | |
t = setTimeout( function() { | |
fn.apply( ctx, args ); | |
}, time ); | |
}; |
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
var http = require("http"); | |
function request(url) { | |
var options = { | |
hostname: url, | |
port: 80, | |
path: '/', | |
method: 'GET' | |
}; | |
var req = http.request(options, function(res) { |
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
<% | |
Dim myVar | |
On Error Resume Next | |
'下面一行代码会在MSXML 4.0没有被安装或者已经损坏的情况下产生错误 | |
Set myVar = Server.CreateObject("MSXML2.DOMDocument.4.0") | |
If Err.Number <> 0 Then | |
' 在这里处理错误 | |
' 结束错误处理,避免以后发生的错误无法被发现 | |
On Error GoTo 0 | |
Else |
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
#coding:utf-8 | |
import re | |
string = ''' | |
TagDict.Add "@胡同口@","@1386@" | |
TagDict.Add "@时尚@","@1357@" | |
TagDict.Add "@汽车@","@1336@" | |
TagDict.Add "@旅游@","@1378@" | |
TagDict.Add "@家居@","@1396@" | |
TagDict.Add "@数码@","@1242@" | |
TagDict.Add "@都市@","@1276@" |
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
#coding:utf-8 | |
''' | |
@author:FX | |
2013-1-3 | |
''' | |
import random | |
import threading | |
import time | |
import Queue | |
import speech |
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
function gzdecode($data) { | |
$len = strlen($data); | |
if ($len < 18 || strcmp(substr($data,0,2),"\x1f\x8b")) { | |
return null; // Not GZIP format (See RFC 1952) | |
} | |
$method = ord(substr($data,2,1)); // Compression method | |
$flags = ord(substr($data,3,1)); // Flags | |
if ($flags & 31 != $flags) { | |
// Reserved bits are set -- NOT ALLOWED by RFC 1952 | |
return null; |
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
# Get all folders paths from given path upwards | |
# | |
# @type file_path: string | |
# @param file_path: absolute file path to return the paths from | |
# | |
# @return list<string> of file paths | |
# | |
# @global nestingLimit | |
def getFolders(file_path): | |
if file_path is None: |
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 locale | |
import codecs | |
print locale.getpreferredencoding(); | |
print codecs.lookup(locale.getpreferredencoding()).name |
NewerOlder