Friday, June 10, 2011

Facebook Session Syncing

As of recently I've been working on a project that involves working with the Facebook Javascript SDK. Other than some hiccups here and there it has been a fun little project working with combining a ColdFusion application using jQuery and the Facebook Javascript SDK.

One of the first things anyone has to get working is the Facebook Authentication which involves finding out:
  1. Is the person logged into Facebook.
  2. Has the person granted Facebook access to your application.
This is actually done fairly simply:

FB.getLoginStatus(function(response) {
  if (response.session) {
    // logged in and connected user, someone you know
  } else {
    // no user session available, someone you dont know
  }
});

This is a fairly straightforward process, you can see how you could easily build a structure around this logic.

But I've ran into a bit of a snag. This authentication is ran every time the page loads, as it should. It needs to check if the user is still logged in and get the users information again for javascript to access.
But the javascript runs when the DOM loads (or when the page loads depending on what you're doing) while the server side ColdFusion code runs before this.

So if I wanted ColdFusion to query up specific local user information I couldn't do this ahead of time because I don't know the validated user's id until AFTER the javascript runs.

This leaves us with a few options.

We could keep a local ColdFusion session along with a Javascript Facebook Session. This would have to rely on the Javascript making an AJAX call to ColdFusion after the user is validated and ColdFusion then storing the needed javascript information in a session variable. This creates a bit of an issue though because this means the security is relying entirely on the javascript and there is also a timing issue.

Example:
Page 1 loads: Facebook Authentication runs > validated > fires a call to ColdFusion > ColdFusion sets a session variable.

> Now the user clicks a link for Page 2 >

Page 2 loads (and wants to get user specific info from the local database): ColdFusion checks the session > see's the stored user information > queries up the user local information and builds the cfm pages > Facebook Authetication runs > fails >

Now what?
We already got and returned the local user specific information to the browser before the facebook authentication ran and failed.  Sure we could put some javascript in there to do a redirect or reset the page but that's hardly secure. What would be even worse is if the page was doing updates to the local data. We would have just updated the data before the authentication failed and would now have to trigger some kind of roll back that depends entirely on the javascript to run properly.


My only solution thus far is that when using the Facebook Authentication all local authentication required content has to be called via javascript/ajax calls AFTER the authentication goes through. This isn't always a bad thing but it does create much more work for the user's browser to process vs the server side simply loading up the pre-processed page.

Saturday, December 11, 2010

Single Page Applications

I have to say, after spending the last few months building a semi large scale single page application, I think I'm in love. I've done plenty of work using jQuery and AJAX calls before but have never gotten all the way into using JSON data in a much larger scale.

None of this is new concept and I've done plenty of similar applications before but when applying it on a much larger scale you can really see the speed and usability benefits between having a 30+ page application to having a 1 page application loading and removing different components on demand.

It's also increased my hatred for needing to support Internet Explorer and it's lack of javascript speed but it's almost a good thing because it forces you to build more flexible code. (although also sometimes less flexible code).

The next challenge?
Learning more about PUSH data services. Although I think HTML5 and other services need to evolve more.
I almost cringe at the thought of trying to learn Lifecycle or BlazeDS kind of services only to have newer HTML5 type services trump them.

Not enough time and brainpower in the day..

Wednesday, September 8, 2010

Recursive Madness




If S leads to Z, and Z leads to S, where does S start and Z begin?
IF Q then Y/T?
Can Q, Y and T coexist?
Does Y end if S>Z still continues.

The human brain can only multi-task 2 things at a time. Should an artificial one be capable of more, or will Q/Y/T/S>Z overwhelm?

Sunday, June 13, 2010

My Take on Android

So I've had my Incredible on Verizon running Android 2.1 for about a month plus now and I realized I was well overdue for a review.

I should point out, this has been my first smart phone despite my geeky ways. I always avoided getting a smartphone because the last thing I wanted to do was be even more wired to the internet. When the Nexus One came out I was greatly intrigued and really thought about getting it but decided to wait because I like Verizon Wireless and I also knew many other phones were coming out. But since having the phone, I've noticed I'm actually on the computer a lot less. I don't need to site at the computer checking to see if I have new email or new facebook notifications because my phone lets me know when I have them.

The hardware is much better than I originally thought and was afraid of. Being a flip phone user for the last 5+ years, I was afraid that the size of the phone would be a huge turnoff. I really didn't want to carry around a giant phone in my pocket and worry about breaking the screen all the time. But it's actually less bulgy than my previous flip phone and with basic case that fits the phone like a glove, I've yet to damage or scratch it (knock on wood right?).

Being a Google fanboy I knew I would like Android but when you add the beauty of HTC Sence on top of it, it's just a great device. The integration with Google services like Gmail, Calendar, Maps, Latitude are all seamless. Part of my weekly routine is to check if Google has released and new apps in the Android Market. Since I already used most of Google's services on my PC, everything was just instantly on my phone.

The integration with Facebook was also a nice touch. While there have been many issues with Facebook in general lately, I really liked the fact that I could easily link my Google contact with my Facebook contact and then my phone automatically combines all the Facebook contact info with the google contact info. More than half of my contacts also have auto updating default photo for them because it grabs their Facebook default photo. Again, it's just simple and convenient.

The touch interface itself really didn't take long to get used to. When I think about everything I'm doing on the phone it's surprisingly quick to navigate around on. Without a doubt quicker than a phone with keys and arguably even quicker than using a mouse on a computer.
Typing has definitely taken some getting used to. I've gotten a lot better at it, but I do miss being able to type out text messages without even having to look at the screen while doing it. The haptic feedback really helps to let you know that you at least hit a key, even if it wasn't the right one. 80% of the time now I'm actually typing words wrong but phone predicts what word I was trying to type and fixes the majority of my bad typing correctly and automatically. Once I got used to it my typing greatly improved because I wouldn't spend so much time hitting the backspace knowing that the phone will just fix it for me.

Currently, my main applications/widgets I couldn't live without:

  • Gmail
  • htc clock/weather widget (seriously it has clouds rolling across my screen.. awesome!)
  • Pandora (I stream music to my phone all day at work)
  • Google Listen (manages all the podcasts I listen to while at work)
  • Facebook (naturally, the app works nicely, could use some improvements but that's all on FB)
  • Google Calendar 
I also use Latitude which lets me see where my friends are on google maps, but I don't have many friends who use it's still weird knowing that my phone is tracking me. Google sky map is awesome, the youtube app works but needs improvement, music player is nice and has cover flow, the browser works but it would be really nice to have a FULL version of flash. 

Flash mobile to me is basically useless because few sites support it. And the mobile versions of sites that do never have full videos because they think phones can't handle it. If I goto the daily show website I'm redirected to the mobile version, which only gives me access to short little video clips instead of the full episodes. If I goto the full versioned site, I can't play the full videos because it needs the full flash player. Other sites that don't have mobile versions I simply cannot play the videos at all. So it's basically pointless. My phone has a 1gz processor in it and can still download and play audio/video a hell of lot faster than my PC could 8 years ago so give me full videos!

Battery life needs a LOT of work. Going phone a flip phone that would last 3+ days to a phone that lasts maybe 8+ hours is a big change. Right now it's become part of my routine to make sure that I have my charge cable with me when I goto work, and again when I come home. I would be screwed if I ever forgot it and I really don't think I should have to buy a cable for home, a cable for work and a cable for in my car just in case. It will last all day if I don't do any audio/video streaming don't play games or really do any heavy usage, but that kind of negates the purpose of having a smart phone. There are a lot of options for viewing what is using up the battery and things can all be tweaked to run less and use less battery. It took some getting used to but I'm getting there.

My understand is both battery life and flash and other things will be greatly improved once I get Android 2.2 on the phone. Right now it's up to HTC to get the update out (hopefully in the next month).

Other side notes.. 
The 8 megapixel camera is great. I'm not a huge photo person but I enjoy being able to now take quality photos with my phone and be able to just upload them directly to youtube, or email or flickr right from my phone.
Navigation also works very nicely but I haven't used it since I have a GPS device already. 
Games are a great time waster. I've spent many hours playing "Robo Defense", which is actually the only app I've bought so far. I've also been playing a lot of Reversi, Red Stone and Word Search.

All in all it's been a great device and I'm really looking forward to getting Android 2.2 on it and also find more time to start developing Android Applications myself.

Thursday, March 25, 2010

Adobe Flash Platform

Adobe Flash Platform is here! (more or less).
Flash Builder 4, ColdFusion Builder, and the new Flash Platform service.

It looks like I have some demo copies to download!

I really like Adobe's intro video for it.

http://www.adobe.com/flashplatform/

Wednesday, February 17, 2010

Job Market / Tech Industry

As I've now been unemployed / self employed for several months now, I've put a lot of thought into expanding and/or changing my career direction.

I've done many different roles in the IT field, but I've always been primarily a Web Application Developer. Sure I've done PC support, network setup, server setup and support and the list goes on but I've always been classified as a Web Application Developer for the past 10 years. Being a Web Application Developer has meant many things and been many projects over the years. Web services, ecommerce, security, photo editing, social media, blogs, podcasts, inventory systems, PDF scanning, system automation, file management, project management, database designs, etc. You name it and I've done it in one way shape or form, and always the primary language of choice has been ColdFusion.

ColdFusion can do almost everything the other languages can do just as good if not better and faster. In the past I've always had the ability to use ColdFusion because it was available to me where I worked so why do it in any other language than the one I can do with my eyes closes?

However, ColdFusion has 2 major flaws being that it isn't cheap and it isn't well advertised.
When I say that it isn't cheap I mean that ColdFusion hosting is typically more expensive to buy, and it is also more expensive to purchase $2000 worth of ColdFusion software if you are setting up your own server.
What I mean by advertising is that you can't exactly goto most colleges and find courses teaching ColdFusion. If you look at the last 10 years of tech learning, you will find Microsoft .NET and related Microsoft products being sold and taught by the dozen. You'll also find JAVA and PHP more lately because they are good languages but first and foremost.. they are free.

All of that said, combined with my current job searching dilema, I decided to do some quick number crunching to help my figure out where I should go from here. The numbers displayed here are the results of all jobs posted within the last 60 days on Monster.com that are still actively listed as of today:

Language Wisconsin Nationwide
ColdFusion
2
177
Java
63
5000+
.NET
53
3973
PHP
15
1926
Python
4
934
C#
31
3256
Flash
22
1596

Now keep in mind that I'm fairly certain Monster removes jobs if the company asks for it and also if the time payed for is expired, but these are still valid numbers if you look at it as a very rough view of the tech market.

As you can see based on the numbers. My ColdFusion skills are not exactly coming in very handy. I certainly have the ability to learn any of these languages. In fact I have dabbled in all of them at some time or another but I'm not interested in having 20 programming languages on my resume that I'm only semi good at. And to make things more complicated, shouldn't I find the job before picking the language? I could invest the next few weeks into learning to be better at Java, only to find a job that wants me to be more skilled at PHP.. and so on. Needless to say, working the tech industry can be difficult and stressing on any programmer. Especially in a job market recession.

Friday, January 22, 2010

jQuery Ajax Tabs IE Caching

The tabs feature is by far one of the more useful user interface options in jQuery.
http://jqueryui.com/demos/tabs/

However, I recently ran across some an odd caching when using the jQuery UI tabs along with the Internet Explorer browser.  When attempting to load or reload an ajax tab in IE, it would get stuck in IE's cache and not reload. This issue would only happen in IE, and not in my tests with Firefox or Chrome.

After some research I did find that there is a "cache" option for the tabs, and also an ajaxOptions.

$("#tabs").tabs({
ajaxOptions: { cache: false },
cache: false
});

At first this seemed to fix the problems. But soon after I ran into the problem again. Now the problem just seemed to be more random based on the content and the URL, which really didn't help me at all and would likely just confuse the end users even more.

Finally the solution came by making sure the URL and content would be random enough to get around the issues with IE. By adding in a random number in the URL, IE finally seems to be smart enough not to cache the ajax loaded page.

http://yoururl/?rannumber=#randrange(1,10000)#

It's not the ideal scenario, but it works, and since this is only being used to load a behind the scene ajax page, the user doesn't even have to see the extra random number being tagged on.