Michael J. Swart

January 27, 2010

Blogger tip: DIY In-Line Forms

Filed under: SQLServerPedia Syndication — Michael J. Swart @ 12:56 pm

Rick Klau of Google recently mentioned a relatively unused feature of Google Docs called Docs Forms. I wanted to mention it in case you haven’t come across it yet. Docs Forms is a feature of Google Docs that allows bloggers to embed forms into their blog articles or web pages. And that includes all blogging platforms (not just google’s blogspot). Basically, these forms can be embedded into any html that supports IFRAMES.

This easy-to-use form-creator opens a huge potential to bloggers that might not have used forms in the past (e.g. me). The list of applications includes surveys, polls, contest submissions, contact pages and so on.

For me, Blogs + Forms allows a higher level of interaction with readers than I had compared to this time last week. And that is an exciting prospect. If you care, you can see how I’m using a form right now on my “Mail Me” page.

There is one thing I worry about though. Blog polls are notorious for producing untrustworthy data. It’s the nature of a self-selected sample population.

For example, I bet Paul Randal’s survey takers, are a bit savvier than average so his blog survey results have to be taken with a grain of salt. In other words, I bet the who’s-Paul-Randal? crowd have a lot of people in common with the No-disaster-recover-plan crowd and they might be under-represented in such surveys.

And what would this blog post be without an example. So without further ado, give the feature a spin:

January 18, 2010

Tic Tac Toe vs. T-SQL

Filed under: SQLServerPedia Syndication,Tongue In Cheek — Michael J. Swart @ 11:50 pm

It's learning

It's learning

Stephen Horne (aka BlueDog67) threw down the challenge last week to Create An Unbeatable Tic-Tac-Toe Game. He did that in this post.

So that’s what I did. Here’s my crack at it (which I also left as a comment):

The curious can download http://michaeljswart.com/wp-content/uploads/2010/01/tictactoe.zip

The zipped file contains two files:

  • One is a bcp output file that contains data. (It is used by the script)
  • The other is a sql script that creates the following tables and procedures:
    • TABLE tttBoard (spaceId, value)
    • TABLE tttMoves(id, turn, bestNextMove)
    • PROCEDURE s_CleanBoard()
    • PROCEDURE s_PrintBoard()
    • PROCEDURE s_MakeMove(@spaceId, @letter)
    • PROCEDURE s_ComputerMove

I decided to use a look up table (tttMoves) to find the best move. I thought it fitting to develop a solution that uses a set of data rather than an algorithm because of it is T-SQL after all. Here are three things I learned.

  • The size of tttMoves is extremely small. Roughly 4500. Think about it. If you take nine ordered spaces on a tic-tac-toe board and put every combination of X, O, or space, there’s still a manageable number of boards to deal with. I removed completed boards and boards showing games that were invalid. 4500 were left. Of these game boards, only about 400 were more complicated than a simple win or a block for their best move.
  • The whole process was a lot quicker than it took the eighties super-computer to learn tic tac toe in WarGames. (Who remembers that? To this day, joshua is a terrible password)
  • A T-SQL tip: This should have been obvious but remember that order of columns in a table matters when using BULK INSERT with a data file using native formatting.

January 17, 2010

An incentive, and a hint

Filed under: SQLServerPedia Syndication,Tongue In Cheek — Michael J. Swart @ 8:21 pm

So last week, I challenged the world to solve a puzzle. This was part of Adam Machanic’s T-SQL Tuesday. And while the entire world does not read my blog, Google Analytics tell me that there are roughly a hundred of you that do.

But even among those of you who read my blog, there were no bites. Not one. So I decided to not give the solution this week. Instead I offer a prize and a hint. First the hint for everyone (it’s a two parter):

  • First, look in the source for a clue
  • secondly, the puzzle is not about cryptography, but can be solved with one or two lines of T-SQL

And now for the prize: Coffee on me. This prize is for one person. I’ve got a $10 Tim Horton’s gift card ready to be sent to the first person to tell me the answer to the puzzle. (A Starbucks gift card if you’re international). So get to it!
Update(1/18/2010)… We have a winner. Check out the solution here.

January 12, 2010

A puzzling situation…

Filed under: SQLServerPedia Syndication,Tongue In Cheek — Tags: — Michael J. Swart @ 12:01 am

A puzzling situation (my T-SQL Tuesday entry). This entry is an actual puzzle. Here I’m asking you to do the impossible (or at least the computationally difficult). Solve for ???:

Good luck

Good luck

Solution next week.

BTW, Don’t even try to attack this using a brute force approach. Even if you could test 1000 values a millisecond it would take like a whole decade to crack it.

Update 1/18/2010: See solution here

Powered by WordPress