Friday, July 4th, 2008
Category: .NET
, Aptana
What does your CEO do? Paul Colton, CEO of Aptana, gets his fingers dirty. He just wrote a post about accessing COM objects from JavaScript with Jaxer.
This is possible as the JavaScript is running on the server, and this server is running on Windows. You can download the source code to check it all out.
HTML:
-
-
-
-
-
function rotate(angle)
-
{
-
var img = COMObject("ImageProcessor.ImageProcessing");
-
-
img.LoadImage(Jaxer.request.documentRoot + "/photo.jpg");
-
img.RotateImage(angle);
-
img.SaveImage(Jaxer.request.documentRoot + "/new.jpg");
-
}
-
</script>
-
-
<input type="button" value="Rotate"
-
onclick="rotate(document.getElementById('angle').value);
-
document.getElementById('img').src =
-
document.getElementById('img').src + '?' + new Date()"/>
-
-
<img id='img' src="new.jpg"/>
-
</body>
-
</html>
-
Tuesday, April 29th, 2008
Category: .NET
, Performance
Omar AL Zabir, the co-founder & CTO of Pageflakes has written about a continuous streaming Ajax proxy that solves the common problem that all Ajax proxies have, the double delay in downloading content on server first and then delivering to the browser.
Omar talks about the continuous proxy that can help solve the problems. The approach for the continuous proxy is:
- Read bytes from external server in chunks of 8KB from a separate thread (Reader thread) so that it's not blocked
- Store the chunks in an in-memory Queue
- Write the chunks to ASP.NET Response from that same queue
- If the queue is finished, wait until more bytes are downloaded by the reader thread

Making a difference
And if you wonder what difference this can make:
Content Proxy served about 42.3 million URLs last month which is quite an engineering challenge for us to make it both fast and scalable. Sometimes Content Proxy serves megabytes of data, which poses even greater engineering challenge. As such proxy gets large number of hits, if we can save on an average 100ms from each call, we can save 4.23 million seconds of download/upload/processing time every month. That's about 1175 man hours wasted throughout the world by millions of people staring at browser waiting for content to download.
There is even more detail on how the proxy has created.
Thursday, April 3rd, 2008
Category: .NET
, Ext
Colin Ramsay thinks that JavaScript and C# can be scarily similar as he shows an ExtJS example:
JAVASCRIPT:
-
-
var win = new Ext.Window({
-
title: 'Order Viewer', layout: 'border',
-
width: 500, height: 500,
-
modal: true, resizable: false, closable: false, draggable: false,
-
items: [ frm, lst ]
-
});
-
-
win.on('render', function() {
-
load(5);
-
});
-
-
win.show();
-
C#:
-
-
var win =
new Ext.
Window{
-
Title = "OrderViewer", Layout = Layout.Border,
-
Width = 100, Height = 200,
-
Modal = true, Resizable = false, Closable = false, Draggable = false,
-
Items =
new [] { frm, lst
}
-
};
-
-
win.Render += delegate {
-
load(5);
-
};
-
-
win.show();
-
This works well for ExtJS since it is written in a style that leads itself to this similarity. Colin also points out ExtSharp, a project that lets you write your Ext application in C#:
I really love Ext but coding in javascript just gives me the chills. So I went out and found a way to use my favorite js library (Ext) and my favorite programming language (C#) at the same time. By using a project called Script# I am able to write C# code and have it converted into javascript, similar to GWT. Building on that, Script# also allows you to code against external APIs, but you need to create the types, methods, properties, etc. for everything in the javascript library. So what I did was write a little console app that parses all of the ExtJS source files extracting out the script comments and writing C# files for each class. The end result is a programmable C# API to access all of the Ext objects and I threw in a couple new things to make life a little easier.
Wednesday, March 19th, 2008
Category: .NET
, Google
, JavaScript
Yoah Bar-David & Itai Raz of Google have introduces the latest Ajax API: Google Visualization API, a new API designed for visualizing structured data.
There is a large visualization gallery that can show you some of the visualizations that you can use.
You tie into the API as you do with other Google Ajax APIs:
JAVASCRIPT:
-
-
google.load("visualization", "1");
-
-
var q = new google.visualization.Query(DATA_SOURCE_URL);
-
q.setQuery("select A, sum(D) group by A");
-
q.send(responseHandlerCallback);
-
Take a look at this very cool example that the Gapminder team came up with (click on play)
This complements the Google Chart API, which just lifted its limits on the number of calls for charts.
NOTE: Google I/O is a conference being held at San Francisco on May 28-29 2008. APIs like this will be talked about. I will be there. And lots of good folks will be there (Steve Souders, Mark Lucovsky, Guido van Rossum, Jeff Dean, Chris DiBona, Josh Bloch).
Monday, March 3rd, 2008
Category: .NET
, JSON

James Newton-King has quickly released a new version of Json.NET that has a new easier syntax for querying and and creating JSON.
Creating JSON
JAVASCRIPT:
-
-
JObject o = JObject.FromObject(new
-
{
-
channel = new
-
{
-
title = "James Newton-King",
-
link = "http://james.newtonking.com",
-
description = "James Newton-King's blog.",
-
item =
-
from p in posts
-
orderby p.Title
-
select new
-
{
-
title = p.Title,
-
description = p.Description,
-
link = p.Link,
-
category = p.Categories
-
}
-
}
-
});
-
Querying JSON
JAVASCRIPT:
-
-
var categories =
-
from c in rss["channel"]["item"].Children()["category"].Values<string>()
-
group c by c into g
-
orderby g.Count() descending
-
select new { Category = g.Key, Count = g.Count() };
-
Check out the project.
Wednesday, February 13th, 2008
Category: .NET
, Ajax
We've been trying to get more .Net-related content on Ajaxian and luckily we were contacted by the AjaxDataControls team about their new v1.0 release.
The AjaxDataControls is a DotNetSlackers.com's open source project built on top of Microsoft Asp.net Ajax Extension. Currently it contains GridView, DataList, Repeater and Pager controls. The main goal of this project is to provide a similar kind of data controls in the client side which the asp.net developers are already familiar with while working with the server side version. The Server side versions of these controls were developed long before the Ajax came into scene, so there is no client side API which the developer can utilize and it is also not possible to bind data which is returned from a Web Service or Page Method call. On the other hand, AjaxDataControls was specially developed keeping these things in mind. It Provides:
1. Exact same API as the Original Server Side version.
2. Exact same declarative model in aspx page.
3. Full Design time support.
4. Lots of extra features like drag and drop, animation, etc.
It is also possible to use these controls in non-MS platform.
Live examples are hosted:
http://dotnetslackers.com/projects/AjaxDataControls
Source:
http://www.codeplex.com/AjaxDataControls
Forum:
http://dotnetslackers.com/community/forums/71.aspx
Tuesday, February 12th, 2008
Category: .NET
, JSON
James Newton-King has posted a new bit of code called LINQ to JSON which is a .NET LINQ style API over JSON.
For example, here is how you could get out categories and how often they are used:
JAVASCRIPT:
-
-
var categories =
-
from c in rss.PropertyValue<jobject>("channel")
-
.PropertyValue<jarray>("item")
-
.Children<jobject>()
-
.PropertyValues<jarray>("category")
-
.Children<string>()
-
group c by c into g
-
orderby g.Count() descending
-
select new { Category = g.Key, Count = g.Count() };
-
There is also a project, JSLINQ which is an implementation of LINQ to Objects implemented in JavaScript. It is built using a set of extension methods built on top of the JavaScript Array object. If you are using an Array, you can use JSLINQ.
Thursday, January 17th, 2008
Category: .NET
, Adobe

CommandProxy is a proof of concept by Mike Chambers (Adobe AIR team) that offers a solution to a feature that Ben and I have wanted in AIR.... the ability to talk to native code:
Two of the most requested features for Adobe AIR have been the ability to launch native executables from an AIR application, and the ability to integrate native libraries into an AIR application. Unfortunately, neither feature will be included in Adobe AIR 1.0.
However, this does not mean that you cannot build an AIR application that has closer / tighter integration with the underlying operating system. This lower level of integration is possible, but it requires some work on your part. I have put together a proof of concept project, which shows how to integrate Adobe AIR applications with c# / .NET code on any operating system that Adobe AIR currently runs on (Mac and Windows). The project is called CommandProxy. It provides a communication proxy between an AIR application and the underlying operating system and could theoretically work with other web based desktop runtimes (such as Mozilla Prism).
How does it work?
The general concept behind the project is similar to the now defunct Artemis project (which was Java based). The AIR application communicates with the CommandProxy process to communicate and integrate with the underlying operating system. Currently the command proxy supports launching processes (and getting the output from the processes) as well as taking a screenshot of the user’s current screen. However, the framework is built in such a manner that it is possible to add new functionality to the proxy.
The project is opensource and more info is available on the project page on Google Code.
Thursday, September 6th, 2007
Category: .NET
, Microsoft
Microsoft's Silverlight 1.0 has been released.
They seem to be touting the media side of things strongest (a.k.a. Kill Flash):
- Built-in codec support for playing VC-1 and WMV video, and MP3 and WMA audio within a browser. The VC-1 codec is a big step forward for incorporating media within a web experience - since it supports very efficiently playing high-quality, high definition video in the browser. It is a standards-based media format that is implemented in all HD-DVD and Blueray DVD players, and is supported by hundreds of millions of mobile devices, XBOX 360s, PlayStation 3s, and Windows Media Centers (enabling you to encode content once and run it on all of these devices + Silverlight unmodified). It enables you to use a huge library of existing video content and provides access to the broad ecosystem of existing Windows Media tools, components, vendors and hardware.
- Silverlight supports the ability to progressively download and play media content from any web-server. You can point Silverlight at any URL containing video/audio media content, and it will download it and enable you to play it within the browser. No special server software is required, and Silverlight can work with any web-server (including Apache on Linux). We'll also be releasing an IIS 7.0 media pack that enables rich bandwidth throttling features that you can enable on your web-server for free.
- Silverlight also optionally supports built-in media streaming. This enables you to use a streaming server like Windows Media Server on the backend to efficiently stream video/audio (note: Windows Media Server is a free product that runs on Windows Server). Streaming brings some significant benefits in that: 1) it can improve the end-user's experience when they seek around in a large video stream, and 2) it can dramatically lower your bandwidth costs.
But there is also the Ajax (or Kill Ajax?) side:
- Silverlight enables you to create rich UI and animations, and blend vector graphics with HTML to create compelling content experiences. It supports a Javascript programming model to develop these. One benefit of this is that it makes it really easy to integrate these experiences within AJAX web-pages (since you can write Javascript code to update both the HTML and XAML elements together.?).
As well as putting out a final version (which will be nicely auto-updated), there was also the announcement that Miguel de Icaza's, and his team at Novell, are now officially the Linux solution via Moonlight.
Microsoft already announced Silverlight 1.1 with all of the goodness of the DLR, so a lot of people are just waiting for that!
Tuesday, July 3rd, 2007
Category: .NET
, JavaScript
, Library
Are you writing classic ASP pages and want to join in the Ajax revolution too? Really? Well, Ajaxed is for you. The framework is simialr to xajax for PHP, in that it allows you to tie in to a named function on th eserver side.
It looks like this:
JAVASCRIPT:
-
-
<!--#include virtual="/ajaxed/ajaxed.asp"-->
-
<%
-
set page = new AjaxedPage
-
page.draw()
-
-
sub init() : end sub
-
-
sub callback(action)
-
if action = "add" then page.return(add(page.RF("a"), page.RF("b")))
-
end sub
-
-
function add(a, b)
-
if not isnumeric(a) then a = 0
-
if not isnumeric(b) then b = 0
-
add = cint(a) + cint(b)
-
end function
-
-
sub main() %>
-
-
<script>
-
function added(sum) {
-
$('c').value = sum;
-
}
-
</script>
-
-
<form id="frm">
-
<input type="Text" name="a" id="a"/>+
-
<input type="Text" name="b" id="b"/>=
-
<input type="Text" name="c" id="c"/>
-
<button onclick="ajaxed.callback('add', added)" type="button">calculate</button>
-
</form>
-
-
<% end sub %>
-
Tuesday, June 5th, 2007
Category: .NET
, Showcase
Jacob DuBray and Freshlogic Studios have a new Ajax application out in the wild:
Folders allows you to work with your files on the internet, the same way you work with them on your desktop. We've turned months of research and development into a simple, modern website that allows you to upload, manage, and share your digital photos, music, movies and documents with your friends. Upload your files, browse through your friends' folders, even search to see what other people are sharing.
Folders also has RSS syndication built right in, giving you what we call "one-click podcasting". Easily evangelize your thoughts and ideas to the world.
