Skip to content

Instantly share code, notes, and snippets.

View mpapierski's full-sized avatar

Michał Papierski mpapierski

View GitHub Profile
@mpapierski
mpapierski / properties.cxx
Created February 25, 2012 02:30
Properties with getter/setter function calls
// Properties with getter/setter function calls
//
// Copyright 2011 Michał Papierski <michal@papierski.net>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
@mpapierski
mpapierski / appserver.cxx
Created February 25, 2012 02:35
Write GUI applications in a compile-time abstract language
// Write GUI applications in an compile-time abstract language
//
// Copyright 2011 Michał Papierski <michal@papierski.net>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
@mpapierski
mpapierski / web.py
Created February 25, 2012 02:47
Yet another very general open source python web framework
import sys
import re
from StringIO import StringIO
import BaseHTTPServer
def home_page():
''' Home page '''
import random
print 'Hello world'
@mpapierski
mpapierski / 99bottles.cpp
Created May 18, 2013 23:33
having fun with C++ metaprogramming and 99 bottles of beer.
#include <cstdlib>
#include <cstdio>
template <int N>
struct bottles;
template <>
struct bottles<100>
{
};
@mpapierski
mpapierski / gist:5653957
Created May 26, 2013 20:43
im not sure why i wrote this
#include <cstdlib>
#include <iostream>
#include <queue>
#include <stdexcept>
struct policy
{
};
struct allocator: policy
@mpapierski
mpapierski / gist:5687079
Created May 31, 2013 18:49
this is how libxml++ should look like
#include <iostream>
#include <libxml/parser.h>
#include <libxml/tree.h>
#include <libxml/HTMLtree.h>
struct xml_attribute
{
xmlNodePtr node_;
std::string key_;
xml_attribute(xmlNodePtr node, std::string const & key)
#include <stdexcept>
#include <boost/type_traits.hpp>
#include <boost/utility/enable_if.hpp>
class binstream
{
public:
struct str
{
inline str(char * & output, std::size_t length)
@mpapierski
mpapierski / linq.cpp
Created August 10, 2013 15:57
sql-like syntax for standard library containers
#include <iostream>
#include <string>
#include <boost/tuple/tuple.hpp>
#include <boost/utility.hpp>
#include <vector>
#include <boost/typeof/typeof.hpp>
#include <boost/foreach.hpp>
struct person
{
@mpapierski
mpapierski / CMakeLists.txt
Created August 27, 2013 18:18
cgicc 3.2.10 cmakified.
#
# cgicc 3.2.10 cmakified
# by Michal Papierski <michal@papierski.net>
#
cmake_minimum_required (VERSION 2.8.7)
project (cgicc)
set (VERSION "3.2.10")
execute_process (COMMAND "(hostname || uname -n) 2>/dev/null | sed 1q"
RESULT_VARIABLE HOST)
@mpapierski
mpapierski / asio_sendfile.cpp
Last active November 7, 2021 19:36
boost.asio + sendfile(2)
// how to use boost.asio + sendfile(2)
// Michał Papierski <michal@papierski.net>
#include <iostream>
#include <string>
#include <boost/asio.hpp>
#include <boost/make_shared.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/ref.hpp>
#include <boost/bind.hpp>
#include <boost/enable_shared_from_this.hpp>