Lights on again

, , 3 Comments »


Based on some mixed feedback Where’s Lou has returned to the light side. I liked the dark theme but after returned to it with fresh eyes it was pretty intense. Plus the amber color palette is kind of “not done” on the internet, so when in Rome…

The theme on deck is Deliciously Blue - so tasty it hurts. :) The two things I was looking for were clean lines and lots of width for the text. Adjusting the css from 760 to 960 overall gave plenty of space in the content area.

Spark += IronPython

, , , 2 Comments »


Something interesting coming down the line in dotnet is a newly enhanced support for dynamic languages. Those are all build on a dynamic language runtime (DLR) that’s a fast and self-optimizing execution engine build on the CLR. Specific scripting languages are parsed and realized as DLR expressions - first on the list are IronPython and IronRuby. I’m pretty sure DLR support for javascript is in the mix also. Yep, dynamic language runtime will include Managed JScript as well as Visual Basic .NET version 10.

To see what was involved in hosting a dynamic language I integrated Python as a language option in the Spark view engine. It’s not bad at all - in fact you can use IronPython in Spark now if you prefer that language. The hard part was figuring out what sort of angle to take presenting the view’s context to the language. With the default C# all of the helpers, viewdata, context variables, and current TextWriter Output are implemented as public members of the base class. That could be done in IronPython, but in that language it would mean “self.” would need to be in front of every reference to those members. Not really optimal.

In the end, after spending a little time trying to get inside Python’s head, it looked like the Tao of Python approach to a view would be to skip the object-oriented mechanisms altogether and instead create the view as flat procedural code that relies on global variables.
Read the rest of this entry »

Spark in the field - MarketWatch

, , , 4 Comments »

Now that the dust has settled I’m happy to point out another place Spark is being used in the field - on the front page of of the MarketWatch financial news site. I do work as an architect at the company which provides this site, but in this case I specifically stepped back from making the decision to use Spark. A while ago I did offer a proof of concept to the team and lead developers responsible for the decision, and went through a few deep-dive sessions with the tech leads.

In the end it was a safe decision to make. Because view engine compiles down to a class which simply blasts output to the text writer there aren’t really any moving parts which can cause problems. If your view works once it’ll work a million times concurrently.
Read the rest of this entry »

Meeting people at PDC 2008

, , 3 Comments »

I’ve recently returned from PDC with Peter Gaard and it was quite an experience. There are a number of new technologies coming down the line which will be described by many other people in more detail than I’d care to attempt. So I won’t. :)

One of the things which I really enjoyed was meeting so many of the personalities I’ve known about, followed, or exchanged a few emails with online. In approximate order of appearance I shook hands and said hi to Phil Haack, Scott Hanselman, Torkel Ödegaard, Don Box, Scott Guthrie, and Jeff Atwood. Very cool - even got a coding horror sticker from the man himself. I was sorry to see Hamilton Verissimo wasn’t in LA, but it was exciting to hear in an open spaces session some of the things that could be percolating for the future in the MEF team he’s joined.

Creating a SQLEXPRESS database file from code

, , 5 Comments »

Creating a SQLEXPRESS database file from code was a bit tricky to figure out. If you’re using it as an embedded database engine, like SQLite, one of the things I was looking for was the ability to “get code and run” a project locally. The internet was especially unhelpful because everything was coming back with descriptions of using Visual Studio or SQL Management Consoles, or with topics about how to handle errors that happen creating the aspnetdb.mdf file.

So to cut right to the chase, here’s how you do it:

public static void CreateSqlExpressDatabase(string filename)
{
    string databaseName = System.IO.Path.GetFileNameWithoutExtension(filename);
    using (var connection = new SqlConnection(
        "Data Source=.\\sqlexpress;Initial Catalog=tempdb;"+
        "Integrated Security=true;User Instance=True;"))
    {
        connection.Open();
        using (var command = connection.CreateCommand())
        {
            command.CommandText =
                "CREATE DATABASE " + databaseName +
                " ON PRIMARY (NAME=" + databaseName +
                ", FILENAME='" + filename + "')";
            command.ExecuteNonQuery();

            command.CommandText =
                "EXEC sp_detach_db '" + databaseName + "', 'true'";
            command.ExecuteNonQuery();
        }
    }
}

Read the rest of this entry »

Spark in the field - CodeSaga

, , 5 Comments »

CodeSaga

Last week Torkel Ödegaard announced the first version of a new project CodeSaga based on several technologies including Asp.Net MVC and Spark.

In CodeSaga - The TFS & Subversion Storyteller he says:

CodeSaga is a source code repository web analysis app, very similar to FishEye. I have been working on this as a hobby project for a while now. It basically grew out of frustration with the existing TFS web tools and the need to have something fun to work on.

For more screenshots, feature descriptions and download info: www.codesaga.com, there is also live demo site for it, have a look: demo.codesaga.com

CodeSaga screenshot

Read the rest of this entry »

Code Reuse vs Tactical Deduplication

, , , 2 Comments »

There have been a great deal of evil introduced to the world in the name of code reuse. I imagine one of the things feeding into this is code reuse always sounds like a good idea to a non-technical roles.

Engineer: I’m making a helper to localize link’s alt text.
Manager: Good idea. Will it be re-usable?
Engineer: Ur… Yes?

From a management perspective reuse almost always looks like efficiency. If you can write it once and use it everywhere it’s a no-brainer. As an architect I often find myself explaining to business stakeholders how combining things which appear similar is a bad move. The idea really doesn’t resonate.
Read the rest of this entry »

People on stackoverflow don’t like funny answers

, , No Comments »

At least not for serious questions. For example, to the question about programming algoriths “Is there a better way to find midnight tomorrow? ” I naturally enough answered “Nope - it’ll be the same way you use to find midnight today.”

It was voted down immediately! Cost me two reputation points.

There ain’t no justice.

Very cool use of macro and _global.spark

, , , No Comments »

Here’s an example Artem Tikhomirov posted on the discussion group of using macros and a few service globals to create a nice little ability to easily register items in the html <head> without duplication. I thought it was remarkable how it demonstrates several different features of the language, and is also a very practical application that boils down to the ability to add stylesheets with a statement as small as ${css("jQuery/clockpick.1.2.4", "jQuery/datepicker/ui.datepicker")}.

From: “Артём Тихомиров”
Subject: Re: [Spark View Engine] #74: Add an attribute to declare a “just once” flag

I’ve ended up with following solution.

In Shared/_global.spark:

<!-- Service globals - do not use directly -->
<global __CssReferences="new OrderedSet[[string]]()" type="ISet[[string]]"/>
<global __JsReferences="new OrderedSet[[string]]()" type="ISet[[string]]"/>
<global __OnReadyStatements="new List[[string]]()" type="IList[[string]]"/>
<!-- End of service globals declaration -->

<macro name="WriteJsReferencesDown">
    <for each="var fileName in __JsReferences">
        <script type="text/javascript" src="~/Content/${fileName}.js"></script>
    </for>
</macro>

<macro name="WriteCssReferencesDown">
    <for each="var file in __CssReferences">
        <link rel="stylesheet" type="text/css"
              href="~/Content/${file}.css"/>
    </for>
</macro>

<macro name="WriteOnReadyStatements">
    <script type="text/javascript" if="__OnReadyStatements.Count > 0">
        jQuery(document).ready(
            function() {
                <for each="var statement in __OnReadyStatements">
                    ${statement}
                </for>
            }
        );
    </script>
</macro>

<macro name="css" files="params string[]">
    <for each="var file in files">
        # __CssReferences.Add(file);
    </for>
</macro>

<macro name="jQuery" additionalFiles="params string[]">
    # __JsReferences.Add("jQuery/jquery-1.2.6.min");
    <for each="var file in additionalFiles">
        # __JsReferences.Add("jQuery/" + file);
    </for>
</macro>

<macro name="js" additionalFiles="params string[]">
    <for each="var file in additionalFiles">
        # __JsReferences.Add(file);
    </for>
</macro>

<macro name="onReady" jsText="string">
    # if(!System.String.IsNullOrEmpty(jsText.Trim()))
    #        __OnReadyStatements.Add(jsText);
</macro>

In Shared/Application.spark:

<html>
    <head>
        <title></title>
        <use content="pageHead" />
        ${WriteCssReferencesDown()}
        ${WriteJsReferencesDown()}
        ${WriteOnReadyStatements()}
    </head>
    <body>
    </body>
</html>

In any *.spark file using default master-layout:

    ${css("jQuery/clockpick.1.2.4", "jQuery/datepicker/ui.datepicker")}
    ${jQuery("jquery-ui-1.6b.min", "i18n/ui.datepicker-ru", "jquery.clockpick.1.2.4.min")}

I really need to refresh Spark docs

, , , , No Comments »

The Spark docs are out of date now in a few ways. Some features added from the recommendations in the discussion group haven’t been fully documented with nice code examples.

I wonder if there is a good editor for Drupal that supports code samples. I’ll have to look into that.

After that there are one or two more things to change. Maybe streamline the debug and precompile support. Maybe also look further into a Visual Studio language extension. Other than that, for the Spark view engine itself I’m thinking it might be getting pretty close to cutting the first official version.

Design by j david macor.com.Original WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in