Code Iterations – A Mentoring Example

refactoring.jpg

One of the pleasures in life is mentoring another developer, particularly when the other developer is smart and motivated to learn.  This article, on populating a tree from a collection of paths, was the result of some weekend prep work and is a good case study on refactoring.  By going through the process myself and documenting it, I was able to present the problem in general terms, and the person I was mentoring did the heavy mental lifting with only occasional guidance on my part.  This worked because I was prepared — had I not done this prep work, I would have taken away from my mentee’s experience to  actually solving the problem himself.

Article here.

Two Articles Win First Prize for March

firstplace.jpg

Well, that was a “first!” — Two articles:

Understanding Merkle Trees

Full Duplex Asynchronous Read/Write with Named Piped

have won first place in Code Project‘s monthly article competition in the categories of “Best Everything Else” and “Best C# Article” for the month of March 2017.

And as always, with great appreciation to the amazing people @codeproject who have made Code Project possible!

 

Who was Born on Your Birthday?

cupcake2.jpg

Six lines (not including imports) of Python code to scrape the website onthisday.com for the “persons of interest.”  Impressive!

Package dependencies:

pip install lxml
pip install cssselect
pip install requests

The Python code:

import requests
from lxml import html
from lxml.cssselect import CSSSelector
from lxml import etree
 
page = requests.get("http://www.onthisday.com/birthdays/august/19")
tree = html.fromstring(page.content)
sel = CSSSelector('.section--person-of-interest')
pois = sel(tree)
 
for poi in pois:
 poi.xpath("div/div/div[1]/p")[0].text_content()

The results (for my birthday):

'1871 Orville Wright, aviator (Wright Brothers), born in Dayton, Ohio (d. 1912)'
'1878 Manuel Luis Quezon y Molina, Second President of the Philippines (1935-42), born in Baler, Aurora, Philippines (d. 1944)'
'1919 Malcolm Forbes, American publisher of Forbes Magazine, born in Brooklyn, New York (d. 1990)'
'1946 Bill Clinton [William Jefferson], 42nd US President (Democrat, 1993-2001), born in Hope, Arkansas'
'1967 Satya Nadella, Indian-American businessman (CEO of Microsoft), born in Hyderabad'