Thursday, April 28, 2011

My Distractions


So I'm a bit of a gamer.  And I recently started playing the beta for Gears of War 3 (since I pre-ordered the game, I'm allowed in early).

For Gears 1, I loved the single player, but was overwhelmed by the multiplayer.  It was a bunch of jumping and dodging and shotgunning.  When you unload a full clip from your assault rifle into a guy running at you just to loose because he fired on shotgun blast, I had it.  I would still play online with friends, but no more random matches.

Gears 2 came out, and the single player was fun, but a bit odd in the story line.  You could definately tell it was part 2 of a trilogy.  I played maybe 2 or 3 rounds online, and had a very similar experience to the first.

Now I'm playing the Gears 3 multiplayer only beta, and I have to admit I'm kinda digging it.  I don't know if I've just had good teams, my perspectives changed, or if it seems balanced, but the past two nights thats all I've played.  I doubt I'll manage many of the unlocks that carry into the full game.  I'm not that good, but hopefully I'll get a few.

Hit me up if you see me online, I'm willing to die by lancer.  GamerTag: Zaaneek

Friday, April 22, 2011

Sql IsNull Usage

Was writing some SQL statement, and was testing a nullable VARCHAR column to make sure it was not equal to null and was not an empty string.   So I started to write this out as:
WHERE ColumnName IS NOT NULL AND ColumnName <> ''

Well, then I looked at some other code I wrote utilizing the ISNULL function, and realized I could write my SQL as:
WHERE ISNULL( ColumnName, '' ) <> ''

This took care of both options, because if it's null, it returns an empty string, the filters it out with the <> ''

Noted for future use!

Friday, April 15, 2011

LINQ goodness

O LINQ, where have you been all my life?  Out loud that makes me feel like Zelda, but programmatically I think it may have changed my life.

Recently I had an List of events that had been loaded from a CSV file.  I then needed to filter this list of 5000 events down to anything happening in a single month, lets say April.

In the past I would have written (and I started to this time as well) a foreach loop that would loop through each event in the List, check the event dates to be occuring between April 1st and April 30th.  If it does, add the event to a new List, if not move to the next.  Then return that new List of Aprils events.

When I started to write this, I thought to myself, this would be easy if I could query it in SQL. Then the light bulb went off and I remembered this LINQ thing I'd been laying with.  I created a var named qry, and selected from my event List all those whose event dates where between April 1st and April 30th.  And ta-da, i just need to return qry.ToList() and I had my result set.

This also, in my opinion, resulted in cleaner and easier to read code.  Unfortunately it will also probably have me trying to put LINQ style queries everywhere...

Facebook Fangate Page

So, to follow up on my previous Facebook post, I wanted to share our solution.

The goal was a fangate page.   A user goes to the page.   If they are a fan, they see one page, if they are not a fan they see a page asking them to like it to view the other content.

Nothing I was finding online was working, especially since FB is moving away from FBML and towards iFrames and we needed to implement their PHP SDK.  Everything we found online, and subsequently tried would prompt the user for permissions to access their account.   We didn't need that, nor did we even want any of it.

Long story short, we had four files and that solved the problem (five if you count the facebook.php file from GITHUB). Assuming you already have a Facebook page setup and have created an app to mess around with-

The structure went like this/index.php
/config.php
/fanpage.php
/becomeafan.php
/library/facebook.php

/config.php looks like this

/index.php looks like this

/fanpage.php can look like whatever you want to display. For testing I made it just

/becomeafan.php can also look like whatever you want to display. For testing I made it just

On a gotcha, this only worked within a Facebook page. When running the .php files directly from the server getSignedRequest didn't return anything, and thus $like_status was always null, and the user was always sent to the becomeafan.php page.

But that's all it took. After all the searching and digging and testing and page updating and refreshing and asking others in the office to click on things.

Thursday, April 14, 2011

New Book Tirade

Well, while I was on a new book tirade I went ahead and made two new purchase through the Amazon store for the Kindle.   I don't actually have a Kindle, but I have the Kindle apps on my iPod and my Droid.

The Pragmatic Programmer: From Journeyman to Master and Professional ASP.NET MVC 2 (Wrox Programmer to Programmer) are both now mine as well.

I've got a lot of reading to do...

Wednesday, April 13, 2011

Facebook PHP

So I developed my first Facebook PHP SDK based page content today.   Took approx two days, server trouble shooting, searching for documentation (highly lacking) and testing code line by line.   And what did I end up with?

To summarize briefly:

If (user likes page) Then
   Display Fan Page
Else
   Display become a fan page
End If

Yup.   Two days, 2 developers, maybe 4 hours each and I got a five line logic structure figured out.

Thanks Facebook.  Thank you for having sucked.

Tuesday, April 12, 2011

Change of direction

Well, I think I'm going to put F# to the side for now and try to learn a little MVC. There's more of a work related push for that. So I've installed MVC 3.0.

Also, trying to do some PHP testing I've installed IIS 7 and the PHP functionality on my Windows 7 laptop. So this should get a bit interesting.

Monday, April 11, 2011

New Book

So like I posted I have the Code Complete book to read, but I had a GroupOn that was expiring so I used it to order a new book from Barnes & Noble.

Professional ASP.Net Design Patterns

I'm kinda exciting. Hoping it will teach some of the design stuff I didn't pick up from learning .Net on my own.

Reading Material

So I just wanted to throw out that I've been reading the book Code Complete by Steve McConnell.

So far I'm on Chapter 16: Controlling Loops. I've learned a bit along the way, and skipped some pages that were no-brainers and duh moments. Maybe I can use this as a reason to put some more posts up.

Sunday, April 10, 2011

F# Seconds

A while ago I played with an F# tutorial. I went back to http://blogs.msdn.com/b/chrsmith/archive/2008/05/02/f-in-20-minutes-part-i.aspx and followd it again.

This is quite different than the .Net I'm used to...

Difficult


So this blogging thing has become a little more diffiicult than i originally thought it would be.  I don't know what I thought this journey would be, but I'm finding a real lack of time to do it.

When I get home I have two options, i could spend some time doing something like this, or I can spend it with my wife and puppy.  I end up choosing the second option.

So if there's anyone that reads this and blogs themselves, how do you keep your motivation going?