This file contains hidden or 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 <stdio.h> | |
| #include <stdint.h> | |
| #include <stdbool.h> | |
| // --------------------------------------------------------- | |
| // 1. 跨平台的硬件位扫描辅助函数 (用于替代 if-else 分支) | |
| // --------------------------------------------------------- | |
| #if defined(_MSC_VER) && !defined(__clang__) | |
| #include <intrin.h> | |
| #pragma intrinsic(_BitScanReverse64) |
This file contains hidden or 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 <boost/asio.hpp> | |
| #include <boost/asio/co_spawn.hpp> | |
| #include <boost/asio/detached.hpp> | |
| #include <boost/asio/use_awaitable.hpp> | |
| #include <iostream> | |
| #include <chrono> | |
| #include <thread> | |
| #include <sstream> | |
| #include <iomanip> |
This file contains hidden or 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 | |
| """由 OpenSSL 的 Configure/Makefile 生成可用于 add_subdirectory 的 CMakeLists.txt。 | |
| 生成的 CMake 在配置阶段按目标平台/架构选择源文件清单与 perlasm 方案, | |
| 在构建阶段用 perl 生成汇编源,因此同一份 CMakeLists.txt 配合已提交的 | |
| 生成头文件即可适配 linux/macos/windows 上的 x86_64/x86/aarch64/arm。 | |
| macOS universal(多架构)或缺少 perl/nasm 时自动回退到纯 C 实现。 | |
| """ | |
| import os | |
| import re |
This file contains hidden or 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
| std::vector<uint8_t> data = | |
| { | |
| 0x00, 0x00, 0xed, 0x01, 0x04, 0x00, 0x00, 0x00, 0x01, 0x3f, 0xe1, 0x3f, 0x88, 0x61, 0x96, 0xdc, 0x34, 0xfd, 0x28, 0x17, 0x54, 0xca, 0x3a, 0x94, 0x10, 0x04, 0xe2, 0x81, 0x72, 0xe3, 0x6d, 0x5c, 0x03, 0x8a, 0x62, 0xd1, 0xbf, 0x5f, 0x87, 0x49, 0x7c, 0xa5, 0x89, 0xd3, 0x4d, 0x1f, 0x6c, 0x96, 0xdc, 0x34, 0xfd, 0x28, 0x26, 0xd4, 0xd4, 0x44, 0xa8, 0x20, 0x09, 0xb5, 0x00, 0xf5, 0xc6, 0x9d, 0xb8, 0x16, 0x94, 0xc5, 0xa3, 0x7f, 0x0f, 0x13, 0x8c, 0xfe, 0x5c, 0x7a, 0x52, 0x3c, 0x57, 0xc4, 0xb0, 0x5e, 0x8d, 0xaf, 0xe7, 0x52, 0x84, 0x8f, 0xd2, 0x4a, 0x8f, 0x0f, 0x0d, 0x83, 0x71, 0x91, 0x35, 0x40, 0x8f, 0xf2, 0xb4, 0x63, 0x27, 0x52, 0xd5, 0x22, 0xd3, 0x94, 0x72, 0x16, 0xc5, 0xac, 0x4a, 0x7f, 0x85, 0x02, 0xe0, 0x00, 0x99, 0x77, 0x78, 0x8c, 0xa4, 0x7e, 0x56, 0x1c, 0xc5, 0x81, 0x90, 0xb6, 0xcb, 0x80, 0x00, 0x3f, 0x76, 0x86, 0xaa, 0x69, 0xd2, 0x9a, 0xfc, 0xff, 0x40, 0x85, 0x1d, 0x09, 0x59, 0x1d, 0xc9, 0x8f, 0x9d, 0x98, 0x3f, 0x9b, 0x8d, 0x34, 0xcf, 0xf3, 0xf6, 0xa5, 0x23, 0x81, 0x97, 0x00, 0x0f, 0x7 |
This file contains hidden or 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
| // g++ -std=c++23 foo.cpp -lssl -lcrypto -lnghttp2 -lpthread | |
| #include <boost/assert.hpp> | |
| #include <boost/asio.hpp> | |
| #include <boost/asio/ssl.hpp> | |
| #include <nghttp2/nghttp2.h> | |
| #include <atomic> | |
| #include <cstring> | |
| #include <deque> | |
| #include <iostream> |
This file contains hidden or 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
| import * as net from 'net'; | |
| // TCP 连接类,仅处理发送和接收 | |
| export class TcpConnection { | |
| // Socket 由外部传入 | |
| private socket: net.Socket; | |
| // 存储接收到的数据 | |
| private buffer: Buffer; | |
| // 读取数据限制, 0 表示无限制 | |
| private readLimit: number; |
This file contains hidden or 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
| // | |
| // jsonrpc.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) | |
| // |
This file contains hidden or 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
| /* | |
| * 需要安装以下依赖: | |
| * yarn add ethers bitcoinjs-lib ecpair tiny-secp256k1 bs58 | |
| * yarn add @types/bitcoinjs-lib @types/ecpair @types/tiny-secp256k1 @types/bs58 | |
| * yarn add ts-node typescript | |
| */ | |
| import { ethers } from 'ethers'; | |
| import { ECPairFactory } from 'ecpair'; | |
| import bitcoin from 'bitcoinjs-lib'; |
This file contains hidden or 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 <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" |
This file contains hidden or 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
| #pragma once | |
| #include <coroutine> | |
| #include <functional> | |
| #include <type_traits> | |
| #if defined(DEBUG) || defined(_DEBUG) | |
| #include <unordered_set> | |
| std::unordered_set<void*> global_crors; | |
| #endif |
NewerOlder