Skip to content

Instantly share code, notes, and snippets.

{"name":"vscode","settings":"{\"settings\":\"{\\n \\\"editor.cursorBlinking\\\": \\\"smooth\\\",\\n \\\"files.autoSave\\\": \\\"onFocusChange\\\",\\n \\\"editor.fontSize\\\": 14,\\n \\\"editor.fontFamily\\\": \\\"JetBrainsMono Nerd Font Propo\\\",\\n \\\"terminal.integrated.fontFamily\\\": \\\"JetBrainsMono Nerd Font Propo\\\",\\n \\\"files.trimTrailingWhitespace\\\": true,\\n \\\"workbench.editor.highlightModifiedTabs\\\": true,\\n \\\"workbench.iconTheme\\\": \\\"eq-material-theme-icons-palenight\\\",\\n \\\"python.analysis.addImport.exactMatchOnly\\\": true,\\n \\\"python.analysis.autoFormatStrings\\\": true,\\n \\\"python.analysis.addImport.heuristics\\\": true,\\n \\\"python.analysis.autoImportCompletions\\\": true,\\n \\\"python.analysis.extraCommitChars\\\": true,\\n \\\"python.terminal.activateEnvInCurrentTerminal\\\": true,\\n \\\"editor.minimap.maxColumn\\\": 70,\\n \\\"workbench.colorTheme\\\": \\\"Dracula Pro\\\",\\n \\\"indentRainbow.indicatorSty
import threading
import time
import requests
# Set the URL to send requests to (choose a test server or an address that responds quickly)
URL = "https://httpbin.org/get"
# Total number of requests to be made
NUM_REQUESTS = 1000
NUM_THREADS = 50
@AliYmn
AliYmn / signature.py
Last active December 4, 2024 19:45
High-Performance API Signature Validation: A FastAPI Journey 🚀
import hashlib
from functools import lru_cache
from json.decoder import JSONDecodeError
from typing import Any, Dict, Optional, Type
from fastapi import Request
from sqlalchemy import select
from libs.db import get_db_session
from libs.exceptions import ErrorCode
from libs.models import Operator
class SignatureService:
@AliYmn
AliYmn / gits-rest-cover.bash
Created December 5, 2024 09:58
A safety wrapper for git reset commands that adds a confirmation prompt before executing potentially destructive reset operations. Helps prevent accidental resets while maintaining all original git functionality.
# A safety wrapper for git reset commands
# Prompts for confirmation before executing potentially destructive reset operations
# Usage: Just use git reset or git reset --hard as normal, it will ask for confirmation (y/n)
function git() {
if [ "$1" = "reset" ]; then
if [ "$2" = "--hard" ]; then
echo -n "Are you sure you want to execute 'git reset --hard'? (y/n): "
read REPLY
if [[ $REPLY =~ ^[Yy]$ ]]; then
command git "$@"