Skip to content

Instantly share code, notes, and snippets.

@ony
ony / build-tags.md
Last active August 29, 2015 14:23
Arbitrary build tags for Exherbo

Background

Sometimes it is not enough to handle dependencies on ::installed packages only through versions. This might be either due to ABI change or due to switch of compiler. To track that information we can tag installed packages with additional information that should mark dependency in ::installed repository as unsatisfied.

GHC (Haskell) packages

@ony
ony / two_iterator_kinds.cpp
Last active August 29, 2015 14:16
Multiple iterators over single container
#include <cstdio>
using namespace std;
struct range
{
int a, b;
struct n_iter
{
int x;
@ony
ony / bootstrap.hpp
Created November 26, 2014 23:40
Bootstrapping in C++ using variadic templates for parallel estimators application
template <typename T>
struct estimate { T mean, lbound, ubound, stdev; }
template <typename T, typename... Rs>
std::tuple<estimate<Rs>...> bootstrap(std::vector<T> &sample, size_t resamples,
std::function<Rs(std::vector<T>)>... estimators)
{
const size_t n = sample.size();
// re-sample and estimate our sample
@ony
ony / cide.sh
Last active August 29, 2015 14:09
Console IDE - script to ease work with CMake projects and test builds
#!/bin/bash
# Copyright (C) 2014 Nikolay Orliuk <virkony@gmail.com>
# Distributed under the terms of the GNU General Public License v2
#
# Console IDE - just a script to ease work with CMake projects and test builds
# under different GCC compiler versions.
#
# .ciderc - file in the current or closest parent folder may be used to customize work
#
# example from my leveldb-tl:
(use '[clojure.core.match :only [match]])
(defn evaluate [env [sym x y]]
(match [sym]
['Number] x
['Add] (+ (evaluate env x) (evaluate env y))
['Multiply] (* (evaluate env x) (evaluate env y))
['Variable] (env x)))
(def environment {"a" 3, "b" 4, "c" 5})
@ony
ony / djvubook.bash
Created October 10, 2012 07:53
Assemble DjVu book from set of different images (including multi-page tiffs)
#!/bin/bash
# djvubook
#
# Author:
# Nikolay Orlyuk <virkony@gmail.com>
#
# Copyright (c) 2012 (c) Nikolay Orlyuk
#
# 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
@ony
ony / PoolSample.cs
Created October 10, 2012 07:02
Sample of how to use generic pool of structs
//
// Main.cs
//
// Author:
// Nikolay Orlyuk <virkony@gmail.com>
//
// Copyright (c) 2012 (c) Nikolay Orlyuk
//
// This program is free software; you can redistribute it and/or modify
@ony
ony / message produced by a lot of software
Created October 6, 2012 14:20
dl-open.c:666 RT_CONSISTENT
Inconsistency detected by ld.so: dl-open.c: 666: _dl_open: Assertion `_dl_debug_initialize (0, args.nsid)->r_state == RT_CONSISTENT' failed!