Skip to content

Instantly share code, notes, and snippets.

View atvKumar's full-sized avatar

Kumaran atvKumar

View GitHub Profile
@atvKumar
atvKumar / sendGmail
Created March 6, 2014 06:10
Simple Send Text Email from Python using Gmail
from smtplib import SMTPException
from email.utils import COMMASPACE
import smtplib
_default_address = ['me@gmail.com']
def SendGmail(subject, body, to_addresses=_default_address,
from_address='server@server.org', debug=False):
email_header = "From: My Server <server@server.org>\n" \
@atvKumar
atvKumar / sendemail.py
Last active August 29, 2015 13:57
Send Email with Attachments
from smtplib import SMTP
from smtplib import SMTPException
from mimetypes import guess_type
from os.path import basename
from email.utils import COMMASPACE
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.base import MIMEBase
from email.encoders import encode_base64
@atvKumar
atvKumar / redisPubSub_wxChat.py
Created April 3, 2014 11:43
A simple Chat Program using redis Pub/Sub
from threading import Thread
# from redisutils import redis_connect
import redis
import wx
###########################################################################
## Class Listener
###########################################################################
@atvKumar
atvKumar / Check_Internet.py
Created April 17, 2014 03:10
Checks if internet connection is on.
import socket
def check_net(address='google.com', debug=False):
"""
Checks if internet connection to address given is valid and working
Defaults to using 'google.com' in an event nothing is passed
Returns : True if resolved and False if not resolved
"""
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
try:
#target photoshop
// $.level = 2;
/*
* Script by Tomek Cejner (tomek (at) japko dot info)
* based on work of Damien van Holten:
* http://www.damienvanholten.com/blog/export-groups-to-files-photoshop/
*
* My version adds support of nested layer groups,
* and exports single layers in addition to groups.
@atvKumar
atvKumar / listdir_flavour1.py
Last active August 29, 2015 14:01
listdir VS walk
def listLocation(root_location,files = [],folders = []):
""" A recursive function to get directory content into arrays
Usage : x,y = listLocation(directory/path)
Returns 2 arrays 1 files array and 1 folders array """
for eachitem in os.listdir(root_location):
filePath = os.path.join(root_location,eachitem)
if os.path.isdir(filePath) and not eachitem.startswith('.'):
folders.append(filePath)
listLocation(filePath,files,folders)
elif os.path.isfile(filePath) and not eachitem.startswith('.'):
@atvKumar
atvKumar / IMDB_Scrapping_01.py
Created May 31, 2014 04:50
Use Requests and Beautiful Soup to Scrap for data
__author__ = 'kumar'
from bs4 import BeautifulSoup
import requests
page = requests.get('http://www.imdb.com/chart/?ref_=nv_ch_cht_2%3F')
soup = BeautifulSoup(page.text)
for x in soup.find_all('td', {"class": "ratingColumn"}):
@atvKumar
atvKumar / Slice1.py
Created November 1, 2014 05:43
Slicing
# In[5]:
x = [[ 795. , 501.0292887 ],
[ 794.97154472, 501. ],
[ 794.96078431, 500. ],
[ 795. , 499.09090909],
[ 795.03921569, 500. ],
[ 795.02777778, 501. ],
[ 795. , 501.0292887 ]]
@atvKumar
atvKumar / file_utils.py
Last active August 29, 2015 14:12
File Utilities
from __future__ import division
from platform import system
from os import stat
from os.path import basename, splitext, dirname, split as splitpath, \
join as joinpath
from datetime import datetime
from glob import glob
import hashlib
import subprocess
@atvKumar
atvKumar / zipbackup.py
Last active December 12, 2015 13:02
Backup Zip
import os
import copy
import subprocess as sp
zip_cmd = ['zip', '-r', '-9', '-T']
lwza_cmd = ['7za', 'a', '-t7z', '-mx9', '-v2g']
def loadExcludedListFromPath(path):
excludedList = list()
for afile in os.listdir(path):