Thursday, April 13, 2006

Monday nights, I play poker in a free poker league. We play for points, and most of the people playing in the league play almost every night (man I wish I could do that!). Anyways, here is a fun hand I had happen.

I was acting in late position, I looked at my cards to find 10s.gif, 10d.gif, everyone had folded to me, just the small and big blind to act. The guy in the big blind is an aggressive player, and I was sure if I went all in he'd call with a marginal hand. So I moved all in. The small blind folded, and big blind guy called.

He had As 8d. So I felt good about the hand, I mean it's really close to 50/50, at least he only had one over card. (Wow, I actually just put the odds into an odds calculator on www.cardplayer.com, and I was 71.97% to 27.68% -- the hands would tie less than 1% of the time.)

Anyhow, the flop came:

   10C.gif, 10h.gif, Ad.gif

I think my opponent just saw his ace at first, because he seemed happy until he realized I had flopped quads. Four of a kind! The turn (which was irrelevant, there was no way I could lose at this point) was an 8s.gif, and the river produced the Ac.gif.

So the quads saved me. He had lost his hand a FULL HOUSE, aces full of eights. He muttered to himself, and left the table, a little annoyed I think.

Anyhow, it was one of those really fun hands that will statistically almost never happen.

Thursday, April 13, 2006 1:33:12 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [1]  | 

I'm digging .NET 2.0! I can say for sure, that it's going to seem like forever waitng to switch over to it at work, but that's ok. So one of the things in .NET 1.1 that was decent, but could use improvement was client uploaded files via the browser.

Enter .NET 2.0 FileUpload Control. Now this may seem geeky, well, I guess if you are reading this you're either a friend, or a geek, so.... The coolest thing about the new 2.0 control is that you don't have to mess around withe MultiPart encded forms. Yep, this baby sits inside a 'normal' <form> tag. Wooooo!

And since it's now a <asp:> control type, you can run validators against it. No more making the user upload a file to determine if it's the correct type, or having to write javascript to check the input box. The really cool thing is that it just works.

Just add the following .aspx code

<asp:FileUpLoad id="FileUpLoad1" runat="server" />
<asp:Button id="UploadBtn" Text="Upload File" OnClick="UploadBtn_Click" runat="server" Width="105px" />

Like I said you can even add Regex, Required Field, etc. validators and set the ControlToValidate argument to the name of your upload control.

Originally, in the codebehind I was doing this:

protected void UploadBtn_Click(object sender, EventArgs e)
{
   if
(FileUpLoad1.HasFile)
   {
      FileUpLoad1.SaveAs(FilePath
+ FileUpLoad1.FileName);
      //Then I was doing a bunch of GDI stuff to work on the image, sized it, and created a new image and saved it.
      //
The problem came when I wanted to delete the original as uploaded above.
      //snip
      
   }
}

Even after getting a handle to the file as an image, from the disk, AND calling the dispose method on the object when I was done with it, I'd still get an exception stating that the file was in use by another process when I was trying to delete the original.

So I talked w/ a guy at work here named Stuart (see blogroll on the right) and he mentioned that it would be good if I could work with it as a stream, instead of having to write it to the disk. So after some playing, I came up with this!

protected void UploadBtn_Click(object sender, EventArgs e)
{
   if
(FileUpLoad1.HasFile)
   {
      //Instead of saving the image, I just assign my variable to the Upload Control's instance of the file as a STREAM.
      System.Drawing.Image imgPhotoResize = System.Drawing.Image.FromStream(FileUploadControl.FileContent);
      
   }
}

Nice! Now there's no file to cleanup when I'm done, all I have to do is save the file from my Image object, and call Dispose() on my instance of that object:

   imgPhotoResize.Dispose();

Thursday, April 13, 2006 8:48:08 AM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  | 
 Thursday, April 06, 2006

So in diagnosing the problem below, it would have maybe been helpful to see the IIS logs, At the time I was using the built in web server (for development) that ships with VS 2005. It requires that you address it via localhost, on a port other than what IIS uses. I tried to have a firend hit it using my Dynamic DNS service, and he could not. He could hit my IIS instance on port 80.

Later, I did find you could do this: Go to your web application properties, start options, choose use custom server, and then put the path to your web application in. You'll have to go into IIS and setup a site, or virtual directory for your app.

 

Thursday, April 06, 2006 7:33:05 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  | 

So I'm into my second night of VS2005, and .NET 2.0. I'm working on a super secret project with a friend of mine. Hopefully we'll have something fun to show in a month or so. Anyways, I decided why not use .NET 2.0?

So I could just code it in 2.0, the way that I would in 1.1, but what would that accomplish? So I've got a really good book, and I'm teaching myself as I go.

One of the first things in .NET 2.0 that sounded really cool (actually it is pretty cool) is Master Pages. A Master Page is basically a file that you define that you can have other pages visually inherit from. What this means is the 10 pages of our site that all have the same layout inherit from one master page. If we want to move the ads, or switch the navigation, it's one file to edit.

Inside a Master Page, you can define areas that are for content. You then add Content Pages to VS 2005. So here comes the issue I ran into, and it took a while to figure out:

   Issue:
   My Master Page was defined as MasterPage.master. I added a bunch of HTML, added a content
   page called default.aspx that was linked to the Master Page. The default content page had the
   word test in it printed from the codebehind. Every time I debugged into this codebehind call,
   I noticed the Page_Load event was being called twice, and it was never a postback. I messed
   around with AutoEventWireUp in both the Master Page and the Content Page, to no avail.

   Solution:
   
I started removing HTML. When I went back to a blank page, w/ no additional HTML, the page
   events behaved correctly. I finally found this was causing the problem (my bad HTML).

      <asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
      
</asp:contentplaceholder>

      <div style="BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #000000 1px solid; BORDER-LEFT: #000000 1px solid; BORDER-BOTTOM: #000000 1px solid"><img alt="#" src="#"/></div>

   
Removing the div tags w/ the inline styles stopped the events from firiing twice. Sure maybe
   it's bad to have inline styles applied to a div, but man I wouldn't expect that type of behaviour.

   I'm going to tackle THEMES and SKINS next, so I'm sure I'll see why soon.

Thursday, April 06, 2006 7:20:17 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [1]  | 

So I live in a decent neighborhood, it's not like Donald Trump is gonna land anywhere near where I live, but I also don't worry too much about crime, or 'hooligans'. It's kind of like Pleasantville, without the idiosyncrasies that made that movie creepy.

So in a neighborhood plastered with sidewalks, why do people walk down the side of the street? I just don't get it. Here's the capper, yesterday, I saw a woman pushing a baby stroller down the street. When she got to parked cars, instead of using the sidewalk, she walked past the cars in the middle of the street.

I see this many times per week. Walkers, runners, moms. What the hell? I don't get it. Then to top it of you get these awful looks when you drive past them. Can someone explain this to me?

Thursday, April 06, 2006 7:58:52 AM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  | 
 Sunday, April 02, 2006

Friday night was a ton of fun. My wife and daughter were out of town, so I hosted a poker game. We had 12 people show up, and it was one of the weirdest poker nights for me in a long time. I dealt most of the night, we ran two tables, each having six players.

I swear that almost every single hand I dealt either had the makings of a flush, or a straight, and a lot of straight flush possibilities. One of the first hands of the night I started off with:

  5s.gif, 6h.gif

A nice little connector I thought, so I limped in to see a flop, which came: 7c.gif, 8c.gif, Kd.gif. Nobody seemed that interested in the pot, so I bluffed at it for 2x the big blind. Two callers. The turn comes 9h.gif. Sweet I've made my straight! So I check. It checks around... damn. The last card Jc.gif. So I bet about five times the big blind. One guy folds, the other raises me the same amount, I call, and loose to a flush. Doh! I didn't even notice it.

Ok, not a big deal, still have plenty of chips. But now I'm gunshy. So a few hands later, I get pocket sevens (7s.gif, 7h.gif). I call the bets and the flop comes 7c.gif, 8c.gif, 9d.gif. Crap. I've flopped a set, but man there's a flush possibility, and a straight draw. So I bet big, 6x the big blind.

Two people call. Crap. Now the Jc.gifcomes off. Great. I check. Two more huge bets. I think I'm so smart and say, "I'm gonna lay this one down...." The river comes off w/ 2d.gifsomething innoculous. The two huge betters reveal their hands, a pair of kings, and two pair! Damn... I made the wrong call again.

That's really not like me.

Ok so I figure, time to recompose myself. Let those two hands go.

So here's where the night got interesting, my neighbor Brent, was just TEARING through the competiion, he had knocked three people out (2 of them rebought into the game, to be knocked out minutes later) then it was time to combine the two tables.

We all played for a while, and two or three people got knocked out. Brent was poised to win the tournamnet, no questions, hands down, when he leaned over to me and said "My babysitter has to leave at midnight, do you think I'd win if I stayed?"

I said, "Dude, you'd have to be a moron to lose with the amount of chips that you have."

He was bummed out because 1st place paid $150 on a $20 entry. So out of desperation, or frustration, he started betting all his chips on every hand, no matter what cards he had. Now this may seem cool, for someone that had a good hand, but the thing to remember in a situation like this is, if you lose the race against a chip bully, you're out of the tournament!

So one of the very last hands before he had to go, Brent moves all in with Js.gifand 6c.gif. Most of everyone folds, but my good friend eric pauses and says "I have a good hand". He's obviously conflicted, but I know the thought, "If I beat this guy, who has to leave, who does not care if he wins this hand, I'd be poised to win this thing".

So Eric pushes all his chips into the pot. Then a few people later, Darren, decides to go all in as well. Amazing. So our seven handed game has the opportunity (for me) to go from 7 players to 4 (if Brent wins since he's leaving). I think I even said aloud, "I don't know why you guys would tangle with Brent, since he's leaving.... he'll probably knock you out of the game."

Well Eric turns over Ad.gif9c.gif (suit is not important in this hand), Darren turns over Ah.gif10s.gif, and Brent turns over Jh.gif6s.gif. Darren is a strong favorite in this situation. The flop came three rags (4d.gif2c.gifQs.gif) so Darren is still in front, then the Jc.gif came on the turn. Brent is in the lead. The only way Darren can win, is to get an Ace, and Eric is pretty much out of the game at this point. The river brings a 6d.gif, giving brent two pair, Jacks and sixes. Eric and Darren are out of the game.

Brent plays a few more hands, and keeps pushing all in... he thinks he's trying to give his chips away, but everyone just concedes folding their cards. I laid down an Ace Jack, that would have won, but I did not want to risk my position. After Brent leaves, it's just four of us now. It would have been very tough for me to make 1st, 2nd, or 3rd. But now, I'm way better off.

Long story short, we played for another hour or so, and I was able to win the match. Another point, when playing a tournament format, make sure that you can stay for as long as the tournament will run, seldom do we ever finish before midnight. I was shocked when Brent said he could not stay later.

Oh yeah my new table I'm building is about 60% complete, here is a shot of the LCD monitor embedded into the table to keep track of the blinds, and run our tournament software.

Sunday, April 02, 2006 11:29:43 AM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [4]  | 
 Friday, March 24, 2006

My friend, and coworker, Scott Hanselman is going to raise $10,000 in support of Diabetes research. Scott is an amazing guy, and I challenge you to help him meet his goal. They are over 80% of the way there, and you can help. If you've read scott's blog, then you know what an intelligent, interesting and funny person he is, but read this article he wrote, and you'll be even more amazed.

He's not bitching, he considers himself lucky he has his life under control.

Every little bit helps, even a $5 donation will get him closer to his goal. Click the banner below to go to his Walk-a-thon team site, where you can see their progress.

TeamHanselman.gif

Friday, March 24, 2006 9:29:02 AM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  | 
 Saturday, March 04, 2006

I'm not usually into this type of game, but since there was a free demo to download, and I wanted to play something new, without having to purchase another game, I decided to put the demo on. For a demo, it's amazing, four different modes of game play, my favorite was dodging roadblocks, and evading the police.

After playing the demo for SEVERAL hours, I decided that it was worth purchasing.

The full game is completely worth the price paid. The graphics are STUNNING, it runs in up to 1080i. The cars are beautiful to look at, and the surroundings you drive around in are very realistic. Even the physics of the world you are in are pretty accurate. If you saw the movie "Gone in sixty seconds" the game parallels this movie closely, instead of stealing cars, you're racing them.

The game play is great, it breaks down like this:

You're a street racer, you know, in those pimped out cars with huge spoilers (sometimes stacked spoilers even...lol), gawdy rims, and tons of viny to complete the 'rice' effect. You have no respect for public safety, law enforcement or your own vehicles for that matter.

The game starts off with a few minutes of narrative and video cut-scenes. You go up against the street's best racer, a guy named Razor. In the video scene, you're about to beat him, but he has tampered with your ride, and you lose the race, he takes your car.

You meet this girl named Mia, and she becomes your coach, she sets you up with a safe place to store your cars, and explains what you'll need to do to find Razor. You have to defy the law, reak havoc, to gain the attention of Razor's guys, when you've impressed one, you get to race them.

There are 14 'henchmen' and you have to beat each one, with Razor for the end.

The game play is amazing. The feeling you get from speeding down a cramped 2 way street at over 120MPH is amazing. There are some cool features to the game, like being able to slow down time (when you're traveling at a high rate of speed, trying to squeeze through a roadblock, you can hit a speedbreaker, which brings game play to slow motion, allowing you to surgically strike weak points in a roadblock), and being able to completely customize your vehicle down to the smallest detail like tinted window color.

I started off the game trying to keep my cars 'cool'. I quickly found myself going for neon green paint, with bright red and yellow vinyl flames! It's hilarious... need_for_speed_01_kl.jpg

The city you play in has three areas, the first area is unlocked by default and it is HUGE. As you progress in the game and beat your oponents, other areas get unlocked, and the best thing is you can freely move between all three areas. You can drive for hours and not feel like you're seeing the same thing over and over.

The game has nice features like GPS navigation, so if you know where you want to go, set it in your GPS, and you're directed how to get there. This is good for gettng to races, your safe house, or more importantly the shop - where you customize your ride, both visually, and mechanically.

The cut scenes and introductions to new oponents is done very impressively. The whole game is 'overdone' in such a way that makes it feel right. The attitude and feeling you get from playing through the story is crazy how quickly you get into the game.

Each time you beat an opponent, you get an achievement. So you'll be bumping up your Xbox live gaming score almost every time you play.

The game also allows two player local, as well as xbox live play. I have not tried either yet, but will be doing so for sure in the future.

Hands down, check out the demo, at least, I bet you'll end up purchasing it.
 

Saturday, March 04, 2006 2:19:19 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  | 

When I got my Xbox, I was not a huge fan of driving games. I did want a game that I could enjoy playing with my daughter, and this game was one that I had seen and knew would have content that was ok for a younger child.

This game was like a good book, once I started it I could not put it down. The graphics are amazing in this game as well, and it says it runs up to 720p, but it really feels better than that.

The game play breaks down like this:

 You compete in a series of events in 5 international locations ranging from Las Vegas, to London.

 For each goal you achieve, you earn money, which you purchase vehicles with. You start off with a small 4 car garage, and as you progress, filling your garage earns you more spaces to store your vehicle collection.

 The cars in this game are amazing. Think of EVERY exotic car you've ever seen, it's in this game. From the Lamborghini Countach, to the Ferarri Enzo. They even threw in the AMAZING Ariel Atom (a 50,000 1 seater roadster that will do 0-60 in less than 4 seconds!).

 There are various types of races to compete in, race the clock, eliminator (last car is eliminated each lap), street race, cone challenge, speed challenge, etc.  The game does a good job of mixing up the challenges as you race, so it feels like it's always changing and does not get stale.

 Outside of the race environment, there are several things you're able to do. One of my favorites is when a race is over, you're actually able to go back and review the whole race as if you're watching it on television. You can even move cameras from each car, around the track, to your car, or as the race leader, it's so much fun to see what your driving looks like and how you improve as you play through the game.

 You can even walk around inside your garages, admiring your vehicles, it's crazy, fully three dimensional, like a FPS, you can even play the original Geometry Wars as there are arcade style video games located inside your garage.

 Then there are other things you can do like take pictures of your cars (not really sure why you'd want to do this... but....), create your own custom routes, view car details, etc.

 One of the funnest parts of PGR3 is the online integration. If you're connected to Xbox live, every time you compete an individual race, it will show you where you rank in the 'PGR3 world'. You can also race online against other people over the net. It's so much fun, I've come to realize that I suck at online racing, and I'm sure 10 year olds across the country like to spin me out. Heh.

 There is also a feature called Gotham City Television, and you can just watch 'the best' race when they're online.

This is a great game to purchase, I'd say it's a 360 staple, and should be part of your collection.

Saturday, March 04, 2006 1:41:35 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  | 
 Thursday, March 02, 2006

So this is one of those errors that I occasionally run into, and have not been sure what to do. I usually do an iisreset, kill the aspnet_wp.exe process, shut down visual studio, then open visual studio again, and it goes away.

Not today. And of course at the most inconvenient time, my usual kludge to get this error to disapeer did not work. So with some further research I found a KB Article on Microsoft, explaining why this can happen.

The indexing service is known to index temporary asp.net files! I thought it was too good to be true, as a quick fix, I paused the indexing service, did a rebuild on my solution, no error. Sweet! I then followed the instructions in the KB article to tell the indexing service not to index my temporary ASP.NET files.

Also handy if you want to keep the indexing service out of certain other areas.

http://support.microsoft.com/default.aspx?scid=kb;en-us;329065

Thursday, March 02, 2006 5:24:09 PM (Pacific Standard Time, UTC-08:00)  #    Disclaimer  |  Comments [0]  |