Wednesday, April 28, 2010

iPhone Images

I'm experimenting with the iPhone camera and some of the little photo apps that you can get for it.  I'm not sure if I'm taking good photographs or not, but I'm having a fun time with it.  Hard to believe that it has all these imaging capabilities...and it's a phone too.

As is my usual MO, I setup a whole other blog devoted to just my iPhone masterpieces.  Common sense finally took over and I decided to do just a post about it instead.  I may do others and if I'm still into this several months from now then maybe I'll spin off another blog then.

I've enjoyed working with the limitations of the iPhone.  I have to look for places with good lighting or else trick them up some way with the editing software.  The constraints are quite liberating so far.  Anyway...here they are.  I'll keep uploading new images to this Flickr album (RSS):


Wednesday, April 21, 2010

Time to learn

Several years ago I worked with a developer that did all of his development with classic ASP pages. It didn't matter what the task was, a classic ASP page was the answer. Instead of writing a console app or writing a .bat file to run an automated file manipulation task, he would reference COM objects from within the ASP page and run it under an account that had access to the file system and then schedule IE to run with that page as a command line argument. And it ran...most of the time. This guy was very comfortable with his classic ASP. During the time I knew him I never saw him write a windows application or a .net application of any kind. Classic ASP uber alles!

I am not like that.  I certainly have my comfort zones.  I stayed with classic ASP during the initial days of ASP.Net.  I didn't fully leave my spaghetti code ways behind until version 2.0 of the framework came out.  Then I left it behind for good.  But VB6?  I dropped it as soon as I tried my first .Net WinForms application.  I cannot quite explain why.  It was different enough that I found myself spending a lot of time relearning old tasks (like adding items to a drop down box and actually seeing the text).  But I could see the potential.  You'd think I would have seen it in ASP.Net from the get go but I've always been a console/backend/windows developer first and a web developer by necessity.

Anyway, version 2.0 of the framework came along and that got me excited about web development.  It seemed like there were a dozen new technologies to learn.  Right about the time I got up to speed on the relevant (to me) parts of framework 2.0, version 3.0 came out.  Then version 3.5...the version 3.5 sp1...and SQL Server 2008.  I threw up my hands and gave up trying to learn it all.  I picked a few things here and there and learned what I could.  When I found something really useful, like Linq-to-SQL, I would talk it up with the other developers in my department and try to get them using the new better ways.  Some took to the new ways, some kept on slogging the .Net 1.1 way.  You can bring a developer to water but you can't make him Linq.

For me, I usualkly learn so much about new technologies while working on a project that by the time it's finished, I want to rewrite the entire thing in the stuff I was learning while coding with the old stuff.

What is this post about?

This post is about all the new stuff that's come out recently(and somewhat recently) from Microsoft.  I was making a list of books I need to buy to get current on things and realized I was going to be spending a fortune.  Here are the technologies that I want to learn about:
  • MVC 2.0
  • WPF
  • Silverlight 4.0
  • .Net Framework 4.0
  • Powershell (So hard to leave my cmd ways behind, but I need to)
  • JQuery (I'm way behind on this)
  • IIS 7.0
  • SQL Server 2008 (somewhat advanced)
  • Windows 7 (It's cool, I like it, but I'm still stumbling around some)
That's a full year's worth of reading right there.  I'm going to have to go back to doing it like I did in the old days when I ways trying as hard as I could to get out of the technical support department and into development.  I'll buy a book (or two) about each technology and read them from start to finish.  I won't remember all of what I read, but general concepts and terms will stick.  Later, I'll be thinking about a problem and think, "Wait a second....I read something about this..." and I'll flip through a book or Google a certain term and find my solution.  The fun parts of reading these 800+ page behemoths is when I come across a better way to do something I do all the time.  I know that sounds strange but, yes, those are the fun parts.  If it wasn't fun I wouldn't be able to do this for a living.

Anyway, time to get reading. 

Thursday, April 1, 2010

Twitter Feeds For Websites That Don't Have Twitter Feeds

How many times have you come across a website and thought, "Hey!  I'd like to follow this on Twitter!" but when you looked around for a "Follow Me" button on the website, you can't find one.  Not very often right?  I mean, most places have a Twitter feed now.  But not everyone.  So what do you do?

Well, almost every single website that publishes content on at least a semi-regular basis has an RSS feed.  That's your ticket.  You can use the RSS feed to create a Twitter feed.  Here's how:

  • Open a new Twitter account and give it a name and a unique email address.
    • Gmail makes this easy by allowing you to add "+somename" to the account part of your email address.  So if your gmail address is "myname@gmail.com" you can use the email address "myname+something@gmail.com" and it will still go to your regular Gmail account but you can register it as a unique email address elsewhere.
  • Open an account at www.twitterfeed.com.
  • Click Create A New Feed
  • Paste in the URL of the RSS feed.
    • Click Advanced if you want to look through the other options.
  • Click Next and link the feed to your newly created Twitter account.
  • Now go back to your REAL twitter account.
  • Follow the Twitter account you just created.
For instance, I'm interested in player trades and roster changes in the NBA.  There is an RSS feed for this but no Twitter feed.  At least there was no Twitter feed.  Now there is and you can follow it at:


Saturday, March 27, 2010

Numlock Morse Code

In Neal Stephenson's novel Cryptonomicon, Randy Waterhouse finds himself in a prison in the Philippines.  Randy has a laptop with some very valuable information on it that some bad guys want, but since the information is encrypted, they can't get to it.  So they allow Randy to keep his laptop in his jail cell but the only place he can put it is on top of a short, locked, file cabinet that has been chained to the floor.  The battery has been removed so the only way to get power is to leave it plugged in on top of the filing cabinet.  The thing is, Randy doesn't even know what the information is yet, because it's encrypted too. He needs to decrypt the information, but not let the bad guys know he is decrypting it, or rather, he wants them to think he's doing it but give them the wrong information.

He can't show the real decrypted info on the laptop display because he is afraid that the bad guys are trying to use a Van Eck Phreaking antenna that is inside the filing cabinet so they can eavesdrop on his laptop screen (he's already made sure there are no hidden cameras).   So he comes up with some fake decryption that he shows on the screen, but the real info has to be displayed another way.  He writes a program that takes text and translates it into Morse Code.  The program turns the the scroll lock light on and off to simulate dots and dashes.  Now he knows the real info from the blinking light, and the bad guys get the fake info he showed on the screen.

I thought that was kind of cool so I wrote a program that does just that.  The only difference is my program blinks the num lock key instead of the scroll lock key (my keyboard doesn't have a scroll lock key).

If you were to load this application on your windows PC and run the following from the command line:

c:\waterhouse\waterhouse.exe /T:"sos"

You would get this:




Notice the /T:"sos" that comes after the name of the application.  The /T: switch says, "turn this text into Morse code."

You could also type this:

c:\waterhouse\waterhouse.exe /F:c:\morse.txt

/F: says to load a file and turn that into Morse code.  It can be a file on your computer, a UNC path or a file on the web (just prepend it with http://).  The contents of the file c:\morse.txt on my computer happens to be my name.  So when you hit enter, you see this:




Help is available by typing the /? or /help switches.

You can download the compiled application here. (Windows only)

You can download the source code here.

You can download Microsoft's free Visual Basic 2008 Express development environment here.

Wikipedia: Morse code

Sunday, May 17, 2009

Auto Complete Example Project

I've written an ASP.Net project that shows how to configure the Auto Complete Extender(ACE), get back the text and the ID, and pull data to show in a details view. If this is your first time using the ACE, pay special attention to the web service files and the javascript in the default.aspx page.

To run this project you'll need Visual Web Developer 2008 Express, MS SQL Express 2008, and the Adventure Works demo database(AdventureWorksDB.msi).

In addition to the ACE I also used an ASP Update Panel and some basic Linq To SQL.

You can download my example project here. You'll need to set the correct connection string in the web.config file to connect to your copy of the AdventureWorks database. If you need help with connection strings, try this site.

Saturday, May 16, 2009

More AutoComplete

I have been getting a lot of hits on the Google Search Appliance Auto Complete post. I thought I would add a few more notes concerning the Auto Complete control in the ajax.net toolkit. Let's say you have a long list of items in a drop down list. Wouldn't it be better to filter that list based on what the user types? Yeah, of course! That's why we have that functionality all over the web now. The only probelm is that the Auto Complete control isn't as easy to use as the other controls in the Ajax control toolkit.. For instance:

  1. You have to write a web service to handle the back in call to the data source. So if all of your data is in an MS SQL database, or Access, or XML, you have to write the query for that and put it in a web service and tag it with a WebMethod attribute. Read more about web services here.
  2. The webservice that the Auto Complete calls can have any name but it must have the following paramter signature: Public Function GetItemName(ByVal prefixText As String, ByVal count As Integer) As String(). The first variable must be a string and it has to be called prefixText. The second one must be called count and it has to be an Integer. Read more about the Auto Complete extender here.
  3. One final thing you need to know about the Auto Complete extender is that most of the examples you'll find online show how to get back the text that the user selected, but they don't show you how to get back the ID. Let's say you have a dropdown list of car parts. There could be thousands of them. The user types in a few letters, sees the part, arrows down to it and hits enter. What you need now in order to do look ups in your related tables is the ID of that item, not the text itself. How do you get that? Inside my webMethod function I do something like this: tempResult.Add(AjaxControlToolkit.AutoCompleteExtender.CreateAutoCompleteItem(itemname), itemID))
    In this example tempResult is List( Of String). By using this CreateAutoCompleteItem function I can create an item that the Auto Complete Extender knows should be split into a text value to display and an ID value that will actually be used. Now, the return type has to be a string array, so the last line of my function is "Return tempResult.toArray()". I like working with generic lists but you could just as easliy dimension a string array with the size based on the count paramter.
  4. Now, how do I get the value back from the ajax call? In the markup for the AutoComplete Extender, you need to specify a javascript function to be called after the user selects an item. Something like this: OnClientItemSelected="showItem". The showItem function will look something like this:
    function ShowItem( source, eventArgs ) {
    alert( " Key : "+ eventArgs.get_text() +" Value : "+eventArgs.get_value());
    }
  5. What's that? You don't want the value in a javascript alert, you want to assign it to an ASP.net control, like an asp:HiddenField or something like that? Then do a getElementById('hiddencontrolID').value = eventArgs.get_value(); somewhere in your javascript function.
  6. Now you are probably going to ask...what if it's in a User Control and there are lots of them on the page and I don't know what the ID is going to be for each asp:Hidden control? That's an answer for another blog post. If this one generates lots of hits I'll write it up.

Thursday, February 12, 2009

Auto Complete on the Google Search Appliance

At my job we have an .aspx page that displays search results from a Google Search Appliance. Nothing too fancy. The page passes the query, gets the XML results from the GSA, we pair that with an XSLT and sha-zam, search results. It was brought to my attention that some one higher up the chain wanted to know if we could have that "cool google suggest drop down thing" on our search page. Google has it. Amazon has it. Dang near every text box on FaceBook has it. Why don't we? Seveal people told me that there must be a way to enable it, because it's a GSA and Google runs it on their site. Now, I'm as guilty as the next guy when it comes to assuming how hard/easy something is going to be. I'm not pointing fingers. As with most things, there's a little more to it.

First off, the Ajax toolkit from Microsoft has an auto complete extender. It's great for running against SQL tables, or XML files or just about any data source. You can get back the ID of the record that the user selected and really make things snazzy. The question is, how do I use a GSA as a data source?

The GSA does return results in XML, but it doesn't do wild card queries. You can't do a search for "hea*" and get back head, hearing, heart and things like that. You get Dr.Hea and some mis-spellings and that's it. I did some looking on the Google Code site and found a "Search as you Type" project that seemed to do just what I wanted. It said in the documentation that you could turn any text box into a Google suggest box. It was written in PHP but I figured I could download it and convert the page to .Net. Most of it was in javascript files anyway so no biggie. Except that the page doesn't connect to a GSA. It has a pipe delimited text file that it uses as the demo source for the drop down. I looked through the readme.txt looking for some way to magically refernce the GSA. Nothing. What I had found was a Google Base code project that did the same thing as the ajax toolkit from Microsoft. I was right back where I started.

I fumed for a little bit. I drummed my fingers on my desk. I went back to Google's site and looked over their page source and javascript files. Then, as I was taking a swig of Red Bull, I realized what Google was doing. They weren't running against their index either.

Google is fast but not so fast that they can ajax call from your browser back to their index and back to your browser with search results each time you press a key (Update 7/12/2011:  Actually, they are that fast now.  Most of my speculations about Google in this post are obsolete). They have been in the search business for quite a while so there is no doubt that they know the top 1,000 search terms for words that start with each letter of the alphabet. The top 1000 As, the top 1000 Bs and so forth. Google had compiled a list of the Top 26,000 key words (something like that, I'm gusessing) and that's what they are running against when they do the Google suggest ajax call.. That's why when you do an obscure search it doesn't show anything but when you hit "search" you get results.

Now, back to my problem. It's not a problem anymore. I can run a report against our GSA, get back the top 10,000 or so search results, filter out the trash, and have everything I need in a nice and tidy XML document. I can put it in a SQL table or leave it in XML. I'll b able to sort it either way. Now I can use the ajax toolkit Auto Compete extender and in a short amount of time I have the same functionality as Google Suggest for our GSA. Only I'll be using .Net.

I'll post the code and link to the search page when I'm done. Shouldn't be long (will I ever learn to stop saying that).