Sunday, June 15, 2014

How to read phonebook with phonegap from android

                function queryPhoneBook()
// find all contacts field
var options = new ContactFindOptions();
var fields = ["name", "phoneNumbers"];
navigator.contacts.find(fields, onSuccess, onError, options);

                function onSuccess(contacts) {
                var j = 0;
                for(var i=0; i < contacts.length ; i++)
if( contacts[i].phoneNumbers == null )
                if(contacts[i].phoneNumbers.length > 0)
                //var temp = contacts[i].displayName + "" + contacts[i].phoneNumbers[0].value;

var htmlData = '<li id="'+j+'"><a href="#"><h2>'+contacts[i].displayName+'</h2><p class="ui-li-aside">'+contacts[i].phoneNumbers[0].value+'</p></a></li>';
        $.mobile.changePage($("#index"), { transition : "slide"});

Thursday, June 5, 2014

Playing with digital Ocean

amazon ec2 seemed to be complecated though not so difficlut but I am trying didgital ocean now for all my home based research here is what i did today to setup a new instance of droplet and installed Lamp

adduser sandeep


# User privilege specification
root    ALL=(ALL:ALL) ALL
demo    ALL=(ALL:ALL) ALL

nano /etc/ssh/sshd_config
Port 4444

PermitRootLogin no
AllowUsers sandeep

sudo apt-get update
sudo apt-get install apache2

sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql
sudo mysql_install_db
sudo /usr/bin/mysql_secure_installation

sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt

sudo nano /etc/apache2/mods-enabled/dir.conf 
change index.php

Get the Mysql password

tail -1 /root/.my.cnf | awk -F'=' '{print $2}'
Setting Up Java

sudo apt-get install default-jre
sudo apt-get install default-jdk
sudo nano /etc/environment and append this line
source /etc/environment

Installing SFTP/ProFtp

sudo apt-get update && sudo apt-get install proftpd
apt-get install openbsd-inetd
lrwxrwxrwx   1 root root    16 Sep 23 15:34 openlibs -> /opt/GLOBAL/libs
lrwxrwxrwx   1 root root    20 Sep 23 15:34 openservices -> /opt/GLOBAL/services

00 12 * * sat /home/root/monitoring/config/start/
00 12 * * sat /home/root/monitoring/config/stop/

Setting up Smack library in Ubuntu
Setting up two domain names with DO

Setting up a subdomain e.g <blog> in this case

Lets say subdomain name is blog on

sudo mkdir -p /var/www/
sudo chown -R www-data:www-data /var/www/
sudo chmod -R 755 /var/www

put all content with an index file at 

cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/
vi /etc/apache2/sites-available/

update ServerAdmin
add ServerName
update DocumentRoot /var/www/

last and final step:
sudo a2ensite
sudo service restart apache2
/etc/init.d/apache2 restart

create a CNAME record in your owned domain as
* => @ 
give 20-30 minutes to zone file to be propagated.

Using filters on JSON
$scope.selectedTransporter = $filter('filter')($rootScope.CACHE['TRANSPORTER'], $scope.record.transporter_id);

phpmyadmin upgrade =>

sudo add-apt-repository ppa:nijel/phpmyadmin;
sudo apt-get update;
sudo apt-get install phpmyadmin;