šŸ‘‹šŸ»  Hello!

Thanks for visiting! You'll find a bunch of musings I've been writing around these parts since the early 2000's. Lately, I've been reviewing a lot of books. But I also write about code and my experiments using generative AI. But really, you're just here to see pictures of Benson.

Blog Posts

How to play Civilization on your iPad

Do you have an iPad? Because you can totally play Civ on your iPad.

ā€œWHAT?! NO. CIV REVOLUTION DOESN’T COUNT,ā€ you loudly yell.

JUST WAIT! I’m not talking about that. I’m talking about Civ V (and even Civ VI).

Photo Proof here:

How does this magic work?

Yes, you guys will think I’m crazy but I regularly play Civ on my iPad. (What?!). I’m also a masochist. But you can totally make it work.

There are a few options:

  • Through Nvidia’s Geforce Experience app:
  • Have a Windows PC with an Nvidia graphics card (What if you don’t have one? We’ll tackle that farther down.)
  • Make sure GeForce Experience is installed. This basically allows streaming through the same protocol that Nvidia Shield uses.
  • Install Moonlight on your iOS device (iPhone?!?!) or even an Android device. Open source app that can connect / parse Nvidia Shield streams.
  • Play Civ! (Via dragging your finger around to simulate a mouse, sometimes tedious, but it works!)

Pros: You get to play Civ on your iPad!

Cons: Kind of a pain to setup.

Through Remotr:

  • Have a Windows PC (hmm, there seems to be a pattern here).
  • Install Remotr on your PC. It should auto-detect Civ V. It doesn’t auto-detect Civ VI for me though.
  • Install Remotr on your iPad.
  • Open Remotr and play Civ!

Pros: You get to play Civ on your iPad! And it’s much easier to setup on your Windows PC, plus you aren’t tied to an Nvidia only GFX card.

Cons: The iPad app is free (good!). But whenever you disconnect from your game (or maybe something crashes), it will show you one of those cheesy popup ads that won’t let you click away for 10 seconds or so. You can optionally pay for a monthly pro subscription through an in-app purchase. Also, Remotr tries to squeeze your (probably 16:9) resolution display into the iPad’s 4:3 display. So things will look janky. Just change the resolution of Civ to 1024 x 768 and things will look good on your touch screen device. (Obviously, change it back when you get back to your real machine though).

Through Screens (I also have a Mac) or a similar VNC client.

  • Install VNC server of your choice on your Mac or Windows machine.
  • Install a VNC client of your choice on your iPad or other mobile device.
  • Open and play Civ!

Pros: You get to play Civ on your iPad!

Cons: While Civ isn’t what we think of as a graphically intense game, prepare for a bunch of jerkiness as you move the map around, delays while various modals pop up, screen tearing. But… you get to play Civ.

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!