This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Backend API service example, uses nodemon to keep server alive and watch for changes. | |
backendapi: | |
# Tells docker-compose where ./backendapi/Dockerfile is | |
build: ./backendapi | |
# Allows live editing of ./backendapi/app | |
volumes: | |
- ./backendapi/app:/app | |
# Launch Nodemon, using | |
# -L legacy file watching for compatibility with boot2docker / docker-machine. | |
# --watch defined to avoid watching the whole container and causing high CPU usage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//"разделяй и влавствуй" | |
function findEqualSquareAreaSection(width = 0, height = 0) { | |
if(isNaN(width) || isNaN(height) || height < 0 || width < 0) { | |
return null; | |
} | |
const bigSide = Math.max(width, height); | |
const smallSide = Math.min(width, height); | |
if(bigSide % smallSide === 0) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sum(a) { | |
let currentSum = a; | |
function f(b) { | |
currentSum += b; | |
return f; | |
} | |
f.toString = function () { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//O = logN | |
function binarySearch(sortedArray, i) { | |
const mid = Math.floor(sortedArray.length / 2); | |
if (!binarySearch.counter) { | |
binarySearch.counter = 1; | |
} else { | |
binarySearch.counter++; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const add = (a, b) => a + b; | |
function isNumber(value) { | |
return typeof value === 'number'; | |
} | |
function withValidator(isValid, operation) { | |
return function (...args) { | |
console.log(...args); | |
console.log(args); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const apply = (times, fn, value) => { | |
const iter = (counter, acc) => { | |
if (counter === 0) { | |
return acc; | |
} | |
return iter(counter - 1, fn(acc)); | |
}; | |
return iter(times, value); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const getSlugName = () => { | |
let url = window.location.href; | |
let matches = url.match(/\d+$/); | |
if(matches) { | |
let slugName = Number(matches[0]); | |
return slugName; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function addSpaceSeparator(number) { | |
return number.toString().replace(/\B(?=(\d{3})+(?!\d))/g, " "); | |
} |