Skip to content

Instantly share code, notes, and snippets.

@Expl4Life
Expl4Life / docker-compose.yml
Created October 14, 2021 17:45 — forked from hedleysmith/docker-compose.yml
docker-compose.yml example with Node.js file watching on OS X
# 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
@Expl4Life
Expl4Life / closure1.js
Last active November 4, 2018 15:59
findEqualSquareAreaSection
//"разделяй и влавствуй"
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) {
@Expl4Life
Expl4Life / closure.js
Created November 4, 2018 15:35
Closure. Sum function
function sum(a) {
let currentSum = a;
function f(b) {
currentSum += b;
return f;
}
f.toString = function () {
@Expl4Life
Expl4Life / binary search
Last active November 4, 2018 13:14
Binary search
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);
const apply = (times, fn, value) => {
const iter = (counter, acc) => {
if (counter === 0) {
return acc;
}
return iter(counter - 1, fn(acc));
};
return iter(times, value);
const getSlugName = () => {
let url = window.location.href;
let matches = url.match(/\d+$/);
if(matches) {
let slugName = Number(matches[0]);
return slugName;
}
@Expl4Life
Expl4Life / CreateSpaceSeparator
Created August 21, 2017 12:32
CreateSpaceSeparator
function addSpaceSeparator(number) {
return number.toString().replace(/\B(?=(\d{3})+(?!\d))/g, " ");
}