Skip to content

Instantly share code, notes, and snippets.

View zmnv's full-sized avatar
🔮
Creative Developer

zmnv zmnv

🔮
Creative Developer
View GitHub Profile
@zmnv
zmnv / JS ZMNV Banner
Created April 15, 2018 03:53
Копирайт-банер в консоли
const banner = `
\x1b[94m ▄▄▄ ▄▄██████▀ \x1b[91m oooooooo ooo. .oo. .oo. ooo. .oo. oooo ooo \x1b[0m
\x1b[94m ▀▀██ ███████▀▀ \x1b[91m d.""7d8P \888P"Y88bP"Y88b \888P"Y88b \88. .8' \x1b[0m
\x1b[94m ▄█▀ ███████▀ \x1b[91m .d8P' 888 888 888 888 888 \88..8' \x1b[0m
\x1b[94m ██▄▄███████████▄▄ \x1b[91m .d8P' .P 888 888 888 888 888 \888' \x1b[0m
\x1b[94m ▀█████████████▀ \x1b[91m d8888888P o888o o888o o888o o888o o888o \8' \x1b[0m
\x1b[0m`;
module.exports = banner;
@zmnv
zmnv / JS Simple Colorizer
Created April 15, 2018 04:17
Разукрашивает текст
'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;
/* Original:
┌──────────────────────────────────────────────────────┐
│ _____ _ _ _____ _ 1.0.0 │
│ | _ |___ ___ |_|___ ___| |_ | __| |___ _ _ _ │
│ | __| _| . | | | -_| _| _| | __| | . | | | | │
│ |__| |_| |___|_| |___|___|_| |__| |_|___|_____| │
│ |___| │
│ │
│ © Valeriy Zimnev (@zmnv), 2018 │
└──────────────────────────────────────────────────────┘
@zmnv
zmnv / observable-1-basic.js
Last active October 13, 2018 07:00
Что такое Observable. Примитивная реализация. https://www.youtube.com/watch?v=NK-WzH3RBds
'use strict';
/* Исходная задача */
for (let letter of 'Hello, world!') {
console.log(letter);
}
/* Добавляем гибкости */
/*
Пример жёсткой связанности.
Переменная state и функция связаны из-за того,
что сама переменная используется в функции.
*/
let state = 0;
function updateState() {
state++;
@zmnv
zmnv / cuteNumbers.js
Last active December 29, 2018 16:32
Cute Numbers with spaces. Cyrillic labels by last number.
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':
@zmnv
zmnv / group-array.js
Created December 29, 2018 16:46
Group array elemens by elements size
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;
}, [[]]);
@zmnv
zmnv / sleep.js
Created December 29, 2018 16:50
Sync waiting time
function sleep(milliseconds) {
const initiation = new Date().getTime();
while ((new Date().getTime() - initiation) < milliseconds);
}
module.exports = sleep;
{
"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. */
@zmnv
zmnv / gulp-4-scss.js
Last active February 7, 2019 14:39
Gulp 4 CSS to SCSS with watch
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')