Skip to content

Instantly share code, notes, and snippets.

View zhanghongquan's full-sized avatar

ZhangHongquan zhanghongquan

View GitHub Profile
@zhanghongquan
zhanghongquan / cs.cpp
Created January 9, 2020 09:21
measure context switch time
#include <chrono>
#include <condition_variable>
#include <functional>
#include <iostream>
#include <thread>
#include <vector>
class FlipFlop {
public:
inline void notify() {
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Simple async crawler/callback queue based on gevent."""
import traceback
import logging
import httplib2
import gevent
@zhanghongquan
zhanghongquan / multicast.cpp
Created May 12, 2014 07:27
multicast on all network interface (only linux
#include <sys/types.h>
#include <ifaddrs.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>