Wednesday, October 24, 2012

jsSaturday


On Saturday, November 10, 2012, I will be speaking at JavaScript Saturday.  This event will be held in Long Beach, California. Here is the description directly from JS(SATURDAY) site:

Javascript Saturday is a complete one-day Training from the best of the Javascript experts aimed at all levels of expertise.

Have no experience in Javascript? - Go from beginner to advanced in a day.

Want to know about Javascript frameworks and how to advance in your career - This event is for you.

Victim of Information overload? - You will learn what you need to know to succeed and become an expert in JavaScript.

I love attending events like this. While I can learn from books and online tutorials, nothing beats being able to ask an expert a question. My session will be on jQuery Mobile. This will be an entirely new talk geared towards teaching you the things you need to know to get up and running as quickly as possible. 

This event has a regular price of $95, but I have the promotional code for you. It will lower the price down to just $30. If you can't get your company to pay $30 for all day training, then you really should think about finding a new job. The code is: "RiaConsultingLLC". Enter it into the text box for the promotional code. 




If you come, be sure to say, "Hi." I will be there pretty much the whole day, so you will have plenty of time to ask me jQuery Mobile or JavaScript questions.

Client Side Mobile Device Detection

Device detection can be very complicated. There are entire businesses based on correctly identifying the user's device. Luckily for us to poor to afford such services there is another way to do device detection which doesn't require us to re-invent the wheel.

The actual detection logic comes from Chad Smith and his site: http://detectmobilebrowsers.com. It uses a regular expression to test the user agent string from the device. So far it has correctly detected every mobile device I have thrown at it, but there is a possibility that it may miss a device. Luckily the site is updated frequently, in fact it was just updated six days ago, at the time of writing. I have created an example program which shows one possible way to integrate it into your code. Chad includes code for just about every known web environment, from Apache to Rails, including my favorite, JavaScript.


The site is very simple. It consists of three pages: index.html, desktop.html, and phone.html. Index.html loads and executes the detection script. If it fails, i.e. is not a mobile device, it then jumps to desktop page. If JavaScript is turned off, it simply throws up links to both the desktop and phone pages and allows the user to choose which one they want. 

One important thing to note is that only the index page does detection. If the user wants, we allow them to navigate to the desktop page on their phone. This is important, since most desktop sites have more features than their mobile counterparts. If the user isn't able to achieve their goal on the mobile site and you don't allow them to go to the desktop site, they might not come back.


The key part of the detection script, detectmobilebrowser.js, is towards the end. There it needs a link to go if it successfully detects a mobile browser. In my case it is phone.htmlThe demo code only detects mobile phones, not tablets. There are instructions on how to change the detection code to also detect tablets here.


To try the detection code for yourself, click the link below then select
"Mobile Detect".


For your own site, I recommend that you download the detection code from Detect Mobile Browsers. No telling when the code may get updated again. Also, if you use the detection code in your business, please consider giving Chad a donation to encourage him to keep it updated.


Thursday, October 18, 2012

Windows 8 Store App with JavaScript - First Look

I have a great fondness for JavaScript. When Microsoft announced that it was possible to build Windows 8 Store (formerly Metro) apps with JavaScript, HTML, and CSS3, I had to check it out for myself. 

Microsoft has made a large number of resources available for developers wishing to learn Windows 8. There are websites, videos, books, and hands on labs. All of this material is being offered for free. 

I chose the book, Programming Windows 8 Apps with HTML, and CSS, and JavaScript by Kraig Brockschmidt. The book is available for free at:


The book is chocked full of information, perhaps a little too much. I was looking for the general information about the differences between normal web programming  and programming a Windows 8, but I got a lot more than that. I am not sure what to make of it. I am not into step by step tutorials. Give me some theory, some example snippets, and then leave me alone. But there are a lot of people who like that style and it is at the right price. The book has  12 chapters. They cover lots of ground including: app anatomy, page navigation, controls, data binding, collections, layout, files, input and sensors, and media. 

To help me get my head around Win 8 coding I decided to port a game I am working on. It was surprisingly easy. In just a few hours I was able to get the game to the same state it was in as a web app, then easily add some cool built in animations to it. It went so well that I've decided to bring the app out for Windows 8 first. 

Overall Microsoft has done an amazing job of making it easy to build Win 8 apps in JavaScript. If you haven't tried it yet, I highly recommend that you do.

Wednesday, October 17, 2012

Free JS Design Patterns Book

I know how tough it can be when you want to learn and don't have a lot of money. So every time I come across a free or low cost resource, I promise to share the wealth. 

Here is another free book to help all of you JavaScript padawans, Learning JavaScript Design Patterns. Once again this book is by Googler Addy Osmani.

This book is great introduction to design patterns in general and JavaScript design pattern in specific. It has fifteen chapters covering topics like:  writing design patterns, categories of design patterns, anti-patterns, jQuery plugins, and modern module design patterns. 

This time around the book isn't downloadable, it is a website with accelerators to the chapter that you are looking for. I have it bookmarked on my ASUS Transformer tablet. For those of you who prefer an actual book or ebook, here is the link to it on O'Reilly's website. 


It will cost you a bit of money, but you help keep it free those who can't afford to buy it.



Tuesday, October 16, 2012

Free Backbone.js Book


As many of you know, I am a fan of Backbone.js. In fact, it has been the subject of talks that I have given recently. After the talks, people often ask for more references on backbone, but other than a few websites, there wasn't much available. But now there is and it is free!



Backbone Fundamentals is a book by Googler and backbone expert, Addy Osmani. The book is available in epub format for free on GitHub. Here is the link: Backbone Fundamentals.

The contains 165 pages divided into 10 chapters. It covers a lot of topics, things like the fundamentals, the internal workings of Backbone, building an application, common problems and solutions. It even includes one of my favorite subjects, building mobile applications with Backbone and jQuery Mobile. It has an easy to read, casually informative style which is packed fully of  coding knowledge. And it can't be beat for the price, so be sure to download it.

Be sure to check out my in-depth and affordable JavaScript Workshop coming this May to Southern California. I am partnering-up with the South Bay Mobile User Group and PeopleSpace for this course. I challenge you to find deeper JavaScript training for less. Hurry before it fills up.




Monday, October 15, 2012

jQuery Mobile UI Builder

If you've used either Apple's Interface Builder or Microsoft's Blend to build UI, then having to do it by hand in HTML seems like a big step backwards. But there is help and it is free. The Intel Open Source Technology Center has released its Rapid Interface Builder (RIB) tool. It runs only in Google Chrome, but it will save you huge amounts of time laying out your UI.

RIB supports both jQuery Mobile and Tizen (a new mobile still in development) widgets. It allows create your UI in the browser then download the source code to your PC. Later I will do a more in-depth walk-through of this amazing tool. 

Rapid Interface Builder


Layout mode
Preview Mode

SoCal Code Camp LA 2012 Wrap Up

A big thanks to all of the people who attended my four sessions Saturday and Sunday. It is always humbling to see a standing room only crowd listening to me speak. If you haven't done so already: please rate my talks. Here is the link to my speakerrate profile. 

All of the slides to all of my sessions are on slideshare.net. And all of the source code is on GitHub.

For those that attended the packed Beginning HTML5 Mobile Game Programming session, on Tuesday October 16th at 6PM PDT, I will be doing a live Google+ Hangout of an enhanced version of that session. This will be the first of six sessions as we build a complete game from start to finish. The first nine people will be able to ask me questions, the rest can watch it streamed live over YouTube. Hope to see you there.

Be sure to follow me on Twitter for the latest mobile and mobile web development tips and tricks, @therockncoder.

Between sessions on Saturday

Thursday, October 4, 2012

My iPhone 5 Nightmare

I want to say right from the beginning that I don't have an agenda. I was very reluctant to write this post. My blog is normally about development, not about ranting, but I have an issue that no one else seemed to be having with the new iPhone 5. I am not a fan boy or hater of any smart phone platform. I own an Apple iPhone 4, a Google Nexus One (Android), and a Samsung Focus Flash (Windows Phone 7). I like and dislike things with all of them. When AT&T, my carrier, announced that it would allow those of us who have the grandfathered unlimited data plan to keep it with higher data speed iPhone 5, I decided to buy one and I now regret that decision. 

My first iPhone 5 arrived on the afternoon of September 21st. Once I got home, I got the phone up and running in a short amount of time. Backing your data to the iCloud works well. The phone worked great over the weekend.

Monday morning is when things took a turn for the worse. I was listening to music over wireless bluetooth while running. It was still early in the morning, the sun hadn't came up yet. Roughly nine minutes into my run the music stop and my phone appeared to have turned off. A few things of note:

  1. The phone was attached to its charger all night - it had a full charge
  2. The headphones (Motorola S305) were charged and had worked flawlessly for years
  3. The phone was not damaged in any way, shape, or form
I tried to turned the phone on, but it would not turn on. Roughly thirty minutes to an hour later the phone came on by itself. Everything seemed OK except it no longer had a cellular signal. Instead of "AT&T" in the status bar, there was the message, "Searching...". I let the phone sit like that for about an hour before I turned it off and popped the SIM card out. My team at work was close to a major production deployment of our website and I didn't need any distractions. 

After our deployment, I began to make an appointment for the Genius Bar at a Apple store near my work. On that site it gave me some suggestions of how to resolve the issue myself. When I tried to re-install iOS 6 onto the phone, the installation failed with an error code of "-1". Now my phone was completely useless. I made the appointment to speak with a Genius. 

When I arrived that Apple store a few minutes ahead of my appointment it was crowded. After checking in, I waited. My appointment was for 3:50 and by 3:53 a Genius was calling my name. The Genius was unable to fix my phone however. When he tried to install iOS 6, it failed for him too. I braced myself to be told something unpleasant, but the Genius walked over to a drawer, opened it, grabbed a brand new phone. He typed some information into his computer then asked for the SIM card.  I popped the SIM card out of my Windows Phone 7 and he popped it into the new iPhone 5.  After following the activation steps, I was in business again. Unfortunately this story doesn't have a happy ending yet. 

This morning, October 4th, I went for a run again. Once again listening to music over bluetooth on my iPhone 5. When I passed the nine minute mark still listening to music, I smiled, but it wouldn't last. At the 17 minute mark, the phone crashed exactly as it had before. Roughly 30 minutes later it rebooted on its own and once again the message, "Searching..." appeared at the top of the status bar.  I can no longer make phone calls.

I know at least half a dozen people who have iPhone 5s, none of them are having any issues and they are all happy with it. I, unfortunately, am very unhappy. I have made another appointment to speak with a Genius at the Apple store. I will probably call AT&T this evening to see about returning the phone and getting my money back.

UPDATE - 5 October 2012

The end result of my trip to the Apple store was iPhone 5, number 3. The Genius, Mike, was super cool and seemed very knowledgeable but was mystified as to why my phone couldn't get out of search mode. He tried several things including reseting the network  connection, but nothing work. He did posit a theory that there may be a bad file in my cloud backup, which I used when activating both previous phones. Activating it as a new phone isn't really that much of a hassle since I have all of my contact information in my Google account and I don't have that many apps installed.

I still don't have music on the phone so I ran with my Windows Phone. Besides I am too gun shy to try it. Sometime after code camp, when I have my music back on the phone and time for a possible trip to the Apple store, I will try running with it again.