This file contains hidden or 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 <pthread.h> | |
#include <iostream> | |
#include <string> | |
#include <cstdlib> | |
#include <sys/time.h> | |
using namespace std; | |
static int mode = ITIMER_PROF; |
This file contains hidden or 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
void Merge3(const vector<int>& v1, const vector<int>& v2, const vector<int>& v3, vector<int>& v4) | |
{ | |
typedef pair<size_t, const vector<int>*> HeapElem; | |
vector<HeapElem> int_heap; | |
if (!v1.empty()) | |
{ | |
int_heap.push_back(make_pair(0, &v1)); | |
} | |
if (!v2.empty()) |
This file contains hidden or 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
#define _GNU_SOURCE 1 | |
#include <dlfcn.h> | |
#include <string.h> | |
#include <stdlib.h> | |
int open(const char *pathname, int flags) | |
{ | |
typedef int (*OpenFunc)(const char*, int); | |
static OpenFunc real_open_func = NULL; |
This file contains hidden or 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 gevent | |
threads = [] | |
def killall_but_this(): | |
this_thread = gevent.getcurrent() | |
for t in threads: | |
if t is not this_thread: | |
t.kill(block=False) |
This file contains hidden or 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> | |
#include <sys/types.h> | |
#include <sys/socket.h> | |
#include <netinet/ip.h> | |
#include <arpa/inet.h> | |
#include <cstdlib> | |
#include <fcntl.h> | |
#include <errno.h> | |
#include <cstring> |
This file contains hidden or 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/env python2.7 | |
import pypipe # use pypipe from https://github.com/airekans/Pypipe | |
import sys | |
import os | |
_BACKUP_CL = 123456 | |
def is_p4_different(p4_path, shelve_cl): |
This file contains hidden or 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/env python | |
# | |
# This script shows the correct result only when the host(client or server) | |
# is idle(no other network intensive program is running). | |
# So if you run two client on the same host, the result is wrong. | |
import socket | |
import sys | |
import time |
This file contains hidden or 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
l = [("user_a", "file_a"), ("user_b", "file_b"), ("user_c", "file_b")] | |
filenames = map(lambda p: p[1], l) | |
def reduce_func(res, filename): | |
if filename not in res: | |
res[filename] = 0 | |
res[filename] += 1 | |
return res |
This file contains hidden or 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
#! /bin/bash | |
if [ $# -lt 2 ]; then | |
echo Usage: $0 MD5 SO_FILE_NAME | |
exit 1 | |
fi | |
file_md5=$1 | |
so_filename=$2 | |
tmp_so=${so_filename}.$RANDOM |
This file contains hidden or 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 <cstdlib> | |
#include <sys/time.h> | |
#include <cerrno> | |
#include <cstring> | |
#include <iostream> | |
using namespace std; | |
static void my_get_time(timeval* tv) |