Skip to content

Instantly share code, notes, and snippets.

View DragorWW's full-sized avatar

Andreev Sergey DragorWW

View GitHub Profile
@DragorWW
DragorWW / .gitconfig
Created June 15, 2017 17:25 — forked from robmiller/.gitconfig
Some useful Git aliases that I use every day
#
# Working with branches
#
# Get the current branch name (not so useful in itself, but used in
# other aliases)
branch-name = "!git rev-parse --abbrev-ref HEAD"
# Push the current branch to the remote "origin", and set it to track
# the upstream branch
publish = "!git push -u origin $(git branch-name)"
@DragorWW
DragorWW / .editorconfig
Created January 31, 2017 14:48
editorconfig
[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
max_line_length = 80
trim_trailing_whitespace = true
[*.md]
max_line_length = 0
@DragorWW
DragorWW / phoneFormat.js
Created January 17, 2017 13:06
Phone number formatter for RU number.
/**
* Форматирование номера телефона:
* 89992223355 -> +7 999 222 33 55
* @param {string} s немер телефона
* @param {boolean} [plus=true] формат +7 или 8
* @return {string} отформатированный номер телефона.
*/
export default phoneFormat = (s, plus = true) => {
const startsWith = plus ? '+7' : '8';
var jsonToFlow = require('json-to-flow');
var path = require('path');
var schema = require('./swagger.json').definitions;
var _ = require('lodash');
var schemata = _(schema)
.mapValues('properties')
.value();
jsonToFlow(schemata, {
@DragorWW
DragorWW / highstock_PlotBandsWeekends.js
Created December 2, 2016 04:42
highstock highlight weekend
/**
* xAxis: {
* plotBands: getPlotBandsWeekends([<timestamp>, ...])
* },
*/
function getPlotBandsWeekends (dayList) {
return dayList
.filter((t) => {
let day = (new Date(t)).getDay();
let isWeekend = (day == 6) || (day == 0);
@DragorWW
DragorWW / Highcharts-highstock-lang-ru.js
Created December 1, 2016 07:28
Highcharts highstock lang ru
Highcharts.setOptions({
lang: {
months: ['Январь', 'Февраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль',
'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь'],
shortWeekdays: ['ВС', 'ПН', 'ВТ', 'СР', 'ЧТ', 'ПТ', 'СБ'],
weekdays: [
'Воскресенье',
'Понедельник',
'Вторник',
'Среда',
@DragorWW
DragorWW / README.md
Last active August 29, 2016 17:06
JS key repeat event

Вот маленька песочница сделанная на основание стати из learn.javascript.ru.

Вот еще одна песочница от w3c.

KeyboardEvent . repeat

true if the key has been pressed in a sustained manner. Holding down a key MUST result in the repeating the events keydown, beforeinput, input in this order, at a rate determined by the system configuration. For mobile devices which have long-key-press behavior, the first key event with a repeat attribute value of true MUST serve as an indication of a long-key-press. The length of time that the key MUST be pressed in order to begin repeating is configuration-dependent.

Как работает

@DragorWW
DragorWW / webpack.config.js
Last active June 18, 2016 08:51
webpack base config
var ISDEV = 'development' === process.env.NODE_ENV;
var path = require('path');
var webpack = require('webpack');
var autoprefixer = require('autoprefixer');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var SvgStore = require('webpack-svgstore-plugin');
var CleanWebpackPlugin = require('clean-webpack-plugin');
var pathList = {
@DragorWW
DragorWW / vegetarianFilter.js
Last active April 18, 2016 14:56
vegetarianFilter - вегетарианский фильтр для меню на сайтах доставки
/**
* Фильтрация карточек суши на предмет не вегетарианской ингредиентов.
* Фильтр скрывает все itemSelector где есть стоп слова.
*
* @param {string} itemSelector селектор карточек.
* @param {string} paramSelector селектор описания внутри карточки.
*
* @return void
*/
function vegetarianFilter(itemSelector, paramSelector) {
@DragorWW
DragorWW / Singleton.js
Created February 10, 2016 05:28
javascript es2015 singleton patter
let instances;
class MyClass {
constructor() {
if (!instances) {
instances = this;
}
return instances;
}
}