Skip to content

Instantly share code, notes, and snippets.

@Arbow
Arbow / dame_shit.erl
Created July 28, 2008 02:10
These codes show bugs in Erlang's SUB BINARY OPTIMIZED mechanism
%% Notice:These codes show bugs in Erlang's SUB BINARY OPTIMIZED mechanism
-module(dame_shit).
-export([main/0, dame_shit/1, dame_shit2/1]).
dame_shit(Bin) ->
dame_shit(Bin, not_found).
dame_shit(Bin, found) ->
{found, Bin};
dame_shit(<<"\r\n", T/binary>>, not_found) ->
dame_shit(T, found);
def httpAuthUrlFetch(self, url, username, password, mheaders={}):
import base64
encoded = base64.b64encode(username + ':' + password)
authstr = "Basic " + encoded
mheaders['Authorization'] = authstr
return urlfetch.fetch(url, headers = mheaders)
#include <stdio.h>
int add(int i, int j, void (*continuation)(int)) {
int k = i + j;
continuation(k);
}
void print(int i) {
printf("%d\n", i);
}
% Create a signature of your data with Erlang
-module(signit.erl).
-export(start/0,sha_sign/0).
start() -> application:start(crypto).
%% Sign the data using SHA.
%% This will return a 20 byte key for the data
sha_sign(Data) ->
Sha_data = crypto:sha(Data),
@Arbow
Arbow / SimpleWgetService.java
Created November 8, 2008 04:25
一个封装好的java wget库
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
import org.apache.commons.codec.binary.Base64;
/**
import platform
system, _, release, version, machine, processor = platform.uname()
system, release, version = platform.system_alias(system, release,version)
if (system == 'Darwin' and release == '9.1.0'):
#操作系统为Mac OSX 10.5
chroot_path = "/"
namedconf = "/etc"
elif (system == "FreeBSD" and release[:3] == "7.0"):
server.modules = (
"mod_access",
"mod_alias",
"mod_accesslog",
"mod_compress",
"mod_fastcgi",
"mod_rewrite"
)
## a static document-root, for virtual-hosting take look at the
public <T extends Room> List<Integer> getBatchPlayerAmountOfRooms(List<T> rooms) {
if (rooms == null || rooms.size() == 0)
return new ArrayList<Integer>(0);
Collection<String> uidList = FPUtils.map(rooms, new FPUtils.MapFunc<T, String>() {
@Override
public String map(T room) {
return roomCacheKey(room);
}
});
/**
* 根据概率产生相应奖品
*
* @return 相应对应的号码
*/
@SuppressWarnings("unchecked")
public static int getAward() {
Map result = new LinkedHashMap();
for (int i = 0; i < 500; i++) {
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
import org.apache.commons.codec.binary.Base64;
/**