Skip to content

Instantly share code, notes, and snippets.

View IPRIT's full-sized avatar
💅

Alexander Belov IPRIT

💅
View GitHub Profile
@IPRIT
IPRIT / artem.js
Last active April 27, 2020 19:05
// src/store/rabota/search/actions.js:restoreQueryString
let location = state.location;
if (query[ 'subway_station' ] && getObjectValueByPath(state, 'location.subway_station.id') !== ensureNumber( query[ 'subway_station' ] )) {
location = {
subway_station: { id: ensureNumber( query[ 'subway_station' ] ) }
};
} else if (query[ 'location.latitude' ] && query[ 'location.longitude' ] && getObjectValueByPath(state, 'location.geopoint.latitude') !== ensureNumber( query[ 'location.latitude' ] ) && getObjectValueByPath(state, 'location.geopoint.longitude') !== ensureNumber( query[ 'location.longitude' ] )) {
location = {
geopoint: {
@IPRIT
IPRIT / .js
Created August 15, 2018 12:57
/**
* @param {string} ns
*/
export function consoleLogNamespaced (ns = 'global') {
const themes = {
log: {
primaryPanel: ['#ff5644', '#db00af'],
secondaryPanel: ['#424b5c', '#001333'],
borders: ['#ff270f', '#333a47']
},
export function pluralize (number, word, postfixes) {
const mod10 = number % 10,
mod100 = number % 100;
let postfix = '';
if (mod100 >= 5 && mod100 < 21
|| mod10 >= 5 && mod10 <= 9
|| !mod10) {
postfix = postfixes[2];
} else if (mod10 === 1) {
postfix = postfixes[0];
/**
* @param {string} ns
*/
export function consoleLogNamespaced (ns = 'global') {
const themes = {
log: {
primaryPanel: ['#ff5644', '#db00af'],
secondaryPanel: ['#424b5c', '#001333'],
borders: ['#ff270f', '#333a47']
},
@IPRIT
IPRIT / .js
Last active May 11, 2018 12:19
function loadImage (url) {
return new Promise((resolve, reject) => {
let img = new Image();
img.addEventListener('load', _ => {
resolve(img)
});
img.addEventListener('error', _ => {
reject(_)
});
img.src = url;
importScripts('https://npmcdn.com/promise-worker/dist/promise-worker.register.js');
registerPromiseWorker(function (msg) {
return {hello: 'main thread'};
});
var FontsLoader = global.FontsLoader = function (loadAsParallel) {
this._loadAsParallel = loadAsParallel || true;
this._currentProcesses = [];
this._queue = [];
};
FontsLoader.prototype.load = function (fontUrl, mimeType) {
if (this._loadAsParallel || !this._currentProcesses.length) {
return this._loadFont(fontUrl, mimeType);
}
const GRID_COLUMN_ATTRIBUTE = 'grid-columns';
const GRID_CHECK_DEBOUNCE_MS = 100;
const minItemWidth = Number(attrs.gridItemMin) || 100;
const maxItemWidth = Number(attrs.gridItemMax) || 100;
let onWidthChangeDebounced = $mdUtil.debounce(onWidthChanged, GRID_CHECK_DEBOUNCE_MS);
let $window = angular.element(window);
$window.on('resize', ev => onWidthChangeDebounced());
@IPRIT
IPRIT / _bem-mixin.scss
Last active April 7, 2017 00:43
The mixin provides an easy way to build `bem` classes (block, element, modifier) like in example section
/**
* Copyright (c) 2017 Alex Belov
* MIT
*/
/* Prefixes */
$bem-block-prefix: ab-; // .ab-class { .. }
$bem-element-prefix: __; // .ab-class__element { .. }
$bem-modifier-prefix: _; // .ab-class__element_modifier { .. }
// @import "variables";
@mixin transition-default($duration: .1s, $property: all, $delay: .0s) {
transition: $property $duration $transitionDefaultTimingFunction $delay;
}
@mixin transition-series($params...) {
transition: $params;
}