Skip to content

Instantly share code, notes, and snippets.

View IPRIT's full-sized avatar
💅

Alexander Belov IPRIT

💅
View GitHub Profile
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];
@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']
},
@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: {
function atm (sum, limits) {
const obj = {};
let cur = 0;
const arr = Object.keys( limits ).map(Number).sort((a, b) => b - a);
let i = 0;
while (i < arr.length) {
const v = arr[i];
const c = Math.floor( sum / v );
const mc = Math.min( limits[ v ], c );
i++;
const urls = [
'https://ya.ru',
'https://vk.com',
'https://vk.com',
'https://vk.com',
'https://vk.com',
'https://vk.com',
'https://vk.com',
'https://vk.com',
'https://vk.com',
class ListNode {
constructor (val) {
this.val = val;
this.next = this.prev = null;
}
}
class Queue {
constructor () {
this._head = null;
const limits = {
5000: 30456574,
1000: 1567567567454,
500: 245675675,
100: 34566756673,
50: 23567400
};
function atm (sum, limits) {
const obj = Object.create( null );
/**
* Какого числа мне будет доступно N дней отпуска?
*/
var start = '2019-09-10';
var days = 6;
console.log(`Заданное количество дней (${days}) будет доступно`, new Date(new Date(start).getTime() + 365 / 28 * days * 3600 * 24 * 1000));
/**
* Сколько дней отпуска мне будет доступно X числа?
import React, { useEffect, useContext } from "react";
import "./styles.css";
const isNode = true;
const baobab = isNode ? { name: "page", children: [] } : null;
const Ctx = React.createContext(baobab);
function useBaobab(name, attrs) {
const id = Math.random();
import Like from 'assets/mg/reactions/reactions__icon_reaction_Like.svg';
import LikeBig from 'assets/mg/reactions/reactions__icon_reaction_Like-big.svg';
import Haha from 'assets/mg/reactions/reactions__icon_reaction_Haha.svg';
import HahaBig from 'assets/mg/reactions/reactions__icon_reaction_Haha-big.svg';
import Wow from 'assets/mg/reactions/reactions__icon_reaction_Wow.svg';
import WowBig from 'assets/mg/reactions/reactions__icon_reaction_Wow-big.svg';
// todo: вернуть обратно на Bored, когда закончится пандемия коронавирусом
import Bored from 'assets/mg/reactions/reactions__icon_reaction_Virus.svg';
import BoredBig from 'assets/mg/reactions/reactions__icon_reaction_Virus-big.svg';
import Sad from 'assets/mg/reactions/reactions__icon_reaction_Sad.svg';