outaTiME

Adium 1.1.3

Posted in macos, release, security by outaTiME on September 30, 2007

Happy Sunday! Adium 1.1.3 is now available. This bugfix + feature release fixes a number of major and minor problems with previous versions. Notably, crashes in the transcript viewer and events editor are fixed, MSN now works again using the HTTP connect method (needed in many firewalled environments; this was broken by a change to the MSN servers), and Yahoo group chat rooms work again (previously broken by a change to the Yahoo servers).

A couple of the upcoming changes for Adium 1.2 are included in this release, as well: a subsection of the XMPP improvements see the light of day for Adium now rather than later, and the MySpace instant messaging service is now available.

As always, see the Version History for the full changes list.

Adium 1.1.3 is a recommended upgrade for all users of Mac OS X 10.4 or later.

A lot goes into every Adium release, from testing to coding to support. We’re a friendly and active development and user community, but we always want for more hands, eyes, and minds. That means you! Remember, Adium is free, open source software, coded entirely by volunteers. See Contributing to Adium for how you can submit patches and code, help hunt down bugs, and donate! Thanks as always for the continued support of our excellent site and code host NetworkRedux and our download host CacheFly!

(Via Adium News.)

Making Ajax Elegantly Fast

Posted in development, javascript, xhr by outaTiME on September 30, 2007

Sometime ago I was messing around with various techniques for ways that we can optimize asynchronous calls to the server via XMLHttpRequest (and the ActiveX equivalent of XMLHTTP). I wrote about one of those techniques known as branching in an article for Digital Web Magazine called Seven JavaScript Techniques You Should Be Using Today back in April, however, there was a flaw in the function that when one request is made before another one is finished, you would run into an error since it is using the same reference to the instance object for the request. That’s cool in theory, but bad in practice. The benefit you get with that is that you never create more than one XMLHttpRequest object for all your requests. This is fine for light weight use, and when you know for sure that you won’t be making frequent requests simultaneously. But when does that ever happen? Really.

Here’s what that code looked like:

Outdated asyncRequest function

var asyncRequest = function() {
    function handleReadyState(o, callback) {
        var poll = window.setInterval(function() {
            if(o && o.readyState == 4) {
                window.clearInterval(poll);
                if ( callback ){
                    callback(o);
                }
            }
        },
        50);
    }
    var http;
    try {
        http = new XMLHttpRequest;
    }
    catch(e) {
        var msxml = [
            'MSXML2.XMLHTTP.3.0',
            'MSXML2.XMLHTTP',
            'Microsoft.XMLHTTP'
        ];
        for ( var i=0, len = msxml.length; i < len; ++i ) {
            try {
                http = new ActiveXObject(msxml[i]);
                break;
            }
            catch(e) {}
        }
    }
    return function(method, uri, callback, postData) {
        http.open(method, uri, true);
        handleReadyState(http, callback);
        http.send(postData || null);
        return http;
    };
}();

Note that the function still branches within the body of the closure, and that branch happens only once. The main issue here is that we need another function that essentially branches the way get the XMLHttpRequest object, but without being run multiple times. In other words, this would be bad:

bad example for XMLHttpRequest

function getXHR() {
  var http;
  try {
    http = new XMLHttpRequest;
  } catch (ex) {
    var msxml = [
      'MSXML2.XMLHTTP.3.0',
      'MSXML2.XMLHTTP',
      'Microsoft.XMLHTTP'
    ];
    for (var i=0, len = msxml.length; i < len; ++i) {
      try {
        http = new ActiveXObject(msxml[i]);
        break;
      }
      catch(e) {}
    }
  }
}

The reason this is slow is because every request for a new XMLHttpRequest object we have to run through the same logic upon each call to this function. Instead we can use what Peter Michaux coined as the Lazy Function Definition Pattern, and apply that technique here. Our optimized (and final) code would then look like this:

Optmized Speedy Ajax Code

var asyncRequest = function() {
  function handleReadyState(o, callback) {
    if (o && o.readyState == 4 && o.status == 200) {
      if (callback) {
        callback(o);
      }
    }
  }
  var getXHR = function() {
    var http;
    try {
      http = new XMLHttpRequest;
        getXHR = function() {
          return new XMLHttpRequest;
        };
    }
    catch(e) {
      var msxml = [
        ‘MSXML2.XMLHTTP.3.0′,
        ‘MSXML2.XMLHTTP’,
        ‘Microsoft.XMLHTTP’
      ];
      for (var i=0, len = msxml.length; i < len; ++i) {
        try {
          http = new ActiveXObject(msxml[i]);
          getXHR = function() {
            return new ActiveXObject(msxml[i]);
          };
          break;
        }
        catch(e) {}
      }
    }
    return http;
  };
  return function(method, uri, callback, postData) {
    var http = getXHR();
    http.open(method, uri, true);
    handleReadyState(http, callback);
    http.send(postData || null);
    return http;
  };
}();

Take closer look at how the getXHR function is redeclared within main declaration to simply return the appropriate object back to the client when requested. And that folks, is Ajax served elegantly fast! Feel free to try it yourself :)

asyncRequest in use

asyncRequest('GET', 'foo.php', function(o) {
  console.log(o.responseText);
});

(Via ./with Imagination.)

Canvas Loading Indicator for the iPhone and beyond

Posted in development, iphone, javascript, xhr by outaTiME on September 30, 2007

Adam van den Hoven wrote a Canvas Loading Indicator after he realised that animated gifs and the iPhone didn’t mesh.

First he wrote the basic spinner:

JAVASCRIPT:

  1.  
  2. function getLoading(context, bars, center, innerRadius, size, color) {
  3. var animating = true,
  4.     currentOffset = 0;
  5.  
  6. function makeRGBA(){
  7.     return “rgba(“ + [].slice.call(arguments, 0).join(“,”) + “)”;
  8. }
  9. function drawBlock(ctx, barNo){
  10.     ctx.fillStyle = makeRGBA(color.red, color.green, color.blue, (bars+1-barNo)/(bars+1));
  11.     ctx.fillRect(-size.width/2, 0, size.width, size.height);
  12. }
  13. function calculateAngle(barNo){
  14.     return 2 * barNo * Math.PI / bars;
  15. }
  16. function calculatePosition(barNo){
  17.     angle = calculateAngle(barNo);
  18.     return {
  19.         y: (innerRadius * Math.cos(-angle)),
  20.         x: (innerRadius * Math.sin(-angle)),
  21.         angle: angle
  22.     };
  23. }
  24. function draw(ctx, offset) {
  25.     clearFrame(ctx);
  26.     ctx.save();
  27.     ctx.translate(center.x, center.y);
  28.     for(var i = 0; i<bars; i++){
  29.         var curbar = (offset+i) % bars,
  30.             pos = calculatePosition(curbar);
  31.         ctx.save();
  32.         ctx.translate(pos.x, pos.y);
  33.         ctx.rotate(pos.angle);
  34.         drawBlock(context, i);
  35.         ctx.restore();
  36.     }
  37.     ctx.restore();
  38. }
  39. function clearFrame(ctx) {
  40.     ctx.clearRect(0, 0, ctx.canvas.clientWidth, ctx.canvas.clientHeight);
  41. }
  42. function nextAnimation(){
  43.     if (!animating) {
  44.         return;
  45.     };
  46.     currentOffset = (currentOffset + 1) % bars;
  47.     draw(context, currentOffset);
  48.     setTimeout(nextAnimation, 50);
  49. }
  50. nextAnimation(0);
  51. return {
  52.     stop: function (){
  53.         animating = false;
  54.         clearFrame(context);
  55.     },
  56.     start: function (){
  57.         animating = true;
  58.         nextAnimation(0);
  59.     }
  60. };
  61. }
  62.  

And then to use it:

JAVASCRIPT:

  1.  
  2. var controller = getLoading(canvas.getContext(“2d”), 9, {x:100, y:100}, 10, {width: 2, height:10}, {red: 0, green: 17, blue: 58});
  3.  

(Via Ajaxian.)

Ext 2.0 Alpha Release

Posted in development, javascript, xhr by outaTiME on September 30, 2007

The Ext team is proud to announce that the first public release of Ext v2.0 is available for download. This new version of the Ext framework introduces a host of new features, a new document center, expanded & better organized samples and bug fixes. Another important aspect to note is that there has not been a significant library size increase in this new version.

(Via Ext JS Blog.)

20071001-outaTiME, clubbers-vol.1

Posted in clubbers by outaTiME on September 28, 2007

Analyzing Web 2.0 Applications with Ajax View

Posted in development, javascript, xhr by outaTiME on September 26, 2007

Hi everyone,


In June I posted information about a number of developer tools, one of which was Ajax View. Ajax View, developed by Microsoft Research, can help improve a developer’s visibility into their web application’s performance and behavior. Recently, the researchers building Ajax View – Emre Kıcıman and Ben Livshits – released a public version of the tool (licensed for academic or other non-commercial use) so I want to share a link and provide a little more information about it.


What can I do with it?


As shown in the demo from MIX07 and described in detail here, you can use Ajax View to profile a site’s JavaScript from your dev machine. Ajax View includes a few default instrumentation policies for basic profiling (timing based on before and after a function call in the caller, timing based on before and after a function call in the callee, etc.) but you can create a plug-in to track the JavaScript you’re interested in. 

How does it work?


Ajax View is an HTTP proxy that instruments JavaScript as it’s served to the client based on a set of rules defined by plug-ins. The download includes a plug-in that contains a commented sample instrumentation policy. This design has a couple important effects:


  • You can customize Ajax View to monitor exactly the JavaScript behavior you’re looking for, whether it’s about performance, or how people navigate through your site.

  • Using Ajax View does not require modification of either the page source or the browser.

Where do I download it and send feedback?


Visit the Ajax View project site to download the latest prototype and try it for yourself. 

We’d love to get your feedback on the kind of instrumentation you’d find useful. Let us know what data about your web application’s behavior would help you detect or debug problems. You can send feedback directly to the project team, or, as usual, comment on this post. 

Thanks! 

John Hrvatin
Program Manager
Internet Explorer


Edit: Updated link for “send feedback directly to the project team”

(Via IEBlog.)

Working with the YUI DataTable Control, Part 2: Changing the Contents of the DataTable

Posted in development, javascript, xhr by outaTiME on September 26, 2007

Don’t miss Part One of this series, in which Satyam explores practical steps on getting started with the YUI DataTable Control.

Daniel Barreiro (Satyam)About the Author: Daniel Barreiro (screen name Satyam) has been around for quite some time. The ENIAC was turned off the day before he was born, so he missed that — but he hasn’t missed much since. He’s had a chance to punch cards, program 6502 chips (remember the Apple II?), own a TRS-80 and see some fantastic pieces of operating equipment in his native Argentina which might have been in museums elsewhere. When globalization opened the doors to the world, his then barely usable English (plus an Electrical Engineering degree) put him on the career path which ended in a 5-year job in the Bay Area back in the days of NCSA Mosaic. Totally intrigued by the funny squiggles a friend of his wrote in his plain text editor, full of <’s and >’s, he ended up learning quite a lot about the world of frontend engineering. It’s been a long journey since COBOL and Fortran. Now he lives quite happily semi-retired in the Mediterranean coast close to Barcelona, Spain. When he’s not basking in the Mediterranean sun, Saytam can be found among the most prolific and knowledgable participants in the YUI community on the YDN-JavaScript developer forum.

In a previous article I wrote about how to get started with your own implementation of the DataTable component. In this article I will cover how to change the contents of the DataTable, especially how to communicate with your database server to make changes and, if successful, show those changes to the user, since in many applications, the contents of the DataTable should be a reflection of the information in a database.

(more…)

(Via Yahoo! User Interface Blog.)

Working with the YUI DataTable Control, Part 1: Getting Started

Posted in development, javascript, xhr by outaTiME on September 26, 2007

Don’t miss Part Two of this series, in which Satyam explores methods for changing data within the YUI DataTable Control.

Daniel Barreiro (Satyam)About the Author: Daniel Barreiro (screen name Satyam) has been around for quite some time. The ENIAC was turned off the day before he was born, so he missed that — but he hasn’t missed much since. He’s had a chance to punch cards, program 6502 chips (remember the Apple II?), own a TRS-80 and see some fantastic pieces of operating equipment in his native Argentina which might have been in museums elsewhere. When globalization opened the doors to the world, his then barely usable English (plus an Electrical Engineering degree) put him on the career path which ended in a 5-year job in the Bay Area back in the days of NCSA Mosaic. Totally intrigued by the funny squiggles a friend of his wrote in his plain text editor, full of <’s and >’s, he ended up learning quite a lot about the world of frontend engineering. It’s been a long journey since COBOL and Fortran. Now he lives quite happily semi-retired in the Mediterranean coast close to Barcelona, Spain.When he’s not basking in the Mediterranean sun, Saytam can be found among the most prolific and knowledgable participants in the YUI community on the YDN-JavaScript developer forum.  YUI’s DataTable Control has many options, more than any single application will use. Unless you want to improvise something different for each and every page, chances are you will be using a subset of those options. As most often is the case, whatever worked your first time, that’s what you will use in the rest of the pages, usually copying it over and then modifying it for each page. Then, in the second or third page, you notice that clicking on a column heading does reorder the data but not in the way you expected; so, you research a little more and find out that the code you so happily copied all over needs some retouching. Given the complexity of the component and the problems you will address with it, planning a little bit in advance is a good idea.This article aims to share with you some lessons from my own implementations of DataTable and from the questions I’ve seen posted on YDN-JavaScript related to this component. DataTable will continue to evolve, and some of the issues addressed here may change in nature over time, but I hope to help shorten your path to a smooth deployment of DataTable based on the 2.3.x release.(more…) (Via Yahoo! User Interface Blog.)

Apache Tuscany 1.0 Available

Posted in development, java, release, security by outaTiME on September 24, 2007

The Apache Tuscany team are delighted to announce the 1.0 release of
the Java SCA project.

Apache Tuscany provides a runtime environment based on the Service
Component Architecture (SCA). SCA is a set of specifications aimed at
simplifying SOA application development. These specifications are
being standardized by OASIS as part of the Open Composite Services
Architecture (Open CSA).

This Apache Tuscany release represents a major milestone as the first
1.0 implementation of the core SCA specifications.

For full details about the release and to download the distributions
please go to: http://incubator.apache.org/tuscany/sca-java-releases.html

To find out more about OASIS Open CSA go to: http://www.oasis-opencsa.org.

Apache Tuscany welcomes your help. Any contribution, including code,
testing, contributions to the documentation, or bug reporting is
always appreciated. For more information on how to get involved in
Apache Tuscany visit the website at:
http://incubator.apache.org/tuscany.

Thank you for your interest in Apache Tuscany!
The Apache Tuscany Team.

(Via Apache News Online.)

20070903-outaTiME, clubbers-vol.3

Posted in clubbers by outaTiME on September 21, 2007