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
// About std::shared_ptr<T> aliasing constructor. | |
// J. Arrieta, Nabla Zero Labs. | |
// October 06, 2018. | |
// | |
// The std::shared_ptr<T> aliasing constructor has the signature | |
// | |
// template< class Y > | |
// shared_ptr(const shared_ptr<Y>& r, element_type* ptr) noexcept; | |
// | |
// According to cppreference.com, it "constructs a shared_ptr which shares |
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
// 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
#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
""" | |
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
""" | |
A brief explanation of WSGI middleware. | |
Nabla Zero Labs | |
""" | |
# The main WSGI application returns the string "Hello, {ip_address}!", where | |
# `ip_address` is the IP address of the host making the request. | |
def application(environ, start_response): | |
print("Main application") |
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
/* | |
A simple pattern for thread-safe, read-only access to an existing, fixed, | |
contiguous memory slice. | |
This pattern is useful when simple chunking would be undesirable. For example: | |
A job may consist of three hard (H) tasks, each lasting two seconds, and three | |
easy (E) tasks, each lasting one second. If we simply pass the first three to | |
one thread, and the last three to a second thread, the second thread will | |
finish after three seconds, and leave the first thread to finish six seconds | |
worth of work. (total runtime: six seconds). The proposed approach would take |
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
/* | |
This program implements a lexer for the Object Description Language (ODL), a legacy metadata format | |
used by NASA's Planetary Data System (PDS). | |
As of this writing, the ODL version is 2.1, and the specification can be found in: | |
https://pds.jpl.nasa.gov/documents/sr/Chapter12.pdf | |
This lexer simply emits the tokens needed by an ODL parser, which is provided as a separate program. |
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
""" | |
knapsack.py | |
Solve small knapsack problems by different methods. | |
(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
def T(n): | |
memo = { | |
1 : (0, "<Base>"), | |
2 : (1, " / 2"), | |
3 : (1, " / 3") | |
} | |
def build_memo(n): |