Skip to content

Instantly share code, notes, and snippets.

View tejashah88's full-sized avatar

Tejas Shah tejashah88

View GitHub Profile
@tejashah88
tejashah88 / ros-install-ubuntu-cosmic.sh
Last active January 9, 2020 11:02
Installing ROS on an Kubuntu Cosmic (18.10) system by building from source
# Source: http://wiki.ros.org/melodic/Installation/Source
function install_ros_first_time() {
# Install bootstrap dependencies
sudo apt-get install python-rosdep python-rosinstall-generator python-wstool python-rosinstall build-essential -y
# Initialize rosdep
sudo rosdep init
rosdep update
@tejashah88
tejashah88 / install-python-scratch.sh
Last active November 24, 2019 22:50
Install python 3 from scratch. Helpful for upgrading python 3 version in GCP's Deep Learning VM.
VERSION=$1
sudo apt install gcc make zlib1g-dev
sudo apt install libssl-dev # needed for SSL support
sudo apt install libsqlite3-dev # needed for SQLite support
sudo apt-get install libbz2-dev # needed for BZ2 compression support
wget "https://www.python.org/ftp/python/$VERSION/Python-$VERSION.tar.xz"
tar xJf "Python-$VERSION.tar.xz"
cd "Python-$VERSION"
@tejashah88
tejashah88 / deep-learn-gcp-setup.sh
Last active November 24, 2019 22:50
A bash script that's helpful for setting up your GCP Deep Learning VM instance to work with Google Colab. Recommended to be used in host and VM computers.
# Usage: install-python <VERSION>
# Example: install-python 3.6.9
function install_python() {
VERSION=$1
sudo apt install gcc make zlib1g-dev
sudo apt install libssl-dev # needed for SSL support
sudo apt install libsqlite3-dev # needed for SQLite support
sudo apt-get install libbz2-dev # needed for BZ2 compression support
wget "https://www.python.org/ftp/python/$VERSION/Python-$VERSION.tar.xz"
@tejashah88
tejashah88 / lagrange-solver-two-constraints.py
Created October 30, 2019 23:49
A min/max finder based on Lagrange Multipliers with two constraints
from sympy import *
x, y, z, l1, l2 = symbols('x y z l1 l2')
f = x + y + 3*z
g = x - y + z
k1 = 2
h = x + 2*z**2
k2 = 59
@tejashah88
tejashah88 / lagrange-solver-one-constraint.py
Last active October 30, 2019 23:40
A min/max finder based on Lagrange Multipliers with one constraint
from sympy import *
from sympy.abc import x, y, z, l
f = x**2 + y**2 + z**2
g = x**4 + y**4 + z**4
k = 9
grad = lambda fn: Matrix([fn.diff(x), fn.diff(y), fn.diff(z)]).transpose()
# grad(f) = lambda * grad(g)
@tejashah88
tejashah88 / RainbowClock.m
Created May 12, 2019 13:23
A rainbow analog clock animation in MATLAB for my ENGIN-136 class.
% Final Project: Rainbow Analog Clock
% Author: Tejas Shah
% Class: ENGIN-136 - Intro to MATLAB
% Clear any vars and current figure and show it on top of screen
clear, clf, shg
% Setup drawing board for clock
axis([-1.1 1.1 -1.1 1.1]);
axis square
@tejashah88
tejashah88 / robot-mousemove-fix.kt
Created November 21, 2018 23:47
Fix for Java's Robot.mouseMove when accounting for High DPI Screens + Mathematical error analysis for modeling how the original mouseMove function is affected.
/* Robot.betterMouseMove is a function that's meant to fix Robot.mouseMove when dealing with Windows's
display scaling in order to make text easier to see. The 'scaleFactor' is the actual scaling factor
as a float > 1.0f.
This is the error vector field that represents the error caused by Robot.mouseMove in which to move
in the x and y direction towards its destination. It's not that useful in hindsight, but kind of cool
that one can model the error as a mathematical function.
"Error" Vector Field: F(x, y) = f(x, y) * i + g(x, y) * j
f(x, y) = (-x + t_x) / (width - t_x)
@tejashah88
tejashah88 / raspberry-pi-opencv-python-setup.sh
Last active November 16, 2018 11:23
Quick & dirty script to install Python 3 OpenCV libraries with main & contrib modules
# Get latest packages
sudo apt-get update && sudo apt-get dist-upgrade -y
sudo apt-get update && sudo apt-get upgrade -y
# Install needed packages to perform common I/O image/video operations and/or math calculations
sudo apt-get update
sudo apt-get install libhdf5-dev libhdf5-serial-dev libharfbuzz-dev liblapack-dev libcblas-dev libwebp-dev \
libilmbase-dev libopenexr-dev libgstreamer1.0-dev libjpeg-dev libtiff5-dev libjasper-dev libpng12-dev \
libavcodec-dev libavformat-dev libswscale-dev libv4l-dev libxvidcore-dev libx264-dev libatlas-base-dev \
gfortran libgstreamer1.0-dev libgtk-3-0 -y
@tejashah88
tejashah88 / opencv_wsl_install.sh
Last active November 16, 2018 11:13
A script to install OpenCV v3.4.3 (including contrib_modules) with python 3 on WSL
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install build-essential cmake pkg-config
sudo apt-get install libjpeg8-dev libtiff5-dev libjasper-dev libpng12-dev
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
sudo apt-get install libxvidcore-dev libx264-dev
sudo apt-get install libgtk-3-dev
sudo apt-get install libatlas-base-dev gfortran
sudo apt-get install python
@tejashah88
tejashah88 / comsc-165-common-lib.c
Last active October 16, 2018 06:02
List of common functions used in COMSC-165.
int readInt();
char readChar();
float readFloat();
string readWord();
string readLine();
void swapInt(int &a, int &b);
void swapChar(char &a, char &b);
void swapFloat(float &a, float &b);
void swapString(string &a, string &b);