List of user sessions in SQL

| category: Programming | author: st
Tags:

The frequently asked problem on interviews.

You have a log of some user activities represented as a table. Every activity record has at least users ID and activity date/time values.

The session is a sequence of activities having less than N minutes between two log records. When the elapsed …

Should database only store data?

| category: Design | author: st
Tags: , ,

Very old subject I remember to discuss in the middle of 1990s... But some people still says that a clean architecture should remove all business logic from the database.

Let's start from referential and domain integrity rules (constraints). Are they business ones? Yes, of course. The e-mail column should be …

Using RapidFort on Windows WSL

| category: My notes | author: st
Tags:

RapidFort services can optimize and secure your containers. The command line interface (CLI) tools enable you to interact with RapidFort services.

See also the official manuals.

The "native" way is using a Linux distribution on your desktop. However, the majority of desktops are running Windows. Fortunately we have WSL (Windows …

Get all subsets from a set

| category: Programming | author: st
Tags: ,

How to extract all combinations (unordered subsets) from a given set in C++?

Let us estimate the count before. Suppose N is the size of a given set, and K is the number of elements in the subset. The count of all combinations (unordered subsets) of size K is

C …

All expressions of 123456789 and signs +/- which value is 100

| category: Programming | author: st
Tags:

Suppose a string of ordered cyphers 123456789. You can insert signs "+" and "-" between any cyphers to make a correct arithmetical expression. The problem is to find all expressions which sum is 100.

This problem may be interesting for dynamic script languages having the function of a string expression evaluation.

E …

When you still need use the singleton pattern?

| category: Design | author: st
Tags:

The singleton pattern has come a long way since early 1990x. The programmer interview question "Write a singleton" in 1995 has evolved to "Write a lazy initialized singleton" in 2000x, and finished by "Why we do not use a singleton?" in 2010x.

Indeed, the unproved using of multiple singletons should …