Skip to content

Instantly share code, notes, and snippets.

View kerimdzhanov's full-sized avatar

Dan Kerimdzhanov kerimdzhanov

View GitHub Profile
#!/bin/sh
echo Xcode installation path: `xcode-select --print-path`
sudo rm -rf `xcode-select --print-path` && xcode-select --install
.ellipsis {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
td.ellipsis {
position: relative;
white-space: initial;
export class CancellableRequest {
private controller = new AbortController();
public fetch(input: RequestInfo, init: RequestInit = {}): Promise<Response> {
init.signal = this.controller.signal;
return fetch(input, init)
.then(res => res.json());
}
@kerimdzhanov
kerimdzhanov / conventional-changelog-config.js
Last active July 23, 2021 13:06
Conventional changelog config example
'use strict';
const config = require('conventional-changelog-conventionalcommits');
module.exports = config({
types: [
{ type: 'feat', section: 'Features' },
{ type: 'feature', section: 'Features' },
{ type: 'fix', section: 'Bug Fixes' },
{ type: 'perf', section: 'Performance Improvements' },
@kerimdzhanov
kerimdzhanov / README.md
Created April 1, 2020 00:29
JavaScript Throttling vs Debouncing

Throttling vs Debouncing

Throttling is a straightforward reduction of the trigger rate. It will cause the event listener to ignore some portion of the events while still firing the listeners at a constant (but reduced) rate.

Unlike throttling, debouncing is a technique of keeping the trigger rate at exactly 0 until a period of calm and then triggering the listener exactly once.

In other words

With Throttling the original function is called at most once per specified period.

@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);
@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 / 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 / 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 / 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'));