Skip to content

Instantly share code, notes, and snippets.

View mentix02's full-sized avatar
💻
coding away

Manan mentix02

💻
coding away
View GitHub Profile
import { useRef, type SubmitEvent } from "react";
export function APITester() {
const responseInputRef = useRef<HTMLTextAreaElement>(null);
const testEndpoint = async (e: SubmitEvent<HTMLFormElement>) => {
e.preventDefault();
try {
const form = e.currentTarget;
#!/usr/bin/env python
import sys
# TestCase = (nums, k, possible_results)
type TestCase = tuple[list[int], int, list[set[int]]]
def k_most_frequent(nums: list[int], k: int) -> set[int]:
"""
Returns a set of k most frequently recurring unique numbers.
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stddef.h>
#include <assert.h>
#include <stdbool.h>
#include <inttypes.h>
#define CAP_GROWTH_RATE 2
@mentix02
mentix02 / expdict.py
Last active January 18, 2026 02:30
Redis who?
import time
import heapq
import unittest
import threading
from typing import Any, Optional
from collections.abc import Hashable
class _MissingType:
"""
@mentix02
mentix02 / Dockerfile
Created September 9, 2025 16:00
A portable kali Docker setup
FROM kalilinux/kali-rolling
# Avoid interactive prompts during install
ENV DEBIAN_FRONTEND=noninteractive
# Update + install common CTF tools
RUN apt-get update && apt-get install -y \
kali-tools-top10 \
kali-tools-web \
kali-tools-wireless \
type WebhookEventAttributes = {
http_request: {
client_ip: string;
user_agent: string;
};
};
type Webhook<EvtType, Data> = {
type: EvtType;
object: 'event';
@mentix02
mentix02 / short.py
Created August 15, 2025 21:19
Visualise short cuiting in action in Python
class Klass:
@property
def value_a(self) -> bool:
print('Value a accessed')
return False
@property
def value_b(self) -> bool:
print('Value b accessed')
return False
@mentix02
mentix02 / earth911.py
Last active August 5, 2025 09:31
Scrapes Earth911. Run `pip install httpx bs4` to run the script.
#!/usr/bin/env python3
"""
File: earth911.py
Author: mentix02 (Manan manan.yadav02@gmail.com)
Task: Scrape search results of search.earch911.com and extract data into a CSV file.
Making a request to search.earth911.com by spoofing the headers to make it look like you're coming from a
browser. We are returned with plain HTML - no JSON API to reverse engineer unfortunately. Parsing this HTML,
we get a list of hrefs over which we loop (asynchronously, of course) and fetch details of the individual
centre (in HTML - from which we extract a dictionary of properties).
@mentix02
mentix02 / context.ts
Last active June 28, 2025 10:10
Auth
import z from "zod";
import { createContext } from "react";
export const AuthDataSchema = z
.object({
id: z.string().optional(),
name: z.string().optional(),
email: z.string().email().optional(),
token: z.string().optional(),
@mentix02
mentix02 / client.py
Created March 15, 2025 20:36
A comparision between aiohttp, requests, and httpx in Python
import sys
import time
import random
import asyncio
import argparse
from typing import Callable, Coroutine
import httpx
import aiohttp
import requests