Skip to content

Instantly share code, notes, and snippets.

View exdeniz's full-sized avatar

Igor Pnev exdeniz

  • VerstkaLab
  • Amster, NL
View GitHub Profile
<a href="tel:1-234-567-8910" aria-label="Телефон поддержки" target="_blank" rel="noopener noreferrer">+1 (234) 567-89-10</a>
@exdeniz
exdeniz / video.html
Created June 25, 2018 06:42
autoplay background video
<video class=“mainSlideBackgroundVideo”preload=“auto” playsinline autoplay muted loop>
<source src="https://archive.org/download/WebmVp8Vorbis/webmvp8_512kb.mp4" type="video/mp4">
<source src="https://archive.org/download/WebmVp8Vorbis/webmvp8.ogv" type="video/ogg">
<source src="https://archive.org/download/WebmVp8Vorbis/webmvp8.webm" type="video/webm">
</video>
export class EventObserver {
constructor() {
this.observers = []
}
subscribe(fn) {
this.observers.push(fn)
}
unsubscribe(fn) {
const output = getQuestions.map(async groupQuestions => {
// Получим описание группы
const { title } = getGroupQuestions.find(groupItem => _.isEqual(groupItem._id, groupQuestions._id))
// Получим блоки для вопроса.
const getQuestionsOutput = groupQuestions.entres.map(async questions => {
return { ...questions, blocks: await Block.find({ _id: { $in: questions.blocks } }) }
})
return {
title: title,
@exdeniz
exdeniz / array.js
Last active June 4, 2018 08:47
N first elements from array
// N first elements from array
const ar = [1,2,3,4,5,6,7]
const arAfter = ar.filter((i, index) => (index < 3))
// split array to few array wit N elements
const foldm = (r, j) => {
return r.reduce((a, b, i, g) => (!(i % j) ? a.concat([g.slice(i, i + j)]) : a), [])
}
@exdeniz
exdeniz / shuffle.js
Created June 4, 2018 08:36 — forked from guilhermepontes/shuffle.js
Shuffle array element ES2015, ES6
// original gist
const shuffleArray = arr => arr.sort(() => Math.random() - 0.5);
// fully random by @BetonMAN
const shuffleArray = arr => (
arr
.map(a => [Math.random(), a])
.sort((a, b) => a[0] - b[0])
.map(a => a[1]);
);
const somevar = { a: 'foo', b: 'bar' }[switchval] || 'default';
//
let switchval = 3;
let somevar = ['a','b'][switchval] || 'default';
@exdeniz
exdeniz / regexp.js
Created June 3, 2018 10:46
Russian phone regexp
const re = /^(\+7|7|8)?[\s\-]?\(?[489][0-9]{2}\)?[\s\-]?[0-9]{3}[\s\-]?[0-9]{2}[\s\-]?[0-9]{2}$/gm
@exdeniz
exdeniz / config-overrides.js
Last active March 14, 2018 20:40
Add stylus and postcss, react-hot-loader and decorator with react-app-rewire
const rewireReactHotLoader = require("react-app-rewire-hot-loader")
const rewired = require("react-app-rewired")
const rupture = require("rupture")
const { injectBabelPlugin } = require("react-app-rewired")
function contailCSSLoader(obj) {
const reg = /css-loader/
if (typeof obj === "string") {
return reg.test(obj)
import { buildFavicon, buildInjectFavicon } from './tools/build-favicon'
import { dest, lastRun, parallel, series, src, watch } from 'gulp'
import { create as bsCreate } from 'browser-sync'
import { buildCss } from './tools/build-css'
import { buildFiles } from './tools/build-files'
import { buildImage } from './tools/build-image'
import { buildPug } from './tools/build-pug'
import { buildSvg } from './tools/build-svg'
import config from './webpack.config'