net comments edit

I just had an interesting unit test failure I haven’t seen before due to DateTime calculation.

The code under test was roughly like this:

public Lifetime GetTokenLifetime(int seconds)
{
  return new Lifetime(DateTime.UtcNow, DateTime.UtcNow.AddSeconds(seconds));
}

The unit test was also pretty straightforward:

[Test]
public GetTokenLifetime_ExpectedLifetime()
{
  var provider = new Provider();
  var lifetime = provider.GetTokenLifetime(120);
  Assert.AreEqual(120, lifetime.Seconds);
}

The test was intermittently failing… and the error pretty much explained why:

Expected: 120
Actual: 120.0000063d

There was just a tiny fraction of a second happening between the first DateTime.UtcNow call and the second DateTime.UtcNow call.

To fix it, I stored the DateTime in a local variable.

public Lifetime GetTokenLifetime(int seconds)
{
  var now = DateTime.UtcNow;
  return new Lifetime(now, now.AddSeconds(seconds));
}

Something to keep in the back of your mind as you’re working with DateTime - or times in general. If you are setting up a date range based on a fixed point, best to store that fixed point somewhere and reuse it.

gaming, xbox comments edit

I haven’t blogged much about games I’m playing recently, so given I’m “between games” at the moment, I figured I’d talk a bit.

Yesterday, after about 172 hours, I finished Skyrim with 1000/1000 achievements. I probably could have finished sooner, but I did spend quite a bit of time building up my various skills and running non-required side missions before getting to the main story. I didn’t get any of the DLC, so the time doesn’t include that.

Back in 2006 I played through Oblivion with a buddy of mine and I don’t remember it being nearly this big. I do remember it being more “grindy” – having to jump a lot to build up stamina, or run everywhere to build up strength. I don’t feel like Skyrim was quite like that, but there was a fair amount of tedium. The alchemy thing – having to make potions – was annoying and tedious. I think there were too many possible combinations of things, too many ingredients. Mining ore to refine into metal ingots that could be fashioned into armor or weapons that you’d then have to improve… yeah, that was pretty tedious, too. But I think the most tedious thing was selling stuff. I had so much stuff to sell and no one had enough money to buy it all. I’d stick it in a chest in my house intending to come back and sell it when I needed money… but I never needed money. I had so much money I couldn’t spend it all. I really wish you could set up sort of a… well, like a consignment deal with the local merchants. Deposit your unwanted stuff in a chest in the shop and over the course of time they’d just take stuff out and put money in.

That’s not to say I didn’t have fun. Skyrim was, for me, incredibly addictive. Just one more mission, just one more quest… and even though a lot of it was sort of the same, I didn’t really get tired of it. If I didn’t have Grand Theft Auto 5 to get to next, I’d go for the DLC on Skyrim.

I played a female orc character, though I spent far too much time getting her to look right considering I play in first person view so I never actually saw her except in a couple of cut scenes after that. I think you had to name your character, too, but they never used her name, or not enough to remember. I think in a couple of ransom notes or something.

What I liked most about Skyrim was how I actually kind of got to know and like (or dislike) some of the NPC characters. Cicero, from the Dark Brotherhood, I hated. I hated him from the first time I met him. He was annoying and whiny. I sold him off to the Blades. The whole battle between the Stormcloaks and the Empire was cool, too – the whole world changes when you decide who to side with and it makes it feel so real and important.

And you could get married in the game, which was neat. I ended up marrying Lydia, my housecarl from Whiterun. It didn’t make sense to me to marry anyone else. She was the first “follower” I got; she was always there and friendly when I went to my house to drop stuff off; and she’s the only real NPC who was totally loyal – she doesn’t stab you in the back or send you on a stupid quest. When I thought about which NPC to marry, it didn’t even occur to me to pick anyone else, like it’d be in-game “cheating” or something. I sort of surprised myself when I felt like that, like it actually mattered somehow, which just speaks to the depth of the game.

Before Skyrim, I ran through Borderlands 2. I got the season pass for that so I’ve run through all the DLC, too, with the exception of this latest “Tiny Tina’s Assault on Dragon Keep.”

I loved the first Borderlands, and this second one didn’t disappoint. Bigger, better, faster, stronger. Great characters, great writing. Some of the Claptrap jokes actually made me laugh out loud and when I think back I still giggle. (“WHY AREN’T YOU LAUGHING? THAT WAS COMING F\^&*ING GOLD!”)

I had intended to play through it co-op with my dad and uncle, but with our various life commitments it was really hard to get together on a consistent basis. In the end, we all ended up playing through on our own, teaming up occasionally for harder battles.

That’s the biggest problem I had with this latest Borderlands. It pretty much assumed you had a group of four people to run through the game with. The harder guys – no way you can beat them on your own. And even some of the DLC was super hard until you really leveled up and were a few levels above the bad guys. I never did kill most of the “Blah the Impossible” or “Blah the Invincible” characters. I got in there with my dad and uncle, we all died enough times that we lost millions, and we still couldn’t kill these guys. I don’t mind a challenge, and I’m a fairly decent player, but it got pretty ridiculous in there. Watching YouTube videos and reading forums for strategy, I wondered where people were getting these full inventories of super-rare weapons, which I have to assume is because they went through the whole rest of the game with the team of people. What about the solo Vault Hunters?

I played through with a couple of different characters, and with one of my characters I played through twice. After all that, plus the DLC, plus the ridiculous challenge in places… it burned me out. I will probably return to it at some point to get through Tiny Tina’s DLC, but it’ll be a bit.

Somewhere in there I played through BioShock Infinite. I liked it, as I liked the rest of the BioShock franchise, but I didn’t feel all blown away by the ending the way many folks did. The game play was fun, the environments very immersive, and I did love the characters. Some of the “jumping onto skyhook lines” stuff got a little frantic. It was a neat idea, but seemed to make it a little more complex than it should have been. I didn’t play through the DLC in that, and I may at some point since they’ll be returning to Rapture, but, again, after GTA5.

personal, blog, gaming comments edit

It’s been a while since I’ve checked in on stuff I do in my off-time, so I figured I’d do a round-up entry to catch up.

Since Phoenix was born it’s been harder to get so-called “free time” to do much. Probably more accurately put: There are a lot of things I like to do, and I have a lot of time to do things if I can involve my toddler, but most of the stuff I want to do isn’t toddler-friendly so I don’t get to do it. I mean, toddlers plus RC helicopters equals disaster.

Jenn’s been helping out a bit trying to get me a bit more time to do stuff on my own. She’ll take Phoe to the zoo or something so I’ll get a chance to pick up some of the activities I used to enjoy but don’t get to as much anymore. What am I up to?

I’m switching up my comic book subscriptions. I’ve had a comic box at Things From Another World for many years and for most of those years I’ve subscribed to the same stuff. I’ve finally started getting caught up on my comic reading (“That 2011 Annual story was great!”) and some of the titles I’ve been subscribing to seem to have jumped the shark, so I’ve been trimming up the list. I’ve canceled Witchblade, The Darkness, and all of my Buffy the Vampire Slayer titles. I’ve been in on those from the beginning, but the stories are feeling played out and stale, and at $3 – $5 a pop, I can find other titles. I’m trying out a couple of new ones like Ten Grand, and I’m keeping Daredevil, Powers, and the myriad Grimm Fairy Tales titles.

I’m getting back into RC helicopters. A few years back I bought the original Blade CX coaxial helicopter from the local hobby shop to start getting into flying. It’s been fun, but I’m not very good at it, and it requires a lot of space with zero wind. Here and there I’ve been upgrading it, adding better blades and so on, but I’ve not really gotten it dialed in. I recently picked up a Blade MSR and a Spektrum DX6i controller and I’m starting to get back into it. The MSR is much smaller so it’s easier to fly indoors, though I still think I need to tweak some of the settings. I’ve also upgraded my Blade CX with a new receiver so I can control both helicopters from the one transmitter. All that, plus I got this monster battery charger so I don’t have the problems getting my batteries properly balanced/charged/stored and I’m good to go.

I’m having fun with frisbee golf. The weather has been really nice this summer so my team at work went to a local course and I played frisbee golf for the first time. I’m not very good, but it’s fun, so I’ve been back a few times since. I picked up a starter kit of discs for myself and one for Jenn. This is something Phoenix can participate in, too – we give her a disc and she throws it all over. (She also runs and fetches your discs after you throw them so you have to watch where they land because they’re not going to stay there long.)

I’m burning hours playing Skyrim. I got Skyrim for Christmas and started playing it a couple months back. That’s a time-sink, right there. It’s kind of relaxing and compelling at the same time. There’s just enough tedium to take my mind off the troubles of the day and enough missions to run that there’s always something to do.

I’m taking online bartending courses. I picked up a membership to Bartending College Online through Groupon a while ago and I’ve had fun watching the videos and learning the various techniques and recipes. I’m not going to quit and go be a bartender, but it’s fun to learn something new that doesn’t have to do with computers.

I haven’t gotten back into electronics with my Snap Circuits yet, but I hope to do that, too. Once it turns to Autumn and the weather goes to crap, frisbee golf will be out and I’ll see about getting into the electronics again. I really enjoy working with them, but about halfway through the exercises that come with the set I realized I don’t have a good grasp of the fundamentals, so I took a pause on it to read a book on the math and basics behind why the components behave the way they do and that’s where I stalled out. It’s not a book you want to read when you’re sleepy, but I think it’s important to understand the basics so I can go beyond what the pre-printed exercises show and maybe make electronic inventions of my own.

I’m trying to migrate my blog to WordPress. Subtext was fun while it lasted, but development on it has pretty much ended and I’d like to be on a supported platform. I honestly thought I’d use my blog as more of a hobby, someplace to try out new code and ideas, but there’s really not any plugin mechanism in Subtext and, while that was the plan, it never came to fruition. Rather than move to another smaller platform and go through the growing pains again (and possible abandonment of the platform) I’m trying to get into WP. That means I have to figure out how to export my content in WP format, though, which isn’t going to be easy.

I’m trying to get my images out of ImageShack. I had a paid account with ImageShack for a year or two to host my images and reduce bandwidth consumption on my hosting provider, but ImageShack randomly deletes or loses images all the time. Like, constantly. Links break, the images disappear… today I found that they’ve “lost” my blog skin images, so my blog doesn’t render right. I’m going to switch to a simpler/lighter-weight skin until I can get that fixed (probably until I move to WordPress – it was time for a change anyway).

vs comments edit

I tried to update to the latest version of NuGet in Visual Studio recently and failed. Miserably. The error I kept getting was:

The process cannot access the file because it is being used by another process.

Totally generic, not even any info about the file being locked.

Looking in the log, I see the following error:

7/29/2013 7:30:36 AM - Install Error : System.IO.IOException: The process cannot access the file because it is being used by another process.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.__Error.WinIOError()
   at System.IO.File.InternalMove(String sourceFileName, String destFileName, Boolean checkHost)
   at Microsoft.VisualStudio.ExtensionManager.ExtensionManagerService.AtomicallyDeleteFiles(IEnumerable`1 filePaths, Boolean justMarkForDeletion)
   at Microsoft.VisualStudio.ExtensionManager.ExtensionManagerService.DeleteDiscoverableFiles(IInstalledExtension extension)
   at Microsoft.VisualStudio.ExtensionManager.ExtensionManagerService.UninstallInternal(IInstalledExtension extension, Boolean forceDelete)
   at Microsoft.VisualStudio.ExtensionManager.ExtensionManagerService.CommitInstalledAndUninstalledExtensions(IEnumerable`1 installedExtensions, IEnumerable`1 uninstalledExtensions, IEnumerable`1 packComponentChanges)
   at Microsoft.VisualStudio.ExtensionManager.ExtensionManagerService.BeginInstall(IInstallableExtension installableExtension, Boolean perMachine, AsyncOperation asyncOp)
   at Microsoft.VisualStudio.ExtensionManager.ExtensionManagerService.InstallWorker(IInstallableExtension extension, Boolean perMachine, AsyncOperation asyncOp)

Again, no info about which file is locked.

I used ProcMon.exe to figure out the sharing violation was happening on NuGet.pkgdef in the new installation of NuGet. Of course, it was happening at exactly the wrong point in the installation process, so I ended up with 10 or 15 nearly-installed-but-corrupted copies of NuGet.

I’m pretty sure this has to do with our antivirus software holding a lock just a little too long on the file, but who’s to say. I just needed it fixed.

Here’s how I fixed it.

  1. Close all instances of Visual Studio.
  2. Go to your global Visual Studio extensions folder. NuGet doesn’t install in your per-user folder; instead, you’ll see it in Program Files. Something like: C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Extensions
  3. Look in that folder. You will see a lot of randomly named folders like “sdjfksiov.djd” and so on. Most (if not all) of those are NuGet. You’ll want to be aware of which ones are NuGet and which ones aren’t, particularly if you have other extensions installed. (You can tell if it’s NuGet because it’ll have a bunch of NuGet.*.dll files in there. If you don’t see NuGet stuff in there, you’ll want to keep it.)
  4. Rename that Extensions folder  to something like: C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Extensions_RENAMED
  5. Download NuGet directly from the Visual Studio extension gallery.
  6. Execute the downloaded NuGet.Tools.vsix file you just downloaded. Don’t do it through Visual Studio. Just double-click the .vsix file to install it.
  7. NuGet should successfully install. As part of that install, it will create the Extensions folder again, so you will once again see C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Extensions
  8. Open up your renamed extensions folder and move all of the non-NuGet extensions into the new Extensions folder.
  9. Now open Visual Studio. You should see the new version of NuGet installed and working.
  10. You can delete that renamed Extensions folder once you’ve verified everything is working.

I fought with this for a long time. Enough that I corrupted my whole VS install and had to pave my machine and fully reinstall. Hopefully this will help other folks that see the same issue.

One additional note: My local user account isn’t an administrator, but when I need to do admin operations I can provide credentials. This process seems to require you’re actually running as an administrator account. Simply providing credentials to elevate the privileges didn’t work for me.

UPDATE FOR VS 2015 - THIS TRICK MAY OR MAY NOT ALWAYS WORK: After installing VS 2015 RC1 I found this problem started happening with many more extensions besides just NuGet. I’m not sure if VS 2015 extensions install differently or if more extensions have just adopted the way NuGet installs. There’s also the added challenge of add-in dependencies.

For example, the “Powershell Tools” extension immediately had an update after install. I tried this, but found that “Powershell Tools” relies on another add-in also being installed, so having an empty extensions folder doesn’t work. However, after locating the dependencies and making sure those were all in place, I still ended up with the file lock error. I never did find a combination of actions that could work around it.

I effectively can’t update any add-ins after they’re installed in VS 2015 RC1 on the machine with the guilty antivirus software. Installing on a VM without the antivirus software, everything works swimmingly.

UPDATE MAY 8, 2017: After a lot of research I found that this was caused, for me, by the McAfee Endpoint Encryption full-disk encryption product, not the antivirus. The lack of antivirus in my initial tests was a red herring; the VM I tested with also did not have the full-disk encryption product running. This problem was acknowledged as an issue in this McAfee KB article. The solution if this is what’s causing it for you is to tell full-disk encryption to exclude devenv.exe and VSIXInstaller.exe. Note the KB article doesn’t mention VSIXInstaller.exe; that’s an omission in the article.

Here’s a registry snippet to tell McAfee Endpoint Encryption to exclude these files. Once you do that, reboot, and the problem should be solved. I’ve tested this on Windows 7, Windows 2008 Server, and Windows 2012 Server. YMMV; I’m not responsible if your stuff breaks; disclaimer disclaimer disclaimer.

Windows Registry Editor Version 5.00
 
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\MfeEEFF\ExemptedProcesses]
"1"="devenv.exe"
"2"="VSIXInstaller.exe"

Well, I made it to 37. And, in the usual internet custom of blogging something reflective and profound when your birthday comes around, well… here I am, jumping on the bandwagon, contributing my part to that large batch of published information in the category of “Well, It Matters To Me.”

I don’t really feel 37 mentally, though my hair is more gray now than it’s ever been, so it’s starting to show externally. I don’t exercise like I should (because, frankly, it’s boring as crap) so I’ll claim being out of shape as well.

But I feel like I’ve done a lot, or at least enough to satisfy my definition of “a lot,” so I think there’s something to be said for that. My daughter, Phoenix, is now two and a half and the energy she exhibits puts tropical storms to shame. I think in that respect keeping up with her is something that keeps me young, though it keeps me exhausted at the same time.

I go to the chiropractor every month and I was mentioning to him how I always figured that I’d get into better shape as she got older. You know, she starts out as a baby and doesn’t require too much of my energy, but as she gets older and I have to keep up, I’d gradually get stronger and in better shape and everything would work out. “That’s, uh, that’s really not how it works,” he said, as he caused my spine to make a pretty awful cracking noise.

I think the biggest thing I’ve found as I get older is that I have a lot less time. When you’re young and single, you can just put your shoes on and head out to see a movie. You can go to the comic store on a whim and hang out for a couple of hours. Want to do a total dungeon siege in Skyrim? Go for it. You won’t be neglecting anyone and as long as you have a pizza, you’re set to go.

Now I’ve got a loving wife and a crazy kid. I wouldn’t trade them for the world. Seriously, they’re the best people I know and I can’t imagine life without them. So keep that in mind when I say this: There are times when I feel like I’ve lost something of myself and that my time feels a bit “held hostage.”

I still make it to the comic store, but it’s more monthly than weekly. I don’t hang out as long. And I’m having to become way, way more selective about what I read – not because of budget, but because I don’t have time to read. I spent a couple of magical hours a week or two ago finally getting to read the 2011 annual for one of the comics I get and reading through a full year-and-a-half of stories for another comic.

Evenings? Fuhgeddaboudit. Get home, toddler’s already there. You gotta be daddy from the time you get home until 8 when she goes to bed. You might get a reprieve if you hand her the iPad (she can figure out Netflix herself and find something to watch). Between 8 and 10 it’s nice to have an adult conversation that won’t be interrupted by a toddler, so it’s husband time. Usually that means you can do something that doesn’t require too much attention while you watch a movie together or something like that. But it’s not much. Nothing where it’d require any actual focus.

When I do get time, it’s an exercise in extreme time optimization. I might get, say, four hours while Jenn takes Phoe to the zoo. What do I do? Well, I really would like to go eat at this restaurant that Jenn’s not so into, but that means 15 minutes there, 30 to eat, 15 minutes back – nope, that’s an hour of my four. Skip eating, I have no time for that. OK, let’s say an hour of reading comics, 30 minutes of failing to learn guitar using Rocksmith, an hour to try and actually make headway in Skyrim… you get the idea. It’s a near minute-to-minute itinerary. And there are so many things I want to do. I want to learn electronics (got the books, got some Snap Circuits…). I want to make a little movie with the Muppet Whatnot Jenn got me. I’m taking online bartending classes (just for fun, not for career change). I have comics to read, home media center stuff I want to work on… you get the idea. That doesn’t even count the little things around the house that need to be fixed/re-painted/etc.

I just haven’t the time.

Maybe that’s really what it means to get older. You just don’t have the time anymore, so you have to really prioritize and just give up on some of the things you’d rather do.

But the good stuff is really good. Watching Phoenix just get into the Batman is Brave! book (and want to hear it over and over) is awesome. Hearing the crazy stuff she comes up with – words and phrases I had no idea she knew – is amazing.

So, here I am. 37. I’m not sure this is where I envisioned myself being, but it’s not a bad place to be. I can’t really say I have a “five year plan” because, I mean, I don’t know what I’m eating for dinner tonight. I don’t even remember what I ate for dinner last night.

And maybe that’s OK.