Skip to content

Instantly share code, notes, and snippets.

View dmarchuk's full-sized avatar

Daniel Marchuk dmarchuk

View GitHub Profile
@dmarchuk
dmarchuk / throttle in javascript.js
Last active July 20, 2018 13:43
Delay function after last action (keydown)
function throttle(f, delay) {
var timer = null;
return function () {
var context = this, args = arguments;
clearTimeout(timer);
timer = window.setTimeout(function () {
f.apply(context, args);
},
delay || 3000);
};
@dmarchuk
dmarchuk / splitArrays.js
Last active July 20, 2018 13:44
Split arrays into an object of arrays (by string before "_")
function splitArrays(arrayData) {
var data = arrayData;
var arrays = {};
if(data) {
data.forEach(function (str) {
// Get id piece
str_api = str.substring(0, str.indexOf('_'));
@dmarchuk
dmarchuk / simple-reset.css
Last active May 11, 2018 09:35
Simple reset css
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
@dmarchuk
dmarchuk / textarea-synchronize-scroll.js
Last active July 20, 2018 13:44
Synchronizing scroll of two elements
var scrollAreas = $('#content, .meltdown_preview');
var textArea = $('#content');
var previewArea = $('.meltdown_preview');
var timer;
var sync = function () {
var percentage, x;
if ($(this).attr('class') == 'meltdown_preview') {