Skip to content

Instantly share code, notes, and snippets.

View ProProgrammer's full-sized avatar

Deep Sukhwani ProProgrammer

View GitHub Profile
@ProProgrammer
ProProgrammer / README.md
Last active November 12, 2022 19:08
India Air quality over states map - Created using Folium

A Leaflet.js map created with Folium and the default D3 threshold scale. See the Gist for the python code to generate the dataframe. The map was generated with the following Python code:

map = folium.Map(location=[21, 78], zoom_start=5)
map.geo_json(geo_path=state_geo, data=state_data,
         columns=['State', 'SO2_average'],
         key_on='feature.id',
         fill_color='YlOrRd', fill_opacity=0.7, line_opacity=0.2,
         legend_name='Air Quality')
map.create_map(path='air_quality.html')
@ProProgrammer
ProProgrammer / README.md
Last active August 29, 2015 14:18
See the gist via bl.ocks.org (want to see the map created using Folium)

First folium working map, planning to view it via bl.ocks.org

@ProProgrammer
ProProgrammer / RemovePeriodFromFolderName.py
Created January 14, 2015 14:04
A quicky python script to remove period from folder names
import os
# Change to directory where the files you want to work with are present
os.chdir('path/to/folder')
for item in os.listdir(os.getcwd()):
if not os.path.isfile(os.path.join(os.getcwd(),item)):
if '.' in item:
os.rename(item, item.replace('.', ' '))
print item
@ProProgrammer
ProProgrammer / RemovePeriodFromFileNames.py
Last active August 29, 2015 14:13
A quick dirty script to remove period (.) from file names in a folder
import os
# Change to directory where the files you want to work with are present
os.chdir('path/to/folder')
esclist = ["list","of","items","to", "escape", "renaming"]
for item in os.listdir(os.getcwd()):
if os.path.isfile(os.path.join(os.getcwd(),item)):
if '.' in item[:-4]:
@ProProgrammer
ProProgrammer / DirectoriesWithPeriodInName.py
Last active August 29, 2015 14:13
A quick dirty script to list all directories in a given folder that have a period (.) in their name
import os
# Change to directory where the folders are located that you want to work with!
os.chdir('path/for/directory')
for item in os.listdir(os.getcwd()):
# os.path.isfile returns true if the specified path is a file
# Hence not os.path.isfile returns true if the specified path is NOT A FILE (i.e. a directory)
if not os.path.isfile(os.path.join(os.getcwd(),item)):
if '.' in item:
@ProProgrammer
ProProgrammer / pywinauto.py
Created December 23, 2014 05:32
Work on Automating Windows application using pywinauto
from pywinauto.application import Application
app = Application.start('notepad')
app.Notepad.MenuSelect('Help->AboutNotepad')
app.AboutNotepad.OK.Click() #May have to do it twice to bring notepad application in focus first and then click on OK in the second time.
# app.AboutNotepad.OK.Click()
app.Notepad.MenuSelect('Format->Font')
app.Font.FontComboBox.Select('Arial')
app.Font.FontStyleCombo.Select('Bold Italic')
app.Font.OK.Click()
@ProProgrammer
ProProgrammer / sqlite_post_images.py
Created December 23, 2014 04:58
Posting images to sqlite database - Incomplete script
import sqlite3 as lite
import os
import sys
# def con_to_file(filename):
# #Ensure correct filename / filepath is given as argument to the function
# con = lite.connect(filename)
# cur = con.cursor()
@ProProgrammer
ProProgrammer / sqlite.py
Created December 23, 2014 04:56
Sample SQLite connection builder using Python
import sqlite3 as lite
import sys
con = None
try:
con = lite.connect(u"C:\\Python27\\test.db")
cur = con.cursor()
@ProProgrammer
ProProgrammer / TimingPopOnLists.py
Created November 23, 2014 12:43
Timing Pop Operation on lists
"""
Timing code execution time.
From book: Problem Solving with Algorithms and Data Structures: http://interactivepython.org/runestone/static/pythonds/AlgorithmAnalysis/Lists.html
This code times the execution of pop operation for popping first element in a list and popping last element in a list.
For timing the test case execution, we are here using Python's timeit module. More about it: https://docs.python.org/2/library/timeit.html
"""
import timeit
popzero = timeit.Timer("x.pop(0)", "from __main__ import x")
@ProProgrammer
ProProgrammer / TimingListsExecution.py
Last active August 29, 2015 14:10
Execution time of list creation using 4 most common methods of list creation in python
"""
Timing code execution time.
From book: Problem Solving with Algorithms and Data Structures: http://interactivepython.org/runestone/static/pythonds/AlgorithmAnalysis/Lists.html
This code times the execution time of each function.
test1() uses concatenation method to create a list of 1000 numbers from 0 to 999
test2() uses append method to create a list of 1000 numbers from 0 to 999
test3() uses list comprehension to create a list of 1000 numbers from 0 to 999
test4() uses range function inside list function to create a list of 1000 numbers from 0 to 999
For timing the test case execution, we are here using Python's timeit module. More about it: https://docs.python.org/2/library/timeit.html
"""