Skip to content

Instantly share code, notes, and snippets.

View smartm13's full-sized avatar
Hopping!

Mihir Parikh smartm13

Hopping!
View GitHub Profile
@smartm13
smartm13 / large.txt
Created February 13, 2025 14:46
large page
133K TOKENS ESTIMATED
### Historical Context
The Constitution of the United States is the supreme law of the United States of America1. It was framed by a convention of delegates from twelve of the thirteen original states in Philadelphia in May 1787, Rhode Island being the only state not to send a delegate2. The aim of the convention was to revise the Articles of Confederation, the first constitution of the United States2. However, the delegates decided to create an entirely new form of government1.
Road to the Constitution
The Articles of Confederation, adopted in 1777, created a weak central government with limited powers2. The Confederation Congress could make rules and request funds from the states, but it lacked enforcement powers, could not regulate commerce, or print money2. The states retained considerable autonomy, leading to disputes over territory, war pensions, taxation, and trade, threatening to fragment the young nation2.
Recognizing the shortcomings of the Articles, leaders like James Madiso
@smartm13
smartm13 / fix_vectore_weaviate_mount.sh
Last active December 31, 2024 12:17
Corporate script for Fix Vector to VectorE Docker Mounts
#!/bin/bash
# Check if WEAVIATE_KEY is set
if [ -z "$WEAVIATE_KEY" ]; then
echo "Error: WEAVIATE_KEY environment variable is not set. Exiting."
exit 1
fi
# Extract env_name and account_name using the command provided
path=$(df -h | grep "file.core.windows.net" | grep "shareddata" | awk '{print $6}')
@smartm13
smartm13 / streamlit_helper.py
Last active January 11, 2023 16:36
Decorate this before st.experimental_memo and later check if function has already cached a given set of args+kwargs
import functools
def st_cache_monitor(func):
""" A decorator to handle query_cache=hit/miss utility """
@functools.wraps(func)
def wrapper_func(*args, _querying_cache=None, **kwargs):
""" Wrapper to original func to handle special argument _querying_cache """
if _querying_cache is Ellipsis:
raise LookupError("_querying_cache=`miss`")
@smartm13
smartm13 / plot_kmeans_comparison.ipynb
Created October 3, 2021 00:51
K-Means on Toy datasets
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@smartm13
smartm13 / hello_walrus.ipynb
Created November 7, 2019 13:06
Trying new python 3.8 Walrus operator in a leetcode problem to solve using one-liner
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@smartm13
smartm13 / DeleteOldFilesJob.py
Last active March 25, 2019 12:45
UNTESTED. python3 script to delete all files OLDER than minAge_sec inside basepath (recursively)
#!python3
#script to delete all files OLDER than minAge_sec inside basepath (recursively)
#set these args before running
basepath="."
minAge_sec=14*24*60*60 #14days
logfilepath="~/deletionJob.log"
#ofcourse, logfilepath should lie outside basepath
import os,time
@smartm13
smartm13 / batchFindReplace.py
Last active March 15, 2019 17:35
Batch string find replace #untested
#batch find replace
basepath=input("Enter fullpath of project rootdir:")
findtext=input("Enter fullpath of find_to text file:")
reptext=input("Enter fullpath of replace_with text file:")
endswithfilter=input("Enter the string the target files should end with [.html for example]:")
#setting
progress=1000#report after every n no. of files.
encoding='latin-1'#encoding to read and write all files with
@smartm13
smartm13 / burp2requests_module.py
Last active February 26, 2019 22:06
A python function to convert raw http request (mostly copied from burp or verbose curl) into a requests function.. Creates a dynamic function that can accept variables.
def burp2req(rawDump):
"""paste the raw dump from burp suite and replace all variables b/w << >>.
It will return an equivalent py function that accepts variables from dump and returns response obj"""
head=list(map(str.strip,rawDump.split("\n\n",1)))
if len(head)==2:head,body=head
else:head,body=head[0]," "
l1,head=head.split('\n',1)
l1,head=l1.split(),dict([map(str.strip,h.split(":",1)) for h in head.split('\n') if h.strip()])
host=head.get('Host',head.get('host',head.get("HOST",None)))
pr="https://" if l1[-1]=="HTTP/1.1" else "http://"