Skip to content

Instantly share code, notes, and snippets.

@hassanabbasi
hassanabbasi / getDOMPath.js
Created November 12, 2020 03:41
Get the DOM path for any given HTML element
function getDOMPath(element) {
var path = '', i, tag, selector, className, childIndex, childrenOfParent;
for (; element && element.nodeType == 1; element = element.parentNode) {
tag = element.tagName.toLowerCase();
className = element.className.trim();
childrenOfParent = $(element.parentNode).children();
childIndex = childrenOfParent.length > 1 ? (childrenOfParent.index(element) + 1) : null;
@hassanabbasi
hassanabbasi / Api.js
Last active December 21, 2019 10:34
Generalized API Manager for Javascript based applications
import axios from 'axios';
import qs from 'qs';
// Customized Axios object for API calls
var Api = axios.create({
// NOTE: Replace the API URL
baseURL: 'http://api.example.com/',
responseType: 'json',
withCredentials: true
// Add whatever you want to configure Axios here
@hassanabbasi
hassanabbasi / link-share-meta.html
Last active March 24, 2017 06:43
Meta properties for social media link sharing