HTML 5 deserves to be called Web 3.0

by martin 20. April 2010 23:48

I have been praising HTML 5 everywhere lately.  I am very impressed despite the fact that they couldn't agree on a single video codec.  Canvas and WebSockets are going to revolutionize what web applications can do, so there is no wondering why Microsoft feels intimidated enough to be the very last major web browser not to support it what-so-ever.  Let's see, FF Chrome Opera and Safari all have it as do the Android and iPhone browsers.  For peat sakes, Google even released two different plugins that give HTML 5 support to IE, so you know it isn't a matter of not being able to do it with all the resources that MS has.  So what is the only other logical reason why they have been holding out?  Politics.  They are probably afraid of what this will do to MS office.  I couldn't even begin to imaging how wonderful Google Apps would be if they only had to write to HTML 5 compliant web browsers.  Also, just as HTML5 has been labeled the "Flash Killer", it probably yields Microsoft's Silverlight a lot less useful too.  Too bad for me and you....  Web 3.0 will have to wait just a bit longer until either Microsoft decides it is ready for it or until the world realizes that IE hasn't been the "best browser" for many years now and finally switches to Chrome.

Click this link to see some really cool HTML 5 Canvas tag examples.

I was amazed to read that the GWT was extended to support WebGL and can now successfully convert the Java version of Quake II to HTML5 and JavaScript.  Amazing!

 

Currently rated 2.0 by 1 people

  • Currently 2/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

AJAX | JavaScript

KML Tours 1.0 released

by martin 2. October 2009 23:54

I have just released version 1.0 of KML Tours.  Now anyone can easily convert their GPS track files into virtual tours for free.

Try it out for yourself, or stop by to see some of the tours that others have uploaded.

KML Tours

Currently rated 5.0 by 3 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Sorting custom data objects the easy way

by martin 28. September 2009 22:32

I recently had to implement custom sorting on couple of ASP.net pages that had to bind to a collection of custom data objects.  Not wanting to re-invent the wheel on every page, I looked for an easier solution online.  I ran across at least two worth mentioning: Generic Sorting Using Reflection in .NET By Jon Wojtowicz (http://www.eggheadcafe.com/articles/pfc/propertycomparer.asp) and Rocky Lhotka's MSDN article where he presents his Generics based PropertyComparer.  I liked Jon's solution in that it was written using recursion so that you could easily sort by properties of properties.  However Jon's implementation was not "Generics" based.  Rocky's implementation was generics based, but it lacked the recursion that my solution needed.  In the end, I ended up modifying Jon's code to be generics based.  I sent Jon an email asking for permission to share his modified code online, but unfortunately he never responded to my email.

Below is a link to my patch file to Jon's PropertyComparer.cs file.  You can download the original directly from Jon's project hosted on EggHeadCafe in the link above.

PropertyComparer.patch (2.99 kb)

Here is an example of how you would use this to support sorting in a Telerik RadGrid:

        protected void RadGrid1_SortCommand(object source, GridSortCommandEventArgs e)
        {
            List<Employee> employees = (List<Employee>)RadGrid1.DataSource;
            CompareOrder cmpOrder;
            GridSortExpression expression = new GridSortExpression(); 

            if (e.NewSortOrder.Equals(GridSortOrder.Ascending))
            {
                cmpOrder = CompareOrder.Ascending;
                expression.SortOrder = GridSortOrder.Ascending;
            }
            else
            {
                cmpOrder = CompareOrder.Descending;
                expression.SortOrder = GridSortOrder.Descending;
            }

            employees.Sort(new PropertyComparer<Employee>(e.SortExpression, cmpOrder));

            expression.FieldName = e.SortExpression;

            e.Item.OwnerTableView.SortExpressions.Clear();
            e.Item.OwnerTableView.SortExpressions.AddSortExpression(expression);
            e.Item.OwnerTableView.Rebind();
            e.Canceled = true;
        } 
 

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , , ,

ASP.Net | C#

JavaScript to redirect to https

by martin 22. July 2009 21:41

First off, you should never use JavaScript as a security enforcement mechanism, but you can use it within your server's "HTTPS required" error page to automatically (and easily) redirect your viewers to the proper secure page.

So first, configure IIS or Apache to "Require SSL".  This will automatically take all users that attempt to target a non HTTPS url to your servers configured 403 (or 403.4) error page.  Now go edit that error page (my IIS 7 error page was located at C:\inetpub\custerr\en-US\403.htm; for IIS 6 it was C:\WINDOWS\Help\iisHelp\common\403-4.htm) and add something like this:

<script type="text/javascript">

//<![CDATA[

function RedirNonHttps() {

    if (location.href.indexOf("https://") == -1) {

        location.href = location.href.replace("http://", "https://");

    }

}

//]]>

</script>

Then, simply call the RedirNonHttps function on page load :

<body onload="RedirNonHttps();" >

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

JavaScript

RegEx helper method to make extracting patterns from strings a cinch

by martin 12. July 2009 15:10

Quite often I find myself trying to create a custom string from the “pattern” found in an input string.  Through trial and error, I have found a real simple and powerful way to do this, and here it is!  It works simply by using the grouping operator “()” for regular expressions and utilizing the power of String.Format.  This implementation is written as a .Net 3.5 extension method for the String class.  I overloaded it to be more flexible; you can pass in RegexOptions, a String representation of a regular expression, or a precompiled Regex object for optimal efficiency.  One important note is that Regex works such that the entire expression is always the first group match (grouping 0) and that all groupings that you explicitly state start at grouping number 1 and enumerate up from there.

StringRegexHelper.cs (1.54 kb)

    1 using System;

    2 using System.Text.RegularExpressions;

    3 

    4 namespace CustomExtensions

    5 {

    6     public static class StringRegexHelper

    7     {

    8         public static String FindAndFormat(this String StringToSearch,

    9             Regex RegularExpressionToSearchFor, String FormattingExpression)

   10         {

   11             String strResult = null;

   12             Match match = RegularExpressionToSearchFor.Match(StringToSearch);

   13             if (match.Success)

   14             {

   15                 String[] arrCaptures = new String[match.Groups.Count];

   16                 for (int i = 0; i < match.Groups.Count; i++)

   17                 {

   18                     arrCaptures[i] = match.Groups[i].Captures[0].Value;

   19                 }

   20                 strResult = String.Format(FormattingExpression, arrCaptures);

   21             }

   22             return strResult;

   23         }

   24 

   25         public static String FindAndFormat(this String StringToSearch,

   26             String RegularExpressionToSearchFor, String FormattingExpression)

   27         {

   28             return FindAndFormat(StringToSearch,

   29                 new Regex(RegularExpressionToSearchFor),

   30                 FormattingExpression);

   31         }

   32 

   33         public static String FindAndFormat(this String StringToSearch,

   34             String RegularExpressionToSearchFor, String FormattingExpression,

   35             RegexOptions RegularExpressionOptions)

   36         {

   37             return FindAndFormat(StringToSearch,

   38                 new Regex(RegularExpressionToSearchFor,

   39                     RegularExpressionOptions),

   40                 FormattingExpression);

   41         }

   42     }

   43 }

Here are 3 examples of how this can be used:

    1 strResult = "myusername-file1.txt".FindAndFormat(@"(\w+)-.",

    2     "{1}@ad.domain.com");

    3 // Returns "myusername@ad.domain.com"

    4 

    5 strResult = "BatchFile072009.txt".FindAndFormat(@"BatchFile(\d\d)(\d\d\d\d)\.txt",

    6     "Batch file for year {2} and month {1} retrieved from {0}");

    7 // Returns "Batch file for year 2009 and month 07 retrieved from BatchFile072009.txt"

    8 

    9 String strInput = "John_Doe;123-45-6789;04/12/2005";

   10 strResult = strInput.FindAndFormat(@"(\w+)_(\w+);(\d{3})-(\d{2})-(\d{4});(\d+)/(\d+)/(\d+)",

   11     "Last name = {2}  First name = {1}  SSN = {3}{4}{5}  DOB = {6}-{7}-{8}");

   12 // Returns "Last name = Doe  First name = John  SSN = 123456789  DOB = 04-12-2005"

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

C#

Anonymous HTTP PUT with IIS 7

by martin 22. June 2009 21:32
From googling around in trying to get HTTP put enabled on IIS 7, I have concluded that turning on HTTP PUT verb support requires the installation of the WebDAV handler extension and that even then it only works in integrated authentication mode.  If this is not true, please let me know as I was forced to write my own put HTTP handler.  It actually turned out to be a lot easier than I thought it was going to be though.  Implementing IHttpHandler, I ended up just having to binaryread the request into a byte array and then use a binarywriter to write it to a file after validating the PhysicalPath of the request for user permissions and validating that the "pattern" is safe (ex. file extension, path).  I haven't tested the performance against the IIS 6 native solution, but it seems quite fast on today's server hardware.

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , ,

ASP.Net | C# | Windows

Welcome

Please contact me if you have a great idea for a project and need technical expertise in designing, developing, or integrating a custom software solution. 

Recent Comments

Comment RSS