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
%% 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); |
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
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) |
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
#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); | |
} |
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
% 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), |
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 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; | |
/** |
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 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"): |
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
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 |
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 <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); | |
} | |
}); |
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
/** | |
* 根据概率产生相应奖品 | |
* | |
* @return 相应对应的号码 | |
*/ | |
@SuppressWarnings("unchecked") | |
public static int getAward() { | |
Map result = new LinkedHashMap(); | |
for (int i = 0; i < 500; i++) { |
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 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; | |
/** |
OlderNewer