SOS

Shane O'Sullivan's technical blog… really ties the room together

How to easily check a WebOS app version

Posted by Shane O'Sullivan on October 7, 2011

If you’re a WebOS developer and would like to be able to notify your users when a new version of your app is available, a very efficient way to do that is to use the Yahoo Query Language.

Take a look at this page:

It shows a YQL query to select the version of the app com.chofter.palmdevutils, giving the following result

{
 "query": {
  "count": 1,
  "created": "2011-10-07T14:58:53Z",
  "lang": "en-US",
  "results": {
   "p": "Version: 1.3.0"
  }
 }
}

Fetching this JSON object requires far less data that reading the entire HTML page and parsing it yourself. To see the final link that you would use, copy the link from the bottom of the Yahoo page, like this one http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20html%20where%20url%3D%22https%3A%2F%2Fdeveloper.palm.com%2Fappredirect%2F%3Fpackageid%3Dcom.chofter.palmdevutils%22%20and%0A%20%20%20%20%20%20xpath%3D’%2F%2Fdiv%5B%40id%3D%22app-price-system-version%22%5D%2Fp%5B3%5D’&format=json&callback=

Posted in Javascript, WebOS, yql | 1 Comment »

JavaScript performance tips

Posted by Shane O'Sullivan on September 28, 2011

Every now and again a question comes up at work as to which of two or more approaches to the same problem in JavaScript performs better. I’ve started using the fantastic site jsperf.com to document these, so I’ll append to this post whenever I add a new test. I hope you find these useful, as they are answering questions that pertain to practical JavaScript usage.

Creating a regex inside and outside a loop

Declaring variables in a loop or outside it

Using hasOwnProperty or testing with undefined and void 0

Using indexOf or substring to test the end of a string

Extend Without Foreach

Posted in Javascript, performance | 1 Comment »

Tip: Declare regular expressions once and reuse for performance win

Posted by Shane O'Sullivan on September 22, 2011

A pattern I see quite often in JavaScript is of people using a regular expression in a loop, e.g.

 

for (var i = 0; i < array.length; i++) {
array[i].match(/something/);
}

The naive assumption is that a regex is some special native thing, like a boolean. However regular expressions have a cost to construct, which you can see in this performance test – http://jsperf.com/creating-a-regex-in-and-outside-a-loop

So, if you’re using a regular expression in JavaScript more than once, declare it first and reuse it to see a dramatic performance gain

Posted in Javascript | 3 Comments »

CSS Box Sizing makes me happy

Posted by Shane O'Sullivan on September 13, 2011

Quick note: For anyone fighting for years against the CSS box model, where the visible size of an element depends on the sum of it’s width, height AND padding, check out the box-sizing: border-box;. It does exactly what we need, where if you say


.myclass {
width: 100%;
padding: 10px;
}

then myclass will still take up 100% width of its container, instead of overflowing.

https://developer.mozilla.org/en/CSS/box-sizing

Posted in Technical | Leave a Comment »

This is what a successful platform launch looks like

Posted by Shane O'Sullivan on September 2, 2011

… pity it had to happen as a result of a liquidation sale.

WebOS looks to be on it’s last legs, and HP has announced that it’ll never make new WebOS hardware. In the meantime, the fire sale of TouchPads has done fantastic things for us WebOS developers. The image below is a graph of the Flickr Mundo HD sales for 2011.

If only HP had anything resembling courage, rather than wimping out with the revelation that “Competition is hard? What? No one told me! Run away!!”, this sales trend might have actually continued for a long time.

Ah well, I’ll enjoy it while it lasts!

Touchpad Sales of Flickr Mundo HD

Posted in apps, Flickr Mundo, Palm, Tablet, WebOS | 2 Comments »

Unpacking webOS .ipk files on a Mac

Posted by Shane O'Sullivan on August 28, 2011

Quick tip: For some reason, the archive files that webOS uses as application installers are very awkward to extract on a Mac. It’s simple on Windows.

After a little digging, I found a handy script at http://forums.precentral.net/webos-development/235149-extract-build-ipkg-mac-osx.html that does the trick.

Posted in Palm, WebOS | 3 Comments »

HP Enyo talk from the London Ajax conference

Posted by Shane O'Sullivan on July 3, 2011

I really enjoyed talking about HP Enyo at the London Ajax groups conference on July 2nd.  People were genuinely interested, and hopefully will take a closer look at the framework, which I find great to develop HTML5 apps with.

You can view the talk below [source]

The slides are embedded below.

Thanks to Dylan from SitePen for organising everything and RIM for sponsoring the event.

Posted in Ajax, enyo, Palm | 3 Comments »

Come hear about HP Enyo at the London Ajax event

Posted by Shane O'Sullivan on June 30, 2011

I’m very happy to have been invite to speak at the London Ajax event on July 2nd, 2011 – http://londonajax.com/ .  I’ll be giving a talk about the new HP Enyo framework, and how you can use it to develop HTML 5 apps.

 

Posted in Ajax, enyo | 1 Comment »

Sweep line Voronoi algorithm in JavaScript

Posted by Shane O'Sullivan on March 22, 2011

Years ago I translated Steven Fortune’s sweep line Voronoi algorithm to C++, and have been meaning to make a JavaScript version for some time, but never got around to it.

Now, someone has actually done it with the D3 charting library, and it’s fantastic.  Check it out at http://mbostock.github.com/d3/ex/voronoi.html

Posted in Javascript, voronoi | 9 Comments »

Quick canvas effect prototyping

Posted by Shane O'Sullivan on March 7, 2011

I’m doing some playing around with image processing on HTML5 Canvas elements, and so I’ve hacked together a simple page for prototyping different algorithms. Check it out http://chofter.com/EffectPrototyping.

The code abstracts away most of the complexities of working with Canvas elements, and just lets you get down to what you need: your pixel manipulation algorithms.  It provides a number of test images and examples to get you started, so have fun!

Oh and yes, it’s pretty ugly :-)

Posted in Technical | Leave a Comment »

 
Follow

Get every new post delivered to your Inbox.

Join 533 other followers

%d bloggers like this: