Skip to content

Instantly share code, notes, and snippets.

@icylord
icylord / lzma2_xz_compress.cc
Created February 9, 2018 08:33 — forked from ArtemGr/lzma2_xz_compress.cc
liblzma: compress (g)string into (g)string
#include <lzma.h> // http://tukaani.org/xz/
#include <memory> // unique_ptr
#include <stdexcept> // runtime_error
#include <glim/gstring.hpp> // Here glim::gstring can be replaced with std::string.
using glim::gstring;
static void xzCompress (const gstring& from, gstring& to) {
// See also LZMA example at: http://git.tukaani.org/?p=xz.git;a=blob;f=doc/examples/01_compress_easy.c
lzma_stream strm = LZMA_STREAM_INIT;
std::unique_ptr<lzma_stream, void(*)(lzma_stream*)> freeStream (&strm, lzma_end);
#include <asio.hpp>
#include <asio/ssl.hpp>
#include <algorithm>
#include <atomic>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <memory>
#include <thread>
@icylord
icylord / client.cpp
Created September 24, 2017 02:09 — forked from yayj/client.cpp
ASIO ping-pong test modification for io_service per thread.
//
// client.cpp
// ~~~~~~~~~~
//
// Copyright (c) 2003-2012 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//

现整理收集C++世界里那些“牛人”的个人博客。凡三类:一是令人高山仰止的大牛,对C++语言本身产生过深远的影响的人;二是C++运用炉火纯青的高手,有原创性的技术干货;三是中文世界里的C++牛人。

C++大牛的博客

@icylord
icylord / Makefile
Created June 24, 2017 14:04 — forked from sehe/Makefile
Boost shared memory lockfree circular buffer queue
all:consumer producer
CPPFLAGS+=-std=c++03 -Wall -pedantic
CPPFLAGS+=-g -O0
CPPFLAGS+=-isystem ~/custom/boost/
LDFLAGS+=-L ~/custom/boost/stage/lib/ -Wl,-rpath,/home/sehe/custom/boost/stage/lib
LDFLAGS+=-lboost_system -lrt -lpthread
%:%.cpp
@icylord
icylord / cluster
Created July 4, 2014 01:19 — forked from jdeng/cluster
// generate [0..n-1]
auto seq = [](size_t n) -> std::vector<size_t> {
std::vector<size_t> v(n);
for (size_t i=0; i<n; ++i) v[i] = i;
return v;
};
auto index = seq(n);
// n * n distance matrix
std::vector<D> dists(n * n);