Skip to content

Instantly share code, notes, and snippets.

@vladon
vladon / build_boost_1_60_0.txt
Last active May 18, 2018 14:20
Build Boost 1.60 on Linux and Windows
// linux:
sudo ./bootstrap.sh --with-toolset=clang
sudo ./b2 --reconfigure stage toolset=clang cxxflags="-std=c++1z -fPIC -O3 -Werror -Wno-unused-local-typedef -Wno-deprecated-declarations -Wno-unused-function" link=static,shared variant=release threading=multi linkflags="-fPIC" define=BOOST_SYSTEM_NO_DEPRECATED -q toolset=clang
-fPIC" define=BOOST_SYSTEM_NO_DEPRECATED -q
// windows:
bootstrap
b2 headers
Add this to /etc/apt/sources.list
<snip>
deb http://security.ubuntu.com/ubuntu precise-security main restricted
deb-src http://security.ubuntu.com/ubuntu precise-security main restricted
deb http://security.ubuntu.com/ubuntu precise-security universe
deb-src http://security.ubuntu.com/ubuntu precise-security universe
deb http://security.ubuntu.com/ubuntu precise-security multiverse
deb-src http://security.ubuntu.com/ubuntu precise-security multiverse
</snip>
@vladon
vladon / http_client.cpp
Created August 21, 2015 08:30
How to download from url and return contents as a string (using libcurl)
#include "http_client.h"
#include <memory>
std::string http_client::get_from_url(const std::string & a_url)
{
std::string result;
auto curl_deleter = [](CURL * curl_easy_handle)
{
@vladon
vladon / boost_asio_streambuf_to_string.cpp
Last active May 27, 2023 06:45
Returns `boost::asio::streambuf` contents represented as `std::string`
std::string buffer_to_string(const boost::asio::streambuf &buffer)
{
using boost::asio::buffers_begin;
auto bufs = buffer.data();
std::string result(buffers_begin(bufs), buffers_begin(bufs) + buffer.size());
return result;
}
@vladon
vladon / qt4_to_qt5
Created May 18, 2015 11:54
Transition from Qt4 to Qt5: one overloaded version of QPainter:drawPixmapFragments absent in Qt5
void drawPixmapFragments(QPainter *painter, const QRectF *targetRects, const QRectF *sourceRects, int fragmentCount,
const QPixmap &pixmap, QPainter::PixmapFragmentHints hints)
{
for (int i = 0; i < fragmentCount; ++i) {
QRectF sourceRect = (sourceRects) ? sourceRects[i] : pixmap.rect();
QPainter::PixmapFragment pixmapFragment =
QPainter::PixmapFragment::create(
targetRects[i].center(),
sourceRects[i],
@vladon
vladon / keybase.md
Created March 6, 2014 20:13
keybase.md

Keybase proof

I hereby claim:

  • I am vladon on github.
  • I am vladon (https://keybase.io/vladon) on keybase.
  • I have a public key whose fingerprint is D321 06EE 21C1 C49F 188C 7022 345B D262 014C E009

To claim this, I am signing this object: