Things are getting quite busy @work and there have been no updates for a while as a result. But as year end approaches I want to wish all a every merry Christmas and a happy holiday season.

 

Just one thing: careful about all those turkies you're wolfing down, don't get too carried away. Hmm... stuffing!


 

I've been using Google Reader as my default RSS syndicator and I am very pleased with it thus far.

With Base and FeedBurner, they truly are delivering what the web has promised since the early century - service orientation. Middleware scalability issues aside, which are worthy of reams of documentation and discussion, the movement at the forefront has instead been the orphan of Netscape: Javascript, with plenty of help and support from innovative extenders that are paving new roads via DOM and AJAX.

 

-------------------- 

DOM and AJAX

Sitting on a tree

R-E-A-D-I-N-G

--------------------

 

sorry folks, just had to. =)


Get it(Embedded Resources) From the Outside

 

In ASP.Net 2.0+, if you've been wondering how to access embedded resources outside of the context of a page or control, you can wonder no more.

 

Instantiating a new System.Web.UI.Page will net you access to its System.Web.UI.ClientScriptManager, a class that can't be inherited or instantiated short of Reflection. You can get at any embedded resource via ClientScriptManager.GetWebResourceUrl(Type type, string resourceName)

 

Code similar to the following can be used to trick out your handlers and modules to insert javascript, css, images, flash movies, mp3s, whatever. FWIW below code is used in the syntax highlighting System.Web.IHttpModule that runs here.

 

C# Listing
// inserts embedded resources into the

// rendered html passed in

private string insertResources(string html)

{

    System.Web.UI.Page page = new System.Web.UI.Page();

    string res1 = "<link href=\"" 

        + page.ClientScript.GetWebResourceUrl(

        typeof(Highlighter), "TeleCenti.Web.Css.snippet.css") 

        + "\" rel=\"stylesheet\" type=\"text/css\" />";

    string res2 = "<script type=\"text/javascript\" src=\""

        + page.ClientScript.GetWebResourceUrl(typeof(Highlighter),

        "TeleCenti.Web.Script.snippet.js") + "\"></script>";

    int headIdx = html.IndexOf("</head>");

    int htmlIdx = -1;



    if (headIdx < 0)

    {

        htmlIdx = html.IndexOf("<html>") + 6;

        if (htmlIdx < 0)

            htmlIdx = 0;

    }

    if (headIdx > 0)

        html = html.Insert(headIdx, res1);

    else

        html = html.Insert(htmlIdx, res1);

    int htmlCloseIdx = html.IndexOf("</html>");

    if (htmlCloseIdx > 0)

        html = html.Insert(htmlCloseIdx, res2);

    else

        html = string.Concat(html, res2);

    return html;

}

 

Happy coding.


Source Code Syntax Highlighting

 

Developers like to set different amounts of spaces for their tab settings. Sometimes we just use the default tab settings of our favorite IDE. Sometimes we're stuck with a particularly non-friendly IDE for a specific project, which doesn't allow adjusting the tab spacing. In these circumstances, it is helpful to convert tabs to spaces for blogging.

 

C# Listing
public static string TabToSpaces(string inStr, int numSpaces) {

    StringBuilder buf = null;

    char[] chars = null;

    char curr_char;



   string str = "some characters";



    int i = 0;

    if (inStr == null)

    {

        return null;

    }

    chars = inStr.ToCharArray();

    buf = new StringBuilder();



    while (i < inStr.Length)

    {

        curr_char = chars[i];

        if (curr_char == '\t')

        {

            for (int z = 0; z < numSpaces; z++)

            {

                buf.Append(' ');

            }

        }

        else

        {

            buf.Append(curr_char);

        }

        i++;

    }

    return buf.ToString();



}

 

some inline cpp System::Console::WriteLine("halo!"); test inline cpp

 

more c#

C# Listing

public void Main(string[] args)

{

     // comments

} 

 

some inline c# highlighter = HighlighterFactory.GetHighlighter("C#", "C#"); gets a c# highlighter

 

C/C++ Listing

    #pragma once

    protected:

        /// <summary>

        /// Clean up any resources being used.

        /// </summary>

        ~Form1()

        {

            if (components)

            {

                delete components;

            }

        }

 

In most situations outside of <pre> tags, browsers ignore spacing beyond a single white space. When you want to display a non-breaking space, sometimes it can be helpful to convert spaces to their non-breaking browser counterparts.

more inline c# #region public static string SpaceToNbsp(string inStr) { } convert space to nbsp.

some inline Java highlighting public synchronized String MakeLines(int numLines) {/* comment */ } make some pretty line numbers

tabular java:

Java Listing

import java.util.HashMap;



/**

 * A rudimentary cache.

 */

public class Cache extends HashMap {



    public synchronized Object get(Object key) {

        return super.get(key);

    }



    public synchronized Object put(Object key, Object value) {

        return super.put(key, value);

    }



    public synchronized void clear() {

        super.clear();

    }

}


more inline cpp:int j = *static_cast<__box int*>(o1); __nogc new o()->optimize();
Testing out the sytax highlighting extension.

 


Checked out The Simpsons™ movie last night with Lisa. That movie rocked. Felt like a long episode--about an 1 hour 1/2--yet watched in many scenes like a movie.

Here's a minor list of movie-like visual f/x used:

  • 3D compositing and cell shading 
  • Multilayer motion parallax (back & foreground)
  • High resolution zoom
While keeping the traditional Simpsons episodic elements: 
  • Twitch humor
  • Cartoon violence
  • High speed chase
  • Great ending

In fact, it feels so much like a regular episode that I'm surprised they didn't try to incorporate more additional cinematic elements. For example, a stronger characterization of the antihero. All in all, 90 minutes of Homerification that you just can't get in one sitting on TV. Which is decent.