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 <iostream> | |
#include <thread> | |
#include <future> | |
#include <boost/asio.hpp> | |
using namespace std; | |
namespace asio = boost::asio; | |
int main() { |
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 of how to use boost::asio::async_result | |
#include <iostream> | |
#include <boost/asio.hpp> | |
#if BOOST_VERSION >= 106600 | |
template<typename CompletionToken> | |
typename boost::asio::async_result | |
<CompletionToken, void(boost::system::error_code, std::string)>::return_type |
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 <iostream> | |
#include <thread> | |
#include <vector> | |
using std::vector; | |
using std::string; | |
using std::make_shared; | |
// Compile using: | |
// # clang++ -stdlib=libc++ -std=c++11 -O0 -g -fsanitize=thread -lpthread -o test main.cpp |
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
use std::io::prelude::*; | |
use std::fs::File; | |
use std::thread; | |
macro_rules! iotry { | |
($e:expr) => (match $e { Ok(e) => e, Err(e) => panic!("{:?}", e) }) | |
} | |
fn writer(mut f: File) { | |
loop { |
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
1. alice.create-channel | | |
2. Room::new_channel X | | |
3. Room::joined_channel | | |
---------------------------------------------------------------------------------------- | |
4. | bob.search-channels | |
5. | Room::new_channel Y | |
6. | Ch::user_authenticated alice | |
---------------------------------------------------------------------------------------- | |
7. | bob.join-channel Y |
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
unbuf='stdbuf -i0 -o0 -e0' | |
function now { | |
date +'%M:%S' | |
} | |
# usage: ./my-program 1> >(prepend my-program-tag) 2>&1 & | |
function prepend { | |
while read line; do echo "`now` $1| $line"; done | |
} |
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
import okhttp3.*; | |
import okio.Buffer; | |
import javax.net.ssl.*; | |
import java.io.IOException; | |
import java.io.InputStream; | |
import java.security.GeneralSecurityException; | |
import java.security.KeyStore; | |
import java.security.cert.Certificate; | |
import java.security.cert.CertificateFactory; |