Skip to content

Instantly share code, notes, and snippets.

View micfan's full-sized avatar

Michael micfan

  • Palo Alto
View GitHub Profile
@micfan
micfan / boost_asio_ticker.cpp
Last active May 5, 2022 16:44
boost-asio-ticker-example
// environment: C++14, gcc-11.2
// build command: g++ -o ./boost_asio_ticker boost_asio_ticker.cpp -lpthread
#include <iostream>
#include <boost/asio.hpp>
#include <boost/bind/bind.hpp>
#include <chrono>
class Ticker {
public:
#include <iostream>
#include <memory>
using namespace std;
typedef unsigned char BYTE;
int M = 0xA5;
int A = 0xc9;
int N = 256;
int init = 0x55;
@micfan
micfan / smallpt_miloyip.cpp
Last active April 6, 2019 11:08
Smallpt CPP
/*
## ref
https://www.cnblogs.com/miloyip/archive/2010/06/23/cpp_vs_cs_GI.html
http://www.kevinbeason.com/smallpt/
## build
g++ Miloyip-GL.cpp.cpp -lm
## run
```bash
# py27
import os
import sys
import logging
class EvenLogger(logging.Logger):
from logging import NOTSET
def __init__(self, name, level=NOTSET):
#pragma once
#include <boost/noncopyable.hpp>
#include <boost/beast/websocket.hpp>
#include <boost/beast/websocket/ssl.hpp>
struct websocket_stream : boost::noncopyable
@micfan
micfan / APUE.ch.8.process
Last active January 27, 2019 21:38
APUE_examples
// APUE.Chapter.8
// fork(), exec(), wait()
// Michael.Fan
#include <unistd.h>
#include <stdio.h>
#include <sys/wait.h>
int main ()
{
m = 20
def compute_divisor(num):
line = ['-' for i in range(0, 20)]
ret = []
for _ in range(0, num):
if _ == 0: pass
elif num % _ == 0:
ret.append(_)
@micfan
micfan / .Xmodmap
Last active December 13, 2020 21:13
switch Caps and Ctrl key with Debian & Ubuntu X enviroment
#######################################################################
# Path: ~/.Xmodmap #
# Feature: switch Caps and Ctrl key with Debian & Ubuntu X enviroment #
#######################################################################
remove Lock = Caps_Lock
remove Control = Control_L
keysym Control_L = Caps_Lock
keysym Caps_Lock = Control_L
add Lock = Caps_Lock