Skip to content

Instantly share code, notes, and snippets.

Avatar

Dan Kerimdzhanov kerimdzhanov

View GitHub Profile
View text-overflow-ellipsis.scss
.ellipsis {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
td.ellipsis {
position: relative;
white-space: initial;
View cancellable-request.ts
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 Aug 15, 2020
Conventional changelog config example
View conventional-changelog-config.js
'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 Apr 1, 2020
JavaScript Throttling vs Debouncing
View README.md

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 Apr 9, 2018 — forked from 6174/Random-string
Generate a random string in JavaScript In a short and fast way!
View Random-string
//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 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 / 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 / async-each-promise.js
Last active Mar 21, 2020
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());
promise
.then(() => console.log('done!'))
You can’t perform that action at this time.