Thursday, 30 January 2014

Find your Lost Android Phone

A lost phone is worrisome. You would fear that someone misuse your phone pushing you in serious troubles. I'm not talking about SIM, because you can block that. But what if you have very vital information stored in your phone??! Then definitely it is a serious issue. Prevention is better than cure. First of all implement the following steps:

  1. Go to Settings->Security->Device Administrators->Android Device Manager
  2. Tap on it and activate it.
  • Now if your phone is lost, go to google play store
  • There you can see a gear like button on the top right corner of your page, click on it and select Android Device Manger
You have 3 options:

  • Ring: You can ring your phone
  • Lock your phone
  • Erase all data: This will erase all data but not SD card. Also  Android Device Manger wont work if you erase the data


  • Tuesday, 28 January 2014

    Replace spaces in a string with %20

    Here's the code to replace all the spaces with %20 in a given string.

      1 #include<iostream> 
      2 using namespace std;
      3 int main() 
      4 { 
      5     int i,len,count=0; 
      6     char *str; 
      7     str=new char[100]; 
      8     cout<<"Enter your string: "; 
      9     gets(str); 
     10     len=strlen(str); 
     11     for(i=0;i<len;i++) 
     12     { 
     13         if(str[i]==' ') 
     14             count++; 
     15     } 
     16     int newlength=len+count*2; 
     17     str[newlength]='\0'; 
     18     for(i=len-1;i>=0;i--) 
     19     { 
     20         if(str[i]==' ') 
     21         { 
     22             str[newlength-1]='0'; 
     23             str[newlength-2]='2'; 
     24             str[newlength-3]='%'; 
     25             newlength=newlength-3; 
     26         } 
     27         else 
     28         { 
     29             str[newlength-1]=str[i]; 
     30             newlength=newlength-1; 
     31         } 
     32     } 
     33     cout<<"String after replacing: "; 
     34     puts(str); 
     35     return 0;
     36 } 

    Removing duplicates from the string

    Here's the code to remove duplicates from a given string. In this program, I've used a variable called tail which is used to remove all the duplicates and also acts as boundary for string comparison.


      1 #include<iostream> 
      2 using namespace std;
      3 int main() 
      4 { 
      5     char *str; 
      6     str=new char[50]; 
      7     cout<<"enter"; 
      8     cin>>str; 
      9     int tail = 1,len;
     10     len=strlen(str); 
     11      for (int i = 1; i < len; ++i) {
     12         int j; 
     13         for (j = 0; j < tail; ++j) {
     14              if (str[i] == str[j]) break;
     15          } 
     16         if (j == tail) { 
     17             str[tail] = str[i]; 
     18             ++tail; 
     19          } 
     20     } 
     21  str[tail] = 0; 
     22  for(int i=0;i<len;i++) 
     23      cout<<str[i]; 
     24  return 0;
     25 }
    I appreciate your suggestions if any....Thank you

    Reverse a String

    Here's a program to reverse a string. Although I'm not sure about the time complexity, this program has worked well

      1 #include<iostream> 
      2 using namespace std;
      3 int main() 
      4 { 
      5     char *a, *b,c; 
      6     int i,j; 
      7     cout<<"Enter: "; 
      8     a=new char[50]; 
      9     b=new char[50]; 
     10     cin>>a; 
     11     int l=strlen(a); 
     12      
     13     for(i=0,j=l-1;i<l-1,j>0,i<j;i++,j--) //Swap last and first characters
     14     { 
     15         c=a[i]; 
     16         a[i]=a[j]; 
     17         a[j]=c; 
     18     } 
     19     for(i=0;i<l;i++) 
     20         cout<<a[i]; 
     21     return 0;
     22 } 
         

    Friday, 24 January 2014

    Program to determine if a string has unique characters

    This is a simple program to check if all the characters in a string are unique or not if no additional data structure is provided.
      1 #include<iostream> 
      2 using namespace std;
      3 int main() 
      4 { 
      5     int i,l,j; 
      6     bool f=true; 
      7     char a[50];
      8     cout<<"Enter: "; 
      9     gets(a); 
     10     l=strlen(a); 
     11     for(i=0;i<l;i++) 
     12     { 
     13         for(j=l-1;i<j;j--) 
     14         if(a[i]==a[j]) 
     15         { 
     16             f=false; 
     17             break; 
     18         } 
     19     } 
     20     if(f) 
     21         cout<<"All unique"; 
     22     else 
     23         cout<<"Not unique"; 
     24     return 0;
     25 } 
     26 

    Saturday, 18 January 2014

    Bugs!!

    Do you know how the name bug came into picture in computer world??? In computer world, a bug is a "mistake" in a program whereas in real world, a bug is kind of "moth". Then how these two were related?? Here is the answer:

    In early days of computer, when its hardware is very sensitive, a small moth caused a relay to fail when Aiken, Hopper were working on Harvard Mark1 computer. Hopper and other programmers taped the deceased moth in a log book with the note "First actual case of bug being found."

    The log book is currently on the display at Navel Museum in Dahlgren, Virginia. This was the first computer documented bug.

    Professor Aiken would come into the facility during a slack time and inquire if any numbers were being computed. Then the programmers would reply that they were debugging the computer!!!!!

    In this way we bug came into computer world !!


    Facebook Themes


    The other day I was searching for some apps in google play store and I found themes for Facebook. It was surprise to me but that did last only few minutes because of the poor layouts. Themes shown in gallery and themes applied to facebook account were different. Also facebook icon i.e.  is completely removed and the new layout is completely misplaced in some themes...so be selective in choosing these themes and not all are good! For those who want to try have a look:

    1. Go to chrome webstore and search for Facebook themes and download the one with facebook icon shown here: .
    2. Now after installation type chrome://extensions in address bar and search for facebook themes.
    3. In options click on explore and install your favorite theme it takes just a second!
    4. Go to your facebook account and you can see the applied theme.


    5. If you want to switch to default, just go to installed tab and click on disable!