Andrew R. Miller

Finding solace in a chaotic world of software development

ReSharper

I’ve been using ReSharper for a few days now, and felt like I should throw a shout-out. ReSharper is a pretty amazing tool for code refactoring (and more) that has recently undergone massive maintanance, which included some pretty big performance increases. If you’ve ever tried ReSharper before, but uninstalled it because of performance (like myself), now is the time to reinstall.

Obligatory blog for the tool that has saved me so much time already =)

PS: One “weird” thing I’ve found so far is inserting custom snippets: rather than typing the defined shortcuts, I have to right-click and say “Insert Snippet”.  Then click “My Code Snippets” and I’m able to insert my custom snippet.  This is, at least for me, kind of a burden..so if anyone knows how to re-instate the original macro, please let me know!

SEO-friendly URLs with UrlRewriter.NET

Thanks to the help of UrlRewriter.NET, creating SEO-friendly urls in your web app is a pretty simple process.  The setup process is relatively quick, but I wanted to detail my experience and include a small “GOTCHA!” that I came across while configuring this on my latest project.

To set up URL rewriting:

1.  Download the proper DLL and reference it in your project.
2.  In your web.config add a section reference that points to this DLL, like this-

<configSections>    <section name="rewriter" requirePermission="false" type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter" /> </configSections>
   <section name="rewriter" requirePermission="false" type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter" />

3.  Now add the section for rewriter that contains your rewrite rules, such as this one-

<rewriter>    <rewrite url="~/Manufacturers/([a-zA-Z-/]+)$" to="~/Manufacturers.aspx?Slug=$1" /> </rewriter>

4.  Add an HttpModule, like so-

<httpModules>

    <add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter" />

</httpModules>

5.  If you try to run this through IIS, rather than your ASP.NET Development Server (especially say…when you deploy the app), you might get a 404 for any of your redirected pages.  If this is happening, open IIS and go to the properties for your website.  On the Home Directory tab, click the Configuration button.  Click the “Insert…” button next to the listbox on the bottom.  In the resulting window, uncheck the “Verify that file exists” checkbox, and press the “Browse…” button.  Browse to C:\WINDOWS\Microsoft.NET\Framework\v2.0.50725\ and select the file “aspnet_isapi.dll”.  This should add the file to the Wildcard Application Maps list.  Try to hit one of your url-rewritten pages now (you might also restart your website first) and see if it’s working.

At least for me, this step wasn’t commonly included in the online tutorials for setting up URL rewriting, so it stopped me up for a little bit.  However, all kudos go to my coworker, Joshua Arnold, for telling me about this little “gotcha”.

Pretty alerts with jQuery UI Dialog

If you’re doing some client-side validation and need a “pretty” way to display styled error messages to the user, why not use the jQuery UI Dialog? It looks tons better than a normal alert, and is easy to use. Here’s a quick implementation.

In your HTML, create an error div:

<div id="Alert" title="Error" style="display: none;">    Error </div>

Now in the javascript, initialize the dialog:

$(document).ready(function() {

   $("#Alert").dialog({

      bgiframe: true,

      modal: true,

      width: 552,

      autoOpen: false,

      buttons: {

         OK: function() {

            $(this).dialog('close');

         }

      }

   });

});

And finally, wherever you’re doing the error checking:

if (_driveTypeTotal > 100) {

   $("#Alert").html("Drive Type totals cannot exceed 100 percent");

   $("#Alert").dialog("open");

}

Alternating Row Style with JQGrid

Lately, I’ve been working a lot with JQGrid. It’s a great jquery plugin, and got even better when the new 3.5 beta was released.  It ties in very nicely with JQuery UI, however there’s no integrated way of implementing alternating row styles. Doing this programmatically isn’t difficult by any means, but since I’ve not seen any examples online I thought I’d post how I did it.

My javascript code:

$("#myGrid").jqGrid({    ...    gridComplete: function() {        var _rows = $(".jqgrow");        for (var i = 0; i < _rows.length; i += 2) {            _rows[i].attributes["class"].value += " alt";        }    } });

EDIT: Someone made a pretty excellent comment, further reducing my jQuery statement. I figured I’d edit my post to include it:

$("tr.jqgrow:even").addClass("alt");
Tags: , ,

The State Of The Economy And Job Security

Lately, everyone seems to be talking about the economy.  One of things that I hear the most is that the economy is terrible and we’re lucky to have jobs.  At first, such talk was rather unsettling.  I started thinking, “How is my resume?”, “Man, I really need to get a LinkedIn profile.”, and “I need to start networking more.”  Eventually as the panic subsided, I started to look at these rumors rationally.  I started to do some research.  The results were rather surprising.

My coworker Tomi linked me this article from BusinessWeek article:

Tech-related jobs figure prominently on Jobfox’s list of 20 “recession-proof” occupations. Among the most sought-after positions are software developer, which ranked No. 2; system administrator, who manages increasingly complex corporate networks, at No. 6; and quality-assurance tester, who designs automated processes for testing products, at No. 12.

Now that’s what I’m talking about!  I’ve always been a believer that despite whatever hardships or economic “crisises” might be plauging the world, nothing can stop innovation and heartfelt desire.  I hate to sound like a corny motivational poster, but if you have the skill and creativity to make it in this industy – you will.

Just a few links:

  • Monster search for “software engineer” in Austin, TX – 82 results
  • Dice search for “software engineer” in Austin, TX – 151 results
  • HotJobs search for “software engineer’ in Austin, TX – 161 results

Synchronous jQuery AJAX Requests

This is a basic feature of the jQuery ajax call; but as it’s something that I just learned I figured I’d share it.

To perform a synchronous jQuery AJAX request (the process will wait for the AJAX call to be completed) you simply need to set the async option to false – as such:

function Submit() {    var result;       $.ajax({          type: "GET",          contentType: "application/json; charset=utf-8",          url: "/Update/CheckSubmitStatus/",          dataType: "json",          data: { locationId: $("#hdnLocation").val() },          async: false,          success: function(obj) {             if (obj === true) {                result = confirm('Are you sure you want to submit this data?');             } else {                alert("You cannot submit this form until all rows with sales data are filled out");                result = false;             }          },          error: function(obj) {             result = false;          }       });    return result; }

This example will fire on the click of a submit button.  It will then call a server-side method to make sure that the client is allowed to click the button: if not, the user will receive an error message – however, if the user is allowed to click this button they will then be given a confirm window…if they say ‘Yes’ the form is submitted…if they say ‘No’, the form is not submitted.

Visual Studio 2010 CTP & .NET 4.0

Yesterday I downloaded the CTP of VS 2010, and I’m very excited to start playing with it.

The 10-4 Video Podcast series offers some good information; the first episode is exceptionally good for helping to download and install the VM instance.

The Visual Studio 2010 Datasheet has some more information, for anyone curious.

I haven’t read anything about it, but I’m really hoping to see some improvements in Intellisense in the new version.  I’ve had numerous unexplainable issues with my intellisense in the past, and if VS2010 fixed them…well, I’d be ecstatic =D

I’ll post back with more info & screenshots once I get it installed later today/tonight.

A Note Regarding Hosting

When I first got it into my head to create a site, I decided I needed a host capable of hosting both PHP and .NET 3.5.  After a lot of searching, I decided to go with LFC Hosting.  It has been a bit of a struggle, to say the least.  In the end, I wasn’t satisfied with their PHP hosting capabilities, so I’ve switched over to Dreamhost.  Dreamhost doesn’t do .NET, but I really needed something that could host my blog stably, and they certainly do.  So far, I am very satisfied with the change.

When I made the migration, I also updated to WordPress 2.7 and I must say, it’s slick~

Setting Up a Successful Blog in 6 Steps

I’ve setup a number of Wordpress blogs in the past few years, and in doing so have learned quite a bit about how to make the process as quick and painless as possible.  From the minute you setup Wordpress until you get your very first visitor, these 6 steps will maximize your searchability and ensure the most fulfilling experience for your visitors.

1.  Install the All In One SEO Pack plugin.

This is an amazing plugin that will help to make sure that your blog shows up high when people search for keywords relevant to your site. After all, there’s not much point in sharing your thoughts with the world if no one can find them…right?

2.  Install the Google XML Sitemaps plugin.

This plugin is essential for maintaining a high-ranking site. It will automatically create a sitemap.xml file whenever you update your blog. Then, it sends that file to Google, Yahoo, and Live search (all automatically!) and ensures that your site comes up near the top in relevant searches.

3.  Install the Akismet plugin.

Once your blog starts to get some traffic, it will also get some unwanted traffic from spammers. This plugin will automatically filter out spam comments from your posts/pages- giving you more time to do important things, like drink Mtn Dew. Beware, this can sometimes filter out non-spam comments, so be sure to check it every once in a while.

4.  Install the Google Analyticator plugin.

First, you’ll need to create a site at Google Analytics. Then, after installing the plugin, you’ll be able to watch your traffic grow over time. It’s not terribly difficult to throw the analytics code into your footer manually, but using this plugin will ensure that you never accidentally lose that code when you change themes. (A mistake I learned the hard way!)

5.  Create content!

…and make it good! You need to give your visitors a reason to come back – again and again.

6.  Get a slick theme!

It might seem a little backwards, to choose a theme after you’ve written the content, but here’s my basic theory.  After registering your domain and setting up Wordpress, it will take about a week/week and a half before you’re indexed on major search engines.  That being the case, I see that week and a half as a window- the time where you can really focus on the meat of your blog to ensure that once you’re finally indexed ALL of your content is indexed.  Having 10 blog posts versus 1, for example, will affect your ranking quite a bit.

Having said all that, now it’s time to get that awesome theme!  There are some really awesome looking themes available, and many of them are free.  I wouldn’t pay for a theme until you’re absolutely certain that none of the free ones will suit your needs.

Here are some links:

Calculating Sales Tax

Calculating sales tax in an ecommerce web application may seem pretty insignificant.  In reality, it’s actually pretty confusing and VERY important.  Before I start though, a disclaimer: these are just my findings, and could very well be incorrect.  I would recommend consulting a CPA or, better yet, your state government, to make sure you’re calculating sales tax correctly (the government will help you for free, btw).

The first (and only concrete) rule is this: any and all sales tax collected by your ecommerce site must be submitted to the government.  Whether you collect too little or too much, all of it must be submitted.  The good thing is that as long as you submit it all, you’re not breaking the law.  So if you accidentally collect too much, as long as you submit to Uncle Sam every cent that you collected, you’re fine.  If you collected too little, however, you must submit the proper sum (making up the difference from your own pocket)…so be warned: while many people/consultants/corporations take sales tax for granted, this is actually a very serious matter.

The rules of how sales tax is to be collected will vary by state.  It is important to collect information from your client beforehand: in which states do they have a physical presence?  In which states do they ship?  Physical presence is very important!  Publication 44 describes the sales tax rules for California; however if you don’t live in California I would encourage you to seek out the appropriate rules for your state.  In California, for example, a county sales tax is due if you ship from a county with a physical presence to another county with a presence..however, only the base sales tax is due if you ship from a county where you have a physical presence to a county where you do not.  Likewise, if you ship to another state, sales tax is not due.

I would really encourage anyone building a web ecommerce application to research the sales tax laws for their local state/district.  The laws are different for every state, so it can be very confusing; and the penalty for a mistake could be a very severe fine.  Let us all do our due diligence and come out on top =D