Skip to content

Instantly share code, notes, and snippets.

Avatar

Anubhav Sinha anubhavsinha

View GitHub Profile
@anubhavsinha
anubhavsinha / edge_detection.py
Created Aug 26, 2017
canny edge detection and gaussian blur
View edge_detection.py
# 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)
View region_masking.py
# 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 Aug 23, 2017
color selection using numpy
View color_selection.py
# 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 Apr 24, 2017
To check which directory is taking the space
@anubhavsinha
anubhavsinha / mysql-ex.py
Created Mar 28, 2017
mysql python connection
View mysql-ex.py
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 Mar 28, 2017
git revert to old commit id
View git.sh
git reset --hard af55c4e
git push -f origin HEAD:branch-name
@anubhavsinha
anubhavsinha / password.sh
Created Feb 17, 2017
Simple CLI life-hack of the day to find 'password' on your target drives
View password.sh
# 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 Jan 30, 2017
hide and show desktop icons on mac
View desktop.sh
#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 Feb 17, 2017
Getting started with Angular 2
View angular2.sh
#!/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 Jan 22, 2017
Who is eating my RAM?
View ram.sh
ps aux | awk '{print $6/1024 " MB\t\t" $11}' | sort -n