Skip to content

Instantly share code, notes, and snippets.

View kerimdzhanov's full-sized avatar

Dan Kerimdzhanov kerimdzhanov

View GitHub Profile
@kerimdzhanov
kerimdzhanov / mysql_data_types_size.md
Last active December 28, 2015 21:49
MySQL data types size reference tables

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
@kerimdzhanov
kerimdzhanov / raf.js
Last active December 31, 2015 00:29 — forked from paulirish/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 / chaijs-cheatsheet.js
Last active July 6, 2016 23:52
Chai.js expectations cheatsheet
// 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)
@kerimdzhanov
kerimdzhanov / 001_getting_started.md
Last active December 3, 2017 19:21
VPS Deployment Instructions

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 / README.md
Created January 4, 2018 22:56
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
kerimdzhanov / mocha.conf.js
Last active August 3, 2018 08:21
Setup mocha/chai.js/sinon stack w/ es6 features
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 / next-second.js
Last active October 16, 2018 14:26
Executes a given `fn` at the beginning of the next second
/**
* 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 / Random-string
Created April 9, 2018 11:42 — forked from 6174/Random-string
Generate a random string in JavaScript In a short and fast way!
//http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript
Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
/**
* 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
kerimdzhanov / async-each-promise.js
Last active March 21, 2020 18:37
Iterate through an array asynchronously one by one using the ES6 promises
const array = []; // array to iterate
const promise = array.reduce((p, entry) => {
p.then(() => {
return new Promise((resolve, reject) => {...});
});
}, Promise.resolve());
promise
.then(() => console.log('done!'))