Sunday, June 15, 2014

How to read phonebook with phonegap from android

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

                function onSuccess(contacts) {
                //navigator.notification.alert(contacts.length);
                var j = 0;
                $.mobile.showPageLoadingMsg(true);
                //$("#userList").html('');
                for(var i=0; i < contacts.length ; i++)
                {
if( contacts[i].phoneNumbers == null )
continue;
                if(contacts[i].phoneNumbers.length > 0)
                {
                //navigator.notification.alert(contacts[i]);
                //var temp = contacts[i].displayName + "" + contacts[i].phoneNumbers[0].value;
        //navigator.notification.alert(temp);

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>';
$("#userList").append(htmlData).listview('refresh');
j++;
        }
        }
        $.mobile.changePage($("#index"), { transition : "slide"});
$.mobile.hidePageLoadingMsg();
}

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


passwd
adduser sandeep

visudo

# 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

https://www.digitalocean.com/community/tutorials/how-to-set-up-multiple-wordpress-sites-using-multisite

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
JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
source /etc/environment
echo $JAVA_HOME

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/procmon.sh
00 12 * * sat /home/root/monitoring/config/stop/procmon.sh

CLASSPATH="/usr/java/bin:/home/s_gcm/gcmserver:/home/s_gcm/gcmserver/libs"
https://www.digitalocean.com/community/tutorials/how-to-configure-proftpd-to-use-sftp-instead-of-ftp
Setting up Smack library in Ubuntu
wget http://www.java2s.com/Code/JarDownload/xmlpull/xmlpull-xpp3-1.1.4c.jar.zip
http://www.java2s.com/Code/JarDownload/xmlpull/xmlpull-xpp3-1.1.4c.jar.zip
Setting up two domain names with DO
https://www.digitalocean.com/community/tutorials/how-to-set-up-multiple-wordpress-sites-on-a-single-ubuntu-vps

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


Lets say subdomain name is blog on zoogaru.com



sudo mkdir -p /var/www/blog.zoogaru.com/public_html
sudo chown -R www-data:www-data /var/www/blog.zoogaru.com/public_html
sudo chmod -R 755 /var/www

put all content with an index file at 
/var/www/blog.zoogaru.com/public_html/

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

update ServerAdmin blog@zoogaru.com
add ServerName blog.zoogaru.com
update DocumentRoot /var/www/blog.zoogaru.com/public_html

last and final step:
sudo a2ensite blog.zoogaru.com
sudo service restart apache2
or
/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;