2012 in review – Tech Muffins & Musings Smoothie

The WordPress.com stats helper monkeys prepared a 2012 annual report for this blog.

Here’s an excerpt:

600 people reached the top of Mt. Everest in 2012. This blog got about 6,900 views in 2012. If every person who reached the top of Mt. Everest viewed this blog, it would have taken 12 years to get that many views.

Click here to see the complete report.

11 Reasons Why Windows Phone 7 is Better Than Android

I, myself, am an Android developer and have been developing apps for it for around 3+ years. I’ve seen Android emerging from the 1.5 version to the latest 4.0.3 (or Ice cream Sandwich). I had the privilege to use the very first Android handset G1 and used many others including latest phone like Sensation etc. But, the first time I heard Windows Phone 7 announced, as a mobile developer I looked into it with the mind that Microsoft cannot do anything good especially with the smartphones. But I was astonished. The clean, awesomely visible and attractive UI was the first catch. I seriously liked the idea of rainbow-less screens and dig in depth the WP7 OS.

Regardless of the numbers, WP7 is one of my favorite mobile platforms, outshining Android in almost every aspect. Don’t believe me? Well, allow me to try and change your mind.

Windows-Phone-7-Series

Windows Phone 7 Series

Streamlined User Interface

Android’s are different depending on the SKU of the handset. In other words, the UI you’ll be dealing with when using, say, a Motorola handset, will be radically different than one from Samsung or HTC. The ambiguity can be disconcerting. With WP7, you know what kind of interface you’re going to be working with, regardless of the handset manufacturer. We’d imagine that an un-tweaked user interface would also make lives easier for developers, as well. We love some Android user interfaces, but loathe others. With WP7, at least you know what user interface to expect, regardless of the handset maker.

WP7 Has An Easier-To-Use Interface

Windows-Phone-7-UI

Windows Phone 7 UI

It really does. And look, we get it. An Android is a power user’s phone, and we know that if you’re really looking for power-use, you’ve got to be willing to learn some things. But we’re the geeky minority here, and you’ve got to keep in mind that most people are looking for a phone that makes it easiest to do their day-to-day tasks. Keeping that in mind, WP7’s “tile” system is simply easier to organize and find the things you need to throughout the day. It looks cooler too; way cooler, actually.

WP7 Has Apps That Aren’t Crap

Open-source is good, and it’s a compelling reason to support Android as a mobile platform, but let’s face it: You’ve got to sift through some real $#@t in the Android Marketplace to find apps that are worth downloading, much less buying. Most people fail to realize that the Windows Mobile SDK has been around for quite some time now, and it shows in the Marketplace, especially on the gaming side of the spectrum. Many of the games we played featured awesome 3D graphics and a level of polish simply not(yet)-to-be-found in the Android hemisphere. Microsoft has a far stricter criteria set than Google about which apps and games can populate their respective marketplace.

Microsoft LIVE Integration Is Cool

Windows-Phone-7-Xbox-Live

Windows Phone 7 Xbox Live

If you’re achievement junkies like we are (you know who you are), then a WP7 handset is a must-have. Have a game on Xbox or PC that you love playing? Pop over to the Windows app store; chances are there’s a mobile version of that same game, where you can continue earning points and unlocking achievements with your handset. You can also keep tabs on your buddies’ achievements, and tweak and enhance your Xbox Live avatar. Granted, this integration is still in an infancy stage, but we’d be willing to bet that we’ll be seeing deeper and more intuitive connections between gaming and phones in the near-future. Forward progress is good progress.

Microsoft Mobile Office Integration

Windows-Phone-7-Office

Windows Phone 7 Office

We were actually blown away by how deep this rabbit-hole goes. Microsoft Word Mobile Edition, by way of an example, is actually a very intuitive little program, allowing you remote access documents using SharePoint Server 2010, you can use the “find” tool to look for particular words or phrases, and you can even email documents directly from the program.

We’ve had the pleasure of testing some Android phones that can dock with workstations to function as a laptop; imagine how crazy it would be if Windows launched a similar product with a full-fledged Office Suite. That’d be one step closer to a true fusion between phones and computers, and we’re all for that.

People Hub

Windows-Phone-7-People-Hub

Windows Phone 7 People Hub

The most amazing thing in Windows Phone 7.5 (“Mango”) is the People Hub. No matter how many social networks you use and how many accounts do you have on them, WP7 will manage everything. All you have to do is to add your accounts by giving usernames and passwords and WP7 will fetch all your friends, followers, buddies and place them in your contacts. What if I have same person on Facebook, Twitter and Windows Live, etc? Well, it will link all accounts under one name. Yes, that’s correct! It will match the names and link all the accounts with same name as a single contact. You can also manually add or remove an account as per your needs.

What the benefit of it? Let me tell you, it’s enormous. WP7 kills the need of checking all your social applications again and again. You don’t have to keep an eye on Facebook, Twitter and LinkedIn. All you’ve to do it to open your people app and everything goes listed here. All the feeds, tweets, updates are here. Also, you’ve all your notifications gathered at a single place. Similarly, you can write a status once and publish it to all or may be some specific networks in once.

Microsoft Isn’t Constantly Getting Sued by Apple

Whether targeting HTC a year ago or Motorola last fall or even Samsung (which is remarkable seeing how they are a flat out key supplier of Apple’s hardware components) just a few days ago, Apple has been regularly suing the hell out of Android handset makers; mostly in regards to hardware and software patents. So why is Apple seemingly ignoring WP7 in the courts? Well, there could be numerous reasons: Optimistically, it could be because the software and hardware developments on WP7 are truly original and innovative, meaning Apple can’t accuse Microsoft of lifting their ideas. A more realistic reasoning? Apple doesn’t see WP7 as that big of a threat…yet.

Stability

This is speaking from personal experience with various handsets across both platforms, but to put it simply, WP7 has just been a more stable experience. Apps like Facebook and Netflix simply run the way they were meant to with far less of the hiccups and crashes found on the Android platform. This runs parallel with the overall theme behind WP7 mobile devices: Simplicity. Granted, WP7 had to forgo some of the more complex actions Androids are capable of (i.e. lack of tethering support, lack of ability to capture screenshots, no multi-tasking), but to us, that’s a worthy trade for a phone that will do what you want it do, every step of the way.

Zune is a Native Client, and it’s Not Pay-Per-Song

We like Zune as a service—you pay a monthly fee and can download as many songs as you want, as opposed to being pigeonholed into paying per song, like with Apple and Android. Also, we really enjoy the fact that Zune is a native client that comes fresh out-the-box with WP7—setting up music services on an Android involves downloading various apps (like Google Music, which then has to synch to your Google Wallet, which then has to synch to your Google Music Server, which then needs a Gauntlet from Moredore to unlock your songs, which then needs…well, you get the point) that is just sort of a hassle, and glitchy to boot. Again, simplicity reigns supreme.

Snappier Keyboard

All right, we’re getting down to the nitty-gritty, and this is a minor nit to pick, but for the most part (with the exception of the Android Sprint Galaxy, which actually featured a physical slide-out QWERTY keyboard), Windows Phone 7 had a snappier, and more importantly, a more consistent keyboard that was snappy and accurate, regardless of the device. And, though Droid offered a few keyboard-contenders with the Galaxy S2 and the Incredible, others were really bad, (ahem, Droid X2, cough).

No Ad-Ware!

That’s right, there is nary a pop up ad to be found, whether you’re in the Windows Marketplace, or playing a game. There is nothing more irritating when using an Android that having to manually close pop-up adds, many of which appear mid game. There are, indeed, advantages to more stringent app restrictions, and WP7 seems to have found a perfect balance.


Source: Maximum PC

Social Network Authentications with Omniauth and Authlogic

As I discussed my experience developing an application in Rails 3 using authlogic and omniauth in my last post, Here is the tutorial as promised.

Step 1:

First of all you need to setup a Rails 3 application using authlogic gem. If you’re feeling some difficulty, try these tutorials for help:

Authlogic railcasts: http://railscasts.com/episodes/160-authlogic
Authlogic with Rails 3 tutorial: http://www.dixis.com/?p=352

Step 2:

Add the following line to your gemfile:

gem 'omniauth'

and then install the bundle

bundle install

Step 3:

Now create a ruby file in config/initializers. I’ve named it as omniauth.rb. Put the following code in it:

Rails.application.config.middleware.use OmniAuth::Builder do
    provider :twitter, 'CONSUMER_KEY', 'CONSUMER_SECRET'
    provider :facebook, 'APP_ID', 'APP_SECRET'
    # Mention other providers here you want to allow user to sign in with
end

* You can get the keys by creating an application on twitter and facebook each.

Step 4:

A user can be authenticated e.g., for twitter by redirecting him to:

http://HOST:PORT/auth/twitter

After authentication, user will be redirected back to

http://HOST:PORT/auth/twitter/callback

We can handle this callback and redirect user to a controller#action where we can process his registration and/or session handling as well as can fetch some useful data. For this, add the following lines in your routes.rb file:

resources :authentications
match '/auth/:provider/callback' => 'authentications#create'

Let’s add a couple of links on our login page which allow user to sign in via facebook or twitter:

<a href="/auth/twitter">Sign in with Facebook</a>
<a href="/auth/facebook">Sign in with Twitter</a>

Step 5:

Until here, we’ve nicely setup the user part of authentication. Now we’ve to handle the callback from social websites after authentication. Create a scaffold authentication. Here are required code snippets:

Authetications Migration:

class CreateAuthentications < ActiveRecord::Migration
    def self.up
        create_table :authentications do |t|
            t.integer   :user_id
            t.string    :provider
            t.string    :uid
            t.timestamps
        end
    end

    def self.down
        drop_table :authentications
    end
end

Authentication Model:

class Authentication < ActiveRecord::Base
    belongs_to :user
    validates :user_id, :uid, :provider, :presence => true
    validates_uniqueness_of :uid, :scope => :provider
end

Step 6:

And lastly, the authentications controller will be contain following code:

class AuthenticationsController < ApplicationController
  def create
    omniauth = request.env['omniauth.auth']
    authentication = Authentication.find_by_provider_and_uid(omniauth['provider'], omniauth['uid'])

    if authentication
      # User is already registered with application
      flash[:info] = 'Signed in successfully.'
      sign_in_and_redirect(authentication.user)
    elsif current_user
      # User is signed in but has not already authenticated with this social network
      current_user.authentications.create!(:provider => omniauth['provider'], :uid => omniauth['uid'])
      current_user.apply_omniauth(omniauth)
      current_user.save

      flash[:info] = 'Authentication successful.'
      redirect_to home_url
    else
      # User is new to this application
      user = User.new
      user.authentications.build(:provider => omniauth['provider'], :uid => omniauth['uid'])
      user.apply_omniauth(omniauth)

      if user.save
        flash[:info] = 'User created and signed in successfully.'
        sign_in_and_redirect(user)
      else
        session[:omniauth] = omniauth.except('extra')
        redirect_to signup_path
      end
    end
  end

  def destroy
    @authentication = current_user.authentications.find(params[:id])
    @authentication.destroy
    flash[:notice] = 'Successfully destroyed authentication.'
    redirect_to authentications_url
  end

  private
  def sign_in_and_redirect(user)
    unless current_user
      user_session = UserSession.new(User.find_by_single_access_token(user.single_access_token))
      user_session.save
    end
    redirect_to home_path
  end
end

Step 7:

Update your user model and add following lines in it:

def apply_omniauth(omniauth)
  self.email = omniauth['user_info']['email']

  # Update user info fetching from social network
  case omniauth['provider']
  when 'facebook'
    # fetch extra user info from facebook
  when 'twitter'
    # fetch extra user info from twitter
  end
end

And here your go. You application is all ready for authentication with facebook and twitter. And yes, you can also register/signin using conventional email and password technique.

Interesting Fact:

The application that we’ve coded above not only supports one-time user registration using social networks. It also supports multiple social accounts for a single user. Yes, you read that right.

Remember, we have separate authentications table. So a user can have more than 1 way of  entering in the site. How to do this? Well, it’s as simple as reading this line. Once the user is signed in, you can redirect him again to the paths we used initially for signing him in. That is, you can write these lines again in your user’s homepage

<a href="/auth/twitter">Sign in with Facebook</a>
<a href="/auth/facebook">Sign in with Twitter</a>

and he’ll have multiple social accounts associated with same user. Of course, you can hide the links of those networks user has already connected with his account.

How is this done?

Go though the code of the authentications controller again. We’ve a nice little condition there:

elsif current_user
  # User is signed in but has not already authenticated with this social network
  current_user.authentications.create!(:provider => omniauth['provider'], :uid => omniauth['uid'])
  current_user.apply_omniauth(omniauth)
  current_user.save

In case user is signed in, another authentication will be added for him and that’s all. Try to logout and login with newly added network. Yes, it meant to be as easy as 1,2,3…

Share the post if you liked it and it helped you.

Rails, Authentications, Social Networks and Me

In the first application I developed in Ruby on Rails, I was asked to give user the option of logging in the site without registration using his/her social network account. Being new to the RoR, it was a bit difficult to play with bit complex plugins. But somehow I created two sample applications, one for twitter and other for facebook. The gems/plugins I used at that time were twitter-auth and facebooker respectively.

It was all coming good until I had to incorporate them in one application. It was pretty painful process and required quite a bit of customization. Afterward, the next requirement was to allow user to merge accounts. Believe me, it was something that took some effort of even the experienced resources I was working with. It needed overriding of few methods and we even made some changes in the plugins’ sources especially the facebooker.

Last week, I had to develop a quite similar website in Rails 3. I seems to be a horror when I received the requirement document as I’d never worked in Rails 3 before. But when I actually started development, it worked like a charm. I’m duly impressed by the power of Rails 3 and it’s ease of use. In a far lesser time, my application is all ready with basic and social authentications.

As I write, most website owners will want to allow access to their sites using facebook, twitter and other social networking sites to save user from giving all the personal data again and remembering another username/password combination. So, I thought to publish what I’ve done so far to help other newcomers in Rails working out a solution.

This time, I used following gems to build solution:

  • Authlogic
  • OmniAuth
  • fbgraph
  • twitter

Though, OmniAuth is recommended with device, I used it with authlogic and it worked fine. OmniAuth is very powerful gem which not only allows you to authenticate but you can do everything related to social networks, like post a link on facebook, with it.

I’ll soon be releasing a complete tutorial for beginners on authlogic and omniauth. Till then, you can build an application with Rails 3 using authlogic.

Authlogic railcasts: http://railscasts.com/episodes/160-authlogic
Authlogic with Rails 3 tutorial: http://www.dixis.com/?p=352

Or you can google a bit and find a tutorial on authlogic+rails 3 of your liking.