Saturday, December 8, 2012

Giving away 2 free copies of jQuery Mobile Cookbook

I wish to thank all my friends, readers and well wishers. Your constant encouragement and support helped me complete my very first published book. I'm now very glad to announce that my book jQuery Mobile Cookbook just got published by Packt Publishers. The link is here: http://www.packtpub.com/jquery-mobile-cookbook/book



Extract from the publisher website:

Overview:

  • Create applications that use custom animations and use various techniques to improve application performance
  • Use and customize the various controls such as toolbars, buttons, and lists with custom icons, icon sprites, styles, and themes
  • Write simple but powerful scripts to manipulate the various configurations and work with the events, methods, and utilities which are provided by the framework


What you will learn from this book:

  • Create single-page and multi-page applications that use custom CSS and JavaScript transitions; improve performance using Prefetch, DOM-Cache, and Application Cache
  • Use fixed and full screen toolbars, navbars, and buttons; customize them with your own icons, icon sprites, and styles
  • Use XML and JSON data in your application; format page content using layout grids, collapsibles, and nested accordions
  • Build accessible forms; use form controls like flip switches, sliders, and select menus; validate and submit forms using Ajax
  • Use various types of lists such as Inset, Numbered, Nested, Read-only, and Split Button lists; manipulate lists using JavaScript
  • Use JavaScript to dynamically create and initialize controls, load and change pages, handle events; tweak and customize the framework configurations
  • Explore HTML5 semantics and features such as Local Storage, Session Storage, History, 2D Canvas, 3D, Geolocation, Web Workers, Audio, and Video
  • Use custom fonts and backgrounds, upgrade themes, override existing themes; generate and share new themes using the Theme Roller tool


You can purchase the book directly from the Packt website (link above). The book is also available on all popular stores and also online at Amazon, Safari Books Online, Barnes and Nobles, Flipkart, BookAdda to mention a few...

!!! Now comes the best part !!!

One lucky winner from anywhere in the world will get a free ebook copy. 
One lucky winner from anywhere in India will get a free printed copy.

So rush now. Send me a direct email at chetankjain@gmail.com with the below subject.

Email Subject: 
From <Country Name>, I want to read the jQuery Mobile Cookbook

e.g. 
From India, I want to read the jQuery Mobile Cookbook

The two winners will be randomly chosen by me without any bias and announced on this site and by direct email, within 1 week after the last date of submission of the entries. The winners will be decided at my sole discretion. The decision will be final and not subject to review or contest.

Last day to participate and send in your email is GMT Midnight Sunday Dec 16, 2012.

Thursday, May 17, 2012

Node.js: Notes on Install and Upgrade on Ubuntu

To install Node.js, first install the below prerequisite and add the node.js repository.
# sudo apt-get install python-software-properties
# sudo apt-add-repository ppa:chris-lea/node.js 
Now install Node.js and npm (the Node Packet Manager).
# sudo apt-get update
# sudo apt-get install nodejs npm
Thats it. Your Node.js is ready. Test by running the below command.
# node -v
v0.6.18
Node.js stable releases are done quite frequently. To upgrade run,
# sudo apt-get update
# sudo apt-get upgrade nodejs npm  
You could also use the Ubuntu Update Manager to do the update.


If you are the kind who prefers to directly build from the sources then,
# cd <directory>
# sudo wget http://nodejs.org/dist/v0.6.18/node-v0.6.18.tar.gz
# sudo tar -zxf node-v0.6.18.tar.gz
# cd node-v0.6.18
# sudo ./configure
# sudo make
# sudo make install
# node -v
v0.6.18
The latest version was v0.6.18 at the time of writing this post.

For other platforms, installation is simple. See the Node.js installation web page.

Tuesday, April 24, 2012

Ubuntu: Easy steps to install and use Notepad++ and IE on Ubuntu

I like using Notepad++, but it is a windows program and is not available for Linux. There are some jQuery Mobile apps that I need to test on IE. I need a Windows platform. But my primary laptop has Ubuntu.

The solution is to use Wine and boy does it taste good!

First install wine
# sudo apt-get install wine

Download the latest notepad++ installer from http://notepad-plus-plus.org/ and launch it using wine.

# sudo wine <download folder>/npp.xxx.Installer.exe


This will launch the Npp installer and you can complete the fairly simple installation. Thats it, you are done !

Now you can just launch Npp and its a touchdown !
# cd ~/.wine/drive_c/Program Files/Notepad++
# ./notepad++.exe

There is a version of IE available too 
# cd ~/.wine/drive_c/Program Files/Internet Explorer
# ./iexplore.exe

This IE scores pretty decent on www.html5test.com.

Now how about try installing other Windows apps on Ubuntu and having more fun...

Tuesday, April 10, 2012

Fixing Date, Time and Zone on RHEL 6 command line

Had to fix all time related issues on a remote RHEL 6 server which runs without any windowing system. Plain ol' command line. Documenting steps here for future reference:

Check to see if your date and timezone settings are accurate:
# date
# cat /etc/sysconfig/clock

The server I accessed had wrong settings for both the commands. Here are the steps I used to correct:

Find out your timezone from the folder /usr/share/zoneinfo
# ls /usr/share/zoneinfo

Mine was pointing to America/EDT instead of Asia/Calcutta

Update and save the /etc/sysconfig/clock file to
# sudo vi /etc/sysconfig/clock
ZONE="Asia/Calcutta"
UTC=true
ARC=false

Remove the /etc/localtime
# sudo rm /etc/localtime

Create a new soft link to your time zone
# cd /etc
# sudo ln -s /usr/share/zoneinfo/Asia/Calcutta /etc/localtime
# ls -al localtime
Now it should show the link to your time zone

Set your hardware clock to UTC
# sudo hwclock --systohc --utc
# hwclock --show

Update your time from a NTP server (Red Hat NTP server used here)
# sudo ntpdate clock.redhat.com
10 Apr 22:08:27 ntpdate[25695]: adjust time server 66.187.233.4 offset 0.004185 sec

Finally verify the date now
#date --utc
Tue Apr 10 16:39:56 UTC 2012

#date
Tue Apr 10 22:09:58 IST 2012

Add the above ntpdate command in your server startup script or in a cron job to automatically set the system time. The list of ntp servers can be found here: https://support.ntp.org/bin/view/Servers/StratumOneTimeServers

Monday, March 26, 2012

CouchDB on RHEL6 (Red Hat Enterprise Linux)


Had to install a Couch DB instance on a fresh Red Hat Enterprise 6 Linux Box and it required some time before I got the whole thing up. Better have it documented here for future reference:


1. Get the Prerequisites
First you will have to add the RPM Forge YUM Repository if not already available. Add the new repo:

sudo vi /etc/yum.repos.d/rpmforge.repo


# Name: RPMforge RPM Repository for Red Hat Enterprise 6 - dag
# URL: http://rpmforge.net/
# (Put "x86_64" instead of "i386" if appropriate.)
[rpmforge]
name = Red Hat Enterprise $releasever - RPMforge.net - dag
baseurl = ftp://ftp.pbone.net/mirror/atrpms.net/el6-i386/atrpms/stable
enabled = 1
protect = 0
gpgcheck = 0

Save the file and get the prerequisites:

sudo yum clean all
sudo yum groupinstall 'Development Tools' 'Development Libraries' 'GNOME Software Development'
sudo yum install \
  cvs zip gcc-c++ glib2-devel gtk2-devel fontconfig-devel libnotify-devel \
  libIDL-devel alsa-lib-devel libXt-devel freetype-devel pkgconfig \
  dbus-glib-devel curl-devel autoconf213 xorg-x11-proto-devel libX11-devel \
  libXau-devel libXext-devel wireless-tools-devel glibc-static libstdc++-static \
  yasm mesa-libGL-devel esound-libs esound-devel ccache mercurial glibc-devel \
  ncurses-devel openssl-devel libicu-devel erlang js-devel libtool which make

If Mercurial is not found, you can install a RPM package from RPMForge using the below commands
(replace VERSION with your version/architecture):

sudo wget http://packages.sw.be/mercurial/mercurial-VERSION.rpm
sudo rpm -Uhv mercurial-VERSION.rpm

If curl was not found, install from sources

sudo wget http://curl.haxx.se/download/curl-7.20.1.tar.gz
sudo tar -xzf curl-7.20.1.tar.gz
cd curl-7.20.1
sudo ./configure --prefix=/usr/local
sudo make
sudo make test
sudo make install

If Erlang was not found, download, build and install Erlang:
sudo wget http://erlang.org/download/otp_src_R14B03.tar.gz
sudo tar zxvf otp_src_R14B03.tar.gz
sudo cd otp_src_R14B03
sudo ./configure && sudo make && sudo make install

If js-dev (SpiderMonkey) was not found, build from the source files
sudo mkdir mozilla
sudo cd mozilla
sudo wget http://ftp.mozilla.org/pub/mozilla.org/js/js185-1.0.0.tar.gz
sudo tar xzf js185-1.0.0.tar.gz
cd js/src
sudo autoconf-2.13
sudo ./configure
sudo make
sudo make install

2. Install CouchDB
Now you are ready to install CouchDB from sources. The configure line below is for 64-bit, adjust for your arch (or leave out --with-erlang if configure can find out for itself). You can use a release tarball instead of a checkout, in that case skip right to the ./confgure line.

sudo svn checkout http://svn.apache.org/repos/asf/couchdb/trunk couchdb
cd couchdb
sudo ./bootstrap
sudo ./configure --with-erlang=/usr/lib64/erlang/usr/include --with-js-lib=/usr/local/lib/ --with-js-include=/usr/local/include/js/
sudo make
sudo make install

3. Configure CouchDB
a. Edit config file to your need, change the port etc
sudo vi /usr/local/etc/couchdb/local.ini

b. Create user, modify ownership and permissions
sudo groupadd -r couchdb
sudo adduser -r -d /usr/local/var/lib/couchdb -M \
  -s /bin/bash -g couchdb couchdb

c. fix permission
sudo chown -R couchdb: /usr/local/var/lib/couchdb /usr/local/var/log/couchdb

4. Launch CouchDB


sudo -u couchdb couchdb

Or as daemon:
sudo /usr/local/etc/rc.d/couchdb start

Or at startup as a daemon:
sudo ln -s /usr/local/etc/rc.d/couchdb /etc/init.d/couchdb
sudo chkconfig --add couchdb
sudo chkconfig --level 345 couchdb on

5. Test Install:

Now you should see something meaningful when you click
http://127.0.0.1:5984/_utils/index.html 

Saturday, February 18, 2012

2 new Page Transitions in jQuery Mobile v1.1

In my earlier post I had written a simple demo to show the various transitions that are available with jQuery Mobile. The official documentation v1.0.1 for page transitions is available here.

But with jQuery Mobile v1.1, the official documentation has been updated and is much better compared to the older version. You will also see the page looks much simpler and showcases how the transitions would look for pages and also dialogs. Just click on the buttons and you can see the live demo. Excellent work on updating the documentation.

Also very exciting to see that two new transitions have been added, the Turn and the Flow. So now we have a total of 8 transitions that are available by default. Pretty cool.

Of course the brave can extend the framework and try to create their own custom transitions using CSS3 and JS.

Thursday, February 16, 2012

TV apps using jQuery Mobile

The idiot box finally graduates to an internet box!

Internet on TV is catching on quite fast. I've been reading reports that predict a billion(s) dollar market that will open up for TV apps. Ah the hype .. these things are always in billions. But anyways, considering the number of people who have a TV and the number who watch it (almost everyone?), I guess this could be quite realistic.

Many advantages I guess, lesser strain on the eyes, no burnt laps and no lost fertility with laptops on top of laps. I'm online 100% of the time. Definitely I stand to gain. My 6 year old kid too. I'd rather have him play Angry birds and all those HD games on TV compared to him holding my super heated mobile and straining his eyes watching the small screen.

So now that I've made my point beyond all doubt, it is agreed that TV apps is the next big thing!
So where do I start? I do not have an Internet TV yet! Not to despair, one could install the recently launched Opera TV Emulator and have the next best thing.

The steps are detailed here and are very easy to follow. You have to get the Virtual Box and install it. Then get the Opera TV Emulator, unzip it and you are ready to go. On launching the emulator virtual machine, the Opera TV browser comes up and you will also be given a link to install the H.264 codec, this is to play the MP4 videos.

You can now directly start browsing. Now lets get bolder. How about our first TV app. Fairly simple I would say.

Just point the TV browser to your jQuery Mobile app and bingo! It just works. Isn't that amazing! You code once in jQuery Mobile and the code runs on a wide variety of mobile devices, tablets, desktops and now even on TV! This is true cross platform development. There are other emulators, but from first looks, I feel Opera TV emulator is the simplest to install and use.

Though not officially supported by jQuery Mobile, my few basic apps seemed to work fine. I even tried audio and video and they work fine. The full list of current jQuery Mobile supported browsers is available here. No mention of any TV browsers. TV browsers need to be tested in detail with jQuery Mobile. But I find this totally exciting !

http://www.html5test.com/results-tv.html lists the current state of affairs in the TV browser world when it comes to HTML5 support. It sure is promising. The coming days will see these scores improve and probably match or exceed the desktop browser scores. Who wants those old computers anyways. Its the era of the mobiles and the tablets. When I pointed the Opera TV browser to html5test.com, the score was 330+6 bonus points. This score is among the top 3 after Chrome and Firefox.

Finally, one conclusion from all this - it sure is high time I replace my old TV with an Internet TV. Suggestions ?

Thursday, February 9, 2012

It pays to blog

"See one, Make one, Teach one!" - [video: Charles McCathieNevile (Opera), see @00:19:00]

Working on a pet project, I stumbled upon jQuery Mobile a few months ago and have been hooked on to it since then. There were quite a few things that I learnt and few more things that I discovered. I started to blog a few posts on the topic and boy does it pay to blog!

One morning I log on to my blog and find that the traffic had jumped by a few hundred page views within a single night. I used to have just a handful of daily visits earlier. Initial thought was that some bot had tried to wreck havoc on my blog. Eventually I found the true reason. My post on prefetching pages using jQuery Mobile, had been retweeted by @jquerymobile. Traffic hasn't looked down since. Even today the number of pageviews on a daily basis, is tenfold more than the earlier days. Its been two months now.

Within a week of this, I got an email by a leading international publisher asking if I were interested to write a book on jQuery Mobile. I almost fell off my seat. Mostly a new version of the famous Nigerian scam mail. I was skeptical. But a quick cross check proved otherwise. This was for real!

Govind my friend urged me on, "Chetan, this is once in a life time opportunity. Just take it!"

I had to submit a proposal over the new year weekend. One of these days I'll make it up to my wife and kid for me sitting with my laptop all through the new year's eve. Couldn't have done it without their support and understanding.

The proposal got reviewed and also got selected over two other proposals. I eventually signed the contract last month. The book will take a few months to roll out. I expect it to be available by Q4 of 2012 (if all things go well). This will be an interesting experience and I am quite excited about the same.

This also means that I have a few contractual obligations with my publisher and have to pick and choose what I blog about going forward. But there are enough topics in jQueryMobile and the HTML5 world in general and I will surely be posting more frequently now.