Skip to content

Instantly share code, notes, and snippets.


Qichao Zhang usbuild

View GitHub Profile
usbuild /
Created Sep 8, 2020
python jit代码示例
# coding=utf-8
import dis
import mmap
import struct
from ctypes import *
from functools import wraps
from typing import Union
import numpy as np
usbuild / stc8_ir.c
Created Aug 26, 2020
View stc8_ir.c
#include <STC/STC8G.h>
#include <intrins.h>
sbit IR_PIN_IN = P3 ^ 2;
typedef unsigned char uchar;
typedef unsigned int uint;
typedef unsigned int u16;
// 开启bbr
modprobe tcp_bbr
echo "tcp_bbr" | tee --append /etc/modules-load.d/modules.conf
echo "net.core.default_qdisc=fq" | tee --append /etc/sysctl.conf
echo "net.ipv4.tcp_congestion_control=bbr" | tee --append /etc/sysctl.conf
sysctl -p
// 安装程序
usbuild / cbind.c
Last active Dec 29, 2018
implement C closure! you can pass closure to external c apis via function pointer.
View cbind.c
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#define CODE_SIZE 200
typedef union slot_t {
usbuild /
Last active Dec 12, 2018
debian ubuntu server initialize
#!/usr/bin/env bash
#install tmux git subversion wget uuid-dev liblzma-dev libgdbm-dev libncurses5-dev libbz2-dev libssl-dev libreadline-dev libsqlite3-dev libffi-dev
if [[ 1 -eq 2 ]]; then
echo "set-option -g default-shell /bin/zsh" > ~/.tmux.conf
mkdir ~/usr
mkdir ~/download
usbuild / co.cpp
Created Nov 7, 2018
A Simple cpp coroutine implementation
View co.cpp
#include "co.hpp"
#include <assert.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <map>
#include <mutex>
using namespace pm::common;
usbuild / jit_calculator.c
Last active Nov 1, 2018
A naive calculator with interpreter and jit. Just for teaching and demo.
View jit_calculator.c
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <assert.h>
#define STACK_MAX 100
#define CODE_SIZE (2 * 1024 * 1024)
usbuild / blockchain.go
Last active Apr 2, 2018
simple implementation of blockchain
View blockchain.go
package blockchain
import (
usbuild /
Last active Apr 2, 2018
a naïve implmentation of raft consensus algorithm
import sys
from flask import Flask, jsonify, request
from threading import Thread, Lock
from collections import defaultdict
import time
import urllib
import random
import logging
import json
usbuild / shm_queue.cpp
Last active Mar 29, 2018
a circular queue using shared memory, eventfd and unix domain socket
View shm_queue.cpp
//#pragma once
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#include <stddef.h>
#include <string>
#include <sys/time.h>
#include <time.h>