Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
# -*- coding: utf-8 -*-
""" задачка """
a = [1,2,3]
def aggregator(accum, item):
""" пример ф-ции 'аккумулятора' для обработки части данных в распределённом фрейморке
//ldflags="-lboost_filesystem -lboost_system"
#include <iostream>
#include <locale>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
#include <boost/utility/string_ref.hpp>
#include <boost/filesystem.hpp>
#include <boost/algorithm/string.hpp>
@gruzovator
gruzovator / inotify_monitor.cpp
Last active July 18, 2016 19:36
inotify files modifications monitor
/** files modifications monitoring via inotify
Attention: inotify monitoring of a file have some problems.
E.g. some editors rm then creates files with sthe same name when editing.
So, it's a more robust to monitor entire dir
*/
#include <iostream>
#include <string>
#include <functional>
#include <stdexcept>
@gruzovator
gruzovator / py-logging-config-example.py
Created May 5, 2015 05:27
Python logging configuration exqample
#!/usr/bin/env python
# -*- coding: utf-8 -*-
""" source: http://www.lexev.org/en/2013/python-logging-every-day/
Settings for root logger.
Log messages will be printed to console and also to log file (rotated, with
specified size). All log messages from used libraries will be also handled.
Three approaches for defining logging settings are used:
@gruzovator
gruzovator / pyhdfs_test.py
Created April 21, 2015 06:50
PyHDFS test
#!/usr/bin/env python
# -*- coding: utf-8 -*-
""" Script to test WebHDFS (pyhdfs python lib)
2015-04-21
"""
import argparse
import sys
import os
import re
@gruzovator
gruzovator / ptree_perfomance.cpp
Last active August 29, 2015 14:17
test xml via boost ptree generation
// cxx="g++" cxxflags="-O2"
/**
Test boost ptree perfomance.
2015-03-27
*/
#include <iostream>
#include <vector>
@gruzovator
gruzovator / format.sh
Last active August 29, 2015 14:15
clang-format
#!/bin/sh
# style lines can be copied to Qt Creator Beautifier plugin
clang-format-3.5 -style='{
Language: Cpp,
Standard: Cpp11,
UseTab: Never,
IndentWidth: 4,
ColumnLimit: 100,
AllowShortIfStatementsOnASingleLine: false,
@gruzovator
gruzovator / futures_queue_test.cpp
Last active August 29, 2015 14:15
testing parallel code execution
// build: g++ -std=c++11 futures_queue_test.cpp -lpthread
// usage (single-threaded variant): ./a.out 10 single
// usage (multi-threaded variant): ./a.out 10 parallel
#include <iostream>
#include <sstream>
#include <functional>
#include <algorithm>
#include <future>
#include <chrono>
#include <iostream>
#include <stdexcept>
#include <map>
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/xml_parser.hpp>
using namespace std;
using namespace boost::property_tree;
int main(int argc, char const *argv[])
@gruzovator
gruzovator / ScopeExit.hpp
Created February 12, 2015 07:24
c++11 scope exit
/** Scope exit */
template<typename Callable>
class ScopeExit
{
Callable m_callable;
public:
explicit ScopeExit(Callable c) : m_callable(c) {}
ScopeExit(const ScopeExit&) = delete;