Building Web Sites with Microsoft Technologies

I just finished a continuing education class at Lakeland Community College in Kirtland, OH. I am putting the slides for the class out here if they are useful to anyone.

Here are the presentation and class materials for the 5 classes:

Part 1: ASP.NET
Part 1: ASP.NET project files
Part 2: .NET Framework
Part 2: .NET Framework project files
Part 3: Database concepts
Part 4: ADO.NET
Part 4: ADO.NET project files
Part 5: Putting It All Together
Part 5: Putting It All Together project files

Questions? Shoot me an email.

Great Free Differencing Tool for Mac

For some odd reason, searching in Google for a file differencing tool for Mac does not return anything promising. The best I found easily was a blog post saying to use the FileMerge that gets installed with Xcode. You can run it from the command line.

Command line? Look, I am a Microsoft developer most of the time. That means I both expect and need things to be kinda easy.

Luckily, I searched a little further and found Sourcegear's DiffMerge. Just like you would expect, graphical, easy to use, and free.

Thanks, Sourcegear!

Crank Out Some iPhone Apps - Outsource Them!

If you have been reading my blog, you know my story--I am a Microsoft developer by day, and an iPhone/iPad developer by night. The problem--when you have a wife and kids and a house (or even a social life) this is not really sustainable for long.

With iOS4 coming out, I have been doing a little less coding lately and a little more reading about iPhone development. One of the things I have been reading is books by others promising ways to write apps quickly or make money on iPhone apps. A lot of them I just laugh at. So when I read an ad promising to let me write iPhone quickly without writing code--well, I had to read the book just to see what they were promising.

To my surprise, it was a really good idea! The book, How To Create iPhone Apps with No Programming Experience is actually a great step-by-step methodology to get apps built the easy way--by explaining what you want and handing it off to someone else to code. The book comes with a few extras, the most interesting on how to make money with free apps, which you probably already know. But the book itself was a good read. If you have any thoughts about trying to write an iPhone yourself but just don't have the time, this is a great solution.

The best part of the book was the description of some of the completely ridiculous apps that have made big money. The point being, of course, that marketing is every bit as important in the iPhone app gold rush as programming. You can have a slick app, but if you have no marketing plan, it will disappear in the mountain of apps released daily. Conversely, if you have an idea for an app that you can market, maybe a crazy simple app could make you rich. And if you outsource them, you can crank out ten in the time you would have done one yourself.

Anyway, check out How To Create iPhone Apps with No Programming Experience. It is a great no-nonsense approach to getting your app out there for people to download.

BTW--I have unofficially crossed the 50,000 app download mark. How exciting is that!!

Review process for iPad apps--Yikes!

So I submitted my first iPad app almost 2 weeks ago. After being lulled into a false sense of confidence following iPhone app reviews, I have had a bad experience with this review.

iPhone app reviews had gotten down to a few days at the end of last year and earlier this year. So I expected the iPad app review for my first app to be, I don't know, vaguely like that.

When I saw my app go from "submitted" to "in review" so quickly, I was very optimistic. But then came an extremely long delay. And OK, I am fine with a delay--I am sure everyone is submitted iPad apps right now.

But then came the frustration. After 8 days (yes, 8 days) I get a notice that my app had been rejected. The reason? I had called it "FindIt for iPad" on the title screen, and this is a copyrighted term. Fair enough--I probably should have thought of that. But what required 8 days to figure out that "iPad" was prominently placed on the main page?????

Then, of course, the process has to start over from scratch. Again, I get it--a new binary, and anything can be in it. So the new executable has to be completely tested. So we are now a full 16 days from the initial submittal. And I don't have much confidence that it is really being reviewed any more when it says "in review." (See rant above about "how did it take 8 days to figure out 'iPad' was prominently placed on the main page.")

Scary stuff. Hopefully this helps someone out there avoid the same issue I had.

Anybody need $5/mo PHP hosting?

So it turns out I overbought my PHP hosting a bit....and I have a bunch of extra bandwidth. It is great hosting from HostNine, including MySQL database, Control Panel, Fantastico Deluxe with Joomla and WordPress, etc etc. I bought a reseller account because I needed to host for several of my clients. This was a good deal, but I have a bunch of unneeded bandwidth that is going to waste.

Anyway, let me know if you are interested. We can work out how much throughput and space you need. You can't get quality hosting like anywhere for $5/month!

I think I can take on 4-5 new accounts, so I will offer this deal to the first 4 or 5 people to get in touch with me. Good luck!

Best. Mac Memory. Ever.

I have really wanted for a while to upgrade my MacBook Pro from 4G to 8G, but I didn't want to fork over the $800 (recently dropped to $600) to get it from the Apple Store. There are lots of sites out there that offer premium memory for discount prices--how do you know you will get good memory and good customer service? You ask your other Mac friends where they get there memory!

Luckily, my friend Dave Ferrell (a.k.a. XCodeGuy) has owned Macs for a long time and has a number of do's and don'ts when it comes to software, hardware, and peripherals. He recommended, which he said has great prices and the memory has always worked for him.

I have to say the customer experience with RamJet was above average. Between the emails alerting me to the status of the order, the status of shipping, and the status of my refund, I was very impressed. Yes, I said REFUND. RamJet will buy back your existing memory for a nice price. I was able to buy my new memory for $359 and get $50 back for my Apple memory. So for almost 1/2 the price of the Apple memory, I got my 8G and I am loving it!

So, if you need solid memory for less than you would pay for genuine Apple memory, you can't miss with RamJet. Thanks guys!

Pretty tired of Magic Mouse issues

As you are probably aware, I am huge fan of the Mac and of Apple products. The are solid, well engineered, and I have had few issues with any Apply hardware.

Except for the Magic Mouse, which has caused me a lot of frustration. My first mouse I got at Christmas of 2009 for use with my early-2009 unibody 2.66Ghz MacBook Pro. It worked great for a while--it was easy to make the transition to it, and I really like having the desktop even less cluttered because it is wireless.

But then, after a few months, I started experiencing a strange issue. A large percentage of the time, even if I clicked all the way over to the left of the mouse, it would act like I was doing a right-click. After having my wife try it too (to make sure I wasn't doing something wrong) and confirm it was acting strangely, I took it back and had it replaced.

Then, everything worked well for a few months. Until I disconnected the MacBook Pro from everything and used it away from my mouse and keyboard. Ever since I brought the MacBook Pro back and reconnected it, I have to manually disconnect and reconnect the mouse every time I start up my laptop.

One of the things I love about Apple products is that they just work. We pay a premium for them, and they are worth it, because they save us time. But what about when they don't work? Then we paid a premium for junk--and worse yet, with high expectations, because Apple stuff is supposed to *just work*.

This is definitely the kind of thing that would have annoyed me on the PC. On the Mac, I am just fed up. I want my money back.

Detect IE6 and redirect to compatible site in CRE Loaded

There are tons are beautiful CRE Loaded sites--if you are ever in the market for one, I personally am a huge fan of AlgoZone and RocketTheme for CRE Loaded and Joomla themes. But one of the downsides of the nicer themes is compatibility issues. For those of you who have not jumped on the CSS bandwagon, or for others of you unaware of the "old days" of web development, there has been a huge shift over time in the way styles are applied to sites.

In the old days, tables were your only tool. Whatever you needed to do, you created tables, nested tables, and played with table attributes. Tables could do a lot, but the final code for a complex page was all but incomprehensible, and forget trying to debug someone else's. It could be a real mess to find and fix errors, or to try to add new elements into pages.

The shift over time has been to use CSS styles applied to DIV tags. This keeps a great deal of presentation details separate from the pages, allow for page content to be developed apart from really complex styles. In addition to separating the actual code, this also provides great ways to take a page and render it completely differently based completely on the CSS applied. Content management systems in particular make extensive use of this because their individual widgets can display simple content, and the CSS applied can really change the output. This would have been a very difficult job in the old table days.

So back to CRE Loaded styles. I recently was working on putting a new template on a storefront, when one of my team members thought to look at the in IE6. The results were horrific. The site not only looked bad, elements such as the product menu just didn't show up. We ran some stats and found to our surprise that nearly 10% of potential customers coming to the store use IE6. So something had to be done.

I decided the easiest solution was to set up another domain, check the browser type, and then redirect IE6 users to the other domain. Connection information in CRE Loaded would stay the same, so both sets of users would share the same database, and the job would be trivial.

So, I searched the code and found a good place to put the IE6. The first step was the put the following in includes/application_top.php:

// first.....since IE6 performs very badly with our template....
// detect the browser and send all those poor souls to the
// old template

$a_browser_data = browser_detection('full');
if ( $a_browser_data[0] == 'ie' )
if ( $a_browser_data[1] <= 6 ) { $url = (!empty($_SERVER['HTTPS'])) ? "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] : "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; $url = str_replace("", "", $url); header('Location: ' . $url ) ; } }

I found some great code to detect the browser type here. I put that code in includes/browser_detect.php.

Then I went to test, and discovered that half the time I clicked on things, I was being redirected to the old site. After some seaching, I found that the domain is actually stored in a few pages of the php script. I changed those, and then I was staying consistently in the new site. Perfect.

Next I went into the admin side of the new site, and changed the template. Oh wait. The default template is stored in the database! The database that I am sharing between the sites! Time for more analysis.

I searched and searched through the code and discovered that DEFAULT_TEMPLATE was the variable that I needed to set, but DEFAULT_TEMPLATE was not set anywhere in the code. I realized my lack of PHP knowledge was hurting me, so I started looking up constant definition in PHP. It became clear that the value was being set somewhere, but searching the codebase had turned up nothing. Then I realized there must be somewhere in the code that all the configuration variables were being pulled in from the database and constants were being created for them.

After more searching, I discovered the code I expected was in includes/application_top.php, not far from where I had inserted the above lines:

// set application wide parameters
$configuration_query = tep_db_query('select configuration_key as cfgKey, configuration_value as cfgValue from ' . TABLE_CONFIGURATION);
while ($configuration = tep_db_fetch_array($configuration_query)) {
define($configuration['cfgKey'], $configuration['cfgValue']);

PHP does not allow you to redefine the constants there was no way to let this loop occur and then redefine the value later. Instead, you could either put an if clause in the code, look for DEFAULT_TEMPLATE, and set the value there, or instead set your override value first, then check as you are looping to see if the value is already defined, and only define it if it is not. It was late at night, so I chose the first. The more bulletproof way would really be to set up an include to define overrides and then put the conditional logic in this loop to skip any values that are currently defined. When I have some free time I will definitely refactor this code.

Anyone ever try to do anything like this? Let me know if you had a better solution. Thanks!

The Infamous "Access Denied" AJAX Error

A client of mine had a website issue--the red X in the lower left in IE saying an error had occurred. I dug in a little and discovered the famous pop-up that you have probably seen if you have done any amount of AJAX development:

The error message can change slightly depending on your browser, but you will get some variation of "This page is accessing information that is not under its control. This poses a security risk. Do you want to continue?" or "Access denied" or "Access is denied."

Essentially, here is the problem. It is not uncommon, especially in large corporate environments, for the web services being called to actually live in a different domain from the page that is rendered. Browsers consider it a security hole to be displaying data from site X and be performing an XmlHttpRequest against site Y. And this is probably for the best.

To remedy this situation, you need to either (1) get your application and web services on the same domain or (2) provide some kind of proxy that allows for calling the web service on the other domain within your own domain.

Sometimes this is easier said then done, but I was very lucky in my case. My client actually was using a domain name that resolved to the same domain the page was being served up from. They had created separation in case the web services and web sites were ever migrated to different machines. So, it was a simple matter of using the same domain for the services used by the web site.

The client is actually moving in the direction of making all their machines the same, at least for this collection of web apps and services. It is not often a resolution to a problem is so easy. Anyway, this is something to keep in mind when you get the "access denied" error on an AJAX-enabled site.

Good luck out there!

Draw text faster with CGContextShowTextAtPoint

The FindIt puzzles have turned out pretty well, but there are still a few things I am not happy with. The things that bother me most--slow load times on the puzzle selection page and on the puzzle screen. The load time on the puzzle selection page is not horrible--usually 2 to 3 seconds. But my goal is to release an update to FindIt Premium that will include all the puzzle packs to date. If I am seeing 2-3 seconds for 10 puzzles, what will it be like at 30? This clearly needs to be improved.

Luckily, this part was easier to figure out. To get the game out the door, I used text files for the data. With some time to step back and get the game cleaned up, I changed the puzzle metadata over from flat files to SQLite and Core Data. This has had a small impact on load time--around 2 seconds. Not that significant for just 10 puzzles, but in my profiling, and I seeing a significant increase as the number of puzzles increases. So my update for this should be coming out soon.

But what about the main page load time? Again, I performed some analysis to determine what was the bottleneck. I had assumed loading the page data from files again was the problem. So I started commenting out code and testing. Sure enough, the puzzle data loaded very quickly from a single file. That wasn't it.

Next I tried changing my looping logic, changed from a dynamically allocated NSMutableArray to an array I preallocated to the correct size, and even changed my short-cutting logic to decide whether to write out a letter or not. None of these were the culprit.

But then I commented out my writing the letters to the screen with NSString drawInRect. Immediately, even my largest puzzles (85x85) loaded in a second. So I set out to find a more efficient way to write out text. As I learned more, I saw that drawInRect is really trying to do a lot for you--like using the output area of the text for alignment and clipping. I am just trying to write out a single letter, so this was all unnecessary overhead.

If you are doing something like this, try CGContextShowTextAtPoint. This is a much more high-performance function that is not trying to align the text or perform clipping--it is just writing out the letters the way you tell it to. For me, this was perfect, and much more efficient. I noticed load time on even the largest puzzles was much more efficient, around 2 seconds or so, down from as many as 5.

This is also good news since I plan to release an iPad version of FindIt. Sure, the processor is going to be faster, but I also plan to display a lot more on a page. Considering that, I wanted to be sure to have the efficiency tweaked for optimal performance.

Hopefully this helps you too! Good luck with your iPhone and iPad development!

Caveat on Caching in ASP.NET

If you are working with the System.Web.Caching.Cache component in ASP.NET, there is something you should probably know. The cache is not a virtual location where data is being stored; instead, the cache is a collection, and as such, the objects being put into it are being put in by reference, not by value.

I was working with a client today and they were experiencing an issue that no one could figure out. I dug into it, and discovered that they were doing the following:

1) Creating an System.Xml.XmlDocument object and loading it with data
2) Inserting this object into the cache
3) Removing some nodes from the object

Following a page transition, they were pulling the document back out of the cache, and they could not understand why nodes seemed to be disappearing. This is when I explained how the cache works, and that is it not saving a representation of the object when it is inserted into the cache, but rather putting the object into the cache collection.

Just a good thing to know if you plan to be caching and changing objects. Good luck out there!

Expected specifier-qualifier-list before 'NSManagedObjectModel' error and how to fix it

I was putting Core Data into an existing application. I was cutting and pasting a lot from the excellent Apple example, iPhoneCoreDataRecipes. No, this is not a bunch of code examples to show you how to get started with Core Data...but it is a working example of how to get an app up and running with Core Data using SQLite as a back-end persistent store.

So, I was happily cutting and pasting code between iPhoneCoreDataRecipes and my iPhone app (the premium version of FindIt, if you must know) when I ran into the following error everywhere:

Expected specifier-qualifier-list before 'NSManagedObjectModel'

The object changed (i.e. it was not always 'NSManagedObjectModel') but the error was consistent. And yet I was copying everything over from the .m and .h files in the Apple example. Strange.

My first thought was checking that I had included the Core Data framework in the app. Yup. That wasn't it.

Then I realized--it was the global prefix file. I went and checked out the Apple example, and sure enough, Core Data was there. I just needed to through this into my _Prefix.pch file as well, and all the errors went away.

Hope this helps you too!

This year's MacHeist is coming soon / Is Squeeze worth it?

If you are a Mac user, don't miss this year's MacHeist software bundle, due to arrive March 2nd. MacHeist offers great niche software for free or nearly free. I usually find at least one piece of software in the bundle that I end up using regularly. Whatever else, it is cool to get your hands on new, high-quality, low-cost Mac software and take if for a spin.

Right now, MacHeist is offering a free license for LateNiteSoft's Squeeze for Mac. The idea sounds awesome--just like compressing directories on the PC. If you are not aware of the process, file compressors sit in between the OS's file access methods and the file system, and make the files work exactly as they did before, but compressing them on writes and decompressing them on reads on the fly. The amazing part--since physical file access is typically the slowest part of the read or write, compression reduces disk access but increases CPU time. Since CPU is very cheap compared to the physical access, you usually *improve* performance while you are decreasing disk usage. This makes disk compression under most circumstances a no-brainer.

But I had interesting results in using Squeeze. I had a directory of wave files that I tried to compress. The directory was around 200MB. Here is a screen capture of directory information from Path Finder:

Here is what I saw in Squeeze:

Hmmmmm. 22GB saved on a 200MB directory? For some reason, I am skeptical. I am a developer, so I know fairly minor things like this happen--it is no reason to dismiss a piece of software. But this was in addition to the fact that is kept running, and I was not seeing significant compression on any directories. Anybody else have any good or bad stories to relate on Squeeze for Mac?

Windows screen capture utility

You probably run into this situation--you need to take a snapshot of a section of the screen for a million different reasons, either to show someone or document something or include in an email. I probably reach for a tool ten times a day to do this. The Mac and Windows Vista and 7 have this functionality built in; but what about those of us still working on XP at work?

Enter Brian Scott's Cropper. Cropper is a simple, lightweight, and free solution to this problem. Install the app from the download at the like above and launch it. It will place the Cropper icon in your system tray. Then, when needed, you can double click this icon, and pop up a sliding control on the screen to select an area for copying.

I used SnagIt for years and disliked several things--it seemed very bloated and slow to do simple screen captures. Plus, how many times did you highlight the upper left corner and start clicking and dragging only to see you had not gone up high enough or the left far enough? Then, you are pulled into the next screen, to exit out and try again. Painful.

Cropper instead is very cool in that you can use the mouse or keyboard to move the selected area--even performing a "nudge" with the arroe keys. All around great piece of software. Thanks so much, Brian!!!

My concerns with Quattro Wireless

I have several iPhone apps that are using Quattro Wireless as a major part of my ad serving. Quattro is a pretty good provider in that they seem to offer very competitive rates and typically have offered a pretty strong fill ratio.

That is, until lately. I have noticed my fill ratio drop significantly, reaching between 20-30% in recent weeks, and hitting an abysmal 10% average for the last 3 days. I am sure Quattro has a lot of requests, with the huge growth in iPhone apps lately, and the unprecedented downloading that has been going on. But 10%??!?!? These guys are paid to provide a service, and I was not very happy with the previous 20-30% range.

I really hope Apple buying Quattro can turn this kind of marked decline around. But I am not waiting to see what happens. Over the weekend, I converted my apps over to use the MobClix provider, which promises 100% fill rate--presumably caching ads and presenting them when a new one is not available from the provider.

I am actually pretty impressed with MobClix. I used them for one of my apps, and I am slowly starting to convert over to them for other apps as well. Their framework is small, integration was simple, and I have noticed a significant reduction in application errors from users that are running MobClix over other providers. If you get a chance, check them out. If nothing else, the promise of 100% fill rate has really caught my attention!