Tuesday 25 February 2014

WhatsApp brings free voice call

WhatsApp CEO Jan Kaum ,at the MWC, Barcelona, announced that WhatsApp will add the voice call facility by the second quarter of this year. This movement is seen as worrying for telecom operators globally.WhatsApp's acquisition by Facebook would not alter the plan to develop the product to reach the next 1 billion users. No advertising will added to the service, the CEO said.


Monday 24 February 2014

Nokia Android phones !!


Nokia revealed three ‘X’ phones- the Nokia X, the Nokia X+ and the Nokia XL , at the Mobile World Congress in Baecelona.

Features:
4-in touchscreen with more RAM and storage on the X+
5-in touchscreen, 5MP rear camera, 2MP front camera on XL.

They do not run the Android OS but able to run the Android applications. These phones will relay on Microsoft's cloud apps.

Pricing :
The Nokia X will cost 89 Euros (Rs. 7,600 approx.), Nokia X+ will cost 99 Euros (Rs. 8,500 approx.) and Nokia XL will cost 109 Euros (Rs. 9,300 approx.).

Sunday 23 February 2014

Whatsapp service restored



WhatsApp, the popular instant message service, restored after the outage on saturday night (Feb 22, 2014). The app was down for around three hours.Tweets came from all around the world about the issue. By early morning WhatsApp tweeted that the service has been restored.
WhatsApp is in news as Facebook announced that it is buying the service for $19 billion.

Friday 21 February 2014

Breaking the Vigenere cipher : Java programming

Suppose a text is encrypted using the Vigenere cipher. The given Java program can be used to break the cipher and read the content.

*-----------------------*

import java.io.*;
public class decipher
{
public static void main(String args[])
{
  String ctext="cipher_text_here";
  ctext=ctext.toUpperCase();
  String key="enter_key";
  char[] alphabet = {’A’,’B’,’C’,’D’,’E’,’F’,’G’,’H’,’I’,’J’,’K’,’L’,’M’,’N’,’O’,
  ’P’,’Q’,’R’,’S’,’T’,’U’,’V’,’W’,’X’,’Y’,’Z’};
  String plaintext = "";
  int k=0;
  for(int i=0; i < ctext.length(); i++)
     {
     int keypos = 0,ciphpos=0;
     char c=ctext.charAt(i);
     int value = (int) c;
        if(value<65 value="">90)
        {
        System.out.print(c);
        }
        else
        {
        for(int j = 0; j<26 j="" p="">           {
           if(key.charAt(k%key.length())==alphabet[j])
           {k++;
            keypos=j;
            break;
           }
           }
        for(int j = 0; j<26 j="" p="">           {
           if(ctext.charAt(i)==alphabet[j])
           {
           ciphpos=j;
           break;
           }
           }
        System.out.print(alphabet[(ciphpos-keypos+26)%26]);
        }
     }
 }

}


Wednesday 19 February 2014

Creating a deadlock situation - Programming in C

Use the following header files:

stdio.h
pthread.h
unistd.h

program:


pthread_mutex_t fir_mx;
pthread_mutex_t sec_mx;

 void *fn1()
 {
  pthread_mutex_lock(&fir_mx);
  pthread_mutex_lock(&sec_mx);
  printf("Thread 1 locks mutex\n");
  pthread_mutex_unlock(&sec_mx);
  pthread_mutex_unlock(&fir_mx);
 }
 void *fn2()
 {
  pthread_mutex_lock(&sec_mx);
  pthread_mutex_lock(&fir_mx);
  printf("Thread 2 locks mutex\n");
  pthread_mutex_unlock(&fir_mx);
  pthread_mutex_unlock(&sec_mx);
 }
 int main(void)
 {
 pthread_t tid1;
 pthread_t tid2;
 pthread_mutex_init(&fir_mx,NULL);
 pthread_mutex_init(&sec_mx,NULL);
 int t;
 while(1)
 {
 pthread_create(&tid1,NULL,fn1,NULL);
 pthread_create(&tid2,NULL,fn2,NULL);
 pthread_join(tid1,NULL);
 pthread_join(tid2,NULL);
 }
 }













Thursday 6 February 2014

Writing to only specific files in a directory : C program

Suppose we have a file named 'hello' (could be even an executable one) and we need to write the content of this file into some other files of selected extension (for example, only the binary files) . This simple C program will help you to do this task. Include stdlib.h and dirent.h .

Program:

int main()
{
 DIR * d;
 FILE *fp1,*fp2;
 char* ext;
 int i;
 char * dirname = ".";
 struct dirent *handle;

 d = opendir(dirname);
 if(!d)
    printf("Directory not opened");
 while((handle=readdir(d))!=NULL)
 {
    ext=strchr(handle->d_name,'.');
    if(ext!=NULL)
       if(strcmp(ext+1,"bin")==0)
          {
            char ch;
            fp1=fopen(handle->d_name,"w");
            fp2=fopen("hello","r");
            fseek(fp2, 0, SEEK_END);
            long fsize = ftell(fp2);
            fseek(fp2, 0, SEEK_SET);

            char *string = malloc(fsize + 1);
            fread(string, fsize, 1, fp2);
            fclose(fp2);
            string[fsize] = 0;
            for(i=0;i < fsize; i++)
                fprintf(fp1,"%c",string[i]);
          }
 }
 return 0;
}