Skip to content

Instantly share code, notes, and snippets.

View AnishLushte07's full-sized avatar

Anish Lushte AnishLushte07

  • LeadSchool
  • Mumbai
View GitHub Profile
https://mherman.org/blog/dockerizing-a-react-app/
https://scotch.io/tutorials/react-docker-with-security-in-10-minutes
Node best practice: https://github.com/goldbergyoni/nodebestpractices
@AnishLushte07
AnishLushte07 / usePageVisibility.js
Last active April 21, 2024 08:02
ReactJS custom hook for page visibility change. Track tabs and window switch.
/*
* This react hook tracks page visibility using browser page visibility api.
* Reference: https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibility_API
*
* Use: const pageVisibilityStatus = usePageVisibility();
* Return type: boolean
*/
import { useState, useEffect } from 'react';
@AnishLushte07
AnishLushte07 / useSwipeHook.js
Created October 9, 2020 17:04
ReactJS Custom hook for swipe gesture on mobile browser using Hammer.js
/*
* Swipe hook gives functionality to detect user swipe event on give container.
* Dependency: hammerjs (npm install hammerjs --save)
*
* e.g
* Component.js
* const swipeContainerRef = useRef();
* useSwipeHook(swipeContainerRef, leftSwipeCallback, rightSwipeCallback)
* <div ref={swipeContainerRef}>Swipe hook will catch events for this container</div>
*
@AnishLushte07
AnishLushte07 / Flatten object
Created June 13, 2020 07:04
Flatten javascript objects into a single-depth object
function flattenObj(obj, preKey) {
const entries = Object.entries(obj);
return entries.reduce((acc, curr) => {
let [key, value] = curr;
return typeof value !== 'object'
? Object.assign(acc, { [preKey ? `${preKey}.${key}` : key] : value })
: Object.assign(acc, flattenObj(value, preKey ? `${preKey}.${key}` : key));
}, {});
@AnishLushte07
AnishLushte07 / trie.js
Created April 27, 2020 14:41
Implementation of Trie data structure in javascript
function Node() {
this.keys = new Map();
this.end = null;
this.setEnd = function() {
this.end = true;
}
this.isEnd = function() {
return this.end;
}
}
@AnishLushte07
AnishLushte07 / package
Created October 3, 2019 05:39
Useful packages
Cron monitor tool: https://github.com/zricethezav/gronit
@AnishLushte07
AnishLushte07 / parent.sql
Created July 31, 2019 09:52
Tree selection sql
select id,
name,
parent_id
from (select * from user_categories
order by parent_id, id) products_sorted,
(select @pv := '104') initialisation
where find_in_set(parent_id, @pv)
and length(@pv := concat(@pv, ',', id))
@AnishLushte07
AnishLushte07 / index.html
Last active July 19, 2019 12:45
Candidate UI
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
<body>
<script>
@AnishLushte07
AnishLushte07 / resource.txt
Created June 23, 2019 17:19
Angular 7 resource
Rich text editor: https://www.npmjs.com/package/@syncfusion/ej2-angular-richtexteditor
@AnishLushte07
AnishLushte07 / links.txt
Last active September 13, 2019 11:17
Drag and drop eg