Musings of a dad with too much time on his hands and not enough to do. Wait. Reverse that.

Category: technology (Page 36 of 36)

Poor man’s date calculator

A relative asked me the other day, “how old was Tom when he died?” Well, I had to first look up when Tom died: June 23, 1984. Then, I had to look up when Tom was born: March 29, 1916. Then, I had to ask myself: “how the heck am I going to calculate the age difference?”

There are date calculators out there, but what if I’m offline or just want to do a quick calculation on my own hardware? Well, we can do some quick-and-dirty calculations in PowerShell! As I see it, there are a few use cases here:

Use Case 1: How old was Tom when …?
Given two dates–a person’s birth date and the date of some event (death, marriage, birth of a child, etc.)–what was that person’s age at the time of the event? In PowerShell, getting the “years old” is relatively easy with a one-liner (I created two variables, though, just for readability):

$birth_date = [datetime]"3/29/1916"
$death_date = [datetime]"6/23/1984"
"Tom was {0} years old when he died" -f [math]::floor((new-timespan -start $birth_date -end $death_date).Days / 365.2425)

However, getting the months and days after that is trickier and will be cleaner looking if I put it in a script, so check it out here.

Use Case 2: When was Sarah born?
Consider this photo of one of my ancestor’s tombstone:

The tombstone of Sarah Osburn says she was 23 years, 3 months, and 9 days when she died on December 15, 1872. So, when was she born? We can calculate this use case quite easy with a PowerShell one-liner:

"Sarah was born on {0:MMM dd, yyyy}" -f ([datetime]"12/15/1872").AddYears(-23).AddMonths(-3).AddDays(-9)

 

Use Case 3: When did Betty die?
Certainly, the first two use cases are real questions I’ve encountered in my genealogical endeavors. We could, though, consider a third use case: assume we have a person’s (we’ll call her “Betty”) birth date and age information at the time of an event…say, her death. When, then, did she die?

Well, it seems we can re-implement our solution to Use Case 2 to solve this problem. Let’s assume Betty was born on April 14, 1912 and died at age 73 years, 2 months, and 3 days old. On what day did she die?  PowerShell will tell us:

"Betty died on {0:MMM dd, yyyy}" -f ([datetime]"4/14/1912").AddYears(73).AddMonths(2).AddDays(3)

So, there you go: a poor man’s date calculator for all your genealogical needs!

Music to drive by

When I’m not listening to podcasts in the car, I, of course, like to listen to music. Terrestrial radio, though, is lame and I’m too cheap for satellite; so, the music I listen to is either songs I’ve downloaded to my phone or songs I’ve downloaded to a USB drive that I can plug into my console.

I’ve collected a few CDs over the years and have managed to digitize about every one of them. At last count, my digitized music catalog consists of over 8700 songs across 600+ albums. My catalog is just under 50 Gb…which means, it can fit on a single flash drive…which means I should be able to take my entire catalog with me on important trips like clearance day at the Frugal Hoosier!

Unfortunately, my car stereo seems to have some limitations and when I pack 8000 or so songs on a drive, the stereo a) takes 5-10 minutes to even read the drive and b) never seems to read all the songs on the drive. So, I need to start being selective about what songs I take with me. I don’t want to have to click through 600+ folders, though, and drag-and-drop files one-at-a-time.  Who has the time for that? What if I copy over songs by genre, such as “Rock” or “Metal” or whatever? Or I could make a list of favorite bands or albums and copy over anything that matches that list.

Well, I can do all this through the wonder of PowerShell. Here’s a script I put together to inventory all the MP3s in my Music folder and collect various ID3 tag information on them including genre, artist, album, etc. Finally, it copies MP3 files that meet my conditions–like favorite genres or whatever–over to my flash drive.

Unfortunately, this script is pretty slow: I think largely because I have to instantiate the shell.application COM object to get the MP3s’ ID3 tag information.  Your mileage may vary. Initially, I tried several of the open source .NET ID3 libraries out there but could get none of them to work. At any rate, this thing works for me, so I thought it might be worth sharing. Now, get rockin’ down the highway!

Going to CodeMash 2018

Who wouldn’t want to be in Sandusky, Ohio in January for some geeky learnin’? Plus: it sounds like that Polar Vortex may be retreating a little for the week, so, bonus!

It’s been something like 7-8 years since I last attended CodeMash. I’ve heard the venue has changed a lot and the conference has expanded significantly. Used to be that the thing would sell out within an hour of going live!

Anyway, I’m looking forward to attending. As with most conferences I patronize, I like to plan ahead by pre-selecting as many sessions as I can: often, I agonize over my decisions because I tend to find multiple, interesting sessions happening at the same time. I want to do that agonizing ahead of time so I don’t waste a lot of time making decisions during the conference itself.

Unfortunately, I’m not finding the CodeMash Schedule page too helpful. I’m used to conference schedules where the time slots are on the Y axis and sessions listed across the X axis. That way, for, say the 8am session, I can scroll horizontally across all the scheduled sessions and pick the most appealing one. The CodeMash Scheduling page lists all the sessions vertically by their time slots. The data’s there: there just ought to be a better way to display it for my needs.

Well, there is: thanks to Python. I wrote a Jupyter Notebook to ingest the session data via the CodeMash API and then used pandas to pivot the data into a dataframe helpful to my needs. Then, I just exported this dataframe out to Excel and, voilà, I have my solution!

Now, off to spend a few hours deliberating over the offerings!

Newer posts »

© 2025 DadOverflow.com

Theme by Anders NorenUp ↑