Archive for the ‘software’ category

Forcing a user to read (or scroll through) all text before accepting terms

December 10th, 2009

If you’ve used a computer before you’ve undoubtedly scrolled through and agreed to some sort of agreement.  Most likely it was some sort of software license agreement that you didn’t read about some website you were signing up on or an application that you were installing.

Maybe, if you’ve installed enough software or been on enough websites you’ve come across an instance where they actually forced you to scroll all the way down to the bottom of the text before you were able to click “I Agree” or whatever acknowledgment they wanted you to use.

Well I was recently faced with creating this exact situation in a web application and ended up using jQuery to accomplish this in my ASP.NET application.  For my particular situation I ended up putting my content inside a scrollable div.  This can easily be done by using a textbox if you wanted without much effort.

Basically, here’s what you’ll need.

  1. Reference jQuery (I’m not going to go into that, you can easily find that out here)
  2. Put a DIV on your page containing your text that needs to scroll (obviously you’re putting more than a few sentences or you wouldn’t be in this boat)
  3. Put a button on your page that, once enabled, will log the user’s acceptance and redirect them accordingly
  4. Some simple JavaScript to tie the DIV’s scrolling event to your button

Here’s our DIV:

<div style="width: 400px; height: 400px; overflow: auto; id="Terms">
<p>Lots of text to read.</p>
<p>Lots more text to read</p>
</div>

Here’s our button:

<asp:Button ID="ContinueButton" runat="server" Text="Continue" />

Here’s our JavaScript:

<head runat="server">
<script type="text/javascript" src="js/jquery-1.3.1.min.js"></script>
<script type="text/javascript">
     $(document).ready(function() {
 
          // Initially disable the button
          $("#ContinueButton").attr("disabled", "disabled");
 
          // Map the function below to the scroll event of our Terms DIV
          $("#Terms").scroll(function() {
               if ($("#Terms").AtEnd()) {
                    // Enable the button once we reach the end of the DIV
                    $("#ContinueButton").removeAttr("disabled");
               }
           });
     });
 
     $.fn.AtEnd = function() {
         return this[0].scrollTop + this.height() >= this[0].scrollHeight;
     } 
</script>
</head>

And that’s it. This code is light weight and works in IE, Firefox, Chrome and Safari. Have any feedback or suggestions on how to make it better? Let me know.

CMD HTTP Request – command line HTTP request utility

December 9th, 2009

More and more I find that I need to setup some kind of job or scheduled task to accomplish something in .NET on a reoccurring basis.  Typically in the past I’ve written Windows Services to accomplish this.  While effective, these definitely take longer to write and are harder to debug than say a simple ASP.NET page.  What I’ve done lately is started to move these non-critical, non-security sensitive processes into ASP.NET pages that can be called on a specific schedule via Windows Task Scheduler.

When I started moving this way I realized that I wanted to find a small utility that I could run from a command line to initial a web page request.  It had to be something I could run from a scheduled task and something that I could use to save or log the results.  After doing my due diligence Googling I realized there wasn’t such a utility that I could easily run from within Windows without installing all kinds of libraries and non-Windows based tools.  So, like any good programmer, I made my own.  Enter CMD HTTP Request.

As I said, this utility is small, light weight and runs on Windows via the .NET Framework.  You don’t need any special commercial programs to run it and it will even check your pages for keywords you specify and save the request’s results to disk as a HTML file.  This, essentially, is your log of what happened during that request on that date and time.

I won’t go into too much more detail here.  I think you get the main idea.  You can  download the source code or executable from the project page on Codeplex and learn more about it.  As always, feel free to leave me any feedback or suggestions either here or via the project page on Codeplex.

CMD Email v2.0 released

November 14th, 2009

CMD Email, the email command line utility I developed (originally discussed here) has been updated to version 2.0.

Here are new features for v2.0:

  • Updated to target .NET 3.5 Framework
  • Added support for message body being loaded from a file
  • Added support for multiple file attachments
  • Added support for logging to the Windows Application Event Log

You can download the latest runtime or source from the project page on CodePlex.

Visual Studio 2008 is a piece of shit!

July 3rd, 2009

It’s been one of those weeks :(

visual-studio-wait

It should be noted that I was able to take a screen shot, upload it to WordPress and make this blog post before that message went away and I was able to interact with Visual Studio.NET again!

Google Chrome for Mac

June 9th, 2009

You can get an early build of Google Chrome for Mac here.  Use at your own risk!

I’ll let you know if it blows up my Mac in my next post…

Why can’t the Gmail notifier launch the Chrome browser?

May 29th, 2009

Google’s Gmail Notifier system tray application for Windows can’t launch Google Chrome when it’s not setup as your system default browser.  Uh, hello?  Both of these are Google applications, you think they would have updated the notifier to support this by now.  As you can see here from my screen shots the Gmail Notifier options show every other browser I have installed EXCEPT Google Chrome.

notifier-main-window

notifier-browser-options

There must be some way to hack this.  I even made sure that I had the latest version of the notifier and I do.  Anybody have any idea on how to accomplish this?

Outlook 2007 dropped print range – WTF?

April 23rd, 2009

One of my co-workers asked us (the IT department) how she could print a certain page number or range of pages using Microsoft Outlook 2007. Since I was the only one in IT to have Outlook 2007 we looked at things on my system. Honestly, I don’t know if I had tried that before so I wasn’t entirely sure where you would set those options. My first guess would have been in the print options, where else?

Well, after fumbling around for a few minutes we realized that there didn’t seem to be anywhere to actually set these options. Shortly after my other IT co-worker found this Microsoft support article offering up workarounds since they decided to remove this feature.

Why the heck? “Gee, this is a really useful feature, let’s take it out and make them use workarounds.” “Good idea, this should hinder productivity!”

SQL Server 2008 SP1 Final Released?

April 1st, 2009

We’ve had an open support ticket with Microsoft due to some bugs we’re seeing with SQL Server Reporting Services 2008.  After Microsoft saying that the Update Pack 4 for SQL Server 2008 (released back in mid-March) would fix our problems, they sent us an email this week letting us know that the final version of Service Pack 1 for SQL Server 2008 would be released yesterday, March 31, 2009.

Unfortunately so far the links they’ve provided don’t go anywhere.  I’ll be checking these links through the day and the rest of the week and will post any further updates if I actually do find the “real” links.

According to our internal document, below is the information about SP1:

Microsoft SQL Server 2008 Service Pack 1

Release date: March 31, 2009

How to obtain

To obtain SQL Server 2008 SP1, visit the following Microsoft Web site:

http://www.microsoft.com/downloads/details.aspx?FamilyID=66ab3dbb-bf3e-4f46-9559-ccc6a4f9dc19

To obtain Microsoft SQL Server 2008 Feature Pack, April 2009, visit the following Microsoft Web site:

http://www.microsoft.com/downloads/details.aspx?FamilyID=b33d2c78-1059-4ce2-b80d-2343c099bcb4

To obtain Microsoft SQL Server 2008 Express Edition SP1, visit the following Microsoft Web site:

http://www.microsoft.com/downloads/details.aspx?FamilyID=01af61e6-2f63-4291-bcad-fd500f6027ff

It should be released on March 31, 2009.

Enabling and configuring HTTP compression in IIS6

February 5th, 2009

As I mentioned in my last post, I had to figure out various ways to make my latest project’s ASP.NET application run faster.  One of the ways that I was able to get some “free” (i.e. no code changes) performance was to enable HTTP compression on our web server.

While not a new concept, for some reason I really hadn’t researched this too much before recently.  I knew that IIS 7, which we aren’t using,  had great support for this but didn’t think IIS 6 could support it.  After not much Googling I was all setup with HTTP compression and immediately noticed some great results (measurements were done with Fiddler, check it out if you want to debug your HTTP traffic).

This process I’m going to describe can easily be found out on the interwebs.  I figured I’d just streamline it a bit, provide some screen shots, and take out all the extra crap that I read to get my ASP.NET site screaming with HTTP compression.

You need to know is that these changes will require you to bounce (restart) IIS in order for them to take effect.  So, plan to do this during off hours or set them aside for your next regularly scheduled maintenance window.  Don’t just go and tweak all of this on your production web server in the middle of the day.  That would be bad!

The first thing you’ll want to do is open up the Internet Information Services (IIS) Manager on the target server.  Once in the management console you’ll want to right click on the name of your server and select All Tasks > Backup/Restore Configuration.  This will allow you to create a backup of everything in case you screw something up while trying to do all of this.

Metabase Backup

Luckily I didn’t need to use this but you can never be too careful.

After you save all that you will want to go back to that same server node and right click again.  This time you want too bring up the properties for the server instance.  From there, click the check box labeled Enabled Direct Metabase Edit.

Enable Metabase editing

Enabling this will allow us to later edit the metabase file (XML) directly.  This is much easier than trying to run some of the command line utilities that you can use that basically accomplish the same thing.  Some may disagree, but I feel like I can change a few values in an XML file way more quickly than trying to get the cryptic syntax right for various IIS script utilities.

Next, expand the local server node and right click on the Web Sites folder to bring up the properties.  From there select the Service tab and enable the Compress application files and Compress Static files check boxes.

Enable HTTP compression

Optionally, you can change the temporary directory where IIS will store the compressed files (default is %windir%\IIS Temporary Compressed Files) and put a size limitation on this folder.  I left both of these options with their default values.  I will probably revisit the size constraint option once our site is live and I can watch it for a while.  For now, unlimited is fine.

Next, go back up a level in the IIS management console and right click on Web Service Extensions and choose Create a new web service extension (as opposed to Web Sites, which we were just using).  Call the new extension HTTP Compression and point it to %windir%\system32\inetsrv\gzip.dll.  Finally, before you click OK be sure to check the Set status checkbox so that it is enabled (Allowed).  When it’s done you’ll see the new extension listed like this:

Enable gzip

The good news is that you have set all of the settings that you need to get HTTP compression working in its most basic form.  If you restart IIS (I always use the trusty iisreset command) you will be compressing your HTTP requests right now.  The bad news is that the most basic compression won’t do you much good if you’re serving up anything other than Classic ASP pages or static HTML files.  The fix for that is to edit that Metabase file that we talked about earlier.

I’m not 100% sure if you really need or want to restart IIS now or not.  To be safe I would probably go ahead and do it.  When I first went through this process I was pulling information from a few different resources so I did things in more of a step process.  You’re getting a step by step list of things that I found over the course of a few different days.  So with that said, go ahead and restart IIS to get the compression working.

Now the easy GUI part is over.  We’re going to open up the Metabase file and start to change some values in the XML.  What you need to do is open up the Metabase.xml file located at %windir%\system32\inetsrv\Metabase.xml in Notepad or some other text editor.  Once opened we want to find the sections that look like this (search for compression/deflate):

Original metabase values

We need to tell the types of extensions that each scheme is to support and compress. The static types need to go under the HcFileExtensions and the dynamic under HcScriptFileExtensions.  This needs to be set for both the gzip and deflate entries (so you’ll add each extension twice).  Like the samples show, you need to put each extension that you add on a new line.  Be sure to follow this carefully as I recall reading something that said IIS is very picky about this.  Here are the extensions that I added:

Static (HcFileExtensions):

  • htm (default)
  • html (default)
  • txt (default)
  • css
  • js

Dynamic (HcScriptFileExtensions):

  • asp (default)
  • dll (default)
  • exe (default)
  • aspx
  • asmx
  • ascx

Finally be sure to set the HcDynamicCompressionLevel values to 9.  The level of compression for dynamic content is set to 0 by default. This could be increased to a maximum of 10 depending on your available CPU resources. Everything I read says that generally setting it to 10 is bad; in most cases it will have a negative impact on your throughput. This is something you’d need to do some tests with to figure out what works best for you. It’s also worth noting that setting it to 0 does not mean no compression, it just is a lower compression (which also means it will be the fastest).  I went with 9 to be safe and it seems to have worked out fine for me.

The end result looks like this:

Updated metabase file

Do another reset of IIS and you’ll be compressing content used by most ASP.NET sites.  You can obviously add more extensions to some of the areas if needed.  There are a few things like axd fieles that I considered compressing but read that it could cause all kinds of problems.  I am going to continue to research this and may do some testing for myself to see if I can potentially add this file type in to my dynamic (script) extension list.

Final Notes:

You should know that the process I’ve described here enables compression for all of the sites on your server.  If you would like to target only one website or a smaller subset of sites you will need to make some additional changes in the Metabase file in other areas (i.e. IISCompressionSchemes node).  I didn’t do that so I am not going to go into detail about that.  If that’s something that you want to do it shouldn’t be too hard to find additional information on doing this.

Also, while I stated in the beginning that enabling this was a way to get a “free” performance gain, it’s obviously not free.  You’re going to pay the price somewhere.  In this case the server will need to do more processing/work now to compress these files before they’re sent down the wire to your users.  Based on what I’ve read and what I’ve seen from my testing, IIS 6 is pretty darn efficient with this and as long as your CPU load is under 80% you should be fine to enable this.  That obviously will need to be a decision that you make based on the amount of traffic your site gets, the hardware your server has, etc.

Cumulative update package 3 for SQL Server 2008

January 30th, 2009

Since we have been developing with SQL Server 2008 here at work on my latest project I have been keeping an eye on its available updates and fixes (at least until they come out with Service Pack 1). Cumulative Update Package 3 has been made available now.

Per Microsoft:

A supported cumulative update package is now available from Microsoft. However, it is intended to correct only the problems that are described in this article. Apply it only to systems that are experiencing these specific problems. This cumulative update package may receive additional testing. Therefore, if you are not severely affected by any of these problems, we recommend that you wait for the next SQL Server 2008 service pack that contains the hotfixes in this cumulative update package.

After scanning down the list it seems that we could benefit from at least two or three fixes listed:

  • FIX: You may encounter a deadlock scenario when you use table variables in SQL Server 2005 or in SQL Server 2008
  • FIX: When you use a ReportViewer control to view a SQL Server 2008 Reporting Services report that contains two pages, the formatting for the second page is lost
  • FIX: When you print a report by using the SQL Server 2008 Reporting Services Client-Side Printing functionality, the spacing is too small or too large

I would probably take Microsoft’s advice and hold off installing this update if you’re not specifically seeing any of the issues mentioned in the fix list.

You can download Cumulative update package 3 for SQL Server 2008 here.