Skip to content

Instantly share code, notes, and snippets.

@Jackarain
Jackarain / stackoverflow.cpp
Last active December 17, 2024 15:56
async_simple 的爆栈问题测试代码
#include <algorithm>
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include "async_simple/coro/Lazy.h"
#include "async_simple/coro/SyncAwait.h"
// asio_coro_util.hpp 在 demo_example 下, 这里仅仅为了调用 AsioCallbackAwaiter 这个简单的 Awaiter 而已.
#include "asio_coro_util.hpp"
@Jackarain
Jackarain / awaitable.hpp
Last active September 29, 2024 13:52
c++ 20 协程简易实现
#pragma once
#include <coroutine>
#include <functional>
#include <type_traits>
#if defined(DEBUG) || defined(_DEBUG)
#include <unordered_set>
std::unordered_set<void*> global_crors;
#endif
@Jackarain
Jackarain / ssl_stream.hpp
Created November 25, 2023 08:06
基于 c++ 20 的 boost asio ssl_stream 实现
//
// ssl_stream.hpp
// ~~~~~~~~~~~~~~
//
// Copyright (c) 2023 Jack (jack dot wgm at gmail dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
@Jackarain
Jackarain / print_data_len.cpp
Created November 22, 2023 15:36
print_data_len
void print_data_len(const std::vector<uint8_t>& data, uint16_t target_len = 0x7FFF)
{
if (data.size() < 4) {
std::cerr << "数据长度小于4,无法转换为 uint16_t。" << std::endl;
return;
}
std::cout << "print len: " << data.size() << "\n";
uint16_t p1 = 0;
@Jackarain
Jackarain / logging.hpp
Last active August 16, 2022 14:47
一个现代c++实现的日志库
//
// Copyright (C) 2019 Jack.
//
// Author: jack
// Email: jack.wgm at gmail dot com
//
#pragma once
#include <version>
#include <codecvt>
//
// yield_cancellation_slot_bind.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2019 Jack (jack dot wgm at gmail dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
@Jackarain
Jackarain / async_connect.hpp
Last active September 3, 2022 13:06
Happy Eyeballs support
//
// async_connect.hpp
// ~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2019 Jack (jack dot wgm at gmail dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
@Jackarain
Jackarain / yield_cancellation_slot_bind.hpp
Created March 7, 2022 04:22
用于 asio 的 basic_yield_context 绑定 cancellation 信号
//
// yield_cancellation_slot_bind.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2019 Jack (jack dot wgm at gmail dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
@Jackarain
Jackarain / command key map
Last active January 11, 2022 20:12
Command autohotkey 键映射
#c::
Send,^{c}
Return
#v::
Send,^{v}
Return
#s::
Send,^{s}
@Jackarain
Jackarain / multipart.hpp
Last active September 13, 2021 06:25
This is a parser for multipart written in C++
//
// Copyright (C) 2021 Jack.
//
// Author: jack
// Email: jack.wgm at gmail dot com
//
#pragma once
#include <boost/exception/all.hpp>