This file contains 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
""" | |
The server code is based entirely on D. Beazley's talk "Topics of Interest (Python Asyncio)" | |
given in 2015 at the Python Brazil conference. | |
http://pyvideo.org/python-brasil-2015/keynote-david-beazley-topics-of-interest-python-asyncio.html | |
The server can handle 60,000 requests in 2.020 seconds (29,696 requests/second) in a ~2015 macOS. | |
""" |
This file contains 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 <atomic> | |
#include <functional> | |
#include <iostream> | |
#include <sstream> | |
#include <string> | |
#include <thread> | |
#include <vector> | |
#include <iterator> | |
#include <chrono> |
This file contains 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
// -*- coding:utf-8; mode:c++; mode:auto-fill; fill-column:80; -*- | |
/// @file SecureMemoryRegion.cpp | |
/// @brief Provide region of memory that never swaps to disk. | |
/// @author J. Arrieta <Juan.Arrieta@nablazerolabs.com> | |
/// @date October 15, 2017 | |
/// @copyright (c) 2017 Nabla Zero Labs | |
/// | |
/// $ clang++ -o SecureMemoryRegion SecureMemoryRegion.cpp -std=c++1z \ | |
/// -Wall -Wextra -Ofast -march=native |
This file contains 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
// I am interested in practical comparisons between C++ and Go. To this end, I | |
// find "good" Go code (by some definition of "good") and translate it into C++. | |
// | |
// It is mostly unimportant what the code does (in fact, it does not do anything | |
// at all). What matters is to attempt to capture the same API and semantics. | |
// | |
// This file implements a class called "Awareness" found in the hashicorp repo: | |
// | |
// https://github.com/hashicorp/memberlist/blob/master/awareness.go | |
// |
This file contains 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
package main | |
import ( | |
"crypto" | |
"crypto/rand" | |
"crypto/rsa" | |
"crypto/sha256" | |
"crypto/x509" | |
"encoding/pem" | |
"fmt" |
This file contains 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
# egg_drop.py | |
# | |
# Solution to the general egg drop problem via: | |
# | |
# 1. A recursive-memoized algorithm | |
# 2. A bottom-up table construction | |
# | |
# (C) 2017 J. Arrieta, Nabla Zero Labs | |
# MIT License. |
This file contains 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 <chrono> | |
#include <iostream> | |
#include <memory> | |
#include <string> | |
#include <thread> | |
#include <unordered_map> | |
#include <vector> | |
// In practice these would be actual types instead of aliases. | |
using Id = int; |
This file contains 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
/// Experiments with string view, dispatching, and stuff like that. | |
/// J. Arrieta | |
#include <algorithm> | |
#include <iomanip> | |
#include <iostream> | |
#include <locale> | |
#include <string> | |
// POSIX only | |
#include <sys/stat.h> |
This file contains 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 <cctype> | |
#include <fstream> | |
#include <iostream> | |
#include <iterator> | |
#include <sstream> | |
#include <stdexcept> | |
#include <string> | |
inline bool semantic_compare(std::size_t n, const char *value, | |
const std::string &s) { |
This file contains 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 <cassert> | |
#include <iostream> | |
#include <memory> | |
#include <type_traits> | |
#include <vector> | |
template <typename T> | |
class Pool { | |
public: | |
using Block = typename std::aligned_storage<sizeof(T), alignof(T)>::type; |