This file contains hidden or 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
/* Click by div'container' or any element inside in browser and ctrl+v to paste image. */ | |
/* Pls copy any image in clipboard before :) */ | |
import { Component, OnInit, ElementRef, ViewChild } from '@angular/core'; | |
@Component({ | |
selector: 'catalog-page-upload', | |
template: /*html*/` | |
<div class="container" (paste)="onPaste($event)"> | |
<h1>Привет , мир!</h1> |
This file contains hidden or 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 gulp = require('gulp'), | |
sass = require('gulp-sass'), | |
concat = require('gulp-concat'), | |
prefix = require('gulp-autoprefixer'), | |
rename = require('gulp-rename'); | |
plumber = require('gulp-plumber'); | |
function css() { | |
return gulp | |
.src('./scss/**/*.scss') |
This file contains hidden or 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
Show hidden characters
{ | |
"compilerOptions": { | |
/* Basic Options */ | |
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */ | |
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ | |
// "lib": [], /* Specify library files to be included in the compilation. */ | |
// "allowJs": true, /* Allow javascript files to be compiled. */ | |
// "checkJs": true, /* Report errors in .js files. */ | |
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ | |
// "declaration": true, /* Generates corresponding '.d.ts' file. */ |
This file contains hidden or 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 sleep(milliseconds) { | |
const initiation = new Date().getTime(); | |
while ((new Date().getTime() - initiation) < milliseconds); | |
} | |
module.exports = sleep; |
This file contains hidden or 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 groupArray(array = [], size = 10) { | |
const res = array.reduce((p, c) => { | |
if (p[p.length - 1].length == size) { | |
p.push([]); | |
} | |
p[p.length - 1].push(c); | |
return p; | |
}, [[]]); |
This file contains hidden or 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 cuteNumber(num) { | |
num = ''+num; | |
return num.replace(/(\d)(?=(\d\d\d)+([^\d]|$))/g, '$1 ');; | |
} | |
function cuteNumberObjects(num, replacer = ['объект', 'объекта', 'объектов']) { | |
num = cuteNumber(num); | |
switch(num[num.length - 1]) { | |
case '1': |
This file contains hidden or 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
/* | |
Пример жёсткой связанности. | |
Переменная state и функция связаны из-за того, | |
что сама переменная используется в функции. | |
*/ | |
let state = 0; | |
function updateState() { | |
state++; |
This file contains hidden or 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
'use strict'; | |
/* Исходная задача */ | |
for (let letter of 'Hello, world!') { | |
console.log(letter); | |
} | |
/* Добавляем гибкости */ |
This file contains hidden or 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
/* Original: | |
┌──────────────────────────────────────────────────────┐ | |
│ _____ _ _ _____ _ 1.0.0 │ | |
│ | _ |___ ___ |_|___ ___| |_ | __| |___ _ _ _ │ | |
│ | __| _| . | | | -_| _| _| | __| | . | | | | │ | |
│ |__| |_| |___|_| |___|___|_| |__| |_|___|_____| │ | |
│ |___| │ | |
│ │ | |
│ © Valeriy Zimnev (@zmnv), 2018 │ | |
└──────────────────────────────────────────────────────┘ |
This file contains hidden or 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
'use strict'; | |
const cs = (text, colorForeground, colorBackground) => | |
colorBackground ? | |
`\x1b[${colorForeground}m\x1b[${colorBackground}m${text}\x1b[0m` : | |
`\x1b[${colorForeground}m${text}\x1b[0m`; | |
module.exports = cs; |