Skip to content

Instantly share code, notes, and snippets.

@marufsiddiqui
marufsiddiqui / Readme.md
Last active January 5, 2025 18:10
Order Return tech spec

Okay, this is a good breakdown of the order return flow. Let's create a data structure that captures this information on the client-side using TypeScript and useReducer with Context. This approach offers good state management and allows for persistence.

Data Structure (TypeScript)

interface ProductDetails {
  productId: string;
  salesLineId: string;
  product: {
    name: string;
@marufsiddiqui
marufsiddiqui / cache.tsx
Created August 29, 2024 12:08
2 way to interact with Apollo Cache
function clearWishlist2() {
const cache = apolloClient.cache
cache.modify({
id: cache.identify({ __typename: 'GraphqlWishlistItems' }),
fields: {
items(existingItemRefs) {
existingItemRefs.forEach((itemRef: Reference) => {
cache.modify({
id: cache.identify(itemRef),
fields: {
function findModalFooter1(children: ReactNode): ReactNode {
return React.Children.toArray(children).find((child: ReactNode) => {
if (!child || !React.isValidElement(child)) {
return null
}
if (child.type === 'ModalFooter') {
return child
} else if (React.Children.count(child) > 0) {
return findModalFooter(child.props.children)
}
@marufsiddiqui
marufsiddiqui / 1.json
Last active September 6, 2023 14:03
json
[
{
"date": "2023-09-01T05:24:47.000+00:00",
"feedback": "title: Hervorragend, feedback: Ich habe dieses i Phone ca. 2 Wochen und bin mehr als zufrieden. \nDie Kamera ist mega gut und macht qualitativ hochwertige Bilder.\nAuch das Laden geht sehr schnell. Und der Akku des Handys hält bei meinem Gebrauch mehr als einen ganzen Tag. \nDas Design ist auch hochwertig und gut verarbeitet. Alles in allem kann man nicht meckern. \nAuch die Kopplung mit IPad und Apple Watch funktioniert wie immer einwandfrei. \n\nAlles in allem bin ich sehr zufrieden mit dem Kauf und bereue es nicht. \nIch nutze Apple seit circa 2 Jahren und bin immer wieder zufrieden !, advantages: Kamera gut, Batterie gut"
},
{
"date": "2023-08-31T21:26:10.000+00:00",
"feedback": "title: Super, feedback: Meine Freundin hat mir zuerst das 14 Pro Max Geschenkt nach langem überlegen ob sie iPhone mag oder doch bei Samsung bleibt hab ich ihr das 14 pro in Gold geschenkt weil das Pro zu groß ist für Sie! Jetzt sind wir beide bei App
targetingEntries.forEach(([key, value]) => {
if (key && value) {
googletag.cmd.push(() => googletag.pubads().setTargeting(key, value))
}
})
googletag.cmd.push(() => {
const slots = googletag.pubads().getSlots()
if (slots?.length) {
googletag.pubads().refresh()
export const FULL_WIDTH_DIMENSION_CATEGORY = {
xs: {
width: 330,
height: 159,
},
sm: {
width: 463,
height: 159,
},
md: {
@marufsiddiqui
marufsiddiqui / testResultsProcessorNodeEnv.js
Created May 19, 2021 09:56
Adds jest-env node for the tests that can run in node only
const fs = require('fs')
const _prependNodeDocBlock = filePath => {
const docBlock = `/**
* @jest-environment node
*/
`
fs.readFile(filePath, 'utf8', (error, result) => {
if (error && error.code !== 'ENOENT') {
return console.log(error)

Disable Device Enrollment Program (DEP) notification on macOS Catalina.md

With full reinstall (recommended)

   a. Boot into recovery using command-R during reboot, wipe the harddrive using Disk Utility, and select reinstall macOS

   b. Initial installation will run for approximately 1 hour, and reboot once

   c. It will then show a remaining time of about 10-15 minutes

@marufsiddiqui
marufsiddiqui / useE2EMock.ts
Created January 27, 2021 11:47
useE2EMock hook
import { useLocation } from 'react-router'
import { parse } from 'qs'
import { useEffect, useRef } from 'react'
interface Params {
refetch: () => void
shouldSkip?: boolean
}
export const useE2EMock = ({ refetch, shouldSkip = false }: Params): void => {
@marufsiddiqui
marufsiddiqui / App.js
Created October 20, 2020 13:51
useShowMore React hook
import React, { useCallback, useState } from "react";
import "./styles.css";
const useShowMore = ({ items = [], initialVisibleItems = 4 }) => {
const [filteredItems, setFilteredItems] = useState(
items.slice(0, initialVisibleItems)
);
const [expanded, setExpanded] = useState(false);
const hasMoreItems = items.length > initialVisibleItems;