Skip to content

Instantly share code, notes, and snippets.

View vlyahovich's full-sized avatar
💭
✨ Brewing Magic

Vadim Liakhovich vlyahovich

💭
✨ Brewing Magic
View GitHub Profile
function partition(inputArray, callback) {
const result = {};
for (const [indexOfValue, value] of inputArray.entries()) {
const propertyKey = callback(value, indexOfValue);
if (propertyKey === null || propertyKey === '') {
continue;
}
if (!{}.hasOwnProperty.call(result, propertyKey)) {
result[propertyKey] = [];
}
/** @return {number} Width of a scrollbar in pixels */
function getScrollbarWidth() {
const div = document.createElement('div');
div.style.visibility = 'hidden';
div.style.overflow = 'scroll';
div.style.width = '50px';
div.style.height = '50px';
div.style.position = 'absolute';
document.body.appendChild(div);
const result = div.offsetWidth - div.clientWidth;
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
import {Dict} from '../interfaces';
export interface XhrResponse {
data: any;
statusCode: number;
statusText: string;
headers: Dict;
request: XMLHttpRequest;
code?: string;
}
import {forEach, isArray, isDate, isObject} from 'lodash';
export interface XhrResponse {
data: any;
statusCode: number;
statusText: string;
headers: Dict;
request: XMLHttpRequest;
code?: string;
}
@vlyahovich
vlyahovich / touchEmulator.js
Created December 10, 2015 09:14
Touch trigger emulation
(function () {
'use strict';
var Touch = function (target, identifier, pos, deltaX, deltaY) {
deltaX = deltaX || 0;
deltaY = deltaY || 0;
this.identifier = identifier;
this.target = target;
this.clientX = pos.clientX + deltaX;
@vlyahovich
vlyahovich / boot.js
Created November 9, 2015 08:23 — forked from jdx/boot.js
zero-downtime node.js app runner
// This script will boot app.js with the number of workers
// specified in WORKER_COUNT.
//
// The master will respond to SIGHUP, which will trigger
// restarting all the workers and reloading the app.
var cluster = require('cluster');
var workerCount = process.env.WORKER_COUNT || 2;
// Defines what each worker needs to run
@vlyahovich
vlyahovich / happy_git_on_osx.md
Created October 23, 2015 13:54 — forked from trey/happy_git_on_osx.md
Creating a Happy Git Environment on OS X

Creating a Happy Git Environment on OS X

Step 1: Install Git

brew install git bash-completion

Configure things:

git config --global user.name "Your Name"

git config --global user.email "you@example.com"

@vlyahovich
vlyahovich / composition.js
Created October 9, 2015 09:44
Composition
const barker = (state) => ({
bark: () => console.log('Woof, I am ' + state.name)
});
const driver = (state) => ({
drive: () => state.position = state.position + state.speed
});
const murderRobotDog = (name) => {
let state = {
name,
(function () {
var mixin = function () {
if (arguments.length === 0) {
return this;
}
var args = _.toArray(arguments);
args.unshift({});