Monthly Archives: May 2009

Windows 7 RC Available for Download Now [Windows 7]

The official Windows 7 Release Candidate is now available for all users through Microsoft’s Customer Preview program.

Officially the folks at Redmond had said the release would be available tomorrow (May 5), and while it’s not May 5 anywhere in the US at the time of this writing—hey, it’s May 5 somewhere.

To download Windows 7 RC, you’ll need to hit up the link below, head to the bottom of the page to select which version of Windows 7 you want (32-bit or 64-bit), select your language, and then sign in with your Windows Live account (that means you’ll need to get one if you don’t have one already). After that, just grab yourself a cold drink and wait. So far the download is moving swiftly for me (around 450KB/s) and should be done in just over an hour and a half. Hopefully they can keep it up, but if not, remember: This download and product keys will be available through the end of June, so you’ve got plenty of time.

If you give it a go, let’s hear how the download goes for you in the comments. Maybe Microsoft won’t underestimate the web this time around. Thanks Travis!

Update: The download page—which worked just a few minutes ago and will very likely start working again in the next day (if not much sooner)—appears to have been pulled. I’m getting a “We are sorry, the page you requested cannot be found” error message.” My download’s still going strong, but you may not have the same luck I did. Not a great start, Microsoft, but we won’t hold it against you until it’s officially May 5.

Update 2: Okay, it’s five minutes later and it’s working again. Let’s just hope that we’re just seeing a few getting-started hiccups. If you aren’t having luck at first, it might be worth trying again in a few minutes. We’re going to check out of the minute-to-minute updates at this point, but you can help us out by keeping your fellow readers up-to-speed on how it’s worked for you in the comments.

Update 3: The gHacks blog recommends signing in with a Windows Live ID at the TechNet or MSDN servers, even if you’re just a member of the RC-grabbin’ public, and grabbing your registration keys and downloads from those servers to avoid the release-day bum rush.

Mark Jaquith: Force CSS changes to “go live” immediately

If you update your WordPress theme’s style.css, you may have noticed that you have to “force-reload” your site in your browser to see the changes. This is because your browser keeps a copy of the CSS cached on your hard drive. Depending on how your server is set up, it may not check for a new version of the stylesheet for a couple hours, or longer! And even if you force-reload to see the changes, visitors who have previously accessed your site may still get the old CSS. One way to solve this is to “version” your CSS file, by adding ?v=123 to the URL in the <link /> to your stylesheet. This is rather a pain to have to do by hand every time, so here is a much better way:

<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); echo '?' . filemtime( get_stylesheet_directory() . '/style.css'); ?>" type="text/css" media="screen, projection" />

This automatically updates the ?12345678 ending part every time you modify the file. Boom. Now everyone instantly sees your changes.

Google Profiles Now the Best Way to Get In Search Results for Your Name

Google Profiles in search resultsPeople who don’t live their lives online like I do often ask me: How can I make it easy for people to find me on the web? While before I might have suggested Facebook, LinkedIn, or just a straight-up personal nameplate site, now I’d advise ‘em to set up their Google Profile.

Unless you have a well-linked web site you maintain with your full name all over it, Google search results for your name can vary in quality, and include lots of stuff that’s out of date. So it makes sense that Google’s trying to make people search results better by including Google Profiles in them. Your Google Profile is a pre-fab nameplate with your identifying vitals: name, location, title, company, and interests. Here’s what mine looks like right now.


My Google Profile

(GOOG even included support for their competitor’s photo-sharing product, Flickr, for the photo strip; I also dig the Google map of places I’ve lived–so that people can say “oh yes, this is Gina Trapani who used to live in Brooklyn.”)

If you fill out enough information in your Google Profile, it will show up at the bottom of the GOOG’s web search results for your name. (For me, “enough information” meant entering “where I live now” and “what I do.”) This comes in especially handy for people with common names, like my former co-worker at Gizmodo, Jason Chen. See the list of Jason Chen’s who have GProfiles returned in the screenshot at the top of this post.

Problem is, who is going to know to fill out their Google Profile?

In a clever marketing move to ramp up Google Profile adoption, last week GOOG offered 25 free business cards to the first 10,000 folks who filled out enough information in their Google Profile and ordered the dead-tree cards. I did just that on Friday, and now my Google Profile appears at the bottom of search results for my name.

As a web-based freelancer who’s web findability is super-important, it only made sense to hand over my personal info for publication in my profile. But will it for any other Gina Trapani? As more and more people get online, claiming your name will only get more important and competitive. If Google can collect enough complete profiles, I wouldn’t be surprised to see them appear at the top instead of the bottom of results for proper names at some point. But Google’s going to have to offer more than a few free paper business cards which essentially say “Google me” on them to get folks to opt in.

Using jQuery with Client-Side Data Binding Templates

A few weeks back I posted about a JavaScript data binding template solution that I’ve been using that makes it easy to bind JSON data to a client-side template without having to write a lot of JavaScript code.  One of the people that commented on that post asked if I could put together a sample that demonstrated the templates in action.  It took me a few weeks to get to it, but I finally made some time to put a sample together that demonstrates the fundamentals of using the client-side templates and binding JSON data to them.  As a review (in case you didn’t read my earlier post), the template solution I’ve been using recently on a client project is based on some code written by John Resig (creator of jQuery) which is extremely compact.  Here’s a tweaked version of his original code that I wrapped with a jQuery extender function (credit goes to Rick Strahl as well for a few tweaks he added):

$.fn.parseTemplate = function(data)
{
    var str = (this).html();
    var _tmplCache = {}
    var err = "";
    try
    {
        var func = _tmplCache[str];
        if (!func)
        {
            var strFunc =
            "var p=[],print=function(){p.push.apply(p,arguments);};" +
                        "with(obj){p.push('" +
            str.replace(/[rtn]/g, " ")
               .replace(/'(?=[^#]*#>)/g, "t")
               .split("'").join("\'")
               .split("t").join("'")
               .replace(/<#=(.+?)#>/g, "',$1,'")
               .split("<#").join("');")
               .split("#>").join("p.push('")
               + "');}return p.join('');";

            //alert(strFunc);
            func = new Function("obj", strFunc);
            _tmplCache[str] = func;
        }
        return func(data);
    } catch (e) { err = e.message; }
    return "< # ERROR: " + err.toString() + " # >";
}

The parseTemplate method can be applied against a client-side template like the one below.  Notice that the template is wrapped in a script block with the type set to text/html so that it isn’t rendered by the browser.  JSON properties are written out by using the <#= …  #> syntax and the template engine has full support for embedded JavaScript code.

<script id="MyTemplate" type="text/html">
    <table style="width:400px;">
        <thead>
            <tr>
                <th>First Name</th>
                <th>Last Name</th>
                <th>Address</th>
            </tr>
        </thead>
        <tbody>
        <#
            for(var i=0; i < d.length; i++)
            {
               var cust = d[i];
        #>
                <tr>
                   <td id="CustomerRow_<#= i.toString() #>">
                        <#= cust.FirstName #>
                   </td>
                   <td>
                        <#= cust.LastName #>
                   </td>
                   <td>
                      <#= cust.Address.Street #>
                      <br />
                      <#= cust.Address.City #>, <#= cust.Address.State #>
                      &nbsp;&nbsp;<#= cust.Address.Zip #>
                   </td>
                </tr>
        <#
            }
        #>
        </tbody>
    </table>
    <br />
    <#= d.length #> records shown
</script>

This template outputs a simple table like the one shown next.  Sure, I could’ve generated the table using DOM manipulation techniques, but being able to tweak a data template is much easier and productive in my opinion.

image


In order to use the template you’ll need to have some JSON data available.  Here’s an example of creating JSON by hand and binding it to the template using the parseTemplate method shown earlier.  The data returned from the template data binding operation is passed to the html method of the target div which displays the data in the browser.  Note:  I’m defining the “d” property in the JSON object since WCF uses that name by default when it returns serialized JSON data.

var json =
        {
            "d":
            [
               { "FirstName": "John", "LastName": "Doe",
                 "Address":
                  { "Street": "1234 Anywhere St.", "City": "Phoenix",
                    "State": "AZ", "Zip": 85044 }
               },
               { "FirstName": "Jane", "LastName": "Doe",
                   "Address":
                  { "Street": "435 Main St.", "City": "Tempe",
                    "State": "AZ", "Zip": 85245 }
               },
               { "FirstName": "Johnny", "LastName": "Doe",
                 "Address":
                  { "Street": "643 Chandler Blvd", "City": "Chandler",
                    "State": "AZ", "Zip": 85248 }
              },
               { "FirstName": "Dave", "LastName": "Doe",
                 "Address":
                  { "Street": "18765 Cloud St.", "City": "Mesa",
                    "State": "AZ", "Zip": 85669 }
               }
            ]
        };
var output = $('#MyTemplate').parseTemplate(json);
$('#MyTemplateOutput').html(output);

Of course, in the real-world you’ll probably get the JSON data from some type of service (WCF, ASMX, REST, etc.).  Here’s a WCF service that returns a List of Customer objects and converts them to JSON.  The service has the client script behavior enabled so that serialization from CLR objects to JSON objects occurs behind the scenes automatically.

[ServiceContract(Namespace = "http://www.thewahlingroup.com")]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class CustomerService
{
    [OperationContract]
    public List<Customer> GetCustomers()
    {
        return new List<Customer>
        {
            new Customer {FirstName="John",LastName="Doe",
                          Address=new Address{Street="1234 Anywhere St.",City="Phoenix",State="AZ", Zip=85044}},
            new Customer {FirstName="Jane",LastName="Doe",
                          Address=new Address{Street="435 Main St.",City="Tempe",State="AZ", Zip=85245}},
            new Customer {FirstName="Johnny",LastName="Doe",
                          Address=new Address{Street="643 Chandler Blvd",City="Chandler",State="AZ", Zip=85248}},
            new Customer {FirstName="Dave",LastName="Doe",
                          Address=new Address{Street="18765 Cloud St.",City="Mesa",State="AZ", Zip=85669}}
        };
    }

}


jQuery’s ajax method can then be used to call the WCF service and retrieve the data (jQuery provides other methods such as getJSON that could be used too if desired):

$.ajax(
{
    type: "POST",
    url: "CustomerService.svc/GetCustomers",
    dataType: "json",
    data: {},
    contentType: "application/json; charset=utf-8",
    success: function(json)
    {
        var output = $('#MyTemplate').parseTemplate(json);
        $('#MyTemplateOutput').html(output);

        //Add hover capabilities
        $('tbody > tr').bind('mouseenter mouseleave', function()
        {
            $(this).toggleClass('hover');
        });
    }
});

This code defines the type of operation, service URL to call, any data passed to the service, the content type and a success callback.  Once the service call returns, the JSON data is bound to the template shown earlier by locating the area where the template should be rendered to (MyTemplateOutput in this example) and then calling parseTemplate.  Hover capabilities are also added using jQuery’s bind method to highlight rows as the user moves the mouse in and out of them. 

You can see that the amount of custom Javascript that has to be written is kept to a minimum by combining jQuery with the client-side template which ultimately leads to easier maintenance down the road.  This is just one of several different client-side template solutions out there.  ASP.NET 4.0 will also include a custom client-side template solution as well as mentioned in my previous post.

Download the sample code here

Logo

For more information about onsite, online and video training, mentoring and consulting solutions for .NET, SharePoint or Silverlight please visit www.thewahlingroup.com/.

WP Like Button Plugin by Free WordPress Templates