Skip to content

Instantly share code, notes, and snippets.

// findAllByAaa - find set of matching rows, empty set acceptable
Iterator found = Map.findAllByName("Jeffrey");
// find - get row selected by parameters, return null if not found
Employee employee = employees.find("Jeffrey");
// check - get row selected by parameters, throw exception if not found
Employee employee = employees.check("Jeffrey");
// get - this pattern in this context I would avoid since it can be understood as something between find & check
// Basic singleton implementation
// Requires construction to be called before usage
// (so no lazy initialization)
// --- singleton.h
class Singleton {
public:
Singleton();
virtual ~Singleton();
static Singleton *getInstance() {
// C++11 singleton with lazy initialization & construction arguments
// Requires arguments to be initialized before usage (otherwise default values will be passed)
using namespace std;
// singleton with lazy initialization & construction arguments
template <typename Derived, typename Args>
class SingletonWithArgs
{
public:
@vpiotr
vpiotr / xnode_as_cache.cpp
Last active January 29, 2017 11:12
Demonstrates how to use xnode as cache.
#include "xnode_property_list.h"
#include "xnode.h"
xnode_named_list cache;
// already existing entries will automatically destroyed and replaced
cache.put("MAMA", xnode.value_of("mama"));
cache.put("PAPA", xnode().hold(new Person("PAPA")));
cache.put("TRUMP", xnode().hold(new USPresident("TRUMP")));
@vpiotr
vpiotr / Pair.java
Last active March 27, 2018 12:38
/*
* Author: Piotr Likus, SpaceInSoft, 2015
* License: MIT
*/
package com.spaceinsoft.utils;
/**
* Implements generic pair class that can hold pair of any objects.
* Class is immutable, so setting values is done by creation of new object.
*
/*
* Author: Piotr Likus, SpaceInSoft, 2015
* License: MIT
*/
package com.spaceinsoft.utils;
import java.math.BigDecimal;
import java.math.BigInteger;
/**
/*
* Author: Piotr Likus, SpaceInSoft, 2015
* License: MIT
*/
package com.spaceinsoft.utils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@vpiotr
vpiotr / gnome_commander_centos6.md
Last active October 9, 2016 20:17
Gnome Commander 1.4 installation procedure

HOWTO: Compile & Install Gnome Commander 1.4 on CentOS 6 From TAR

Introduction

Currently there is no automatic way to install Gnome Commander on CentOS 6. Below you will find instructions how to do that using install from compiled sources. Note that this is not a clean install and some things can be missing - it is always best to use automatic install (if available).

Tested environments

/*
* Author: Piotr Likus, SpaceInSoft, 2016
* License: MIT
*/
#include <stdio.h>
// prints unsigned int in binary form
void printBits(unsigned int num)
{
@vpiotr
vpiotr / gedit_update.md
Created July 27, 2016 17:07
gedit - update instruction for Linux Mint 17

HOWTO: Update gedit to v. 3.x in Linux Mint

Introduction

In default setup, Linux Mint installs gedit in version 2.x. In order to use more recent version of this editor (for example for Markdown support), you can follow the instruction below.

Tested environment

Linux Mint 17.3