Author: Dave

Book Review: Miracle Men: Hershiser, Gibson, and the Improbable 1988 Dodgers by Josh Suchon

Those who know me are aware of my intense love for the Dodgers. Despite living in the San Francisco Bay Area for 10 years now, it’s something that I haven’t been able to shake.

This year marks the 25th anniversary since the Dodgers last won the World Series. Because of this, I decided it was the perfect opportunity to read Miracle Men, which takes a look at the scrappy Dodgers team that ultimately went on to win the World Series in 1988.

For the most part, the book is fairly dry read, mostly rehashing play-by-plays from various games during the course of the 1988 season. I’d wager this sort of thing is less exciting than reading a game recap from the night before. That said, it was fascinating to read about so many baseball players that are tied to some of my earliest memories of baseball: Steve Sax, Orel Hershiser, Mike Scioscia, Ramon Martinez, Tim Belcher, Mikey Hatcher, and more.

The areas where this book excelled and became completely interesting were in some of the deeper stories — Hershiser’s pursuit of the consecutive scoreless innings streak, early clubhouse shenanigans during spring training that offended Kirk Gibson, interviews with players on other teams 25 years later, and of course reflections on Kirk Gibson’s incredible home run in game 1 of the World Series.

Some of my biggest takeaways were how different the game was played only 25 years ago. Managers completely abused their pitchers (130 and 140 pitch complete games were the norm, pitching on 2 or 3 days of rest were fine). It surprised me to find out how often balks were called (over 900 times in 1988). Insane!

Bottom line, you’ll probably only enjoy this book if you’re a Dodgers fan. On top of that, you’ll most likely only want to read it for some of the more interesting stories that happened in 1988. It’s a quick read and provides some interesting context on how a scrappy team wound up beating on of the most intimidating teams in baseball in the World Series.

3 stars.

Setting up tests using Tape

Test driven development has become an important process in the software engineering world. It allows coders to develop functions by first creating a series of tests that the new function must solve. The benefit of this is that once your app grows more complex and you add new functionality, you can see if any existing tests have failed, meaning that something broke (and now you know where to find it). Look no further than any popular project on Github and you’ll often see a “tests” folder.

Today, we’re going to talk about setting up tests using Tape.

Tape is an alternative to popular testing suites such as Jasmine and Mocha. Like any tool related to software engineering, there are some developers that strongly prefer Tape over other options. It’s fairly easy to setup and can easily be run in automated task runner tools such as Grunt and Gulp.

To use it as part of your project, you can install it through npm:

  npm install tape --save-dev

Once it’s been added as part of your project, you can create a new tests.js file and require the module.

For our demonstration, we’re going to write a simple test that checks if my name is Dave, plus a few additional parameters.

Start off by setting up your test.js file like so (you can name it whatever you prefer). I’ve commented the code for some additional clarity on what’s happening here.

// Require the Tape module imported from npm
var test = require('tape');

// Write your tests in the code block
test('All about Dave', function (t) {
    // The number of tests that you plan to run.
    // NOTE: If this number doesn't match up with the number
    // of tests that are run, your test will fail.
    t.plan(2);
    
    // Let's setup some variables to test
    var name = "Seymore";
    var city = "Oakland";
    var favBaseballTeam = "Athletics";

    // This test will check for my favorite baseball team.
    // The first parameter is the result, the second is
    // the value you're expecting, and the third is the message
    t.equal(favBaseballTeam, "Athletics", "Favorite baseball team should be Athletics");

    // This test will check for my name.
    // As you can probably assume, it will fail.
    t.equal(name, "Dave", "Name should be Dave");

    // This test will check if city has been set:
    if (city) {
      t.pass("City set");
    } else {
      t.fail("City not set");
    }
});

That’s it! You can run Tape from your terminal and point it to your newly created test.js file in order to run it.

Screenshot 2015-09-01 14.00.18

Using the Mongo CLI to find your data.

We’ve been working on many projects lately that have utilized MongoDB as the primary means of database storage. I have previous experience building and using MySQL databases, so the idea of these NoSQL databases is a new concept for me.

I’m not one to shy away from new technologies, so I’ve been trying to embrace MongoDB and learn how to use it.

One of the most important things I’ve been learning is how to view the databases, collections, and records that I’ve saved in my various applications through the MongoDB command line interface.

Let’s do a quick walk through and pretend I have a database dedicated to baseball.

Once you have Mongo installed on your machine, you run the interface by typing mongo in your terminal. Now, you can bring up a list of databases by typing show databases.

Screenshot 2015-08-20 10.24.51

How do we use a particular database? Easy! Just type use [database_name]


use baseball

Awesome! Of course, you’ll want to do more than just “use” the database. We want to see what’s inside it. This is accomplished by telling mongo to show us all collections (e.g., think of these as “tables” in a traditional SQL database).


show collections

Screenshot 2015-08-20 10.27.33

Awesome! Now we have a collection of teams and collection of players. Well, let’s display everything within a particular collection. In this case, let’s print out all teams that we have stored in our database.


db.teams.find()

Screenshot 2015-08-20 10.28.32

Great!

Now, let’s say you’re looking for a particular record. How do you limit your search to just one thing? Like this:


db.teams.find({team: “dodgers”})

Screenshot 2015-08-20 10.30.04

Now, you can imagine that if we had more data, there are a lot more things that we could search for and find. It’s pretty powerful!

Anyway, this was a quick tutorial on how to use the Mongo DB CLI. I hope you found it helpful!