Skip to content

Instantly share code, notes, and snippets.

Avatar

Dan Kerimdzhanov kerimdzhanov

View GitHub Profile
@kerimdzhanov
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
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
chai.use(require('sinon-chai'));
chai.use(require('chai-as-promised'));
chai.use(require('chai-datetime'));
@kerimdzhanov
kerimdzhanov / README.md
Created Jan 4, 2018
Redux Query Middleware – Automatically add request headers using custom network interface interceptor.
View README.md

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
kerimdzhanov / 001_getting_started.md
Last active Dec 3, 2017
VPS Deployment Instructions
View 001_getting_started.md

Prerequisites

  • 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@12.34.56.78
@kerimdzhanov
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 `.to.be.a(type)` which make failures more informative
expect(result).to.be.an('object')
.that.includes({
foo: 'bar',
baz: 'quux'
});
// to assert property value types i.e. date:
expect(result)
View raf.js
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
// MIT license
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
@kerimdzhanov
kerimdzhanov / mysql_data_types_size.md
Last active Dec 28, 2015
MySQL data types size reference tables
View mysql_data_types_size.md

Textual types

      Type | Maximum length | Size (bytes)
-----------+----------------+------------------
  TINYTEXT |            255 | (2^8−1)
      TEXT |         65,535 | (2^16−1) = 64 KiB
MEDIUMTEXT |     16,777,215 | (2^24−1) = 16 MiB
  LONGTEXT |  4,294,967,295 | (2^32−1) =  4 GiB
You can’t perform that action at this time.