Tag Archives: python

Calculating a square root.

I was just recently asked to calculate the square root of 17 without a math library. I couldn’t do it when I was asked to, so the question has been bugging me of awhile. I was bored today, so I decided to figure it out. The following is a Python function that calculates the square [...]

Posted in Programming | Also tagged , , | Comments closed

Hadoop example for Exim logs with Python.

The following is an example of parsing an exim_mainlog using Hadoop streaming. I’ve implemented both the mapper and the reducer in Python. The mapper and reducer don’t handle all of Exim’s log formats yet but this can be easily extended in the mapper and reducer if you actually end up using the output (this is [...]

Posted in Programming | Also tagged , , | Comments closed

Heap sort in Python.

Here is an example of heapsort in Python. This sorting method happens to be my favorite of the bunch – I like to think that this is the most elegant sorting method, but I’m sure you could argue against me. Edit: I renamed percolateDown to percolateUp because I realized its really more of a “move [...]

Posted in Programming | Also tagged , | Leave a comment