Skip to content

Instantly share code, notes, and snippets.

View dimabory's full-sized avatar
💭
🦁

Dmytro Borysovskyi dimabory

💭
🦁
View GitHub Profile
@dimabory
dimabory / law-of-demetra.md
Last active February 11, 2019 09:20
Law of Demeter
  • Each unit should have only limited knowledge about other units: only units "closely" related to the current unit.
  • Each unit should only talk to its friends; don't talk to strangers.
  • Only talk to your immediate friends.

https://www2.ccs.neu.edu/research/demeter/demeter-method/LawOfDemeter/paper-boy/demeter.pdf

More formally, the Law of Demeter for functions requires that a method m of an object O may only invoke the methods of the following kinds of objects:

  1. O itself
@dimabory
dimabory / kays_oop
Last active February 14, 2019 08:46
Alan Kays Definition Of Object Oriented
http://wiki.c2.com/?AlanKaysDefinitionOfObjectOriented
1. Everything Is An Object.
2. Objects communicate by sending and receiving messages (in terms of objects).
3. Objects have their own memory (in terms of objects).
4. Every object is an instance of a class (which must be an object).
5. The class holds the shared behavior for its instances (in the form of objects in a program list)
6. To eval a program list, control is passed to the first object and the remainder is treated as its message.
This definition is derived from early versions of Smalltalk (Smalltalk-72?), and rules 5 and 6 clearly show Smalltalk's Lisp heritage. Kay remarked as such, noting that rules 4-6 would mutate as Smalltalk developed.
@dimabory
dimabory / deployment_patterns.md
Last active February 27, 2019 12:32
Deployment Patterns

Canary deployment

https://octopus.com/docs/deployment-patterns/canary-deployments
https://martinfowler.com/bliki/CanaryRelease.html


Canary deployments are a pattern for rolling out releases to a subset of users or servers. The idea is to first deploy the change to a small subset of servers, test it, and then roll the change out to the rest of the servers. The canary deployment serves as an early warning indicator with less impact on downtime: if the canary deployment fails, the rest of the servers aren't impacted.

canary-deployment.img

The basic steps of a canary deployment are:

@dimabory
dimabory / dep.md
Created February 22, 2019 14:59
Dependency Elimination Principle
@dimabory
dimabory / mi(a)cro-task.js
Created March 5, 2019 15:31
Explaining Microtasks and Macrotasks in Node
console.log('script start')
const interval = setInterval(() => {
console.log('setInterval')
}, 0)
setTimeout(() => {
console.log('setTimeout 1')
Promise.resolve().then(() => {
console.log('promise 3')
@dimabory
dimabory / tricks.js
Created March 18, 2019 09:20
7 Tricks: JS objects rest and spread
// 1. add props
const user = { id: 100, name: 'Howard Moon'} // { id: 100, name: 'Howard Moon' }
const userWithPass = { ...user, password: 'Password!' } // { id: 100, name: 'Howard Moon', password: 'Password!'
// 2. merge obj
const part1 = { id: 100, name: 'Howard Moon' }
const part2 = { id: 100, password: 'Password!' }
@dimabory
dimabory / palindrome.js
Last active April 3, 2019 11:08
palindrome in the one line
const palindrome = str =>
(s = str.toLowerCase().replace(/[\W_]/g, '')) &&
s === [...s].reverse().join('')
export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
@dimabory
dimabory / eslint-migration.sh
Last active April 21, 2020 10:17
This is a script to automatically install/configure ESLint into TS project.
#!/usr/bin/env bash
# Script Name: eslint-migration.sh
#
# Author: Dmytro Borysovskyi ([email protected])
# Date : 25.08.2019
#
# Description: The following script tries to automatically (partially)
# migrate TSLint to ESLint.
#
VERSION=1.2.0