Skip to content

Instantly share code, notes, and snippets.

View dmarchuk's full-sized avatar

Daniel Marchuk dmarchuk

View GitHub Profile
@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') {
@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 / 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 / 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);
};
/**
* Override default 'renderItems()' function of selectivity
* to accept option with value='' (empty string, item.id === '') as a valid option.
*
* @param items Array of result items.
* @returns HTML-formatted string to display the result items.
*/
$.Selectivity.Dropdown.prototype.renderItems = function (items) {
const selectivity = this.selectivity;
const originalEl = selectivity.options.element;
import csv
import requests
result = ''
for i in range(195):
list_json = requests.get(url, headers={
'X-Requested-With': 'XMLHttpRequest',
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36',
'Accept': '*/*',

Grep string in logs

docker logs nginx 2>&1 | grep "127."

Create file from logs

docker logs nginx > stdout.log 2>stderr.log

Mac - clean docker orphaned volumes

docker volume rm $(docker volume ls -qf dangling=true)

#!/bin/bash
for i in `seq 1 50`;
do
rg -F id=$i\).price;
done
@dmarchuk
dmarchuk / README.md
Last active July 24, 2019 08:24 — forked from stephenway/README.md
BEMIT Cheatsheet
# JS
find . -name '*.js' | xargs wc -l | sort -nr
# SCSS
find . -name '*.scss' | xargs wc -l | sort -nr