Skip to content

Instantly share code, notes, and snippets.

View madmongo1's full-sized avatar

Richard Hodges madmongo1

View GitHub Profile
//
// main.mm
// foo2
//
// Created by Richard Hodges on 21/09/2016.
// Copyright © 2016 Richard Hodges. All rights reserved.
//
#include <vector>
#import <Foundation/Foundation.h>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
struct IO
{
std::istream& input;
std::ostream& output;
std::ostream& error;
// for exposition - a custom variant might be better
#include <variant>
#include <tuple>
// some library constructs
namespace compose
{
struct continue_op_t {
};
constexpr auto continue_op = continue_op_t {};
auto stream = http::request_stream();
co_await stream.async_connect(url, http::get);
auto&& header = stream.header();
std::string store;
auto bytes =
co_await net::async_read(stream, net::dynamic_buffer(store));
@madmongo1
madmongo1 / read.hpp
Created April 9, 2020 19:57
Here's what I mean...
template<
class Stream, class DynamicBuffer,
class ParserType>
struct read_msg_op
: public asio::coroutine
, public enable_stable_storage
{
using parser_type = ParserType;
using message_type =
@madmongo1
madmongo1 / daft_hash.cpp
Created April 20, 2020 12:44
Minecraft hash
/*
* HEADER FILE
*/
//
// Copyright (c) 2020 Richard Hodges (hodges.r@gmail.com)
//
// Official repository: https://github.com/AlexAndDad/gateway
//
#pragma once
//
// Copyright (c) 2020 Richard Hodges (hodges.r@gmail.com)
// Copyright (c) 2020 Alexander Hodges
//
// Official repository: https://github.com/AlexAndDad/gateway
//
#pragma once
#include "polyfill/net.hpp"
template<class T> struct identity {};
template < class... Ts >
struct for_all_types_impl;
template <>
struct for_all_types_impl<>
{
template<class...Args>
bool operator()(Args&&...) const { return false; };
template < class NextLayer >
struct server_accept_op : server_accept_op_base
{
using stream_type = stream< NextLayer >;
server_accept_op(stream_type &stream, server_accept_state &state)
: server_accept_op_base(state)
, stream(stream)
{
}
#pragma once
#include <string_view>
// DEPENDENCY: ORDER wise_enum after string_view
#include "wise_enum/wise_enum.h"
#include <fmt/format.h>
#include <string>
#include <type_traits>
namespace config