Skip to content

Instantly share code, notes, and snippets.

View aadityataparia's full-sized avatar
👨‍💻
🗼

Aaditya Taparia aadityataparia

👨‍💻
🗼
View GitHub Profile
@aadityataparia
aadityataparia / mac_setup.sh
Last active June 21, 2023 09:10
Mac (Silicon) initial setup
# Brew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew update
# ZSH
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# Add brew to path
(echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') >> ~/.zshrc
eval "$(/opt/homebrew/bin/brew shellenv)"
@aadityataparia
aadityataparia / asyncHooks.js
Last active November 15, 2021 09:17
Async callback and effect hooks for React in JS and TS
import { useCallback, useState, useEffect } from 'react'
const defaultState = { error: null, isLoading: false, result: null }
export const useAsyncCallback = (callback, deps = []) => {
const [state, setState] = useState(defaultState)
const cb = useCallback(
(...args) => {
const req = callback(...args)
@aadityataparia
aadityataparia / useAsyncDebounced.js
Last active February 15, 2020 12:44
Debouce async function in react, function returns promise that resolves only when debouced function is fired
import { useCallback, useMemo } from 'react'
import { debounce } from 'lodash'
export const useAsyncDebounced = (callback, time) => {
const debounced = useMemo(
() =>
debounce(
(res, rej, ...args) =>
callback(...args)
.then(res)
@aadityataparia
aadityataparia / when-you-are-bored.md
Last active September 7, 2019 11:35
Movies/TV Shows
@aadityataparia
aadityataparia / localeimporter.js
Last active April 5, 2019 07:58
Momentjs to Dayjs locale importer
const fs = require('fs')
const path = require('path')
const momentLocaleFolder = path.join(__dirname, 'locale')
const dayjsLocaleFolder = path.join(__dirname, 'src/locale')
const saveFolder = path.join(__dirname, 'src/locale')
const Moment = require(path.join(__dirname, './moment'))
function objectToString(obj, prefix = ' ') {
let string = '{'
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>walker vs tree walker</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>
@aadityataparia
aadityataparia / default.conf
Last active February 6, 2019 22:00
Wildcard subdomains config in nginx
server {
listen 80;
listen [::]:80 default;
listen 443 ssl;
index index.php index.html;
server_name ~^(?<subdomain>[^.]+).example.com;
root /var/www/$subdomain;
}