Python Argparse Cookbook

    I use Python as my go to tool for command-line scripts. So I find myself often parsing command-line arguments for these script. Since I use various programming languages I don’t remember anything, so I’m constantly looking at documentation and sadly, Python docs are a bit challenging to read. So, in a similar vein as my […]

    Python Data Science

    My notes, resources and examples using Python, NumPy, SciPy and Matplotlib as alternatives to R and Matlab for data science and analysis. Load Data from Text File import pylab filename = “cool_data.dat” # use skiprows if your data file has headers data = pylab.loadtxt(filename, skiprows=1) An example loading comma delimited data using Numpy: import numpy […]

    Python Dates

    A set of examples using Python date and time functions, including formatting dates, date calculations and other bits in datetime package, similar to my string format examples. First off, all examples use the following import, any additional imports needed will be shown with the example. from datetime import datetime Creating Date Objects # now now […]

    Python String Format Cookbook

    Every time I use Python’s string formatter, version 2.7 and up, I get it wrong and for the life of me I can’t figure out their documentation format. I got very used to the older % method. So I started to create my own string format cookbook. Let me know in the comments of any […]

    Use Python + Selenium to Automate Web Timing

    I’ve been hearing a lot recently about the Navigation Timing spec, which sets a multitude of timing events as javascript properties. There are numerous events in the flow, from the very first navigation event, which could be when the user clicks a search result in Google, to DNS timing to Dom parsing etc. See the […]