Skip to content

Instantly share code, notes, and snippets.

View nlyan's full-sized avatar

Andrew Nelless nlyan

  • London, England
View GitHub Profile
@nlyan
nlyan / with.cc
Last active January 18, 2016 21:39
Pythons 'with' statement in C++
#include <type_traits>
template <template <typename...> class With, typename T> inline
decltype(auto)
make_with_guard (T& value) {
return With<T>(value);
}
#define PP_CAT(A, B) PP_CAT_X(A, B)
#define PP_CAT_X(A, B) A ## B
@nlyan
nlyan / build_openssl_dylib.sh
Created January 4, 2017 08:52 — forked from tmiz/build_openssl_dylib.sh
Build latest OpenSSL Universal Binary on OSX
#!/bin/bash
OPENSSL_VERSION="1.0.1g"
curl -O http://www.openssl.org/source/openssl-$OPENSSL_VERSION.tar.gz
tar -xvzf openssl-$OPENSSL_VERSION.tar.gz
mv openssl-$OPENSSL_VERSION openssl_i386
tar -xvzf openssl-$OPENSSL_VERSION.tar.gz
mv openssl-$OPENSSL_VERSION openssl_x86_64
cd openssl_i386
[andrew@zuul network]$ cat guest.network
[Match]
Name=guest0
[Network]
Address=192.168.3.1/24
[andrew@zuul network]$ cat guest0.netdev
[NetDev]
Name=guest0
Kind=vlan
#include <type_traits>
#include <algorithm>
#include <iterator>
#include <stdexcept>
#include <cassert>
#include <cstring>
#include <endian.h>
// TODO: Add 2 byte, 4 byte read_le
// Check everything works with other word sizes.
@nlyan
nlyan / variant.cpp
Last active September 21, 2017 23:23
#include <boost/mpl/at.hpp>
#include <boost/mpl/size.hpp>
#include <boost/variant/variant.hpp>
#include <type_traits>
namespace {
template <size_t N>
struct emplace_nth_helper {
template <typename Variant>
#include <boost/mpl/at.hpp>
#include <boost/mpl/size.hpp>
#include <boost/variant/variant.hpp>
#include <type_traits>
namespace {
template <size_t N>
struct emplace_nth_helper {
template <typename Variant, typename Transform>
template <typename T>
std::enable_if_t<std::is_base_of<flatbuffers::NativeTable, T>::value,
boost::system::error_code>
operator() (tcp::socket& socket, Message::Header const& header, T& body,
asio::yield_context ctx) const {
boost::system::error_code ec;
/* TODO: Inefficient and dangerous, huzzah! */
std::vector<unsigned char> buffer;
template <typename BufferSequence>
auto
async_write (tcp::socket& socket, BufferSequence const& buffers) {
struct Awaitable {
tcp::socket& socket;
BufferSequence const& buffers;
boost::system::error_code ec;
bool
await_ready () {
RFCs
====
RFC 1035 : Domain names - implementation and specification, November 1987
RFC 2181 : Clarifications to the DNS Specification, July 1997
- defines an "RRSet" as combination of class, name and type.
- deprecates differing TTLs within an RRSet, says should be treated as
an error.
- defines the "origin" as the child name just below the zone cut:
"The name of the zone is the same as the name of the domain
at the zone's origin."
/* Outputs:
Serialized Bytes: 464
Bids: [
{3, 0, 100},
{1, 1.13, 1000},
{2, 1.12, 500},
{4, 1.12, 250}
]
Asks: [