Skip to content

Instantly share code, notes, and snippets.

View rohmanhm's full-sized avatar
💪
yes

Rohman HM rohmanhm

💪
yes
View GitHub Profile
@rohmanhm
rohmanhm / use-debounced-effect.ts
Last active May 6, 2024 12:28
useDebouncedEffect to delay the React.useEffect to immediately being executed. It is useful to save some performance while user changing the state of the component.
import { DependencyList, useEffect } from 'react';
export function useDebouncedEffect(
fn: () => void,
deps: DependencyList,
delay: number
) {
useEffect(() => {
const timer = setTimeout(() => {
fn();

Filename

use{Service}{Action}.query.ts

Code

import { QueryObserverOptions, useQuery } from '@tanstack/react-query';

import { DataShape } from '@/types/api';

Filename

use{Service}{Action}.mutation.ts

Code

import { MutationOptions, useMutation } from '@tanstack/react-query';

import { PayloadType } from '@/types/api';

Refactor from

const CustomLink: React.PropsWithChildren<CustomLinkProps> = ({
  href,
  as,
  className,
  children,
  style = {},
  ...props
}) => {
export function downloadFileFromBlob(fileName: string, blob: Blob) {
const url = window?.URL?.createObjectURL(blob);
const link = document.createElement("a");
link.style.display = "none";
link.href = url;
link.setAttribute("download", fileName);
document.body.appendChild(link);
link.click();
setTimeout(() => {
document.body.removeChild(link);
@rohmanhm
rohmanhm / disable-web-security
Created October 27, 2021 11:12 — forked from yimity/disable-web-security
disable-web-security
open -a "Google Chrome" --args --disable-web-security --user-data-dir
open -a "Microsoft Edge" --args --disable-web-security --user-data-dir
/((https?):\/\/)?(www.)?[a-z0-9]+(\.[a-z0-9]{1,}){1,3}(:[0-9])?(#?\/?[a-zA-Z0-9#_-]+)*\/?(\?[a-zA-Z0-9-_]+=[a-zA-Z0-9-%]+&?.*)?$/gm
@rohmanhm
rohmanhm / index.html
Last active February 18, 2020 09:59
Declare new variable #jsbench #jsperf (http://jsbench.github.io/#b8d1826a76310d767596f59d4dd25ce2) #jsbench #jsperf
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Declare new variable #jsbench #jsperf</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
Verifying my Blockstack ID is secured with the address 1G5KphvEmgjn8TUACct2BNdr4Sj7XhpyD https://explorer.blockstack.org/address/1G5KphvEmgjn8TUACct2BNdr4Sj7XhpyD
@rohmanhm
rohmanhm / cloudSettings
Last active April 10, 2020 07:44
Visual Studio Code Settings Sync Gist
{"lastUpload":"2020-04-10T07:44:40.507Z","extensionVersion":"v3.4.3"}