Skip to content

Instantly share code, notes, and snippets.

Avatar

Yan Huang FinalTheory

View GitHub Profile
@FinalTheory
FinalTheory / test.cpp
Created Dec 26, 2018
std::cout cause frash
View test.cpp
// g++ test.cpp -static -o test -std=c++11
// ./test
struct Foo
{
Foo();
} foo;
#include <iostream>
Foo::Foo()
@FinalTheory
FinalTheory / example.cpp
Last active Dec 4, 2018
Minimal framework internal cost demo
View example.cpp
// g++ example.cpp -O2 -std=c++11 -o example
#include <cstdlib>
#include <string>
#include <chrono>
#include <thread>
#include <mutex>
#include <vector>
#include <functional>
#include <condition_variable>
View get_param_size.cc
#include <iostream>
#include <type_traits>
template<typename ... Args>
struct get_size;
template<>
struct get_size<> {
static constexpr int size = 0;
};
@FinalTheory
FinalTheory / hanoi.cpp
Last active May 22, 2017
C++ Template Hanoi
View hanoi.cpp
#include <iostream>
#include <utility>
template <typename T, T a, T b>
struct pair {
static constexpr auto first = a;
static constexpr auto second = b;
static void print() { std::cout << first << "->" << second << std::endl; }
};
@FinalTheory
FinalTheory / gist:796c4496e366832254f5ab523cdd9ec3
Created May 19, 2017 — forked from mattbierner/gist:090a80d25259b6472827
Compile Time Brainfuck C++ Metaprogramming Evaluator
View gist:796c4496e366832254f5ab523cdd9ec3
#include <utility>
using iochar = char;
using memval = unsigned char;
/* BF Memory Cell */
template <memval val = 0>
struct Cell {
enum { value = val };
View FastPatch.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Author: 黄龑(huangyan13@baidu.com)
# Created Time: 2016/08/18 14:23
# File Name: fast_patch.py
# Description:
#
# Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved
@FinalTheory
FinalTheory / divert_mem_pool.c
Last active Jan 24, 2016
Simple lock-free memory pool based on linked list
View divert_mem_pool.c
#include "divert_mem_pool.h"
#include <stdlib.h>
divert_mem_pool_t *divert_create_pool(size_t max_alloc) {
divert_mem_pool_t *pool =
calloc(sizeof(divert_mem_pool_t), 1);
if (pool == NULL) {
return NULL;
}
@FinalTheory
FinalTheory / CMakeLists.txt
Created Sep 24, 2015
C extension中发起新线程回调Python函数时未获取GIL导致core的演示代码
View CMakeLists.txt
cmake_minimum_required(VERSION 3.3)
project(demo)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2")
set(SOURCE_FILES demo.c)
# if you could not build successfully or error occured when importing nids
You can’t perform that action at this time.