Skip to content

Instantly share code, notes, and snippets.

View simbathesailor's full-sized avatar
🎯
Focusing

Anil Kumar Chaudhary simbathesailor

🎯
Focusing
View GitHub Profile
@simbathesailor
simbathesailor / Hookspassingcallbacks.jsx
Created December 24, 2019 15:44
Hooks passing callbacks
function App() {
// Notice the callback passed to component will be a new reference
// on every rerender for both the callbacks
function callback() {
// some logic
}
function callback2() {
// some logic
}
@simbathesailor
simbathesailor / processenvinjection.md
Last active November 28, 2024 05:16
PROCESS ENV DYNAMIC INJECTION

INPUT

$$_INTERNAL_MATHRANDOMSTART${Math.random()}MATHRANDOMEND$$_INTERNAL__

OUTPUT without loose

"use strict";

"$$INTERNAL_MATHRANDOMSTART".concat(Math.random(), "MATHRANDOMEND$$INTERNAL");

@simbathesailor
simbathesailor / useQRCodeScan.js
Last active November 28, 2024 00:45
useQRCodeScan.js
function useQRCodeScan({
qrcodeMountNodeID = "",
closeAfterScan = true,
getQrBoxDimension,
}) {
const [decodedQRData, setDecodedQrData] = useState({
isScanning: false,
isScanSuccess: false,
isScanFailure: false,
data: null,
@simbathesailor
simbathesailor / intersectionobserver.js
Created January 21, 2020 16:41
intersectionobserver.js
let options = {
root: document.querySelector("#scrollArea"), // null
rootMargin: "0px 0px 0px 0px",
threshold: 1.0 // [0, 0.25, 0.50, 0.75, 1]
};
let observer = new IntersectionObserver(callback, options);
let target = document.querySelector("#listItem");
observer.observe(target);
observer.unobserve(target);
@simbathesailor
simbathesailor / gist:ed2e21ec87f03ec56d07d99a481c12ba
Created November 9, 2019 12:33
How to create iterable for string and array
var t = "test"
t = s[Symbol.iterator]()
t.next() // t
t.next() // e
t.next() // s
t.next() // t
t.next() // done: true
@simbathesailor
simbathesailor / withnames-use-what-changed.jsx
Created November 17, 2019 04:40
withnames-use-what-changed
useWhatChanged([a, b, c, d], 'a, b, c, d'); // debugs the below useEffect
@simbathesailor
simbathesailor / git.txt
Created November 29, 2019 15:15 — forked from ospatil/git.txt
Important git command for branch and tag management
1. get list of remote tags
git ls-remote --tags origin
2. get list of local tags
git tag
3. remove local tag
git tag -d <tag name>
4. delete remote tag
const bypass = [
// function names to avoid logging
];
const collapsed = [
// function names to groupCollapsed
];
module.exports = function(babel) {
const { types: t } = babel;
const wrapFunctionBody = babel.template(`{
@simbathesailor
simbathesailor / getTimezone.js
Created January 26, 2020 02:41
getTimezone.js
import { utcToZonedTime, format as formatTimeZone } from 'date-fns-tz';
//'America/Los_Angeles'
// const utcString = '2019-09-25T12:00:00.000Z';
function getTimeZoneText(utcString) {
try {
const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
if (Intl) {
const zoneDateObj = utcToZonedTime(utcString, timeZone);
@simbathesailor
simbathesailor / intersectionobservercallback.js
Created January 22, 2020 17:42
intersectionobservercallback.js
let callback = (entries, observer) => {
entries.forEach(entry => {
// Each entry describes an intersection change for one observed
// target element:
// entry.boundingClientRect
// entry.intersectionRatio
// entry.intersectionRect
// entry.isIntersecting
// entry.rootBounds
// entry.target