Java books

Learning of a computer programming language is a slow process, so don’t rush through it.

Computer programming books are usually thick and boring to read. And they can’t be read like fiction books. It takes time to cover these books cover to cover.

Here are some points which I follow when reading a book on computer programming language for the purpose of learning a new programming language, and I thought I should share it here if it could benefit others as well:

You Don’t Need To Read All Of It

One thing which I have observed in almost all the computer programming books is that they cover advance topics which a new learner doesn’t need to learn. They are simply impossible to understand at a beginner level. This advanced info is only needed when you have already practiced your computer language skills on real programs.

This means, you don’t need to read all of the book. I would say reading first half of these books is more than enough, and rest half can be ignored for a later time

Practice As You Go

A computer programming book can’t be read like a fiction book. These books come with examples and exercises. It is important that you take your time to actually code them and understand how they work. This will slow down your reading, but there is no fast way to learn a computer programming language, so take your time and practice as the author wants you to.

Sleep When Feel Sleepy

Computer programming books will make you sleepy very often. At such occasions don’t force yourself to keep reading and practicing. Give your brain a break. Take a nap, do something else, and then come back to where you had left. If you’ll force yourself to continue when your brain is asking for a break, you won’t learn it properly.

It Takes Time To Learn Programming

Computer programming is not quick to learn, it takes time. While practicing along with the book, there will be many things which won’t be clear to you and sometime it’ll be frustrating. Just know that you are not alone in your frustration and this is normal, whether learning the programming language or whether practicing it as a professional with many years of experience. Take your time, don’t rush. If something is not clear, revise it and try to understand why it is not working. If it makes you sleepy or dizzy, take a break.

Don’t Continue Unless You Understand

One of the biggest mistakes many people make, they keep flipping pages without understanding the concepts they have just read, or exercises they have just completed. There is a mental rush to complete the book. This however doesn’t help with learning of the language, and wastes more time, since reader has to come back to these sections of the book later anyways to clear these concepts. So if you are stuck at some point, stop and try to get it cleared. Maybe ask someone, or search online. Just don’t move ahead unless you are clear on what you have just read or practiced.



Those who don’t appreciate technology, in the end fail both themselves and you. Try not to work for them.


ver last few years I have learned something as a technology professional which I thought I should write about here, as it might help many readers.

What I have learned is that those clients who don’t understand and/or appreciate technology, are not only extremely hard to impossible to work with, but they also fail themselves and you in the end.

Recently I was exploring background of the successful people in the technology industry, and I noticed that all of them had some sort of background in the technology industry itself, which explains why it is important to have true understanding of the technology industry itself to be successful in it.

Technology is hard to develop, its not an easy task. It takes countless hours of R&D, development, testing, calibration, re-testing, more R&D, more development, before a product is finally ready for production.

And software engineering and development is no exception.

A good piece of software takes a very long time in development, whether its a website, a mobile app, a desktop application or an embedded system. For example, a good website programmed from scratch can take up to three months to complete, with a team consisting of developers, designers, experts of database, networking and server systems. This adds up to the cost. So a good website can easily cost in tens of thousands of dollars.

But, for a lot of clients, who want to build a great website and be on top of search lists, they expect this practice to be something not more than $9.99 per month and they fail to understand why would it cost e.g. $20,000 in initial development plus $300 per month in monthly running costs, and further $1,000 monthly in advertisement.

And I am not referring to free plug-n-play type one-size-fit-all solutions based on WordPress, Joomla, Drupal, etc. Though they also incur some serious cost if properly and beautifully customized to suit a client’s requirement.

Many clients also refer to online freelance websites where developers from certain third world countries offer their services for peanuts, while promising to accomplish tasks which they don’t even understand what they mean.

Developing good technology is time consuming and hard work, and it costs money. 

This all makes it very difficult for a genuine developer to put forward his/her case for a genuine and good quality original work.

My observation for this problem is as follows:

  • From a client’s point of view, a website is just a website. He doesn’t know that it is a default set of web pages or plugins which come standard after signing up with a hosting company. Client doesn’t know that it is based on WordPress or something similar, which in turn is a software evolved over many years. So when he/she wants to hire a developer for a custom solution who asks for a few months and tens of thousands of dollars of development cost, client fails to understand why.
  • Native and non-native apps is another culprit in the mobile app development industry. Non-native apps are basically web pages which present themselves as an app. Majority of the so called app developers, who promise to make apps for cheap, basically just make do this non-native development work. So when a native app developer proposed a bigger cost and time, client fails to understand why.

So now it becomes some extra and hard work for a developer to educate the client why custom and good quality software development actually costs good money too.

The result is, client keeps wasting money in small quantities while not achieving his/her goal, and getting frustrated on it, and not understanding where the problem is. Problem is there in not understanding how the technology works.



[Don’t know the source, found via StumbleUpon]



I thought to put down some of my thoughts about PhoneGap as it might help somebody to save his/her time.

In last one year I have tried a few times to learn PhoneGap, to no avail. I have been doing web and Android development for a few years, and not new to these tools, but somehow this PhoneGap thing never worked for me.

The biggest problem I have faced is the obsolete and outdated documentation, examples and tutorials. Old examples and old code which just wastes your time and gets you nowhere. I wonder how they even roll out any new change without documenting it first.

The very first problem starts with the terms ‘phonegap’ and ‘cordova’. As of writing of this post, which is 30th of April 2013, for a beginner there is no clear mention of what is the difference between cordova and phonegap. It has been almost 2 years that Adobe acquired PhoeGap and renamed it to Cordova (why, I would ask) but they failed to mention it anywhere in the documentations.

in early 2012 I downloaded phonegap and it was cordova version 2.4 even back then. Yet even today when I find tutorials, they refer to it as phonegap and not cordova. This shows how old these tutorials are, and keep you wondering if cordova and phonegap the same thing.

I also found 4 books, two of them published in 2012, and still no mention of the term Cordova except in one of them, and only at a few places because for the rest it is still calling phonegap-x.x.js.

Also, in the latest code as of today, i.e. cordova-2.6.0, the app is initialized using some app.initialize() method in the example which comes with it. However I failed to find anywhere this method documented. All the books and examples are still starting the apps with old <body onLoad=”init()”> way.

Not only this, I also copied pasted codes to my test projects, and they didn’t work. Also trying to switch from app.initialize() to <body onLoad=”init()”> caused the example to fail to do anything.which according to its brief online mention says it should do the same thing.

Now the books, when they say to unzip the file, you wonder where this file exists, because it simply doesn’t exist any more. Makes you wonder how to learn this thing at all. A careful look also shows that in the books or documentation it is looking for this file in folder iOS, notice capital letters, however in the download the folder is ios with small letters. This means somebody updated the downloadable files, removing the ios related installer, but didn’t mention anywhere how to go about with it now.

Given all the frustration and waste of time due to above, I have decided not to waste time on PhoneGap and go with Objective C. Take a longer learning path but do it the right way. As for Android, I can program it native anyways. And as for BB, will simply outsource it to do it in its own C++.

As an end note, for quality and performance oriented app, using PhoneGap, AppMobi, App Maker, Appcelarator and any similar tools for non-native development will only disappoint you in the end. For real work, you have no choice but to go native.

Linux Distros

Linux Distros

Here is some collection of Linux reference items, useful for Linux server admins. I personally refer to them often so decided to put in this blog.

Clear Memory Cache on Linux Server

  1. Connect via shell using a program such as Putty
  2. At the shell prompt type crontab -e <enter> as this will allow you to edit cron jobs for the root user.
    • If you are not familiar with vi (linux editor) you press “i” to insert text and once done hit “esc” and type “:wq” to save the file.
  3. Scroll to the bottom of the cron file using the arrows key and enter the following line:
    0 * * * * /root/
  4. Create a file in '/root' called '' with the following content:
    sync; echo 3 > /proc/sys/vm/drop_caches
  5. Once you have saved this file, the job is complete!

 Find Big Directories

du -smh $(find $1 -type d -maxdepth 1 -xdev) | sort -g

Get the Number of Registered SIP Users on Asterisk

asterisk -rx ‘sip show peers’ | grep -a ‘OK’ 2> /dev/null | awk ‘END {print NR}’

OR if grep gives problems

asterisk -rx ‘sip show peers’ | awk ‘OK’ 2> /dev/null | awk ‘END {print NR}’


asterisk -rx ‘sip show peers’ &> /dev/null | awk ‘OK’ | awk ‘END {print NR}’

Convert MP3 Files to 8KHz Wave

$ lame –decode soundfile1.mp3 soundfile1.wav
$ sox -V soundfile1.wav -r 8000 -c 1 -w soundfile1.raw

To convert a whole clutch o’ files, stick them all in the same directory and do this:

$ for i in *.mp3; do lame –decode $i `basename $i .mp3`.wav; done
$ for i in *.wav; do echo $i; sox $i ${i%%.wav}.raw ; echo ${i%%.wav}.raw; done

Check Number of Files and Folders

ls -l | grep ^- | wc -l
ls -l | grep ^d | wc -l
ls -l | grep ^l | wc -l

echo $(($(ls -l | grep -v ^d | wc -l)-1))

ls *.txt | wc

Using find command with -type switch:

-type c
File is of type c:

b block (buffered) special

c character (unbuffered) special

d directory

p named pipe (FIFO)

f regular file

l symbolic link

s socket

for t in files links directories; do echo `find . -type ${t:0:1} | wc -l` $t; done 2> /dev/null

for t in files links directories; do echo `find . -maxdepth 1 -type ${t:0:1} | wc -l` $t; done 2> /dev/null

ls -l |perl -e ‘while(<>){$h{substr($_,0,1)}+=1;} END {foreach(keys %h){print “$_ $h{$_}\n”;}}’

du -a | cut -d/ -f2 | sort | uniq -c | sort -nr

Backup the Whole Linux System Using Tar

tar -zcvpf /archive/full-backup-`date ‘+%d-%B-%Y’`.tar.gz –directory / –exclude=mnt –exclude=proc .

The above command specifies the options “z” (compress; the backup data will be compressed with “gzip”), “c” (create; an archive file is begin created), “v” (verbose; display a list of files as they get backed up), “p” (preserve permissions; file protection information will be “remembered” so they can be restored). The “f” (file) option states that the very next argument will be the name of the archive file (or device) being written. Notice how a filename which contains the current date is derived, simply by enclosing the “date” command between two back-quote characters. A common naming convention is to add a “tar” suffix for non-compressed archives, and a “tar.gz” suffix for compressed ones.

The “–directory” option tells tar to first switch to the following directory path (the “/” directory in this example) prior to starting the backup. The “–exclude” options tell tar not to bother backing up the specified directories or files. Finally, the “.” character tells tar that it should back up everything in the current directory.

Truncate a File

cat /dev/null > <filename>

Find All Files in a Directory and its Subdirectories

find . -type f | wc -l
du -a | cut -d/ -f2 | sort | uniq -c | sort -nr
ls | wc -l

ls -l | grep ^d | wc -l
ls -l | grep ^l | wc -l

Find All Files in a Directory Only

ls -l | grep ^- | wc -l
echo $(($(ls -l | grep -v ^d | wc -l)-1))

Find All Subdirectories in a Directory

ls -l | grep ^- | wc -l
echo $(($(ls -l | grep -v ^d | wc -l)-1))
find . -maxdepth 1 -type d | wc -l

Find All Softlinks in a Directory

ls -l | grep ^l | wc -l

Find All Subdirectories in a Directory and its Subdirectories

find . -type d | wc -l

Mirror a Website

wget -m <URL>

Remove All Leading and Trailing Spaces in a File

sed ‘s/^[[:space:]]*\(.*\)[[:space:]]*$/\1/’

Add Colors to Grep Outout

export GREP_OPTIONS=’–color=auto’

Mass Renaming of the Files, e.g. js?P to js

find . -name ‘*.js?P’ -exec sh -c ‘mv “$0” “${0%.js?P}.js”‘ {} \;

Mass Renaming Uppercase to Lowercase

for f in `find`; do mv -v $f `echo $f | tr ‘[A-Z]’ ‘[a-z]’`; done

Mass Renaming Convert Spaces to Underscores

rename ‘ ‘ ‘_’ *

Insert A Character, e.g. ‘;’ At the End of Each Line in Vi


Insert A Character, e.g. ‘;’ At the Start of Each Line in Vi


Extracting an APK from Android phone

adb shell pm list packages

Then you may select an app, for instance twitter

adb backup -apk

An important thing here is to not set up a password for encrypt your backup

This is going to create a file named as backup.ap, but you still can’t open it. For this you got to extract it again but using the dd command.

dd if=backup.ab bs=24 skip=1| openssl zlib -d > backup.tar

Now extract the tar contents and that’s it.y select an ap

Change a word in multiple files

grep -rl 'windows' ./ | xargs sed -i 's/windows/linux/g'