This file contains 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
# Define where to store the generated certs and metadata. | |
DIR="$(pwd)" | |
# Create the openssl configuration file. This is used for both generating | |
# the certificate as well as for specifying the extensions. It aims in favor | |
# of automation, so the DN is encoding and not prompted. | |
cat > "${DIR}/openssl.cnf" << EOF | |
[req] | |
default_bits = 2048 |
This file contains 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 <map> | |
template <typename CT=char, typename=std::enable_if_t<std::is_same_v<CT,char>>> | |
class Printer { | |
private: | |
template<typename T> | |
class _has_to_string { | |
template<typename U> | |
static constexpr bool _help(decltype(&U::to_string)) noexcept { return true; } | |
template<typename U> |
This file contains 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
// only works on linux | |
// c++17 standard required | |
// g++-8 -g -std=c++17 -Wl,-E foo.cpp -ldl | |
#include <any> | |
#include <cxxabi.h> | |
#include <dlfcn.h> | |
#include <functional> | |
#include <iostream> | |
#include <map> | |
#include <memory> |
This file contains 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
#ifndef UTIL_VARIANT_HPP | |
#define UTIL_VARIANT_HPP | |
#include <type_traits> | |
#include <memory> | |
#include <tuple> | |
#if __cplusplus >= 201703L | |
#include <variant> |
This file contains 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 python3 | |
import sys | |
import re | |
import json | |
import hashlib | |
import itertools | |
import binascii | |
LANGUAGES = ['zh_CN', 'en_US', ] |
This file contains 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 <typename F> | |
struct curry_wrapped {}; | |
template <typename R> | |
struct curry_wrapped<std::function<R()>> { | |
std::function<R()> _f; | |
// Calling with no parameters ==> call original function directly | |
// 无参调用 ==> 直接调用原函数 | |
inline R operator()() { | |
return _f(); |
This file contains 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
class Dispatcher: | |
def __init__(self): | |
self.tasks = [] | |
def reg_task(self, t): | |
self.tasks.append(t) | |
def run(self): | |
while len(self.tasks): | |
for t in self.tasks: |
This file contains 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 <tuple> | |
using ElementType = size_t; | |
template<ElementType ... es> | |
class SetValidator { | |
protected: | |
static inline constexpr auto cs_ = std::make_tuple(es...); | |
template<size_t _i, size_t _j> | |
static constexpr bool cmp_() { |
This file contains 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 <utility> | |
#include <type_traits> | |
template<typename T> | |
struct comparable { | |
virtual const T value() const = 0; | |
}; | |
template<typename T> |
This file contains 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
// | |
// Created by pnck on 2018/11/19. | |
// | |
#include <type_traits> | |
#include <iostream> | |
#include <functional> | |
#include <random> | |
#include <list> | |
#include <deque> |