Skip to content

Instantly share code, notes, and snippets.

View hkp22's full-sized avatar

Harish Kumar hkp22

View GitHub Profile

Setup Eslint Prettier and Husky in Node JS Typescript Project

1. ESLint

  • Step 1 - Install the dependencies

    • eslint
      • ESLint is a tool for identifying and reporting on patterns found in ECMAScript/JavaScript code.
      • npm install --save-dev eslint
    • typescript-eslint/parser
@hkp22
hkp22 / gist:a384cb553ccbfdcf850ea30cba645810
Created March 13, 2021 22:24 — forked from karlgroves/gist:7544592
Get DOM path of an element
function getDomPath(el) {
var stack = [];
while ( el.parentNode != null ) {
console.log(el.nodeName);
var sibCount = 0;
var sibIndex = 0;
for ( var i = 0; i < el.parentNode.childNodes.length; i++ ) {
var sib = el.parentNode.childNodes[i];
if ( sib.nodeName == el.nodeName ) {
if ( sib === el ) {
@hkp22
hkp22 / iframechange.js
Created March 13, 2021 22:23 — forked from hdodov/iframechange.js
HTML iframe URL change listener for tracking when a new iframe page starts to load
function iframeURLChange(iframe, callback) {
var lastDispatched = null;
var dispatchChange = function () {
var newHref = iframe.contentWindow.location.href;
if (newHref !== lastDispatched) {
callback(newHref);
lastDispatched = newHref;
}
@hkp22
hkp22 / install_lamp_18.sh
Created January 18, 2020 18:32 — forked from ankurk91/install_lamp_ubuntu.sh
Ubuntu 18.04 - PHP development (php 7.3, MySQL 5.7, apache 2.4)
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
# Ubuntu 18.04 dev Server
# Run like - bash install_lamp.sh
# Script should auto terminate on errors
echo -e "\e[96m Adding PPA \e[39m"
sudo add-apt-repository -y ppa:ondrej/apache2
@hkp22
hkp22 / List.vue
Created December 15, 2019 17:25 — forked from Akryum/List.vue
Vue - onScrollBottom composable function
<script>
import { ref } from '@vue/composition-api'
import { onScrollBottom } from '@/scroll'
export default {
setup () {
function loadMore () {
// ...
}
@hkp22
hkp22 / ParseInputStream.php
Created October 30, 2019 21:09 — forked from devmycloud/ParseInputStream.php
Process php://input to get multipart/form-data parameters for PATCH API request
<?php
use Illuminate\Support\Facades\Log;
use Symfony\Component\HttpFoundation\File\UploadedFile;
/**
* stream - Handle raw input stream
*
* LICENSE: This source file is subject to version 3.01 of the GPL license
* that is available through the world-wide-web at the following URI:
@hkp22
hkp22 / social-regexps.js
Created October 23, 2019 19:16 — forked from styopdev/social-regexps.js
Social networks profiles validation regexps
// Facebook
/((https?):\/\/)(www[.])?(mbasic.facebook|m\.facebook|facebook|fb)\.(com|me)\/(?:(?:\w\.)*#!\/)?(?:pages\/)?(?:[\w\-\.]*\/)*([\w\-\.]*)/ig,
// LinkedIn
/((https?):\/\/)(www[.])?linkedin\.com\/(in|company|groups)\/.?\/?.?\/?([0-9]*)/,
// Google+
/((https?):\/\/)(www[.])?plus\.google\.com\/u\/.?\/?.?\/?([0-9]*)/,
// Twitter
/((https?):\/\/)(?:www\.)?twitter\.com\/([a-zA-Z0-9_]+)/,
// IMDb
/(http:\/\/)(www[.])imdb\.com\/.?\/?.?\/?([0-9]*)/,
@hkp22
hkp22 / fbUrlCheck.php
Created October 23, 2019 17:40 — forked from atomicpages/fbUrlCheck.php
A simple facebook URL checker RegEx for PHP or JavaScript
<?php
/**
* A simple regex to test whether or not a facebook url is valid. For basic usage, this will do the job.
* @see Test cases <http://ideone.com/ZMJp4f>
*/
$fbUrlCheck = '/^(https?:\/\/)?(www\.)?facebook.com\/[a-zA-Z0-9(\.\?)?]/';
$secondCheck = '/home((\/)?\.[a-zA-Z0-9])?/';
$validUrl = 'https://www.facebook.com/atomicpages/';
@hkp22
hkp22 / closetags.php
Created July 28, 2019 13:26 — forked from JayWood/closetags.php
Close ALL open HTML tags in PHP string
<?php
function closetags($html) {
preg_match_all('#<([a-z]+)(?: .*)?(?<![/|/ ])>#iU', $html, $result);
$openedtags = $result[1];
preg_match_all('#</([a-z]+)>#iU', $html, $result);
$closedtags = $result[1];
$len_opened = count($openedtags);
@hkp22
hkp22 / tailwindcss.blade.php
Created June 25, 2019 09:54 — forked from mazedlx/tailwindcss.blade.php
Tailwind CSS template for Laravel pagination
@if ($paginator->hasPages())
<div class="flex items-center">
{{-- Previous Page Link --}}
@if ($paginator->onFirstPage())
<span class="rounded-l rounded-sm border border-brand-light px-3 py-2 cursor-not-allowed no-underline">&laquo;</span>
@else
<a
class="rounded-l rounded-sm border-t border-b border-l border-brand-light px-3 py-2 text-brand-dark hover:bg-brand-light no-underline"
href="{{ $paginator->previousPageUrl() }}"
rel="prev"