Obrigado BrazilJS

This past week I had the extreme pleasure of returning to one of my favorite countries to visit, Brazil, to speak at it’s premiere JavaScript conference, BrazilJS. I’ve been to Sao Paulo in the past when I keynoted PHPBrazil but while I was there, everyone told me that I needed to get down to Porto Alegre and now that I’ve been there, I agree with them. I’m going to break this down into three posts. The first about the country and the visit. The second about the conference itself called A little about BrazilJS. And the third about my talk called The Perf Doctor Is In.

Sao Paulo

Sao Paulo was, to be honest, a bit overwhelming. It’s the commercial center of Brazil with 11 million people and an absolutely insane amount of traffic. I was introduced, however, to to some unbelievably passionate and intelligent people in my short time there. I still have many friends from Sao Paulo from my short trip. I was introduced to cachaça (key ingredient in my favorite drink caipirinha – it’s sort of a Brazilian mohito), the concept of Brazilian BBQ (more on this in a bit), found out that two motorcycles can motorcycle cutting traffic in Brazilactually travel down the highway balancing a bookcase between them and fell in love with the country. My favorite day was when we got down to the beach and everybody relaxed. I had never even heard of foot volley which is volleyball with all of the ball handling rules of soccer. Continue reading

Working on a HTML5 REf Poster

Question marksThere’s a ton of new things that I’m working on in my new job on the IE Dev Marketing team but one of them is a 3 part reference poster for HTML/CSS/JS. I’m trying to figure out the correct content and the like for these reference posters and using a ton of things as inspiration. However, I’m kinda at a head smacking keyboard point so I thought I’d ask for help.

What would you like to see on a set of reference posters that we give away at conferences, user groups and the like?

Chances are that you’ll see one of these posters being given away at an event near you sometime soon so it’s in your best interest to chip in and give me some ideas. 🙂

I really don’t want to end up with something as messy and text heavy as some of the reference posters that I’ve run across (not pointing fingers but http://www.visibone.com/html/charts.html…).

First I saw the posters up at HTML5 Poster – http://html5poster.com/. Those are beautiful and I think that people like them but I’m really leaning towards something that would be useful in addition to beautiful so that people would keep them up and use them for a long time to come.

One of the first semi technical inspirations was poster that was part of a kickstarter – http://www.html5blog.org/2012/09/01/the-best-html5-poster/ but I looked at the kickstarter and it failed to raise the desired $4000 in funding so I’m not sure what that tells me.

The next one that I saw was from XHTML-Labs which you can check out at http://www.xhtml-lab.com/html5poster. There’s a similar one for CSS (https://gumroad.com/l/css-cheat-sheet). Reality is that these are not a new concept (http://blogs.msdn.com/b/cbowen/archive/2007/12/09/got-tech-posters.aspx). I’m not ashamed (well, not that ashamed) to say that I had the Silverlight 1.1 Developer Reference Poster (http://www.microsoft.com/en-us/download/details.aspx?id=10423) on my wall at one point. But I started thinking about that and wondering if that’s valuable. Would you like a reference of all of the HTML tags possible and their associated attributes?

Or would you prefer something that was a little more targeted at the new stuff so assumed that you know the basics of the head, body, ul, ol, li and the like? Or is that even useful?

I also saw the SitePoint HTML Reference poster – http://www.sitepoint.com/have-you-got-your-free-sitepoint-html5-reference-poster/. That one goes through and shows a number of little useful tidbits and how they were built. Thoughts on that? It breaks down the idea of three posters being HTML, CSS and JS but we could continue to add to it over time and it could be more than three posters and end up at 10-20-* depending on how many little ideas we come up with. What I don’t like about this is that this seems like a LOT more work than the simple reference ala the ole Silverlight reference poster that I used to have.

There’s also the periodic elements poster but AlaraMills.com at http://alaramills.com/store. It’s definitely a unique take on the HTML spec. It’s not something I’m going to do but I really like the take. My problem there is that then how do I take it to JavaScript and CSS as well.

So I put it to you, what kind of poster would you find valuable/desirable? What would you hang on your wall and refer to?

Please use the comments below or if you want to send me a not privately, ping me on twitter (@joshholmes) or email me at [my first name].[my last name]@[where I work].com (hopefully you can figure out the email without too much trouble…).

Thanks!!!

Touch Me, I Dare You…

Touch me I dare you This week I’m at JSConf and had the pleasure of speaking. The title of my talk was Touch Me, I Dare You. It’s the first talk that I’ve done since I joined Internet Explorer. One of the big things that we’re working on in Internet Explorer is touch. We think that it’s an incredibly important part of life on the web going forward. Why does touch matterThere’s a lot of reasons that we think that. One of the reasons that we think that is that is that we’re looking at the incredible proliferation of touch devices out there in the world. This ranges from all of the smart phones out there to the tablets to the laptops and convertibles that have touch screens as well. It’s a growth space for sure. Touch has reached into almost every aspect of our lives. There’s even a touch screen TV with an interactive display just off the lobby in the hotel here at the conference.

What's your strategy for dealing with touch?

So what’s your strategy for dealing with touch? The first possible strategy is to just simply ignore touch and let the defaults take care of things. If you do that, the browser will treat your finger as a mildly inaccurate mouse. This is a legitimate strategy as long as it’s your strategy and you do it deliberately and take on board some of the other best practices which I’ll talk about in a moment. The second strategy is to retrofit touch support onto your web site. This is a loosing strategy every time. It’s much better to work the other way around and design for touch first. This ensures that you’ve taken the best practices into account typically mouse and keyboard just work at that point.

Hover sucks

The first of the best practices is that hover sucks, don’t use it. The key to touch is that it’s touching. The screen has no idea that your finger is a millimeter from the screen. Some of the browsers will help you and make the touch emulate a hover but it’s not a great experience. Even with a mouse actually, hover still sucks because it’s not a natural motion to try and stay over your content even if it’s not a straight line in order to keep the menu open. If you don’t believe me, try it sometime and think about the users that keep loosing the menu when trying to move from the top to a sub menu.

Touch sized buttons

Hopefully obviously, you need to use touch sized buttons. It’s a great thing that a lot of devices, especially smart phones, allow you to zoom in in really easily into your different controls and interactions but this is not fun. The ideal way to do this to build for touch first and everything that you do here will actually make your mouse and other inputs work better.

Demo of different size fingers The reality is that the finger is much wider than a mouse. How wide? Depends. An NBA player has a finger that’s kinda in the 20mm width range. That’s a big finger and he’s not going to be able to use your site on his touch device. Normal is closer to 11mm which works out to roughly 42px depending on the size, resolution and pixel density of your screen.

Ergonomics & touch

And with touch more than any other type of input, you need to keep your user’s context in mind. They could be walking, holding the device on their lap, on a train, in a stand on a desk like a normal monitor or any other type of context. All of these contexts mean that accuracy might or might not be incredibly accurate. You should design with large targets with plenty of breathing room to help with that. It’s also important to give visual and potentially audio feedback on touch to let people know that something actually happened.

how far to fingers reach on a tablet

Also for touch, you have to think about how long a finger is and how comfortable it is to reach different points on the screen. You can check this yourself on your own touch device. Reaching things in the top center of the screen is tough whereas on the sides and the bottom is a lot easier.

Design for touch first

The natural reading areas are at the top center of the screen. This is true regardless of what type of input you are using because that’s where the eye goes.

 

Remember there's more than one finger

Another thing that is incredibly important to remember is that there’s more than one finger that they could be playing with. It’s actually very possible that two people will be touching your site at the same time. This is in stark contrast to a mouse as there’s only one on the screen at any point in time.

remember there's more than one kind of input

The other thing to realize is that there’s very potentially more than one type of input happening at any given time. People can use mouse, touch and pen input all at the same time. It’s important to keep this in mind and build for that from the beginning.

So how to I do all that?

That sounds like a lot of stuff. So how do I do that in the simplest way possible. One of the issues with a lot of current code is that it will work for either touch or mouse. Or it will ignore pen input. The reality is that we can, with one simple set of events, manage for all of that.

Go Pointers

With IE10, we implemented a new interaction model called Pointer Events. It’s currently implemented as a MS prefixed set of events in just IE10 but we’ve submitted it as a spec to the W3C. The reception from the W3C and surrounding community has been outstanding. It made it from submission to Candidate Recommendations in a fairly blazing 9 months. We’ve been working with a lot of other browser vendors and we’re looking forward to some wide spread adoption.

W3C Pointer StandardThe event model is fairly similar to what you’d see with your mouse but the events you catch are much richer.

The events are pointerdown, pointerup, pointermove, pointerover, pointerout and pointercancel. I made the mistake in the slides of upper casing the second word in each of the events.

Pointer Event Models

At the moment, in IE10, the events are MS prefixed and you should use those in IE10. We’ll talk about support for other browsers in a moment.

 

 

Values on the events include width, height, pressure, tilt, rotation, and more

On each of the events, you get width, height, pressure, tilt, rotation, pointerType (mouse, touch, pen…), event type and more. The great news here is that

 

 

Coding for multi-touch

Coding for multi-touch is actually pretty simple. Each time you get one of the events, you should iterate through the list of current pointers and react to each of them appropriately. This is the primary difference that you’ll have to make to move from mouse and interacting with one item on your page to more than one and interacting with multiple items on your page. Gestures and the like were not something that I discussed primarily because it’s a complex subject and I only had a short 30 minutes.

current touch support on IOS/Android

Current touch support on IOS and some android devices is based on the Apple recommendation of touchstart, touchmove and touchend. There are a couple of issues with this approach. Sidestepping the politics and focusing on the technical, touchstart handles exactly what it says – touch. It doesn’t handle mouse or pen so you have to code separate paths for each.

Touch first coding With pointer events, you only have to code for one thing if the browser supports pointer events but you will have to polyfill on the browsers other than IE10 at the moment. You can do this by hand by just doing a fallback to touchstart and mouse. There’s actually an unintentional bug in the code sample in my slide. I do the pointer event but in the fallback, I only catch touch OR mouse, not both which means that someone with a touch screen won’t be able to use a mouse.

Use polyfills for older browsers

Regardless, it’s much better to use one of the polyfill libraries such as hand.js from Bitovi. I still like to default to the MSPointer events in IE10 because they are native and then polyfill the other browsers where needed at the moment.

 

 

if (window.navigator.msPointerEnabled) {
	
	// MSPointer events which are only in IE10. Use if possible as they are native
	Event(leftOverlay, "MSPointerUp", function() { 
		if(Game.canStart()) { Balls.release(Player.ONE); } }, false);
	
	Event(rightOverlay, "MSPointerUp", function() { 
		if(Game.canStart()) { Balls.release(Player.TWO); } }, false);
	
	Event(leftOverlay, "MSPointerMove", Game.movePaddle, false);
	
	Event(rightOverlay, "MSPointerMove", Game.movePaddle, false);

}

else
{
	
	// these are the polyfill events for hand.js. Use these as a backup currently
	
	// as these are the polyfill.
	
	Event(leftOverlay, "pointerup", function() { 
		if(Game.canStart()) { Balls.release(Player.ONE); } }, false);
	
	Event(rightOverlay, "pointerup", function() { 
		if(Game.canStart()) { Balls.release(Player.TWO); } }, false);
	
	Event(leftOverlay, "pointermove", Game.movePaddle, false);
	
	Event(rightOverlay, "pointermove", Game.movePaddle, false);

}		

wrapup

Hopefully this has been helpful. There’s a lot more that I didn’t get a chance to cover that can be found at http://modern.ie as well as http://docs.webplatform.org/PointerEvents. And as always, you can find me on http://twitter.com/joshholmes.

BTW – the slides are up at http://www.slideshare.net/joshholmes/touch-me-22254401 

Good luck and go touch something…

New frontiers for the Holmes clan

IE LogoIt’s with mixed emotions that I’m leaving Ireland and headed to the exciting world of Redmond, WA, USA. I’ll be moving in early May to the IE Developer Marketing team joining such great folks as Justin Garret . This is the team that’s doing some amazing work such as http://modern.ie and http://arcade.atari.com to name two high profile projects. If you haven’t played with either of these, you should go look at both of them. The partnership with Atari is not only a ton of fun, it’s educational. I’ve used the material there to figure out handling touch behaviours in Win8 apps and more. The http://modern.ie project gives you quick and easy testing of your site for IE with or without you having to run IE and advice on how to fix common issues.

 

The past 2+ years here in Ireland have been an amazing experience.

 

IrelandFrom a work perspective, I’ve met and worked with some of the smartest and most passionate people that I’ve ever had the pleasure to know and had a lot of fun. I love Ireland’s tech eco system, particularly the start-up scene which is well outlined by Frontline Venture Capital (check slide 24 – 🙂 ). I’m going to miss being a part of that scene. I’m not going to get into name dropping here because inevitably I’d miss someone and there’s too many to name but I’ve met and mentored some incredible people at companies. Some of them have ended up installing hardware and software in the Microsoft Technology Centres around the world or high profile projects for Cadbury’s or Lufthansa Airlines or have become the default mechanism for navigating Dublin or are the best way to book a tee time or listen to the radio on Windows Phone and I could go on and on and on. I’ve keynoted a number of great conferences around Europe, spoken at the local Google Tech User Group (yes, they knew that I work for Microsoft and I survived… 🙂 ), spoken at Dublin Web Summit multiple times, met Bono, run envisioning sessions with organizations from Failte Ireland (tourism board for Ireland) to the largest bookie organization in Ireland to many of the top end design firms, ran data centre tours through the data centre based here in Ireland, run international conferences from clubs here in Dublin, written prototypes for apps for banks, local government and more… Additionally, I’ve learned a ton about what it’s like working in a small country and in a small subsidiary of a large company. Both of these lessons have been very interesting, both challenging and exciting at the same time. It’s been a fun and impactful 2 years that I’ll never forget.

 

Mountain Biking in the SnowFrom a personal perspective, I love Ireland. It kinda goes without saying that Scotland is the only place in the world that can rival Ireland for golf. I’ve also found a new passion in mountain biking here and there’s a ton of opportunities to do that. I’ve found rugby as a fantastic spectator sport and I wish that I had grown up playing it (unfortunately my knees are too bad to do so now). But the real impact has been on my family. As you might know, my youngest daughter has special needs (my wife blogs about it at http://www.phoebeholmes.com) and the programs here for her have been unparalleled. The St. Michael’s programs and schools are amazing and if I ever get to an independently wealthy status, I want to try to found something like it in the US. She’s learned to swim, work safely in the kitchen, potty training and more. I could rave on and on about the systems here but my wife does a great job capturing it on her blog. My other daughter has taken up Camogie which is a brilliant, vicious and fast paced game. She’s in the theatre, dancing and has taken up a ton of other hobbies. My boys are doing very well here also. My oldest is in “transition year” which is a brilliant concept. In short, it’s a renaissance year. The year is broken into 4 modules and in each one of these they take different subjects. They try many different types of sciences, maths, arts, sports and so on. A different set each module. They take a ton of field trips to all the museums, parks and more. They are required to do at least 2 weeks of work study where they find a job in a company for a week at a time to learn what different types of companies do. My son did work in a game dev company called BitSmith Games who produces a fantastic game called Ku: Shroud of the Morrigan. He got to do a lot of testing and learned a lot about Unity game development. And my wife fits right in here. She’s half Irish by decent so she looks the part but more so her language, mannerisms and more have all taken on a distinctively Irish slant. She’s not picked up the accent but everything else is spot on. 🙂 She’s gotten involved in the PTA, run fund raisers for the school, toured most of Ireland, been on the radio, been on TV, was interviewed for an international magazine, written large portions of a book, had several blog posts go crazy viral and been very active in many different social circles.

 

I’m really looking forward to the challenges presented by the IE Developer Marketing team. I’ll be based in Redmond which is a new place for me. I’ve visited a number of time and it’s beautiful. The last time I was up, I went to a huge bike swap which was awesome and really endeared me to the area. From a team perspective, I already mentioned some of the things that the team does and I’m really looking forward to working with some really brilliant people. I’ve had the pleasure of meeting a number of the people across the teams that I’ll be working with on a daily basis. I think I can learn a lot from them which always excites me.

BTW – I’m starting in Redmond on May 6th so I’ve got a few more weeks to catch up with folks here…

I’m going to miss Ireland but A: I’ll definitely visit (invite me to come speak at your conference… 😉 ) and B: in this fantastic digital age, it’s not hard to keep in touch. I’ll still be blogging here at https://joshholmes.com. I’ll continue to be on twitter at @joshholmes and I’m on LinkedIn at http://ie.linkedin.com/pub/josh-holmes/0/39/791/.

 

Looking forward to connecting with you and staying connected,

Josh Holmes

Ireland Roadshow

Ireland I’m going to be doing a roadshow around Ireland talking about Windows 8 and Windows Phone development. Come join me for a lap around Windows 8 and Windows Phone 8 development. In this whirlwind afternoon, I’ll pack in a ton of content.

I’ll kick off with a look at the most exciting development opportunities in the market right now – Windows 8 and Windows Phone.

Then I’ll step into the how with the essential things that you need to know about developing on Windows 8 including an overview of the development languages, compatibility with other platforms and making your app really stand out in the crowd with the deep integration into the Windows 8 platform.

Next I’ll dive into Windows Phone 8 and ensure that you have a good grasp on the platform left to right ranging from sharing code with Windows 8 to developing HTML5 based games to hijacking the camera and providing some outstanding lens support.

And I’ll finish up by talking about how to backend all of these applications with a robust restful service accessible from any platform hosted on the Azure platform with the Azure Mobile Web Services.

This is happening on the back of the partner roadshow which will be in the mornings and I’m hitting the afternoons.

Registration links: 2pm to 5pm each day

Belfast Developer Event – 26th February

Cork Developer Event – 4th March

Limerick Developer Event – 5th March

Galway Developer Event – 12th March

Sligo Developer Event – 13th March

Looking forward to seeing you there.

Scale out, not up… Cloud Architecture 101

scaleA common question that I get is how to cut down on one’s Azure bill. People will come to me because they are finding a way to control their spend in Azure while not hurting their service levels. Most of these folks are big proponents of the cloud because of how agile they can be and the fact that it’s got geo-replicated content and traffic and so on.

The first time that I saw this question, I was thinking that this could be tough to tackle as Azure’s pricing is fairly aggressive until I saw their architecture. And it turns out that in most cases, it’s the same issue.

A very common architecture is two large web role instances or so in front of a small worker role instance with some storage plus a SQL Azure database. The basic problem here is that the two large instances means that their unit of scale is a large instance which is an 4 core box with 7 gig of memory that costs about $345 a month to run. This is not leveraging cloud computing. There are definitely times where you need a big iron box but for 99% (made up statistic) of web apps, it’s overkill. Actually, overkill is the wrong term, it’s scaling vertically by throwing bigger hardware at a problem rather than what the cloud is really good at which is scaling horizontally.

The fundamental difference between architecting for cloud verses architecting for old school on premise or fixed contract hosting is that in the old world you had to architect and build for the maximum and hope you never hit it. In the new world of cloud computing, you architect for scaling out horizontally and build for the minimum. This means building small stateless servers that can be added or thrown away on an hour by hour basis.

The fix to these customer’s cost issues is simple, move from 2 larges into how ever many smalls you need and then scale up or down as needed.

The reason that they were running 2 larges rather than 2 smalls is that they are concerned about traffic spikes and the site going down. I completely get that and there are a number of great solutions to this issue. We don’t “auto-scale” automatically in Azure. The reason for this is simple, we charge your for instances that are spun up so it’d be in our interest to aggressively spin up new instances and charge you for them. To avoid even the appearance of impropriety, we don’t auto-scale. However, we give you all of the tools to write your own auto-scaling or manage it remotely.

How do you know how many instances you should be running? Go to the Windows Azure portal and look at your current usage. There’s a ton of diagnostics available through the portal. You should go spelunking there and see what all they have. Some folks are running as low as 1-2% utilization whereas we are pushing for folks to try and run on average between 70 and 80% utilization. In a traditional data centre, we’d never never want for that to be our “normal” for fear of spikes but in Azure, your spikes can be soaked up by the rest of the infrastructure.

Once you figure out where your normal should be, build that out and then use some of the tools to scale up or down as needed.

Mobile tools:

http://udm4.com/iPhone/CloudTools_for_Windo-701342. That’ll give you health stats on your instances and then you can turn them on and off from the phone.

http://mobilepcmonitor.com/ – will let you know when your site has any issues at all. X amount of memory being used, X number of users, server goes down and the like. Clients on iphone, windows phone, windows 8, windows 7 and so on.

 

Autoscale with your own code:

http://archive.msdn.microsoft.com/azurescale – auto-scaling yourself sample all.

http://channel9.msdn.com/posts/Autoscaling-Windows-Azure-applications – Windows Azure Application Block that does auto-scaling for you.

http://channel9.msdn.com/Events/WindowsAzure/AzureConf2012/B04 – more great content on how to do this yourself.

 

Third parties to manage your scale:

http://www.paraleap.com/AzureWatch offers monitoring and auto-scaling.

http://www.azure-manager.com/ – does what it says on the tin. Manages azure for you.

http://www.italliancegroup.com/ – does a managed service/partnership where they manage your infrastructure in Azure.

 

In short, if you are looking at cloud computing, make sure that you architect for the right kind of scaling…

The 12 Apps of Christmas

imageYou know that I’m a Windows Phone/Windows 8/Azure evangelist for Microsoft Ireland. As part of that, I sometimes get to do fun things like run some fun Christmas promotions. This month we’re running a simple promotion called the 12 Apps of Christmas. Here’s the deal… Build an Windows 8 app get a phone.

 

Very simple offer, we have 12 Windows Phone Nokia Lumia 710s to reward those developers that have been very good.

 

To qualify you need to publish a Windows 8 Store app between December 7th and December 31st and email appireland@microsoft.com with a link to your app and your name, address and phone number for delivery. If we have any in stock still, we’ll send one out tout suite… 🙂

 

Rules in brief:

1. You need to be an app developer with an Irish  or Northern Irish developer account. This, unfortunately, doesn’t include Microsoft employees.

2. You app needs to be live in the Windows 8 app store before December 31st.

 

Rules in not so brief (the lawyers heard I might be having too much fun and got involved…):

1. Instructions on how to enter form part of the conditions of entry. By participating entrants agree to be bound by these conditions.

2. The promoter is Microsoft Ireland Limited, of Microsoft Ireland Building 3, Carmenhall Road, Sandyford Industrial Estate, Dublin 18, Ireland.

3. Qualifying apps must be published to the Windows Store (previously called the Windows 8 app store) between December 7th 2012 and 12 midnight GMT December 31st, 2012.

4. Publish 1 new apps to receive a Nokia Lumia 710 (subject to availability)

5. Nokia Lumia 710 phones will be distributed first whilst stocks. Once all phones have been awarded the promotion will cease.

6. The sooner you publish your new apps the sooner you’ll receive your Windows Phone (subject to availability).

7. Apps must be new and published to the public marketplace and excludes updates to existing apps.

8. App must meet the Windows App submission guidelines. There will also be a subjective criteria applied to exclude apps of very low quality that offer no value to Windows 8 users.

9. In exceptional circumstances apps that are not deemed of sufficient uniqueness or quality may be excluded. This decision is solely Microsoft’s to make

10. This offer is only open to developers based in the Republic of Ireland and Northern Ireland who submit apps to an Irish or Northern Irish registered Windows Phone Marketplace account.

11. This offer is limited to the first 12 developers and is limited to 1 phone per developer.

12. There are a number of promotions in progress with Nokia and Microsoft in Ireland and the UK; the apps submitted for this challenge must differ from those submitted elsewhere. i.e. no double counting.

13. The promoter reserves the right to verify the validity of entries and to disqualify any entrant who the promoter believes either has tampered with the entry process or has submitted an entry that is not in accordance with these conditions of entry.

14. The prizes are not exchangeable, transferable or redeemable for cash.

15. The Prize does not include:

a. Any standard or other call or data costs billed by a mobile operator/service provider.

b. Any associated costs billed by a mobile operator/service provider.

16. Successful entrants will be notified via email.

17. The phone winner is liable for all taxes and benefit in kind that may be incurred as a result of the phone.

18. Subject to any applicable law which cannot be excluded, the promoter and its related bodies corporate shall not be liable for any loss, damage or injury suffered or sustained (including but not limited to direct or consequential loss or loss arising from negligence) arising directly or indirectly out of or in connection with the promotion or any prize.

19. Before the prize is awarded, the winner will be required to sign a form to release the promoter from and indemnify the promoter against, any and all liability arising from the use or participation in the prize.

20. Any costs associated with entering the challenge are the responsibility of the entrant.

21. The promoter’s (Microsoft) decision is final.

22. The promoter assumes no responsibility for, and the entrant releases the promoter from responsibility for, any failure to receive an entry or for inaccurate information or for any loss, claim, damage or injury to person or property (including computer systems and servers) as a result of the entrant’s participation in this promotion or the conduct of the promotion generally or as a direct or indirect result of an entrant’s error, any technical problem of any kind including communications or network failure, unauthorized access to, transferring or theft of data, whether caused by the entrant or associated with the equipment or programming used in the conduct of this promotion. If, because of any such problem, this promotion is not able to be conducted as planned and/or the promotion’s administration, security, fairness or integrity are compromised or affected, the promoter may cancel, terminate, modify or suspend the promotion and/or disqualify any entrant involved in interfering or tampering with the conduct of this promotion in any way.

Custom Search with Azure Mobile Services in JavaScript

image I’ve published my first little Windows 8 app using the Azure Mobile Services in JavaScript. It was incredibly quick to get up and running and more flexible than I thought it would.

The one thing that was tricky was that I’m using JavaScript/HTML5 to build my app and since I don’t have Linq in JavaScript, doing a custom date search was difficult. Fortunately I got to sit down with Paul Batum from the Azure Mobile Services team and he learned me a thing or two.

I already knew the backend of Azure Mobile Services was node.js. What I didn’t realize is that we can pass in a javascript function to be executed server side for a highly custom search the way that we can with Linq from C#. The syntax is a little weird but it works a treat.

itemTable.where(function (startDate, endDate) {
            return this.Date >= endDate && this.Date <= startDate;
        }, startDate, endDate)
    .read()
    .done(function (results) {
        for (var i = 0; i < results.length; i++) {
           //do something interesting
        };


Notice that inside the where function, I’m passing in another function. This function gets passed back and operates server side. The slightly wonky part is that the function has to accept the parameters that you pass in as well as you have to pass the variables that will be passed to this function. So reading that sample carefully, see that we’re passing three variables to the server side including the function and then the two actual variables that we want to pass to the function that executes on the server.

This allows for some awesome flexibility, well beyond custom date searches. 🙂