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 <iostream> | |
#include <map> | |
#include <numeric> | |
#include <set> | |
#include <vector> | |
using Graph = std::vector<std::set<int>>; | |
using Coloring = std::vector<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
// Educational implementation of a k-d tree. | |
#include <algorithm> | |
#include <array> | |
#include <iostream> | |
#include <random> | |
#include <stdexcept> | |
#include <string> | |
#include <vector> |
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
// clang-format off | |
/* | |
Basic example showing how could one implement a table-driven state machine in | |
C++. | |
Suppose one has a lamp which can be in one of three states: "Off", "On", | |
"Blink". At any time and via some mechanism, the lamp can trigger two events: | |
"Switch Off" or "Switch On". |
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
// slurp-test.cpp. | |
// | |
// Benchmark several methods to read a file into a C++ std::string. Partly based | |
// on the answers to my question: | |
// | |
// https://stackoverflow.com/questions/2602013/read-whole-ascii-file-into-c-stdstring | |
// | |
// asked on April 08, 2010. | |
// | |
// Tests on several files with different sizes (from a few bytes to a couple of |
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
// Example that shows some coding conventions regarding the use of virtual | |
// functions in C++. | |
// (C) 2020 Nabla Zero Labs | |
// MIT License | |
// Contents of "config.hpp" or similar -- a header containing some build | |
// configuration compile-time constants. | |
namespace nzl { | |
namespace config { | |
static constexpr const auto debug = true; // whether to build in debug mode |
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
// Example Polymorphic Memory Resource (std::pmr) Monotonic Buffer Resource. | |
// J. Arrieta, Nabla Zero Labs | |
// | |
// * Pre-allocate two buffers, one with space for 2 chars and one with space for 256 chars. | |
// * Filled pre-allocated buffers with underscores to peek into them later and see where memory was touched. | |
// * Create two monotonic_buffer_resources, one for each buffer. | |
// * Notice that the main pool receives a pointer to the "backup" pool. | |
// * Create a vector of char that uses the main memory resource. | |
// * Push back on the vector all chars from 'a' to 'z'. | |
// * See how the first char was allocated using the first memory resource (pool). |
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
/// @file make_canonical.hpp | |
/// @brief Transform strings into a canonical representation. | |
/// @author J. Arrieta <[email protected]> | |
/// @copyright (C) 2019 Nabla Zero Labs | |
/// @license MIT | |
#pragma once | |
#include <algorithm> | |
#include <cctype> |
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
/// @file timestamp.hpp | |
/// @brief Return UNIX timestamp. | |
/// @author J. Arrieta <[email protected]> | |
/// @copyright (C) 2019 Nabla Zero Labs | |
/// @license MIT | |
#pragma once | |
#include <chrono> | |
#include <cstdint> |
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 <cerrno> | |
#include <cstdio> | |
#include <cstring> | |
#include <sstream> | |
#include <chrono> | |
#include <sys/types.h> | |
#include <sys/socket.h> | |
#include <netdb.h> | |
#include <unistd.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
// Sample code used to generate a cryptographic key pair via an AWS Lambda function. | |
// (C) 2019 Nabla Zero Labs | |
// MIT License | |
package main | |
import ( | |
"crypto/rand" | |
"crypto/rsa" | |
"crypto/x509" |
NewerOlder