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
// answer to http://blog.zhaojie.me/2012/11/how-to-generate-typoglycemia-text.html | |
#include <algorithm> | |
#include <iostream> | |
#include <string> | |
#include <assert.h> | |
#include <ctype.h> | |
using std::string; | |
void randomizeWord(char* str, int len) |
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
// answer to http://weibo.com/1915548291/z2UtyzuvQ | |
// see also http://www.cnblogs.com/baiyanhuang/archive/2012/11/11/2764914.html | |
#include <boost/bind.hpp> | |
#include <boost/function.hpp> | |
#include <boost/noncopyable.hpp> | |
#include <boost/ptr_container/ptr_vector.hpp> | |
#include <fstream> | |
#include <iostream> |
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 <iostream> | |
template<typename CharT> | |
const CharT* ToString(const char* str, const wchar_t* wstr); | |
template<> | |
const char* ToString<char>(const char* str, const wchar_t* wstr) | |
{ | |
return 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
#include <map> | |
#include <set> | |
#include <stdio.h> | |
typedef std::pair<int64_t, uint32_t> Entry; | |
typedef std::set<Entry> TimerList; | |
TimerList timers; | |
void test(int64_t now) |
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/python | |
import socket, os, hashlib, time | |
md5 = hashlib.md5() | |
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
sock.connect(('server_address', 2021)) | |
start = time.time() | |
length = 0 | |
out = open('/tmp/download', 'wb') |
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 <algorithm> | |
#include <vector> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <sys/time.h> | |
double getTime() | |
{ | |
struct timeval tv; | |
gettimeofday(&tv, 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
DEBUG = false | |
if ARGV.size < 2 | |
puts "Usage: #$0 pattern file_pattern" | |
puts "Example: #$0 '\\d+' '*.rb'" | |
exit | |
end | |
dirname = File.dirname(ARGV[1]) | |
file_pattern = File.basename(ARGV[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
#include <algorithm> | |
#include <string.h> | |
struct AreBothSpaces | |
{ | |
bool operator()(char x, char y) const | |
{ | |
return x == ' ' && y == ' '; | |
} | |
}; |
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 <assert.h> | |
#include <list> | |
#include <boost/unordered_map.hpp> | |
#include <boost/noncopyable.hpp> | |
template<typename T> | |
class HashedList : boost::noncopyable | |
{ | |
typedef typename std::list<T>::iterator ListIterator; | |
typedef typename std::list<T>::reverse_iterator ReverseListIterator; |
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
#user nobody; | |
worker_processes 4; | |
events { | |
worker_connections 10240; | |
} | |
http { | |
include mime.types; | |
default_type application/octet-stream; |