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:
/*
* 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

package passgen;
import java.util.Random;
import java.util.Scanner;
/**
* Exercise 37 from "Exercises for programmers".
* @author Piotr Likus
*/
public class PassGen {
@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")));
/*
* Author: Piotr Likus, SpaceInSoft, 2016
* License: MIT
*/
#include <stdio.h>
// prints unsigned int in binary form
void printBits(unsigned int num)
{
@vpiotr
vpiotr / 99bottles.js
Created October 12, 2017 05:27
99 Botttles of Beer in JavaScript
// 99 Botttles of Beer (see http://www.99-bottles-of-beer.net/)
// Language: JavaScript (SeaMonkey)
//
// Features:
// * no usage of digits
// * strings are not repeated
// * no external libs required
function bottles(x) {