Monday, February 11, 2013

How to move apps from phone memory to SD card in android

You may find many apps on google play which can use to move apps from phone memory to SD card, but for this to work developers need to enable this option in their apps.Following method is valuable if you do have a phone with small internal memory plus loads of apps which you cant move to SD card using apps like APP 2 SD.

  • Download latest version of Android SDK.
  • Connect the phone using USB cable and enable USB debugging mode.Settings -> Applications -> Development and enable USB debugging
  • Open terminal and navigate to android SDK directory, in my instance cd /home/udara/private/android-sdk-linux/platform-tools/
  • Add that directory to path using, export PATH=$PATH:/home/udara/private/android-sdk-linux/platform-tools/
  • Now by typing adb devices command you will get something similar to,

  • Type adb shell and then run command pm setInstallLocation 2.
  • Now on your phone go to Settings->Applications->Manage Applications and you will find most of the applications are now available to move from phone memory to SD card.

I have tested this on a rooted huawei U8160 running android 2.2(froyo) using UBUNTU 12.04. 

Tuesday, February 5, 2013

browscap to JS navigator

Browscap facilitate to identify what a visitor's browser is capable of, an improved version of native php function get_browser(). You need to update browscap.ini which resides on your server periodically in order to get the correct browser capabilities.

In the recent past with rise of the JS world, you can detect HTML5, CSS3 browser capabilities with the use of JS libraries like modernizr or even with simple JS navigator.

browscap output,


JS navigator output,


Tuesday, September 11, 2012

Password Protecting with .htaccess

1. create password file with encrypted password. Save password file as .ht{something} outside web root if possible.

for example .htukrpass file contain following
username:password

2. create .htaccess file with following content


AuthUserFile {fullpath to .htukrpass file}
AuthType Basic
AuthName "our test source dir"
Require valid-user
require user {username}



Monday, July 9, 2012

connect to mailbox with IMAP - php

install
  • php-imap
  • php-cli
modules in-order to work IMAP with php.

search for the  following line in your php.ini file

extension = imap.so

then search for the imap.ini file in /etc/php5/conf.d directory , if not exist create it with following line in it.

extension = imap.so


then restart apache server.

use following php sample code with your server name and user credentials to check connectivity.

XMPP chat logging with bandersnatch


add this in the modules section of ejabberd config file:
  {mod_service_log, [{loggers, ["localhost"]}]}

add this in the listeners section of ejabberd config file, you can use your own password:
  {5526, ejabberd_service, [{ip, {127, 0, 0, 1}}, {access, all},
                          {hosts, ["localhost"],
                          [{password, "secret"}]}]},

create bandersnatch database using given sql. make sure to remove TYPE=MyISAM if you are using innoDB mysql engine. and replace datatype timestamp(14) ,from timestamp all CREATE TABLE scripts.
modify bandersnatch/config.xml with the password.
  <server>
        <connectiontype>tcpip</connectiontype>
        <hostname>localhost</hostname>
        <port>5526</port>
    <secret>secret</secret>
</server>
<component>
    <name>localhost</name>
</component>

change,privacy value in site tag to 0.you need this change to set privacy level to log chat messages with sender and receiver details.
install the perl dependencies:
  sudo apt-get install libnet-jabber-perl

configure Perl interface to the SHA-1 algorithm using cpan.
  install Digest::SHA1

found bug in bandersnatch module you need to import Digest::SHA1 in order to make this work,add following line
  use Digest::SHA1  qw(sha1 sha1_hex sha1_base64);

in /usr/share/perl5/Net/Jabber/Component.pm
to start bandersnatch service
  perl bandersnatch config.xml

Sunday, February 12, 2012

PHP exec, the java process takes 100% CPU (SOLVED)

Exec is always tricky, on any language :-)

Try to:

use background execution (add & symbol at the end)
use shell_exec instead
specify the full path to java executable (may be the one available to PHP is not the one you need?)

export LD_LIBRARY_PATH="";
in the exec call:

Saturday, January 28, 2012

REpresentational State Transfer(REST) and security

What is REST?
Client sends a request to the server witch responds with a representation of required informational Object.This respond usually formatted in JSON or XML.

A RESTful service normally provides two
components in its responses, the response body itself and a status code.Most of the REST servers allow users to specify a response format by sending ACCEPT parameter or by specifying a file extension.Others have hard-coded response formats.

Security Aspects

By Accepting certain data type,certain length and validating each request.

Authenticating/Authorizing requests : by making developers to register for a API key and validate key against the stored key for that particular developer.

by having quotas and data limits

finally by using SSL to encrypt communication.