Skip to content

Instantly share code, notes, and snippets.

View harshsinghal's full-sized avatar

Harsh Singhal harshsinghal

View GitHub Profile
@harshsinghal
harshsinghal / query_llm.py
Last active July 26, 2023 08:37
Accompanying code to go with a series of posts on Retrieval Augmented Generation posts on LinkedIn by Harsh Singhal https://www.linkedin.com/in/harshsinghal/
# ___
# / ()\\
# _|_____|_
# | | === | |
# |_| O |_|
# || O ||
# ||__*__||
# |~ \\___/ ~|
# /=\\ /=\\ /=\\
#______[_]_[_]_[_]_______
@harshsinghal
harshsinghal / create_index.py
Last active July 26, 2023 08:37
Accompanying code to go with a series of posts on Retrieval Augmented Generation posts on LinkedIn by Harsh Singhal https://www.linkedin.com/in/harshsinghal/
# ___
# / ()\\
# _|_____|_
# | | === | |
# |_| O |_|
# || O ||
# ||__*__||
# |~ \\___/ ~|
# /=\\ /=\\ /=\\
#______[_]_[_]_[_]_______
@harshsinghal
harshsinghal / resnet50_service.py
Last active July 7, 2019 17:02
ResNet50 image labeling service using CherryPy web framework
from keras.applications.resnet50 import ResNet50
from keras.preprocessing import image
from keras.applications.resnet50 import preprocess_input, decode_predictions
import numpy as np
import os
import cherrypy
import tensorflow as tf
import uuid
import simplejson
@harshsinghal
harshsinghal / get_iris_insert_pg.py
Last active July 2, 2019 22:33
Grab data using pandas and insert into PostgreSQL db
# Used in blog post https://harshsinghal.dev/post/learn-sql-in-a-browser-with-postgresql-and-pgweb.html
import pandas as pd
from sqlalchemy import create_engine
iris = pd.read_csv('https://raw.githubusercontent.com/mwaskom/seaborn-data/master/iris.csv')
engine = create_engine('postgresql://postgres:postgres@localhost:5432/postgres')
iris.to_sql("iris", engine, if_exists = 'replace', index=False, chunksize=1000)