Skip to content

Instantly share code, notes, and snippets.

View saurabhwahile's full-sized avatar

Saurabh Wahile saurabhwahile

View GitHub Profile
import os
import sys
from datetime import datetime, timedelta
import re
from io import BytesIO
import subprocess
import base64
import imaplib
import email
@saurabhwahile
saurabhwahile / excel_2_g_contacts.py
Created December 23, 2017 05:47
Google Contacts import from Excel
import pandas as pd
from openpyxl import load_workbook
index = ['Name', 'Given Name', 'Additional Name', 'Family Name', 'Yomi Name', 'Given Name Yomi', 'Additional Name Yomi', 'Family Name Yomi', 'Name Prefix', 'Name Suffix', 'Initials', 'Nickname', 'Short Name', 'Maiden Name', 'Birthday', 'Gender', 'Location', 'Billing Information', 'Directory Server', 'Mileage', 'Occupation', 'Hobby', 'Sensitivity', 'Priority', 'Subject', 'Notes', 'Group Membership', 'E-mail 1 - Type', 'E-mail 1 - Value', 'E-mail 2 - Type', 'E-mail 2 - Value', 'Phone 1 - Type', 'Phone 1 - Value', 'Phone 2 - Type', 'Phone 2 - Value', 'Phone 3 - Type', 'Phone 3 - Value', 'Phone 4 - Type', 'Phone 4 - Value', 'Phone 5 - Type', 'Phone 5 - Value', 'Phone 6 - Type', 'Phone 6 - Value', 'Phone 7 - Type', 'Phone 7 - Value', 'Address 1 - Type', 'Address 1 - Formatted', 'Address 1 - Street', 'Address 1 - City', 'Address 1 - PO Box', 'Address 1 - Region', 'Address 1 - Postal Code', 'Address 1 - Country', 'Address 1 - Extended Address', 'Organization 1
@saurabhwahile
saurabhwahile / FBOSpider.py
Created June 18, 2017 04:44
Crawler For FBO.gov
# -*- coding: utf-8 -*-
import datetime
import scrapy
from scrapy.spiders import CrawlSpider, Rule
from scrapy.linkextractors import LinkExtractor
class FBOSpider(scrapy.Spider):
name = "FBOSpider"
start_url = "https://www.fbo.gov/index?s=opportunity&mode=list&tab=list&pageID={page_no}"
@saurabhwahile
saurabhwahile / alert_stock.py
Created April 27, 2017 04:42
Script to alert if a stock value goes below the support
from googlefinance import getQuotes
import winsound
import time
import math
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("stock", help="A google supported stock name. Example, NASDAQ:AAPL", type=str)
parser.add_argument("support", help="beep when below this price", type=float)
args = parser.parse_args()
@saurabhwahile
saurabhwahile / zerodha_to_moneycontrol.py
Last active August 15, 2023 13:46
Script for importing zerodha stocks in xlsx to moneycontrol csv if you want to use moneycontrol terminal
#You'll still have to manually enter dates here, as the xlsx file from zerodha does not show dates(SIP of stocks causes multiple dates)
#EDIT: Usage python zerodha_to_moneycontrol.py <FILENAME>
import sys
from openpyxl import load_workbook
wb = load_workbook(sys.argv[1])
ws = wb.active
csv_list = [["BSE/NSE/ISIN Code","Buy Date","Buy Quantity","Buy Price",]]
@saurabhwahile
saurabhwahile / twitter_unfollow.py
Created September 12, 2016 18:20
Mass unfollow on twitter
import tweepy
auth = tweepy.auth.OAuthHandler(
consumer_key="key",
consumer_secret="secret")
auth.set_access_token(
'token',
'secret')
api=tweepy.API(auth_handler=auth)
@saurabhwahile
saurabhwahile / switch_gateway.bat
Created December 16, 2015 06:02
Switch gateway, Ex: for failover/redundancy
@echo off
for /f "tokens=2,3 delims={,}" %%a in ('"WMIC NICConfig where IPEnabled="True" get DefaultIPGateway /value | find "I" "') do set gateway=%%~a
IF %gateway%==192.168.1.1 (
netsh interface ip set address name="Wi-Fi" static 192.168.1.10 255.255.255.0 192.168.1.41 1
) ELSE (
netsh interface ip set address name="Wi-Fi" static 192.168.1.10 255.255.255.0 192.168.1.1 1
)
@saurabhwahile
saurabhwahile / MorphologicalOperations.java
Created October 1, 2015 06:19
Image Morphological Operations
import java.io.*;
import javax.imageio.*;
import java.awt.image.*;
import java.util.*;
import java.awt.Color;
class Operator
{
@saurabhwahile
saurabhwahile / measure_disk_perf.sh
Created May 24, 2015 09:07
Measure disk performance on linux
repeat=10
while [ $x -gt 0 ]
do
python "C:\\Python27\\lib\\timeit.py" -n 3 "f = open('file.txt', 'wb+'); f.write('chunk'); f.close()" >> results.txt
repeat=$((repeat-1))
done
data="$(awk '{print $6}' results.txt)"
echo $data
python -c "results = map(float, \"\"\"$data\"\"\".split('\n')); from matplotlib import pyplot; pyplot.plot(range(1,11), results); pyplot.savefig('results.png')"
rm results.txt
@saurabhwahile
saurabhwahile / set_proxy.sh
Created March 22, 2015 16:43
Set proxy based on ip address
#replace th0 with interface name and the 1st ip with nic ip and 2nd ip with proxy ip
ip="$(ifconfig eth0|grep 'inet addr'|awk -F':' '{print $2}'| awk -F' ' '{print $1}')"
if [[ $ip = "172.24.0.2" ]]
then
export http_proxy="http://172.24.0.1:3128"
fi