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 | |
url = "http://localhost:8080/test" | |
def postNews(title, source, category, content):#gbk encoding | |
params=urllib.urlencode({"title":title, "source":source, "category":category, "content":content}) | |
resp = urllib.urlopen(url, params) | |
print resp.readlines() | |
resp.close() |
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
DefaultHttpClient httpclient = new DefaultHttpClient(); | |
HttpPost post = new HttpPost("http://localhost:8086/filter.s"); | |
List<NameValuePair> nvps = new ArrayList<NameValuePair>(); | |
nvps.add(new BasicNameValuePair("title", "test_" + ns.getTitle())); | |
nvps.add(new BasicNameValuePair("source", ns.getSource())); | |
nvps.add(new BasicNameValuePair("category", ns.getCategory())); | |
nvps.add(new BasicNameValuePair("content", ns.getContent())); | |
post.setEntity(new UrlEncodedFormEntity(nvps, "gbk")); |
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
private static void compress(byte[] in) throws IOException { | |
System.out.println("before compress size: " + in.length); | |
byte[] out = null; | |
ByteArrayInputStream bi = new ByteArrayInputStream(in); | |
ByteArrayOutputStream bo = new ByteArrayOutputStream(); | |
GZIPOutputStream go = new GZIPOutputStream(bo); | |
byte[] bb = new byte[1024]; |
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
class TaskThreadFactory implements ThreadFactory { | |
final ThreadGroup group; | |
final AtomicInteger threadNumber = new AtomicInteger(1); | |
final String namePrefix; | |
TaskThreadFactory(String namePrefix) { | |
SecurityManager s = System.getSecurityManager(); | |
group = (s != null) ? s.getThreadGroup() : Thread.currentThread().getThreadGroup(); | |
this.namePrefix = namePrefix; | |
} |
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
HttpRequestBase r; | |
r.setHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; InfoPath.2; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)"); | |
r.setHeader( "Accept","image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash," + | |
" application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-ms-application," + | |
" application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml+xml, */*"); | |
r.setHeader("Accept-Encoding", "gzip, deflate"); | |
r.setHeader("Accept-Language", "zh-cn"); | |
r.setHeader("Content-Type", "application/x-www-form-urlencoded"); | |
r.setHeader("Cache-Control", "no-cache"); |
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 datetime | |
start=datetime.datetime.now() | |
end=datetime.datetime.now() | |
cost=end-start | |
print type(cost) |
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
cksum $FILENAME #output the checksum and bytes | |
md5sum $FILENAME #output the md5 |
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
<Connector port="8080" protocol="HTTP/1.1" | |
connectionTimeout="20000" | |
URIEncoding="utf-8" | |
acceptCount="100" | |
maxThreads="250" | |
compression = "on" | |
compressableMimeType="application/json" | |
compressionMinSize="1024000" | |
redirectPort="8443" /> |
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
hexdump -n 1024 -x sourcepush.gzip |