Skip to content

Instantly share code, notes, and snippets.

View oliora's full-sized avatar

Andrey Upadyshev oliora

View GitHub Profile
@oliora
oliora / pseudo_fork.cpp
Last active August 29, 2015 14:07
pseudo fork with C++11
void func_with_fork()
{
// local vars
auto r = std::async(std::launch::async, [&]() {
// forked thread code
});
// main thread code
#include <iostream>
template<typename T>
struct Foo
{
void do_something();
Foo()
{
std::cout << "ctor" << std::endl;
@oliora
oliora / str_range.hpp
Created August 13, 2013 22:04
Sample of different template specialization for raw array and ptr (const char[N] and const char *).
template<typename T>
struct StrRange;
template<size_t N>
struct StrRange<const char[N]>
{
typedef const char * ConstIterator;
StrRange(const char (&t)[N])
: m_begin(t)
@oliora
oliora / echo.bat
Created February 13, 2013 13:19
How to echo text from batch-file without end of line
(echo %version%) > version.txt
@oliora
oliora / gist:4944368
Created February 13, 2013 12:45
Bug in batch-file processing: close parenthesis in echo treated as code block close
@echo off
if 1==0 (
echo first build (debug)
echo second build (release)
)
@oliora
oliora / something.i
Created September 3, 2012 08:08
SWIG interface with using of Python callable as callback
%module(threads="1") something
%{
// Register a callback (called from Python code)
// callbackFunc is a Python callable accepting one argument
void registerHandler(PyObject *callbackFunc)
{
SWIG_PYTHON_THREAD_BEGIN_ALLOW;
const bool hasCallback =