Skip to content

Instantly share code, notes, and snippets.

View prrao87's full-sized avatar

Prashanth Rao prrao87

View GitHub Profile
{"lastUpload":"2022-01-28T17:29:31.646Z","extensionVersion":"v3.4.3"}
@prrao87
prrao87 / install_postman_mint_no_snap.md
Last active May 27, 2025 19:17
Install Postman on Linux Mint (without using snap)

Goal

Postman is a usefull app to build and test APIs, most commonly installed on ubuntu-like systems via snap. On recent distributions of Linux Mint (20 and above), snap installs are no longer possible. The instructions below show how to install Postman via the terminal.

Download Postman

$ wget https://dl.pstmn.io/download/latest/linux64 -O postman.tar.gz

Extract archive

$ sudo tar -xzf postman.tar.gz -C /opt

Make symlink

@prrao87
prrao87 / googleColabHold.js
Last active February 10, 2025 06:57
Prevent google colab from disconnecting on chrome (right mouse click -> inspect -> console tab -> insert code)
function ConnectButton(){
console.log("Connect pushed");
document.querySelector("#top-toolbar > colab-connect-button").shadowRoot.querySelector("#connect").click()
}
setInterval(ConnectButton,60000);
@prrao87
prrao87 / install_jupyter_venv.sh
Created March 10, 2021 21:30
Commands to manage and install virtual environment for Jupyter Notebook
# Install python ipykernel with environment name
python -m ipykernel install --user --name=<my_env_name>
# List or uninstall existing virtual envs for Jupyter
jupyter kernelspec list
jupyter kernelspec uninstall <my_env_name>
@prrao87
prrao87 / .zshrc
Last active December 21, 2023 20:19 — forked from ines/.zshrc
Command to activate / create Python virtual environmment
# Do not use the alias `python3`
# For this to work properly, explicitly specify the python version as necessary on your system
function venv {
default_envdir=".venv"
envdir=${1:-$default_envdir}
if [ ! -d $envdir ]; then
python3.12 -m venv $envdir
python3.12 -m pip install ruff
echo -e "\x1b[38;5;2m✔ Created virtualenv $envdir\x1b[0m"
import streamlit as st
import streamlit.components.v1 as components
from lime_explainer import explainer, tokenizer, METHODS
def format_dropdown_labels(val):
return METHODS[val]['name']
# Build app
title_text = 'LIME Explainer Dashboard for Fine-grained Sentiment'
subheader_text = '''1: Strongly Negative &nbsp 2: Weakly Negative &nbsp 3: Neutral &nbsp 4: Weakly Positive &nbsp 5: Strongly Positive'''
@app.callback(Output('text-input', 'value'),
Input('reset-button', 'n_clicks'))
def clear_form(n_clicks):
"""Empty input textarea"""
return ""
@app.callback(Output('explainer-obj', 'children'),
Input('submit-button', 'n_clicks'),
Input('reset-button', 'n_clicks'),
# ======== App layout ========
app.layout = html.Div([
html.H3('''
LIME Explainer Dashboard for Fine-grained Sentiment
''', style={'text-align': 'center'}),
html.Label('''
1: Strongly Negative 2: Weakly Negative 3: Neutral 4: Weakly Positive 5: Strongly Positive
''', style={'text-align': 'center'}),
html.Br(),
html.Label('Enter your text:'),
import os
from flask import Flask, request, render_template
from lime_explainer import explainer, tokenizer, METHODS
app = Flask(__name__)
SECRET_KEY = os.urandom(24)
@app.route('/')
@app.route('/result', methods=['POST'])
def index():
# ========== Callbacks ================
@app.callback(Output('topic-data', 'data'), [Input('date-dropdown', 'value')])
def get_topic_data(value):
with pymongo.MongoClient(**MONGO_ARGS) as connection:
read_collection = connection[READ_DB][READ_COL]
data = read_collection.find({'_id': value})
# Collect data
data = list(data)[0]
# Perform some expensive calculation
data_transformed = expensive_calc(data)