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 pypy-c | |
from __future__ import print_function | |
import random | |
import math | |
import sys | |
import signal | |
import os | |
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
#include <iostream> | |
#include <vector> | |
#include <string> | |
#include <mutex> | |
#include <future> | |
#include <chrono> | |
#include <utility> | |
#include <assert.h> | |
#include <pthread.h> |
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 <vector> | |
#include <string> | |
#include <mutex> | |
#include <future> | |
#include <chrono> | |
#include <random> | |
#include <utility> | |
#include <assert.h> |
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
template<class F, class ...Args> | |
void timeit(uint32_t repeat, F&& f, Args&&... args) | |
{ | |
auto begin_time = chrono::high_resolution_clock::now(); | |
for(uint32_t i = 0; i < repeat; ++i) | |
f(forward<Args>(args)...); | |
auto end_time = chrono::high_resolution_clock::now(); | |
printf("total time: %lldus\n", chrono::duration_cast<chrono::microseconds>(end_time - begin_time).count()); | |
printf("average time: %lldns\n", chrono::duration_cast<chrono::nanoseconds>(end_time - begin_time).count() / repeat); |
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
template<class T> | |
class TaggedPointer | |
{ | |
public: | |
explicit TaggedPointer(T* ptr = nullptr) | |
:ptr_(ptr), | |
counter_(0) | |
{} | |
inline T* load_ptr() noexcept |
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 | |
#fileencoding=utf-8 | |
from jinja2 import Environment | |
from jinja2 import FileSystemLoader | |
import datetime | |
def guess_autoescape(template_name): |
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
# author: XuTao <[email protected]> | |
# time: Sun Jul 15 21:57:17 CST 2012 | |
# Usage: mv tmux_conf.txt ~/.tmux.conf | |
#------------------------------------------ | |
#-- base --# | |
set -g default-terminal "xterm-256color" | |
#set -g default-terminal "xterm" | |
set -g display-time 3000 | |
set -g history-limit 65535 |
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 | |
#fileencoding=utf-8 | |
import struct | |
import socket | |
class Node(object): | |
__slots__ = ('ip', 'country', 'district') |
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
[Unit] | |
Description=mongod.service | |
After=network.target disable_thp.service | |
[Service] | |
ExecStartPre=/usr/bin/install -d -m 0755 -o mongod -g mongod /var/run/mongodb | |
ExecStart=/usr/bin/mongod -f /etc/mongod.conf --fork --pidfilepath=/var/run/mongodb/mongod.pid | |
ExecStop=/usr/bin/kill -TERM $MAINPID | |
Type=forking | |
PIDFile=/var/run/mongodb/mongod.pid |
OlderNewer