Loudtalks — internet walkie talkie

trim() function for ActionScript and JavaScript

By Alexey Gavrilov on February 7, 2010

Strangely ActionScript doesn’t have trim() function, JavaScript doesn’t have it either.

I needed the one lately and googled it but a few solutions that came up looked weird (using several for() cycles for example). So I came up with this one — if you know how to make it simpler or shorter, l’d be very interested to hear your solution.

Old school style:


function trim(s) {
    return s.match(/^s*(.*?)s*$/)[1];
}

var s = trim(" well done   "); // s = "well done"
 

Modern style:


String.prototype.trim = function() {
    return this.match(/^s*(.*?)s*$/)[1];
}

var s = "   even better  ".trim(); // s = "even better"
 

Enjoy!

(categories: Technology, Solutions box)

Bubblemark update

By Alexey Gavrilov on April 16, 2008

Silverlight 2

I’ve been a out of this little project for a while, busy with things at Loudtalks and Metalink. I even haven’t had a chance to check out Silverlight 2.

Few people asked for it and I was about to go all the way through installing VS2008 but today I received a Silverlight 2 bubblemark port, implemented by Kevin Yang. On my machine it gets ~280 fps, which is 40% increase over 1.1. You can try it yourself here.

Bubblemark validity (correctly) questioned

I’m glad to see that more cross-RIA benchmarks appear these days.

Sean Christmann made the one, which is geared towards measuring complex UI performance. You can check it out here along with an explanation on why bubblemark is not particularly relevant for the task.

For me the value of bubblemark is actually more in education, than in measuring. You can take it and see, how things could be implemented in different platforms. Consider it a rich “hello world” for RIA, which shows the basics — text, graphics, animation, and interaction with the app from a webpage.

Some stats

Finally, I checked out website stats and here are some interesting numbers:

  1. The site was visited 105,000 times by 81,000 visitors
  2. Most users are from US and China
  3. The most requested demo is Silverlight 1.0 closely followed by Silverlight 1.1
  4. Microsoft was the most active “corporate user” of the site with over 2000 visits originating there
(categories: Solutions box)

iPhone performance in Bubblemark

By Alexey Gavrilov on September 24, 2007

From all benchmarks at bubblemark.com iPhone is only capable to complete dhtml one.

Here are the results compared to Safari 3.0.3 (Windows) running on my laptop.

iPhone JavaScript performance

Note that iPhone framerate is capped at 27 fps, which is probably reasonable to keep it stable. iPhone JavaScript performance in this test is roughly equivalent to Pentium M running at 66 MHz and approximately 1/10 of the laptop running in a power saving mode. Developers beware!

Here are the numbers used in the chart:

Pentium M 1.7 GHz
Safari 3.0.3 (Windows)

1 - 96 fps
8 - 93 fps
16 - 92 fps
32 - 62 fps
64 - 30 fps
128 — 10 fps

Pentium M 1.7 GHz @ 600 MHz
Safari 3.0.3 (Windows)

1 - 96 fps
8 - 90 fps
16 - 65 fps
32 - 26 fps
64 - 10 fps
128 — 3 fps

Apple iPhone (ver. 1.0.2)

1 - 27 fps
8 - 22 fps
16 - 9 fps
32 - 3 fps
64 - 1 fps
128 - <1 fps

(categories: Technology, Solutions box)

Quick starts for AIR, Silverlight, and JavaFX

By Alexey Gavrilov on August 28, 2007

Yesterday DevX.com published my article Crash Course in Next-Gen RIA: AIR, Silverlight, and JavaFX. It provides a quick introduction to these technologies by showing how to build a simple stopwatch gadget with each if them (see the screenshot below).

stopwatch in silverlight, air, and javafx

This is my first experience writing for a magazine (right, it’s online only but still a very different genre from blogging) and overall I think it was the great exercise. I learned JavaFX basics while working on it, and built JavaFX version of the bubblemark consequently.

(categories: Technology, Solutions box)

Five secrets of a great GUI (stolen from Mac OS X)

By Alexey Gavrilov on August 1, 2007

Apple logoMac user interface looks fantastic.

Even if you’re not Mac addict, you’d agree, that it has something beyond the look — it feels good too. How did Apple do it? Can you do the same with your application?

These concepts will help you to accomplish that.

1. Continuity

Mac OS X plays the continuity game nicely in its windows manager and it makes a huge difference to user experience. In the real world, things don’t appear from nowhere. They don’t vanish suddenly either. Alice felt uncomfortable, when Cheshire Cat was suddenly appearing and disappearing, so do the users.

Continuity could be very hard to implement but it worth the effort. Ideally the screen should transform between different states seamlessly yet fast. iPhone user interface is a great example of how much you can do despite the lack of computational power. You have the power of a desktop, WPF, Silverlight, Flex and JavaFX — sure you can do better!
Continue reading…

(categories: Solutions box, Usability)

JavaFX — very cool, very slow

By Alexey Gavrilov on July 18, 2007

JavaFX benchmark

JavaFX has been the only RIA technology missing from the set included in Bubblemark. Not any longer. I built JavaFX version of the test, which uses JavaFX markup (i.e. vectors not bitmaps) for balls rendering and therefore compares directly to WPF, Silverlight and Flex.

Check out the JavaFX demo, deployed using Java Web Start here.
Here is the source code.

The first thing you’ll notice is that it’s very slow. The demo takes a very long time to load and start, and real time performance is disappointing. Here is how it compares:

JavaFX — 14 fps
Firefox + Silverlight (JavaScript) — 56 fps
Firefox + Flex — 62 fps
Adobe AIR — 62 fps
Firefox + Silverlight (CLR) — 99 202 fps (update: 202 fps after fixing main timer’s latency)

(All tests were performed on Pentium M 1.7 machine under Windows XP SP2)

It is 4.4x slower than Flash and 7x 14x slower than Silverlight (CLR-based variant).

On a positive side, development with JavaFX is fun, the language is very compact and efficient for building complex dynamic layouts. There is a great converter to JavaFX from SVG format and JavaFXPad is done nicely too.

If only it were 5x faster!

Chris Oliver’s early benchmarking results of JavaFX compiler suggest that there is a hope it could.

(update 08/27/07: Chris Oliver responds in his blog showing how you can make JavaFX bubblemark 5x faster! Here is his version and the source code.)

(categories: Technology, Solutions box)

Building Silverlight CLR applications with Notepad

By Alexey Gavrilov on June 6, 2007

Michael Schwarz explains how you can do this in his blog post.

First of all you need the Microsoft .NET Framework 2.0, which is a free download available at the Microsoft Download Center. Next we need the DLLs that are referenced by the Silverlight project. They are included in the Silverlight 1.1 Alpha plugin download.

After the installation of both files you will have the C# compiler available in you local Windows folder and the Silverlight files in c:\Program Files\Microsoft Silverlight.

That’s actually all tools you need. Read Michael’s post for the detailed explanation or download sample project including magic build.bat file here.

It’s great because a) you don’t have to download ‘Orchas’, which is not a small file by all means, b) you can build Silverlight .NET applications without buying expensive development tools (you can buy them later if you decide to go pro and don’t mind spending ~$800 to make your job easier).

(categories: Technology, Solutions box)

Silverlight: CLR vs JavaScript

By Alexey Gavrilov on May 30, 2007

Finally I managed to build the Silverlight CLR (C#) version of bubblemark demo. Check it out here (requires Silverlight 1.1 alpha).

Result by Framework
Note: Top bar is CLR

Continue reading…

(categories: Technology, Solutions box)

Java version of Bubblemark

By Alexey Gavrilov on May 15, 2007

Richard Bair from SwingLabs created a Java (Swing) port of my browser-based 2D animation test, which previously included DHTML, Flex, Silverlight and WPF variants.

Java version is one of the fastest in the list, which, however, should be discounted for the fact that it uses bitmaps-based animation (like DHTML and Flex with cacheAsBitmap=true) while Flex, Silverlight and WPF variants operate vector objects.

Both IE and Firefox run it at ~100 fps, while Opera (strangely) performs quite differently. It proves the status of the fastest browser again and gets well over 100 fps (up to 200 fps with a single object) but tends to produce some visual artifacts (see sceenshot below).

Continue reading…

(categories: Technology, Solutions box)

Startup idea: CodeTube — broadcast your demo

By Alexey Gavrilov on May 6, 2007

Like every creative person I have many ideas, which look excellent. At least they do until the next morning. Some of them stick though and keep on bothering my mind. It still has a limited capacity so I want to let some of these ideas out. Here is the most troubling one, which didn’t had a name before I started writing this so I’ll be calling it CodeTube — “YouTube for the code”. Yes, I know it’s a silly name but it’s better than The Project.

Continue reading…

(categories: Technology, Solutions box)

Silverlight 3D demo

By Alexey Gavrilov on April 6, 2007

WPF/e 3D demo
Click on the screenshot to open demo page.

Microsoft has no plans for supporting 3D in Silverlight (formerly WPF/e) but since they give us a decent 2D vector renderer it’s quite easy to implement simple 3D graphics using JavaScript and standard WPF/e shapes. As an example I added third dimension to my 2D animation benchmark.

The hard part was to make objects display in the right z-order. WPF/e doesn’t have zIndex support at this time (update: it was added in Silverlight 1.1 alpha) so to manipulate display order you have to change object position in the objects tree. I figured out that to make it work smoothly I have to sort all scene objects by depth first and then render them from front to back (check out the source code to see how it’s implemented).

The result looks good in my opinion although it’s notably slow in Firefox (too much alpha-blending I guess).

(May 30, 2007: I updated this post with the new name of WPF/e)

(categories: Technology, Solutions box)

Apollo Alpha 1 performance

By Alexey Gavrilov on March 20, 2007

I used Adobe’s Apollo Alpha 1, which was released today, to package Flex and DHTML versions of my web animation benchmark. The goal was to try the thing in the action and see how its performance compares to Flex and DHTML animation running in the browser.

Apollo is really cool (see screenshot below) and packaging both Flex and DHTML applications with it is very easy.

Apollo running Bubblemark

Here are some performance results (compared with the same code running inside the browser), which I got on Pentium M 1.7 running Windows XP SP2.

Animation performance in frames per second (fps); higher fps means faster performance.

Browser DHTML Flex Flex (caching)
Apollo Alpha 1 98 65 172
IE 6.0 56 61 90
Firefox 2.0.0.1 55 52 60-90*
Opera 9.01 94 50 100

* Unstable

Please note that Flex version of the test was running with transparent window. HTML-based Apollo applications doesn’t support this (just like any other web-browser).

Although Apple WebKit in Apollo scored 98 fps it looked like its real refresh rate is less than 20 fps and it simply skips rendering of most frames. Opera, while showing the same number, feels much smoother.

I also checked memory consumption and while both applications start with ~30Mb RAM usage the growth rate (yes, memory leaks, which is of course fine for alpha) is quite different. Flex-based Apollo app does only ~1.2 Mb/minute while HTML-based makes as much as 10 Mb/minute.

If you have Apollo runtime installed you can try both applications:

Flex-based bubblemark (download source code)
HTML-based bubblemark (download source code)

(categories: Technology, Solutions box)

WPF/e vs DHTML vs Flash vs WPF performance test

By Alexey Gavrilov on February 27, 2007

WPF/e benchmark screenshot

If you just want to try it yourself here is the page with all tests.

Below are some benchmarking results I got using IE 6.0, Firefox 2.0 and Opera 9.0 on my laptop. For those of you, who like reading here is a longer story.

Continue reading…

(categories: Solutions box)

How to: Getting Certified for Windows Vista logo

By Alexey Gavrilov on December 19, 2006

Certified for Windows Vista badgeHurray! The product we have been developing for one of our customers successfully passed Microsoft’s “Certified for Windows Vista” logo testing (in fact we already have two applications passed it by this time). Since the product itself doesn’t require deep interaction with the system, we expected that preparing it for the submission would be a piece of cake but it wasn’t that simple. Actually it wasn’t simple at all. It took 3 weeks and two working weekends to put it together and submit for testing with confidence.

We started by getting Vista iso from MSDN downloads and installing it under VMWare Server. We used VMWare to have “physical” (as opposed to Remote Desktop) access to that system from different workplaces. That was the simple part yet we found that it won’t install from iso directly but rather needs to be burned on real DVD (the iso is 2.5 Gb) and installed from there. It is reported that the reason is VMWare’s bug causing problems handling large iso images. Anyways, we get it installed and working (oh by the way it’s still working exactly on the same processor, which fed this web-page to you — both Linux, running this webserver and our test Windows Vista are running under VMWare on the same physical server — isn’t it amazing?)
Continue reading…

(categories: Solutions box, Vista)

Download authorization (C#, PHP)

By Alexey Gavrilov on December 13, 2006

Since Google Analytics tells me that the previous post on parsing http query string with regular expressions on C# is pretty popular here is more web developer stuff. Consider you need to implement password protected file download — that is to make some file(s) available to registered users only or say to those only who visited your site. It’s pretty easy to do and all you need is to put your file off folder accessible from the web and wrap download into the script, which would perform authorization first and then feed the file from local file system to user’s webbrowser. While the task is trivial enough to do it yourself, making it nice requires certain efforts or you can get the solution from here.
Continue reading…

(categories: Solutions box)

Things everyone must know about GUI design

By Alexey Gavrilov on December 3, 2006

Vista iconsMicrosoft’s User Experience team did an excellent job putting together Vista User Experience Guidelines. It’s very good, detailed and actually has broader application than just Vista. I wish every software developer / designer read it and at least tried as hard as possible to adhere to rules and suggestions presented there.

Here are some of my favorite’s rules from the guidelines:

“Don’t spend time rebuilding standard UI components; use that time instead to innovate in meaningful ways based on your core competencies and understanding of your customer needs.”

It makes sense although the reality is that over the next five years Windows XP and older systems will still represent significant market share so most developers won’t be comfortable abandoning skins just because on Vista standard controls look good enough.
Continue reading…

(categories: Solutions box, Usability, Vista)

C# function to parse HTTP query string format

By Alexey Gavrilov on November 28, 2006

This is not intended to parse your page’s query string (it’s already parsed by asp.net) but rather to parse data someone would return you in this format. In my case this was PayFlow Pro gateway response. I couldn’t find anything ready to use so I wrote this one myself. If you aware of better solution, please let me know.


Hashtable parseQueryString(string qstring)
{
        //simplify our task
        qstring = qstring + "&";

        Hashtable outc = new Hashtable();

        Regex r = new Regex(@"(?<name>[^=&]+)=(?<value>[^&]+)&", RegexOptions.IgnoreCase|RegexOptions.Compiled);

        IEnumerator _enum = r.Matches(qstring).GetEnumerator();
        while (_enum.MoveNext() && _enum.Current != null)
        {
                outc.Add(((Match)_enum.Current).Result("${name}"),
                        ((Match)_enum.Current).Result("${value}"));
        }

        return outc;
}
 
(categories: Solutions box)

SipBomber 0.8

By Alexey Gavrilov on September 21, 2006

What is it

SipBomber is sip-protocol testing tool for Linux originally developed by Metalink in 2003 for internal use and released later as GPL open source product.

SipBomber screenshot

What’s new in 0.8

Although we knew it was downloaded and used by thousands of developers, we received very little feedback on it and ceased support for this software. The old version (ie 0.7) can be found here. After the launch of this new website I found by looking into server log files that many people still want to download it. Therefore here it is again. The version is 0.8 and now it compiles fine with the latest gcc (tested with Fedora Core 4). If you managed to build 0.7 yourself you don’t need to download 0.8! Here are few links for those who know what to do:
Continue reading…

(categories: Solutions box)

Getting back your zip’s and exe’s from Microsoft Outlook

By Alexey Gavrilov on September 5, 2006

This is an old story. Few years ago Microsoft decided to protect casual Outlook users from mail viruses and removed access to all potentially unsafe attachments with no GUI option to turn it back.

What a wonderful solution!

Anyways here is how you can turn it off.

  1. Close your Outlook
  2. Download this file
  3. Launch it (just double-click on it)
  4. When prompted “Are you sure…?” click “Yes”
  5. Open Outlook and “bingo!” get your attachments

And the last thing. Never open executable files received from unknown recipient.

How it works

The ‘unlock_attachements.reg’ contains records for system registry which tell Outlook to remove .exe, .inf and .zip extensions from its dangerous files list. You can open this file in the notepad and modify it to add some other extensions (like .url).

Since I don’t know which Outlook version you are using I included necessary lines for all versions I know (if it doesn’t work for you — leave a comment with Outlook version and we’ll figure it out). This adds some unnecessary records to your registry but I’m sure you don’t care about extra 20 bytes on your HDD.

Happy Labor Day!
Alex

(categories: Solutions box)