July 28, 2013

HTML5 Web storage

Currently, these are the important forms of storage systems present in the browsers.
  • Cookies
  • Web Storage
  • Indexed database API
  • Web SQL Database

Cookies:
A very tiny amount of storage used by websites to store important information. Generally, this is used to store tracking or authentication data.
Examples are
Cookie to track user’s browsing habits by third-parties
Cookies to evaluate if the user has already been logged into website

Web storage:
It’s a simple mechanism to store larger amounts of data. The CURD operations are performed over a key/value persistence system. Also known as localStorage system.

Pros
  • Really simple API.
  • Already available in all major new browsers.
Cons
  • No query language, schemas, really nothing you'd normally call a database. So it wouldn't scale well where you need to impose organization on a larger data set.
  • They didn't put transactional safety into the standard. I don't think I can sleep at night with an app running that might have race conditions and then have the risk of corrupt data.
  • Closing an app would lose the entire data. Hence, this storage mechanism can’t be used for developing HTML5 based native apps.

Indexed Database (IDB) :
IndexedDB is an API for client-side storage of significant amounts of structured data and for high performance searches on this data using indexes. IndexedDB basically provides a simple flat-file database with hierarchical key/value persistence and basic indexing.
IndexedDB provides separate APIs for synchronous and asynchronous access. The synchronous API is intended to be used only inside of Web Workers but it isn't implemented by any browser yet. The asynchronous API works both within and without Web Workers.
Pros :
  • Pretty similar to NoSQL
Cons :
  • Not yet available in most new browsers.

Web SQL Database
Web Sql is basically sqlite embedded into the browser. It's one of the most useful form of HTML5 web storage.
Pros :
  • Fast and pretty feature-rich sql implementation (besides select/insert/update/delete, you can do joins, inner selects, etc).
  • Advantageous for developing ios and Android apps as the storage persists even after the application is closed.
Cons :
  • Available in Chrome and webkit-based browsers (Safari, etc.) but not Firefox or IE.
  • The W3C Working Group has put a hold on the standard since they say they want at least two independent implementations of the standard, and there's only one so far, since everybody is using sqlite.

Useful links

July 26, 2013

Developing and native packaging for Sencha Touch applications


REQUIRED PROGRAMS


  1. Java
  2. Sencha Touch
  3. Ruby
  4. Compass and Sass
  5. node.js
  6. Sencha Cmd
  7. Android SDK
  8. Cordova
Java
Version: No particular version is required; Latest stable version is preferrable
URL : http://www.oracle.com/technetwork/java/javase/downloads/index.html
Note: Android SDK requires Java
1. Download and install a Java Run-time Environment or JRE
2. The JRE version must be at least JRE 6, JRE 7 is best.
3. Set the JAVA_HOME path on your respective operating systemcls

Sencha Touch (ST)

Version: 2.1.*, Previous apps were built over ST2.1
URL: http://www.sencha.com/products/touch/
Download URL: http://cdn.sencha.com/touch/sencha-touch-2.2.1-commercial.zip
1. Download the appropriate version of Sencha touch bundle from the url.
2. Unzip the downloaded archive
3. The 'sencha-touch-' directory consists of 'touch-', a container of the sencha touch install, examples and documentation.

Ruby

Version: Ruby 1.9.3 is required (Ruby 2.0 is not supported).
URL: http://www.ruby-lang.org/en/downloads/
Note: Compass and SASS use Ruby.
[Windows]
Download Ruby 1.9.3 from rubyinstaller.org. Download the RubyInstaller .exe file and run it.
[Linux]
1. Install distro-specific RVM [Ruby Version Manager]
curl -L https://get.rvm.io | bash -s stable --ruby
2. Install Ruby 1.9.3
rvm install 1.9.3
rvm use 1.9.3
rvm rubygems latest

Compass and Sass

URL: http://compass-style.org/install/
Note: Sencha uses Compass and Sass to develop CSS content.
1. Open terminal / command line on your system.
2. Enter the command 'gem install compass'. This will install the Compass and Sass

Node.js

Version: Latest stable version is preferred; using 0.10.13
URL: http://nodejs.org/
Node.js is requried by Sencha cmd to build the applications
Note: node.js requires python.
[Windows]
1. Download and run the .msi installer
[Linux]
1. $ wget
2. $ tar.gz $ tar -xvzf  
3. $ cd
4. $ ./configure
5. $ make # takes approx. 5-10 minutes
6. $ sudo make install

Sencha Cmd

URL: http://www.sencha.com/products/sencha-cmd/download
1. Download appropriate Sencha Cmd version.
2. Unzip the Sencha Cmd zip file and save the path in environment.
3. [Linux only]  Run the sencha cmd run file using command
./SenchaSDKTools-.run --mode text
4. Save the sencha SDK path in environment variables
5. To verify installation, open terminal/ command line and type 'sencha'. This would give help page of sencha.

Android SDK

Version: api-7 is required by Sencha Touch
URL: http://developer.android.com/sdk/index.html
1. Download the appropriate version of Android SDK for your platform.
2. Install SDK and download required Android platforms
3. Save the android installation directory path in environment variables

Cordova

Version: Currently packaging using 2.8.0
URL: http://cordova.apache.org/#download
Note: Phonegap is an extended feature set of cordova platform
Note: Cordova installation requires node.js to be installed
[Windows]
1. Download the latest version of Cordova
2. Unzip the cordova installation and unzip the required version (Android) platform
3. Set the cordova unzipped directory path into environment variables
[Unix\ Linux]
1.npm install -g cordova



Working with Sencha app

Creating a Sencha application
1. Verify Sencha Cmd is installed
2. We are using ST2.1, not latest 2.2. Latest ST build comes along Sencha Cmd tools
3. Make sure you have the required ST SDK
4. Create sencha app from command using command
sencha generate app app_name /path/to/app
sencha --sdk-path /path/to/specific/sencha/sdk generate app app_name /path/to/app
5. You have app created with the specified or default Sencha version in the specified directory



Converting from Sencha touch application to native android application

There are two different ways to package a sencha touch application to native application. Theya are
1. Cordova native packaging
2. Sencha native packaging

Cordova native packaging
1. Develop the Sencha touch application independently
2. Add cordova.js into resources/js of Sencha application and also add reference of it in app.json
3. Get the sencha touch production build using the command
'sencha app build production'
4. Create a new cordova application (Not in the previous sencha application directory) using command
'cordova create '
where,
- Name of the application like DriveTime
- Package name of the application like com.rr.drivetime
- Physical path of the application on disk
5. Add android to the required cordova application using command
'cordova platform add android'
'cordova build'
which, creates an android folder with the android project structure.
6. Create an Android project over cordova application.
i. Open eclipse
ii. Go to 'File'->'New'->'Project'->'Android Project from existing code'
iii. Select the 'android' directory in the cordova app created above
7. Create a 'www' folder in the 'asssets' directory of the android project
8. Copy and paste the production build created in (3) into the 'www' folder.
9. Deploy the project to device using adb, installed part of Android SDK

Sencha native packaging

1. Develop the sencha application.
2. Go to the sencha application path
3. Add cordova.js to 'resources/js' folder
4. Add cordova.js reference to js category in app.json file
5. Complete the packager.json file [Android sdk, device to install, application name, package name, 'key']
6. Build the native package of the application using Sencha Cmd using command
'sencha app build native'
7. The above step produces a 'apk' file. You can deploy or distribute this apk to devices.

December 30, 2010

Nenu, na modati vimana anubhuti

Hi readers! don't get surprised to see the title in pure telugu, just out of feeling of missing my home I had typed it in telugu. Well, for as long as my journey is concerned I had the best experience on air. I had to face what it would have taken approx. 4/5 flight journeys.
---Chennai---
My flight from Chennai to Delhi was an domestic flight and I had to change to international flight from Delhi to Chicago. All of those who have booked their flights in Air India, just get your ticket checked before you start your journey including the allowed baggage for your tickett. I had a thirty minutes drama at the chennai airport before they allowed the extra baggage; regular baggage limit is 2 pieces. Well, the entire airport crew and staff are a bunch of ignorant fools who don't even know where the security check goes on in their airport esepecially Air India staff, A-holes, they don't know the offer which has been displayed right on their homepage and the comic part was they were using unix. OMG! he had to check each and every command right in he manual. Somehow luckily I did board my first flight, the experience was exciting to see the entire city which i roamed in cars dimnish itself beneath us.

---Delhi---
Delhi airport was much grander than the Chennai airport and the goodness was there was a fusion of modernity and Indian tradition in the architecture. GMR rocked yaar!. The moment I did checked in for my flight, they said the next twist in the story and that was "sorry sir! Your flight has been delayed by 9 hours and the time of departure is tomorrow morning at 9 subject to weather conditions". Well, the relief was they said they would provide accomodation at free of cost but I had to wait for 2 hours right in airport and with so many cancelled flight, the airport has become much worse than the Bihar railway station. I was enquiring at the Air India counter over my accommodation and he was quite reckless, so I did scold "Jaffa bathuku ni dobba!" and suddenly a lady who was co-enquiring about herself turned back. She's a software engineer in IBM and had a chat with her right till next day morning my boarding. The next morning I was quite busy in my breakfast that I missed my bus to the airport. Somehow I did catch some vehicle and went to airport only to find out that my flight has been delayed by an hour.

---Chicago---
I was so excited seeing US from such high altitude. Chicago airport is large enough to fit in 2/3 Chennai airports. As soon as I entered into Chicago, it was my port of entry so I had some regular check and verification. Now, I had another twist in my story and that was I had to re-schedule my flight and since it was the responsibility of Air India, he did it for me at free of cost. And as I was about to check in my baggage, he blatantly said that he wouldn't allow the third baggage and I had to pay a 100$ fine, OMG! Adugu pettina muhurtam bagunatlu ledu. Due to some intelligence and stroke of luck, I escaped my fine. Security check at Chicago airport not the regular kinda check up, it's an out and out body scanner and can you imagine a 200-300 meters waiting queue in united states!! To my stroke of misfortune, even the flight here which has been scheduled at 0820pm is delayed by 0130hrs. Finally, after a long 33-hour journey turning into 42-hour journey and a series of mishaps, I did reach my destination wherein I'll be having to spend next 2 years.