Skip to content

Instantly share code, notes, and snippets.

View Khalian's full-sized avatar

Arunav Sanyal Khalian

  • Vancouver, BC, Canada
View GitHub Profile
@Khalian
Khalian / HoughLines.py
Created December 19, 2015 22:11
Code to remove lines from sheet music files and/or display them
__author__ = 'asanyal'
import cv2
import numpy as np
def getHoughLines(imgFile):
img = cv2.imread(imgFile)
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
edges = cv2.Canny(gray,50,150,apertureSize = 3)
@Khalian
Khalian / removeDockerStuff.sh
Last active May 25, 2016 01:16
Bash script to remove docker images and running containers
#!/bin/bash
#Stop all running containers
docker stop $(docker ps -a -q)
# Delete all containers
docker rm $(docker ps -a -q)
# Delete all images
docker rmi $(docker images -q)
@Khalian
Khalian / rem_kernel.sh
Created February 5, 2016 18:19
Run the script with superuser privileges, first argument is the linux kernel version to remove
rm -rf "/lib/modules/$1"
rm -f "/boot/vmlinuz-$1*"
rm -f "/boot/initrd.img-$1*"
rm -f "/boot/config-$1*"
rm -f "/boot/System.map-$1*"
update-grub2
@Khalian
Khalian / to_black_and_white.pyt
Created February 21, 2016 23:24
A script to convert colored images to black and white
from PIL import Image
import sys
if (len(sys.argv) < 3):
print "Usage : python black_and_white.py inputFile outputFile"
sys.exit(0)
image_file = Image.open(sys.argv[1]) # open colour image
image_file = image_file.convert('1') # convert image to black and white
image_file.save(sys.argv[2])
@Khalian
Khalian / last_modified_webpage.sh
Last active March 15, 2016 22:01
Gives the last modified timestamp of a given HTTP page. Does not work always
#!/bin/bash
if [ $# -ne 1 ]
then
echo "Usage : ./last_modified_webpage.sh urlOfPage"
exit 0
fi
curl -sI $1 | grep Last-Modified
@Khalian
Khalian / killp.sh
Last active March 15, 2016 21:49
Kill processes with a certain name or prefix of name (Note this script is incredibly powerful, handle with care)
#!/bin/sh
echo "Removing all processes associated with name $1"
if [ $# -ne 1 ]
then
echo "Usage : ./killp process name"
exit 0
fi
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
# Download the gecko driver https://github.com/mozilla/geckodriver/releases and put in your path env var
driver = webdriver.Firefox()
driver.get("https://www.google.com/maps/")
elem = driver.find_element_by_id("searchbox")
# Simulates just typing the words in the google maps search box
from geopy.geocoders import Nominatim
geolocator = Nominatim()
location = geolocator.geocode("2550 3rd Avenue Seattle")
print(location.address)
print((location.latitude, location.longitude))
# Output
# 2550, 3rd Avenue, Belltown, Seattle, King County, Washington, 98121, United States of America
# (47.6165771, -122.3473058)
@Khalian
Khalian / .vimrc
Last active May 14, 2017 20:53
My vim RC configurations for macs
set runtimepath+=~/.vim_runtime
execute pathogen#infect()
syntax on
filetype plugin indent on
source ~/.vim_runtime/vimrcs/basic.vim
source ~/.vim_runtime/vimrcs/filetypes.vim
source ~/.vim_runtime/vimrcs/plugins_config.vim
source ~/.vim_runtime/vimrcs/extended.vim
#!/bin/sh
# ARE YOU A VIMPLETON? DONT YOU WISH YOU HAD A RAD VIM SETUP. WELL LOOK NO FURTHER. INTRODUCTING, THE ULTIMATE VIM CONFIG.
# FULLY ASYNCRHONOUS, NON BLOCKING VIM!!!!
# Tested on Amazon Linux 2017 (and by extension RHEL and Fedora machines).
# First install neovim
wget https://gist.githubusercontent.com/Khalian/ebd345b418b6f42a0359b4c89961af4c/raw/a69a496caf247d40535bc194fa2f08923c63d072/install_neovim_to_amazonlinux.sh
sh install_neovim_to_amazonlinux.sh