Skip to content

Instantly share code, notes, and snippets.

@alireza-ahmadi
alireza-ahmadi / retryDynamicImport.ts
Last active October 14, 2024 19:58 — forked from mberneti/retryDynamicImport.ts
This utility function retryDynamicImport enhances React’s lazy loading mechanism by adding retry logic with a versioned query parameter. It retries importing a component multiple times in case of failure, which can be useful for bypassing browser cache or dealing with intermittent network issues. It can be used as a drop-in replacement for React…
// Usage:
// Replace React.lazy(() => import('x'));
// with retryDynamicImport(() => import('x'));
import { ComponentType, lazy } from 'react';
const MAX_RETRY_COUNT = 15;
const RETRY_DELAY_MS = 500;
// Regex to extract the module URL from the import statement
@alireza-ahmadi
alireza-ahmadi / commands.sh
Last active August 3, 2021 03:58
A quick benchmark of two slightly different solutions for checking whether an interface has any empty fields or not
# ----------------- 1 ----------------
# Make sure that both methods work as expected
go test
# Output ->
# PASS
# ok github.com/alireza-ahmadi/isempty 0.677s
# ----------------- 2 ----------------
# Run benchmark to understand the performance difference
# Aliases
alias o="open ."
alias pi="ping blogfa.com"
alias gis="git status"
alias gad="git add"
alias gil="git log"
alias s="source"
alias sp="spotify"
alias google-chrome="open -a 'Google Chrome'"
alias y="yarn"
@alireza-ahmadi
alireza-ahmadi / todo.md
Last active March 22, 2018 13:43 — forked from DeckerCHAN/todo.md
Gist todo list

To Do

  • for an empty checkboxP
  • for a checked checkboxP
// # Usage
//
// Save this file and replace username and password on the last line of the file with
// your Snapp username and password then run the following commands:
//
// yarn init && yarn add request
// node SnappTotalPriceCalculator.js
//
const request = require('request');
@alireza-ahmadi
alireza-ahmadi / BrewPackages.txt
Created November 11, 2016 14:15
List of my installed brew packages - `brew list`
ack
autoconf
automake
awscli
axel
cairo
cassandra
ccat
cctools
cloc
@alireza-ahmadi
alireza-ahmadi / bullet.zsh
Last active November 11, 2016 13:58
My ZSH setup
# Bullet Theme v0.1.0
#
# @author Alireza Ahmadi <[email protected]>
PROMPT=' %{$fg_bold[black]%}●%{$fg_bold[green]%}%p %{$fg_bold[blue]%}%c $(git_prompt_info)% %{$reset_color%}'
ZSH_THEME_GIT_PROMPT_CLEAN="> %{$fg_bold[cyan]%}✛ "
ZSH_THEME_GIT_PROMPT_DIRTY="> %{$fg_bold[red]%}✕ "
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[magenta]%}<"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"

My defaults write options

[Decrease dock's auto-hide delay]
defaults write com.apple.dock autohide-delay -float 0 && defaults write com.apple.dock autohide-time-modifier -float 0 && killall Dock
defaults delete com.apple.dock autohide-delay && defaults delete com.apple.dock autohide-time-modifier && killall Dock

[Speed up mission control animations]
defaults write com.apple.dock expose-animation-duration -float 0.12 && killall Dock
defaults delete com.apple.dock expose-animation-duration && killall Dock
# ------------------------------------------------------------------------------
# Description
# -----------
#
# Insert `ALL_PROXY=socks5://server:port` before the command by pressing
# ESC and p. Heavily inspired by oh-my-zsh's sudo plugin.
#
# ------------------------------------------------------------------------------
# Authors
# -------
public class Loop {
public static void main(String[] args)
{
Integer total = 500000000;
Integer chunk = 50000000;
Integer i = 0;