KeyLimeTie Blog

How to check for hexidecimal characters

By Brian Pautsch – 3/28/2008. Posted to Code Snippets.

If you haven't come across it yet, hexidecimal characters are not allowed in XML documents and cause problems when trying to display or work with them. When working with 3rd party data in XML (not received via a web service), it's always a good idea to validate the data. If you see an error like "hexidecimal value 0x04, is an invalid character, Line 1 Position 20154755", your problem is the data in the XML document. We recently came across this issue and created a simple method to check for valid characters:

Be sure to check out related blog: How to validate strings for XML

1private bool IsValidString(string input)
2{
3    try
4    {
5        char[] values = input.ToCharArray();
6        foreach (char c in values)
7        {
8            //Get the integral value of the character
9            int value = Convert.ToInt32(c);
10            //Valid character (space -> tilde) see: http://www.asciitable.com
11            if (value < 32 || value > 126)
12                return false;
13        }
14    }
15    catch
16    {
17        return false;
18    }
19    return true;
20}

KeyLimeTie Log Cleaner (file pruning application) - FREE!

By Brian Pautsch – 3/16/2008. Posted to Applications.

With all of the applications running on a server, it is important to keep their output pruned. Even with a basic server running a few websites, you can expect to have:
- IIS logs
- SQL Server database backups
- Application-specific logging

Over time, these files can consume a lot of disk space and potentially disable a server. Over the past 5 years, I have worked on-site with nine clients. Of these nine clients, seven of them have encountered this problem. In fact, my most recent client had this problem last week! It happens so often that when someone said the server was was running slow and throwing errors to the web browser, the first thing I said was "I bet the hard drive is full"...and it was.

Why does it happen so often? There are many reasons, but the main reason is because nobody is monitoring the disk space (or monitoring tools are not installed) and the files aren't being properly pruned or archived. To resolve this issue, I created the KeyLimeTie Log Cleaner application free for anyone to download and use. I purposely made it very simple to configure and install; there are plenty of features and options we could add.

To get it running:
1. Download Application
2. Unzip the files to a folder on your hard drive.
3. Open the "profiles.xml" file and edit it for your needs.

<?xml version="1.0" standalone="yes"?>
<Profiles>
	<Profile>
		<!-- Keep this application's logs pruned to 15 days -->
		<Description>KeyLimeTie Log Cleaner</Description>
		<FolderPath>D:\Projects\KeyLimeTie\KeyLimeTie.LogCleaner\Logs\</FolderPath>
		<Extension>txt</Extension>
		<DelOlderThanDays>15</DelOlderThanDays>
		<Recursive>false</Recursive>
	</Profile>
	<Profile>
		<!-- Example: Keep IIS Logs pruned to 15 days -->
		<!-- Setting Recursive true prunes all ftp and website logs -->
		<!-- As new websites are added, no need to update profiles -->
		<Description>All IIS Logs</Description>
		<FolderPath>C:\Windows\system32\LogFiles\</FolderPath>
		<Extension>log</Extension>
		<DelOlderThanDays>15</DelOlderThanDays>
		<Recursive>true</Recursive>
	</Profile>
	<Profile>
		<!-- Example: Keep SQL Server backups pruned to 1 week -->
		<!-- Setting Recursive true prunes all database backups -->
		<!-- As new databases are added, no need to update profiles -->
		<Description>All Database Backups</Description>
		<FolderPath>D:\Databases\Backups\</FolderPath>
		<Extension>bak</Extension>
		<DelOlderThanDays>7</DelOlderThanDays>
		<Recursive>true</Recursive>
	</Profile>
</Profiles>

Fields:
- Description: Profile description
- Folder Path: Location of files to be deleted
- Extension: Extension of files to be deleted
- DelOlderThanDays: Number of days to delete files older than today
- Recursive: Tells application to look for files in subdirectories

Schedule Application:
I installed the software on a few servers and simply created a Scheduled Task through Windows. I have it set to run every day at 4am (after the SQL Server backups are run).

Some ideas...
- Change "Extension" option to be "MatchPattern". Right now, the code searches for all files by the extension. You can put "*" in there and it'll prune all files, but it could be made to be more powerful.
- Create as Windows Service. I have created similar applications as Windows Services...and it's very easy to change this to a Windows Service. But I wanted this first version to be very simple and simple to install. I have seen people have issues with installing Windows Services.
- Create an interface to manage the profiles. It's so easy to update this really isn't necessary.

Internet Explorer 8 Has Arrived!

By Brian Pautsch – 3/6/2008. Posted to Thoughts.

From "ReadWriteWeb"...

Microsoft's next-generation web browser, Internet Explorer 8, has arrived. In a surprising move, after the demo of IE8 and its new features at today's session of the MIX08 conference, the startling announcement was made: "It's available for download now". The new browser showcases many new features and improvements, like Facebook and eBay integration, standards compliance, and the ability to work with AJAX web pages. What's most notable about IE8, though, is more than a sum of its parts. If anything, this launch shows that Microsoft is not taking Firefox's creep into browser market share lightly.

IE8 New Features Shown At MIX08
Standards Compliance
There were hints that IE8 would be a remarkable offering on the IE Blog as they released tidbits about the browser's capabilities. For example, the announcement of IE8's passing of the Acid2 test (a test for standards compliance) marked a milestone in IE8's development. The standards mode was originally going to be turned off by default letting web developers code for it by including a "meta" tag to make use of IE8's new standards compliant mode. Later, Microsoft came to their senses and made the default the standards-compliant mode. Meanwhile, Firefox also claims to have passed the Acid 2 test, but an open bug on bugzilla.mozilla.org seems to say otherwise. One commenter on the thread notes, "So, we essentially do pass the test. However, in some situations, it might still fail, that's why this bug is open."

Facebook Integration
With a Flock-like feature as an unexpected surprise, Microsoft capitalized on their partnership with the popular social networking site, Facebook, to allow IE8 users the ability to get status updates from Facebook right from their browser toolbar.

eBay Integration
Like Facebook, this feature also uses IE8's new technology, called "WebSlices", which introduces a new way to get updates from other sites via the browser itself, without having to visit the web site. With WebSlices, IE8 beta users can subscribe to portions of a page that update dynamically, in order to receive updates from that page as content
changes. eBay will offer webslices, too, letting you track your auctions from the browser toolbar. Basically, WebSlices look like Favorites on your Links toolbar but they have a little arrow next to them - clicking on this arrow will show you a small window of live web content.

Live Maps Integration
Another WebSlice was integration with Live Maps. It appeared that you could even highlight text on a page, like an address, and then right-click and choose Live Maps from the context menu to get a WebSlice preview of that location on a map in a small pop-up window.

Integration with Me.dium
Me.dium integration will be supported in IE8 via WebSlices. Me.dium will now help web surfers discover and view WebSlices directly from the sidebar. The Me.dium sidebar will alert users to the presence of WebSlices on any page – and even allows users to read each WebSlice, without leaving the Sidebar. In addition, Me.dium will make real-time recommendations for other WebSlices on other relevant web pages and provides direct links to them based on the real time activity of other Me.dium users.

Working with AJAX Pages
IE8 will offer better functionality when it comes to AJAX web pages. The example showed a page where you could zoom in using AJAX technology. Previously, hit the IE "Back" button would take you back to the last page you were on. Now, "Back" will zoom you out.

We can now find out what other features IE8 has to offer, since the beta is now publicly available for download. To get IE8, you can download it from here:
http://www.microsoft.com/windows/products/winfamily/ie/ie8/readiness/Install.htm.

 

Photos on Flickr

More Photos »

Search Blog


Get Email Updates

Like what you read here at KeyLimeTie? Sign up for our email list!

Subscribe