Skip to content

Instantly share code, notes, and snippets.

View anubhavsinha's full-sized avatar

Anubhav Sinha anubhavsinha

View GitHub Profile
@anubhavsinha
anubhavsinha / edge_detection.py
Created August 26, 2017 21:43
canny edge detection and gaussian blur
# Running first a gaussian blur (kernel size = 3)
# and then Canny edge detection (low/high = 1:2 or 1:3)
# is a handy way to get the boundaries
from matplotlib import image
from matplotlib import pyplot
import numpy
import cv2
view_from_windshield = image.imread('test.jpg')
working_copy = numpy.copy(view_from_windshield)
@anubhavsinha
anubhavsinha / region_masking.py
Created August 26, 2017 20:03
region_masking
# Region masking is a technique used to run a image processing or computer vision task within a specific region of interest
# Step 1. Build a selector for the region
# Step 2. Build a selector for the pixels of interest
# Step 3. AND the two selectors. It's that simple.
from matplotlib import image
from matplotlib import pyplot
import numpy
view_from_windshield = image.imread('test.jpg')
@anubhavsinha
anubhavsinha / color_selection.py
Created August 23, 2017 20:49
color selection using numpy
# Color selection
# Step1. Read the image
# Step2. Set the threshold (In our case it is to filter out everything except white)
# Step3. Build a selector and
# Steo4. Apply the selector
# Picking the right color model is very important for a successful computer vision task.
# LUV, HSV, RGB, L*a*b etc.
# To be able to read the image file we will use the image package from matplotlib
from matplotlib import image
# To be able to render or plot the image we will use the pyplot package from matplotlib
@anubhavsinha
anubhavsinha / check-size.sh
Created April 24, 2017 06:03
To check which directory is taking the space
du -sh */
@anubhavsinha
anubhavsinha / mysql-ex.py
Created March 28, 2017 17:29
mysql python connection
import MySQLdb
connection = MySQLdb.connect (host = db_host, user = "yaacdev" , passwd = "yaacmydev", db = "mintshowapp_live")
cursor = connection.cursor (MySQLdb.cursors.DictCursor)
query='sql query'
cursor.execute (query)
data = cursor.fetchall()
@anubhavsinha
anubhavsinha / git.sh
Created March 28, 2017 16:45
git revert to old commit id
git reset --hard af55c4e
git push -f origin HEAD:branch-name
@anubhavsinha
anubhavsinha / password.sh
Created February 17, 2017 08:38
Simple CLI life-hack of the day to find 'password' on your target drives
# Simple CLI life-hack of the day to find 'password' on your target drives,
# even if it is deleted. Do keep it short burst to avoid behavioral detection.
sudo strings /dev/sdc | grep -c100 "password"
@anubhavsinha
anubhavsinha / desktop.sh
Created January 30, 2017 03:58
hide and show desktop icons on mac
#hide
defaults write com.apple.finder CreateDesktop -bool false && killall Finder
#show
defaults write com.apple.finder CreateDesktop -bool true && killall Finder
@anubhavsinha
anubhavsinha / angular2.sh
Last active February 17, 2017 06:55
Getting started with Angular 2
#!/bin/bash
# Both the CLI and generated project have dependencies that require Node 6 or higher, together with NPM 3 or higher.
# On Ubuntu 16
# sudo apt-get update
curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
sudo apt-get install -y nodejs # this installs both node and npm
# sudo ln -s /usr/bin/nodejs /usr/bin/node
sudo npm install -g @angular/cli
ng help
# sudo npm install extract-text-webpack-plugin@2.0.0-rc.0 --save-dev # https://github.com/angular/angular-cli/issues/4264
@anubhavsinha
anubhavsinha / ram.sh
Created January 22, 2017 19:35
Who is eating my RAM?
ps aux | awk '{print $6/1024 " MB\t\t" $11}' | sort -n