Skip to content

Instantly share code, notes, and snippets.

View mloskot's full-sized avatar
🏠
Working from home

Mateusz Łoskot mloskot

🏠
Working from home
View GitHub Profile
@mloskot
mloskot / image_read_iterator-blueprint.hpp
Created November 7, 2011 11:36
Christian brainstorming image_read_iterator for Boost.GIL
// Christian Henning's original: http://pastebin.com/Qk3ssZc8
namespace boost { namespace gil {
template< typename Reader
, typename View
>
class image_read_iterator
{
public:
@mloskot
mloskot / boost_property_tree_json_array.cpp
Created December 22, 2011 11:11
Simple example of parsing and consuming JSON array with boost::property_tree
#ifdef _MSC_VER
#include <boost/config/compiler/visualc.hpp>
#endif
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/json_parser.hpp>
#include <boost/foreach.hpp>
#include <cassert>
#include <exception>
#include <iostream>
#include <sstream>
@mloskot
mloskot / moveable_base_animal.cpp
Created January 13, 2012 16:00
Moveable semantic fun
#include <iostream>
#include <string>
#include <utility>
#include <boost/noncopyable.hpp>
struct animal : private boost::noncopyable
{
animal() {}
animal(char const* name) : name(name) {}
@mloskot
mloskot / empty_equals_empty.cs
Created January 14, 2012 00:15
Check equality of EMPTY geometries using SqlGeometry from SQL Server CLR Types
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.SqlServer.Types;
namespace csharp
{
class Program
@mloskot
mloskot / spirit_fusion_vector_optional.cpp
Created March 29, 2012 10:37
Boost.Spirit - fusion::vector as attribute with optional elements
// Version fixed by VeXocide
// Test case based on solution discussed here:
// http://thread.gmane.org/gmane.comp.parsers.spirit.general/24684/focus=24688
#include <boost/config/warning_disable.hpp>
#include <boost/spirit/include/qi.hpp>
#include <boost/fusion/include/vector.hpp>
namespace qi = boost::spirit::qi;
@mloskot
mloskot / smart_ptr_bad_bool_conversion.cpp
Created April 18, 2012 11:21
Smart pointer example with mis-use of bool conversion
// Interesting issue about conversion operators in C++
//http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1592.pdf
#include <iostream>
template <class T>
class Ptr
{
// stuff
public:
/* For NAN */
#ifdef __GNUC__
#define _GNU_SOURCE
#endif
#include <math.h>
@mloskot
mloskot / boost_gil_issue_with_interleaved_ptr.cpp
Created October 10, 2012 15:06
How to use Boost.GIL views attached to bytes array with interleaved_ptr, versus view constructed with cast to pixel type
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Problem reported to Boost mailing list: http://thread.gmane.org/gmane.comp.lib.boost.devel/234991
//
// How to use Boost.GIL views attached to bytes array with interleaved_ptr,
// versus view constructed with cast to pixel type
//////////////////////////////////////////////////////////////////////////////////////////////////////
std::size_t w = 512;
std::size_t h = 256;
std::size_t sizeRow = 1536; // calculated for Windows DIB
std::size_t sizeImage = sizeRow * h;
@mloskot
mloskot / cheat-tmux.markdown
Created December 14, 2012 13:11
tmux key bindings cheat shee

$ cheat tmux

Managing tmux sessions

$ tmux      # start tmux server
$ tmux at   # attach running sessions to a terminal
$ tmux ls # list running tmux sessions