Skip to content

Instantly share code, notes, and snippets.

View mokshchadha's full-sized avatar

Moksh Rai Chadha mokshchadha

View GitHub Profile
@mokshchadha
mokshchadha / iterators.js
Created July 29, 2025 03:00
List of examples on how you can use and benchmark JS iterators
// ECMAScript 2025 Iterator Examples
// New built-in Iterator global with functional operators
// Example 1: Working with Arrays using Iterator helpers
const numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
const result = Iterator.from(numbers)
.filter(x => x % 2 === 0) // Keep even numbers
.map(x => x * x) // Square them
.take(3) // Take first 3
@mokshchadha
mokshchadha / scrape_iimjobs.js
Created May 29, 2025 10:04
Scrape IIM jobs using playwright and JS - May 2025
// Enhanced job scraper that opens individual job links and scrapes detailed data
const { chromium } = require('playwright');
const fs = require('fs');
const path = require('path');
async function scrapeJobsToCSV() {
const browser = await chromium.launch({ headless: false });
const page = await browser.newPage();
// Array to store all job data
@mokshchadha
mokshchadha / Readme.md
Created May 29, 2025 06:14
A service module to merge and club your docx filese to a single docx while preserving the styles

PDF Merger Script Prerequisites

Required software to run the PDF merger and conversion script.

Prerequisites: Node.js and Python are already installed.

Required Software

1. PDF Toolkit (pdftk)

For merging PDF files.

@mokshchadha
mokshchadha / ts_agents.ts
Created May 28, 2025 16:18
Create agents with ease with Google gemini
import {
GenerationConfig,
GoogleGenerativeAI,
HarmBlockThreshold,
HarmCategory,
Part,
Tool,
} from "@google/generative-ai";
interface AgentOptions {
@mokshchadha
mokshchadha / summarise.py
Created October 2, 2024 16:41
Summarise audio/Video files using gemini AI
import streamlit as st
import os
import tempfile
import google.generativeai as genai
import whisper
from pydub import AudioSegment
from dotenv import load_dotenv
load_dotenv()
# Configure the Gemini model
@mokshchadha
mokshchadha / sysctl.conf
Created September 8, 2024 14:33
FreeBSD - sysctl
#
# Add the following flags to your sysctl.conf file
#
kern.ipc.shmmax=134217728
kern.ipc.shmmin=1
kern.ipc.shmmni=1048576
kern.ipc.shmseg=1024
kern.ipc.shmall=1048576
kern.ipc.somaxconn=32767
@mokshchadha
mokshchadha / ide_java_setup.sh
Created September 8, 2024 12:51
freebsd install intellij IDEA
#!/bin/sh
# Function to check the exit status of the last command and handle errors
check_error() {
if [ $? -ne 0 ]; then
echo "Error: $1 failed. Exiting."
exit 1
fi
}
@mokshchadha
mokshchadha / kde_freebsd.sh
Last active September 13, 2024 03:15
Installing KDE plasma on freebsd and connecting via VNC server
# Update package repository
pkg update
# Install X.Org
pkg install -y xorg
# Install KDE Plasma
pkg install -y kde5
# Install SDDM (display manager)
@mokshchadha
mokshchadha / structure_output_weather.py
Created September 6, 2024 08:33
Get structred output from a LLM
import os
import time
from dotenv import load_dotenv
load_dotenv()
from pydantic import BaseModel, Field
from typing import TypedDict, Literal
from langgraph.graph import StateGraph, END
from langgraph.prebuilt import ToolNode
from langgraph.graph import MessagesState
from langchain.tools import tool
@mokshchadha
mokshchadha / gist:fe7f3a415f49dace6e8830a0dd202001
Created October 26, 2023 05:13
create map filter from scratch
function mapArray(arr,cb){
let res = [];
for(const e of arr){
res.push(cb(e));
}
return res;
}
function filterArray(arr, cb){
let res = [];