Skip to content

Instantly share code, notes, and snippets.

@bharadwaj6
bharadwaj6 / heaps.py
Created June 3, 2017 06:56
To calculate running median given a huge list of numbers
from heapq import heappop, heappush
class MinHeap(object):
def __init__(self):
self._items = []
def push(self, item):
heappush(self._items, item)
@bharadwaj6
bharadwaj6 / tsp_heuristic.py
Created August 2, 2017 21:11
Travelling Salesman tour for ~33k cities with heuristic approximation - stanford algorithms thingy
INF = 10 ** 9
class City(object):
__slots__ = ('city_id', 'x', 'y')
def __init__(self, city_id, x, y):
self.city_id = int(city_id)
self.x = x
self.y = y
@bharadwaj6
bharadwaj6 / animal-recognition.ipynb
Last active November 14, 2019 07:29
animal multi label classification (0.9607)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bharadwaj6
bharadwaj6 / Telugu_Language_Model.ipynb
Created May 25, 2018 21:27
Telugu_Language_Model
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bharadwaj6
bharadwaj6 / metastream_server.py
Last active February 26, 2020 16:23
Python streaming server to metastream your local videos with friends and family (https://getmetastream.com/)
from starlette.applications import Starlette
from starlette.responses import StreamingResponse, HTMLResponse
from starlette.routing import Route
from pathlib import Path
VIDEO_PATH = Path('videos')
def stream(request):
git clone 'https://github.com/fastai/course-v4.git'
echo Setting up server...
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -q
sudo apt-get install -y nodejs -q
pip install jupyter jupyterlab --upgrade -q
pip install jupyter_contrib_nbextensions && jupyter contrib nbextension install -q
pip install -r /content/course-v4/requirements.txt -q
wget -q -c -nc https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip
unzip -qq -n ngrok-stable-linux-amd64.zip
perl -pi -e 's|execution_count": null|execution_count": 1|g' course-v4/nbs/*ipynb
nohup jupyter notebook --no-browser --allow-root --ip=0.0.0.0&
kill $(ps aux | grep './ngrok' | awk '{print $2}')