Tags » Python

Creating a filled barchart with matplotlib

This a python tutorial is to make a color filled bar chart with color fill mapped to a variable in the data. This chart was created for this… 294 more words


New Madrid earthquakes - now in 3D

earthquakes along the new madrid seismic zone happen quite often. currently, earthquake.usgs.gov shows three quakes in the area of magnitude 2.5 or greater in just the last 30 days. 144 more words


Write Your Own Blockchain Part 1 -- Creating, Storing, Syncing, Displaying, Mining, and Proving Work

I can actually look up how long I have by logging into my Coinbase account, looking at the history of the Bitcoin wallet, and seeing this transaction I got back in 2012 after signing up for Coinbase. 2,770 more words


How to Generate FiveThirtyEight Graphs in Python

Alexandru Olteanu

If you read data science articles, you may have already stumbled upon FiveThirtyEight’s content. Naturally, you were impressed by their awesome visualizations. You wanted to make your own awesome visualizations and so asked Quora and Reddit how to do it. 56 more words

Machine Learning Frontier

AdBlock Plus - Questionable Exception List

tl;dr – Adblock Plus Add-on for Firefox allows Malware and Phishing domains according to Google SafeBrowsing API in their ‘non-intrusive advertising’ list.

I had recently found myself installing Firefox and some essential add-ons, including… 295 more words

Data Harvesting

ABSP, Ch 13, Practice Project #3

My solution to the Practice Project #3 in Chapter 13 of the excellent book “Automate the Boring Stuff with Python” (ABSP)

import os, sys, PyPDF2, time

print("Enter location of the dictionary (ex: .../dictionary.txt):")
dictLoc = input()
if not os.path.isfile(dictLoc):
    print("Invalid location for dictionary!")

print("Enter location of PDF file to decrypt:")
pdfLoc = input()
if not os.path.isfile(pdfLoc):
    print("Invalid location for PDF file!")

pdfFile = open(pdfLoc, "rb")
pdfReader = PyPDF2.PdfFileReader(pdfFile)
if pdfReader.isEncrypted != True:
    print("PDF file: " + os.path.basename(pdfLoc) + " is not encrypted!")
keysFile = open(dictLoc)
allKeysNewline = keysFile.readlines() # each entry contains a newline "\n" at the end
allKeys = []
for i in range(len(allKeysNewline)):
startTime = time.time()
for key in allKeys:
    if pdfReader.decrypt(key.upper()) == 1:
        print(key.upper() + " is the password")
        endTime = time.time()
        print("It took %s seconds to find the password." % round(endTime-startTime,2))
    elif pdfReader.decrypt(key.lower()) == 1:
        print(key.lower() + " is the password")
        endTime = time.time()
        print("It took %s seconds to find the password." % round(endTime-startTime,2))

print("Sorry, the password of the PDF is not in the dictionary.")
… 6 more words