Skip to content

Instantly share code, notes, and snippets.

@av1v3k
av1v3k / container.js
Created April 4, 2026 14:09
Container App rendering the sub app/MFE app - for Microfrontend
// Any Sub App/MFE imported into the Container
export default () => {
const ref = useRef(null);
useEffect(() => {
mount(ref.current);
});
return <div ref={ref} />;
@av1v3k
av1v3k / docker-compose.yml
Created March 26, 2026 11:57
Docker compose file for spinning MONGODB
services:
mongodb:
image: mongo:latest
container_name: local-mongodb
restart: always
ports:
- "27017:27017"
environment:
MONGO_INITDB_ROOT_USERNAME: admin
MONGO_INITDB_ROOT_PASSWORD: password123
@av1v3k
av1v3k / debounce_throttle.js
Created March 12, 2026 06:35
Debounce & Throttle
/*Debounce Function*/
//==================
/*Wait for the "quiet" moment.*/
function debounce(func, delay) {
let timeoutId;
return function(...args) {
clearTimeout(timeoutId); // Reset the clock every time
timeoutId = setTimeout(() => {
@av1v3k
av1v3k / .js
Created February 12, 2026 11:39
angular | scenario - clicking any button must cancel any existing API request.
//after click of any buttons in the web application, I need to cancel any existing API request and must trigger the new API request associated with the Button. How do I do it in angular ?
import { Subject, switchMap } from 'rxjs';
// Inside your component
private clickTrigger = new Subject<void>();
// Set up the stream in ngOnInit or the constructor
this.clickTrigger.pipe(
switchMap(() => this.myService.getData())
@av1v3k
av1v3k / map.js
Created December 15, 2025 15:47
Use Map in JS
let m = new Map<string, number>([
['address', 500],
['age', 25],
]);
m.set('street', 400);
console.log(m.get('address'))
console.log(m)
@av1v3k
av1v3k / mocha.js
Created December 6, 2025 03:39
mocha & nodemon command: automated
nodemon --exec mocha -R min
@av1v3k
av1v3k / gist:12ff2d1aff0d6a06adca50973e8944cc
Created December 1, 2025 04:44
Created for generating RSA - Public, Private key pair.
https://gemini.google.com/share/3355cbddb91b
@av1v3k
av1v3k / datetime.js
Created November 7, 2025 11:52
convert UTC to IST using ES6 method
new Intl.DateTimeFormat('en-US', {
timeZone: 'Asia/Calcutta',
hour: "numeric",
minute: "numeric",
second: "numeric",
}).format(new Date(new Date().toISOString()))
@av1v3k
av1v3k / product-form.js, product-action.js
Created October 27, 2025 13:45
useActionState() - starter
Product Form:
============
"use client"
import { useActionState } from "react";
import { productAction } from "@/app/actions/product";
export default function ProductForm() {
@av1v3k
av1v3k / firstLocust.py
Created October 12, 2025 17:12
Basic locust program to test
from locust import User, task, between
class MyUser(User):
wait_time = between(2, 3)
@task
def my_task1(self):
print('First Task 1')
@task