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 <iostream> | |
#include <Imlib2.h> | |
int main(int argc, char **argv) { | |
if(argc != 2) { | |
fprintf(stderr, "%s: usage: <image>\n", argv[0]); | |
return 1; | |
} | |
Imlib_Image img; |
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
template <typename T> | |
concept requires_checksum = requires (T a, void *b, ptrdiff_t c, size_t d) { | |
{ a.do_checksum(b, c, d) } -> std::same_as<void>; | |
}; | |
template <typename ...Args> | |
mem::buffer build_packet(Args &&...args) { | |
size_t total_size; | |
auto parts = frg::make_tuple(std::forward<Args>(args)...); |
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 <iostream> | |
#include <string.h> | |
#include <sys/socket.h> | |
#include <sys/un.h> | |
#include <time.h> | |
#include <inttypes.h> | |
#include <unistd.h> | |
#include <atomic> | |
#include <sys/wait.h> |
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
struct timerfd final : file { | |
static auto create_timer(reactor *rtor_) { | |
return new timerfd{rtor_}; | |
} | |
timerfd(reactor *rtor) | |
: file{rtor, timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK)}, current_{} { } | |
// ---------------------------------------------------------------------------------- | |
// Sleep boilerplate. |
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
struct line_iterator { | |
line_iterator(std::string_view sv) | |
: sv_{sv} {} | |
struct iter { | |
iter &operator++() { | |
std::string_view sv = o_->sv_.substr(i_); | |
auto newl = sv.find('\n'); | |
n_++; |
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 <iostream> | |
#include <string_view> | |
#include <cctype> | |
#include <array> | |
#include <cassert> | |
struct insn { | |
uint8_t op = 0; | |
uint8_t arg = 0; |
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
/* | |
* compile with: g++ gorbitsa.cpp -o gorbitsa -ftemplate-depth=99999999 -std=c++2a | |
* Tested with GCC 10.1, does *not* work with Clang 10 | |
*/ | |
#include <iostream> | |
#include <string_view> | |
#include <cctype> | |
#include <array> | |
#include <type_traits> |
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
while (sock->connected()) { | |
auto b = co_await sock->recv(); | |
frg::string_view req{static_cast<char *>(b.data()), b.size()}; | |
size_t newl = req.find_first('\n'); | |
auto http_req = req.sub_string(0, newl); | |
auto s1 = http_req.find_first(' '); | |
auto s2 = http_req.find_last(' '); |
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
/* | |
Requires compiler with C++20 concept support (GCC 10.1/Clang 10 or newer) | |
*/ | |
#include <unordered_map> | |
#include <concepts> | |
#include <iostream> | |
#include <variant> | |
#include <string> | |
#include <vector> |
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
/* | |
* compile with: g++ gorbitsa.cpp -o gorbitsa -ftemplate-depth=99999999 -std=c++2a | |
* Tested with GCC 10.1, does *not* work with Clang 10 | |
*/ | |
#include <iostream> | |
#include <string_view> | |
#include <cctype> | |
#include <array> | |
#include <type_traits> |