Skip to content

Instantly share code, notes, and snippets.

View mokshchadha's full-sized avatar

Moksh Rai Chadha mokshchadha

View GitHub Profile
@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 / pg_freebsd
Created September 5, 2024 16:23
pg_freebsd.sh - install custom pg16 on freebsd
#!/bin/sh
# Configuration variables
POSTGRES_VERSION="16.3"
POSTGRES_PREFIX="/usr/local/pgsql"
DATA_DIR="$POSTGRES_PREFIX/data"
LOGFILE="$POSTGRES_PREFIX/logfile"
BUILD_DIR="/tmp/postgresql-build"
PYTHON3_PATH=$(which python3)
@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 = [];