Skip to content

Instantly share code, notes, and snippets.

View exdeniz's full-sized avatar

Igor Pnev exdeniz

  • VerstkaLab
  • Amster, NL
View GitHub Profile
@exdeniz
exdeniz / base64.js
Created March 31, 2015 14:40
Gulp Task for Base64
gulp.task('stylusURI', function() {
gulp.src('./assets/b/blocks.uri.styl')
.pipe(stylus()) // собираем stylus
.pipe(cssBase64({
baseDir: "../../assets/icons",
}))
.pipe(prefix())
.pipe(gulp.dest('./public/css/')) // записываем css
.pipe(reload({
stream: true
.headerGlass:after {
content: "";
display: block;
top: 5px;
left: -40px;
position: absolute;
width: 63px;
height: 23px;
background-repeat: no-repeat;
background-position: center center;
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'
@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)
@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
const somevar = { a: 'foo', b: 'bar' }[switchval] || 'default';
//
let switchval = 3;
let somevar = ['a','b'][switchval] || 'default';
@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]);
);
@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), [])
}
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,
export class EventObserver {
constructor() {
this.observers = []
}
subscribe(fn) {
this.observers.push(fn)
}
unsubscribe(fn) {