Skip to content

Instantly share code, notes, and snippets.

View itsDiwaker's full-sized avatar

Diwaker Tripathi itsDiwaker

  • envistaInteractive
  • Bengaluru, India
View GitHub Profile
@itsDiwaker
itsDiwaker / utility_event_delegation.js
Last active May 25, 2020 11:40
Event delegation snippet
/**
* Based on jQuery $.on API
* Helpful when trying to bind to an element that might get re-renderd in future
* because of some AJAX call or some other DOM manipulation
* that required detaching the element or it's parent from the DOM.
* Saves the extra code to re-attach all the event handlers.
*/
const delegateEvent = (el, evt, sel, handler, useCapture) => {
if(typeof useCapture === 'undefined') {
@itsDiwaker
itsDiwaker / async-for-each.js
Last active April 16, 2020 12:35
async for loop helper example
const asyncForEach = async (array, cb) => {
for (let index = 0; index < array.length; index++) {
await cb(array[index], index, array);
}
};
@itsDiwaker
itsDiwaker / create_files_from_list_of_names.sh
Created April 12, 2020 14:51
Create snake case mulitple empty files from camel case list of names
#! /usr/bin/env bash
files=(
ccPaymentTotal
getPaymentByMethodType
getTotalPaidByMethodType
getPointsBalance
getLineItemCountByState
getAggregateDiscountTypeForOrder
getAggregateDiscountTotalForOrder