Skip to content

Instantly share code, notes, and snippets.

#pragma once
#include <boost/optional.hpp>
namespace util {
namespace shared_value_detail {
using boost::optional;
// Some values that we'd like to put into shared_value don't have the move
#pragma once
#include <boost/optional.hpp>
namespace util {
namespace shared_value_detail {
using boost::optional;
// Some values that we'd like to put into shared_value don't have the move
@inetic
inetic / CustomTrust.java
Created September 7, 2018 14:23 — forked from reline/CustomTrust.java
Trusting self-signed certificates in Android using OkHttp
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;
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
}
@inetic
inetic / np1sec
Last active November 11, 2016 09:00
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
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 {
#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
@inetic
inetic / async_result.cpp
Last active September 7, 2024 09:44
Example usage of boost::asio::async_result
// 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
#include <iostream>
#include <thread>
#include <future>
#include <boost/asio.hpp>
using namespace std;
namespace asio = boost::asio;
int main() {