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")}
Design by j david macor.com.Original WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in