Skip to content

Instantly share code, notes, and snippets.

View glebcha's full-sized avatar
👨‍💻
do my best

Gleb glebcha

👨‍💻
do my best
View GitHub Profile
@glebcha
glebcha / depcheck.sh
Last active April 25, 2023 10:11
Find unused packages from package.json
#!/bin/bash
# Enhanced version of https://stackoverflow.com/a/52371112/1835055
DIRNAME=${1:-.}
cd $DIRNAME
FILES=$(mktemp)
PACKAGES=$(mktemp)
@glebcha
glebcha / WebstormTweak
Created May 22, 2017 05:04 — forked from abhisheksliam/WebstormTweak
Speed up WebStorm
Here is my recipe how to speed up WebStorm:
Go to Preferences and do next:
Appearance & Behaviour > System Settings > Updates: disable auto update
Appearance & Behaviour > System Settings > Using Statistics: Uncheck allowing sending data
Editor > Live Templates: disable all, leave only what you are really use
Editor > Emmet: disable all emmets
Editor > Intentions: I leave only: CSS, Declaration, JavaScript and Language Injection
Plugins: leave only next (* - can be also disabled in case don't need them):
CoffeeScript *
@glebcha
glebcha / curved_polylines.js
Created September 17, 2014 08:01
Google Maps curved polylines
/*
Simple jQuery Curved Line Plugin for use with Google Maps Api
author: Daniel Nanovski
modifications: Coen de Jong
version: 0.0.2 (Beta)
website: http://curved_lines.overfx.net/
License:
@glebcha
glebcha / gulpfile.js
Last active September 14, 2022 08:39
Gulp task sample (css and js minify+concat, compress images, watching for changes)
// Определяем зависимости в переменных
var gulp = require('gulp'),
cache = require('gulp-cache'),
clean = require('gulp-clean'),
stream = require('event-stream'),
size = require('gulp-size'),
jshint = require('gulp-jshint'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
minifyCSS = require('gulp-minify-css'),
@glebcha
glebcha / detect_failed_promise.js
Last active May 25, 2021 14:48
Fast concept of failed promise detection
function bulkRequest(urls) {
const promises = urls.reduce((result, url) => {
const isValidUrl = Object.prototype.toString.call(url) === '[object String]';
if (isValidUrl) {
result.push(
fetch(url)
.catch(({ message }) => console.warn(`Bulk Request: ${ message }`))
.then(response => ({ [url]: response }))
)
@glebcha
glebcha / gulpfile.js
Last active July 22, 2020 11:05
Gulp task with Less processing (autoprefixer), live reload (browser-sync), javascript (es6, babelify, react), error handling, images optimization, jade templates
'use strict';
/*
Instructions:
1 - Should execute 'npm run prepare'
before the very first run, it will install and symlink all dependencies.
2 - Choose between production 'npm start' and development 'npm run start-dev' modes
(watcher will run immediately after initial run).
@glebcha
glebcha / getType.js
Created April 21, 2020 07:59
Check common js types
const modifier = type => item => Object.prototype.toString.call(item) === `[object ${type}]`;
const checkTypes = ['String', 'Function', 'Number', 'Boolean', 'Object', 'Symbol'];
const is = checkTypes.reduce((checkers, type) => ({ ...checkers, [type]: modifier(type) }), {});
is.Function(null)
@glebcha
glebcha / structuralClone.js
Created July 18, 2018 11:33
Deep object clone without functional properties
function structuralClone(obj) {
return new Promise(resolve => {
const {port1, port2} = new MessageChannel();
port2.onmessage = ev => resolve(ev.data);
port1.postMessage(obj);
});
}
var obj = {a: 1, b: {
c: b

@kangax's ES6 quiz, explained

@kangax created a new interesting quiz, this time devoted to ES6 (aka ES2015). I found this quiz very interesting and quite hard (made myself 3 mistakes on first pass).

Here we go with the explanations:

Question 1:
(function(x, f = () => x) {
const EXTENSION_TYPE = {
0x01: 'PlainText',
0xF9: 'GraphicControl',
0xFE: 'Comment',
0xFF: 'Application'
};
/**
* Returns total length of data blocks sequence
*