Skip to content

Instantly share code, notes, and snippets.

View raveenb's full-sized avatar
:octocat:
Learning, Always!

Raveen Beemsingh raveenb

:octocat:
Learning, Always!
View GitHub Profile
@raveenb
raveenb / JupyterLab_Installation_and_Customizations_Python_3.11.md
Last active January 30, 2023 18:35
Awesome JupyterLab Installation and Customizations (Python 3.11)

JupyterLab Installation and Customizations (Python 3.11)

Make your JupyterLab awesome with Code Completion, Code Typeahead, Font Changes for Code/UI/Output, Faster Autosave, Black Autoformatting, Ruff Lint Suggestions, Rich Pretty Printed REPL Outputs, Darcula Theme, Autoversion of files, Pandas Lux Visualization, Javascript Kernel and more.

General Instructions

  1. Download the zip file of this gist. Unzip the zip file to a directory and give execution rights to the .sh files using chmod +x *.sh
  2. Ensure you are running on a mac and have homebrew installed
  3. Ensure you have python(3.9, 3.10, 3.11) installed and is available in the default path. Otherwise, install the versions you want, using brew install python@3.9 or brew install python@3.10 or brew install python@3.11

Installing JupyterLab

@raveenb
raveenb / fastapi_inside_jupyter.md
Last active September 18, 2023 06:32
Run FastAPI inside Jupyter

How to Run FastAPI inside Jupyter

  • Ensure you have these installed and accessible from the notebook pyngrok, nest_asyncio, fastapi, uvicorn and other libs you want
%pip install pyngrok nest_asyncio fastapi uvicorn loguru
  • Create a FastAPI app
from fastapi import FastAPI
@raveenb
raveenb / ssh.md
Last active March 19, 2021 15:16
Avoiding SSH Connection Timeouts
@raveenb
raveenb / proxy_fix.md
Last active January 20, 2021 16:20
Fix Oauth Issue for Flask+Traefik

If you are using Oauth login/register on a Flask server and its is behind Traefik. You will need to do two things to fix the https and redirect issues. You may be getting errors indicating that the OAuth callback is not valid or is not https enabled. And the intersting part to note is that it will work fine when running on local host and straight up https, but fail when the app is behing a proxy/edege router/traffic multiplexer like Traefik or NGinx.

  1. Do the Proxy fix to the wsgi app inside of the flask app. This is from the flask documentation itself https://flask.palletsprojects.com/en/1.1.x/deploying/wsgi-standalone/#deploying-proxy-setups
# assuming app is the Flask app

from werkzeug.middleware.proxy_fix import ProxyFix

app.wsgi_app = ProxyFix(app.wsgi_app, x_proto=1, x_host=1)
@raveenb
raveenb / ssh_into_android.md
Last active April 18, 2024 06:27
SSH into Android

Connecting to an Android device over SSH

Initial Setup

Install Android App Termux from APKPure or AppStore. If the app exists, just delete and re-install it to get the latest version, The APK can be downloaded from https://apkpure.com/termux/com.termux/ Install the APK using by running

adb install ~/Downloads/Termux_v0.73_apkpure.com.apk
@raveenb
raveenb / FlaskPandasNumpyCustomJSONEncoder.py
Last active October 23, 2019 15:44
Flask JSON numpy Encoder to work with Flask when using Numpy and Timestamp data
import json
import numpy as np
from flask import jsonify
from datetime import datetime, timedelta
class CustomJSONEncoder(json.JSONEncoder):
def default(self, o):
if isinstance(o, np.ndarray): return o.tolist()
if isinstance(o, np.int64): return int(o)
if isinstance(o, set): return list(o)
@raveenb
raveenb / setup_supercurie96.sh
Last active October 23, 2019 15:45
AWS SageMaker Setup to run things in parallel
#!/bin/bash
echo "> Activating Python3 Env"
source /home/ec2-user/anaconda3/bin/activate python3
echo "> Updating Python to 3.7"
conda update -y conda
conda install -y python=3.7
conda install -y pip
echo "> Updating Libraries"
pip install pandas numpy matplotlib ipython ipykernel notebook --upgrade
@raveenb
raveenb / Dockerfile
Last active October 23, 2019 15:43
Fix Docker Debian Jessie issues. Dockerfile changes to get around the apt-get issue in Debian Jessie. Shamelessly copied and adapted from discussion on Stackoverflow here https://unix.stackexchange.com/questions/508724/failed-to-fetch-jessie-backports-repository
FROM python:3.6-slim-jessie
MAINTAINER Raveen Beemsingh <raveenb@hammerhead.io>
RUN apt-get update && \
apt-get -y install cron curl redis-server sudo build-essential && \
rm -rf /var/lib/apt/lists/*
RUN adduser appuser
RUN echo "appuser ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers

Jon is visiting New York City for the first time. He would like to make use of his stay by touring various places around the city. He wonders if there could be any system which helps him to find a most optimal route which covers as many tourist places as possible from his source to his desired destination point.

Luckily, we have Open Street Maps which contatins "tags" on each road describing it. More information about it can be found here, http://wiki.openstreetmap.org/wiki/Elements#Tag.

Now, you as a Software Developer, need to develop a system to solve his problem. Here are the things that will help you,

Using these, when a source and destination points are given, you need to find a route which has a maximum number of tourist places in it.