Skip to content

Instantly share code, notes, and snippets.

Dan Kerimdzhanov kerimdzhanov

Block or report user

Report or block kerimdzhanov

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
kerimdzhanov / Random-string
Created Apr 9, 2018 — forked from 6174/Random-string
Generate a random string in JavaScript In a short and fast way!
View Random-string
Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
kerimdzhanov /
Created Jan 4, 2018
Redux Query Middleware – Automatically add request headers using custom network interface interceptor.

Example Usage

You need to have the following in your initialization file (index.js or redux/index.js):

import {createStore, combineReducers, applyMiddleware, compose} from 'redux';
import {entitiesReducer, queriesReducer} from 'redux-query';
import reduxQueryMiddleware from './middleware/reduxQuery';
kerimdzhanov /
Last active Dec 3, 2017
VPS Deployment Instructions


  • A working Debian/Ubuntu Linux instance

Preparing the deployment server

After creating a VPS drop/node, login as root and update a newly installed system:

$ ssh root@
kerimdzhanov / next-second.js
Last active Oct 16, 2018
Executes a given `fn` at the beginning of the next second
View next-second.js
* Executes a given `fn` at the beginning of the next second.
* @param {function} fn – a function to execute
* @return {number} setTimeout's resulting timeout id, to give ability to cancel execution
function nextSecond(fn) {
const time = (new Date()).getTime();
return setTimeout(fn, (Math.ceil(time / 1000) * 1000) - time);
kerimdzhanov / mocha.conf.js
Last active Aug 3, 2018
Setup mocha/chai.js/sinon stack w/ es6 features
View mocha.conf.js
const chai = require('chai');
// globalize sinon
global.sinon = require('sinon');
// initialize chai plugins
kerimdzhanov / async-each-promise.js
Last active Jan 11, 2017
Iterate through an array asynchronously one by one using the ES6 promises
View async-each-promise.js
const array = []; // array to iterate
const promise = array.reduce((p, entry) => {
p.then(() => {
return new Promise((resolve, reject) => {...});
}, Promise.resolve());
.then(() => console.log('done!'))
kerimdzhanov / chaijs-cheatsheet.js
Last active Jul 6, 2016
Chai.js expectations cheatsheet
View chaijs-cheatsheet.js
// instead of using `expect(object).to.exist`, assert things
// through `` which make failures more informative
foo: 'bar',
baz: 'quux'
// to assert property value types i.e. date:
kerimdzhanov / custom-error.js
Last active May 6, 2016 — forked from justmoon/custom-error.js
Creating custom Error classes in Node.js
View custom-error.js
'use strict';
module.exports = function CustomError(message, extra) {
Error.captureStackTrace(this, this.constructor); =;
this.message = message;
this.extra = extra;
require('util').inherits(module.exports, Error);
View sum-big-numbers.js
* Sum two big numbers given as strings.
* @param {string} a
* @param {string} b
* @return {string}
function sumStrings(a, b) {
var zrx = /^0+/; // remove leading zeros
a = a.replace(zrx, '').split('').reverse();
kerimdzhanov / polling-callback.js
Last active Aug 29, 2015
Javascript polling functions
View polling-callback.js
// The polling function
function poll(fn, callback, timeout, interval) {
var endTime = Number(new Date()) + (timeout || 2000);
interval = interval || 100;
(function p() {
// If the condition is met, we're done!
if (fn()) {
You can’t perform that action at this time.