Skip to content

Instantly share code, notes, and snippets.

@nnnikolay
nnnikolay / Quick guide about DDD.md
Last active August 19, 2018 21:49
It helps to refresh in the mind the main concepts

Expanding on our previous article that covered Object-Oriented Analysis and Design (OOAD), today’s article will explore domain-driven design (DDD). DDD is a software development approach that uses and builds upon OOADprinciples and ideas, so it’s the next logical topic for us to dive into.

Throughout this article we’ll examine what domain-driven design is, how it is commonly implemented in modern development life cycles, and consider a few potential advantages and disadvantages of using DDD in your own projects. Let’s get crackin’!

What is the Domain? To define domain-driven design we should first establish what we mean by domain in this context (and in development in general). The common dictionary definition of domain is: “A sphere of knowledge or activity.” Drilling down a bit from that, domain in the realm of software engineering commonly refers to the subject area on which the application is intended to apply. In other words, during application development, the domain is the “sphere of knowledge and ac

Requirements

You need to have installed brew on your laptop

Development

IDE

Install Visual Studio Code

@nnnikolay
nnnikolay / constellation.md
Last active November 21, 2017 12:54
The task was to find out all the constellations in the space

Given an MxN matrix represented by a 2D perimeter located in space and filled with stars, find the numbers of constellations.

Conditions:

The exact constellation structure to be found is the following:

0 * 0
* 0 *

If no constellation is found then the output should be 0 0.

@nnnikolay
nnnikolay / js.promises.md
Last active November 16, 2017 16:42
Couple of advanced techniques to work with JS promises

Someimtes it can be usefull to do banch of tasks in "parallel" and do not stop if some of them has been finished with the error

Promise.all([
  Promise.resolve(33).then((d) => { throw new Error(d)} ).catch(e => console.error('Inside ' + e)),
  Promise.resolve('test')
]).then(result => console.log(result)).catch(e => console.error(e));

In the output we will see

@nnnikolay
nnnikolay / fix-npm.config
Last active May 13, 2019 21:19
Not the final AWS Elastic Beanstalk deployment for NodeJS. Why not the final? some parts are missing or not tested, like configuration changes. Currently it has been tested for application deployment only.
files:
"/opt/elasticbeanstalk/env.vars":
mode: "000775"
owner: root
group: users
content: |
# enable extra logs
set -xe
# Defines variables for use by the other scripts below.
@nnnikolay
nnnikolay / 00_nginx.config
Created October 23, 2017 09:11
AWS Elastic Beanstalk deployment scripts with: - using Memcached directly from Nginx; - advanced logging info like redirect to url and response time; - redirect to https
files:
"/tmp/deployment/nginx.conf":
owner: root
group: root
mode: "000644"
content: |
user nginx;
load_module /usr/lib64/nginx/modules/ngx_http_perl_module.so;
worker_processes auto;
@nnnikolay
nnnikolay / string-transformation.php
Created May 22, 2017 09:21
Again, from Codility. Need to transform the string regarding the rues as long as there are still matching rules.
<?php
function solution($S)
{
$rules = [
'AB' => 'AA',
'BA' => 'AA',
'CB' => 'CC',
'BC' => 'CC',
'AA' => 'A',
@nnnikolay
nnnikolay / word-machine.php
Last active February 26, 2022 01:17
One of the codility task implemented by me (Word machine with capability add, duplicate, pop, sum and subtract from the stack)
<?php
function solution($S)
{
$stack = [];
foreach(parseCommand($S) as $command) {
try {
$stack = performOperation($command)($stack);
} catch (Exception $e) {
@nnnikolay
nnnikolay / googleServiceStream.js
Created February 23, 2017 15:02
With this module it's possible to crawl google places API in a stream
import stream from 'stream'
import https from 'https'
export default class googleServiceStream extends stream.Transform {
/**
* Initialize the stream
*/
constructor() {
super({objectMode: true})
}
@nnnikolay
nnnikolay / gulpfile.js
Created December 8, 2016 09:23
from one of my AWS Lambda projects
const gulp = require('gulp'),
sourcemaps = require('gulp-sourcemaps'),
babel = require('gulp-babel'),
symlink = require("gulp-sym"),
eslint = require('gulp-eslint'),
del = require('del'),
install = require('gulp-install'),
awsLambda = require('node-aws-lambda'),
runSequence = require('run-sequence'),
zip = require('gulp-zip'),