Friday, January 31, 2014

How to change the URL of moved Wordpress site

If you have just developed a Wordpress site and uploaded it to a remote server, you may end up with a problem of redirecting your site to your localhot though you try to access your site by typing the remote site's URL.
The reason for this problem is URLs of your posts and other pages are still not changed from 'localhost' to your remote server's address. You can do the conversion as follows.

Go to your database and browse 'wp_option' table. Then change the values of 'siteurl' and 'home' in 'option_name' field to your current remote server's address.

Finally go to 'wp_posts' table and go to SQL command tab in your PHPMyAdmin. Type the following query
UPDATE wp_posts
SET guid =
REPLACE(
guid,
"olddomain.com/wordpress",
"www.newdomain.com"
);

Change the  "olddomain.com/wordpress" and "www.newdomain.com" with relavant old domain address (as an example http://localhost/wordpress) and new domain address (as an example http://www.test.com).

Sunday, January 26, 2014

How to unlock Dialog i43 security pattern

Recently my Dialog i43 phone was locked due to trying the wrong security pattern on the display more than 20 times by a kid. I was stucked and was unable to access to any function and the great problem was I had turned off the data and wi-fi which is the default method to solve the problem
How ever I knew Dialog i43 is actually an Alcatel phone. So, I googled my problem and found the solution and it worked well for me. Given below is a quoated solution which is in online.

Refer - http://www.askmefast.com/How_to_unlock_alcatel_one_touch_after_too_many_pattern_attemps-qna2962509.html

You can either change or remove the pattern, please follow these instructions to fix your phone.

►Change the Pattern.
 •Google has a feature when things like this happen. But this feature only works when the phone has internet connection either 3G or WiFi. You can change your pattern by logging in your Google account. To change the pattern:
1. Try guessing the pattern until Google account log in appears.
2. Log in your Google Account.
3. The phone will now ask you to put a new pattern.
4. Put a new pattern and do not forget it again.

►Hard Reset. •If your phone is not connected to the internet you can`t change the pattern using your Gmail Account. Your last option is to hard reset your phone. Hard reset is factory resetting the phone using a combination of hardware buttons. This process will also delete all data on your device. To hard reset your Phone: Because you did not put the exact model name of your Alcatel phone I need the to put the two different methods to hard reset Alcatel phones. Hard reset for Alcatel that doesn`t have recovery menu: (Note: This will delete all data on your phone.)

1. Turn off your phone.
2. Remove the battery for 5 sec.
3. Put it back again, but do not turn on the phone yet.
4. Press and Hold Volume Up and Power button at the same time till you see the Android Logo.
5. Now the phone will reset by by itself, just wait for it to reboot.

Hard Reset for Alcatel Phone with recovery menu: (Note: This will delete all data on the phone.)
1. Turn off your phone.
2. Remove the battery for 5 sec.
3. Put it back again, but do not turn on the phone yet.
4. Press and Hold Volume Up and Power button at the same time till you see the the recovery menu.
5. Touch screen will not work on the recovery menu, use volume key to move up and down, and power button to a select from the options.
6. Select Wipe Data/Factory Reset form the menu.
7. On the next menu select yes.
8. When the reset is done, select reboot system now.

Wednesday, January 8, 2014

ASP.net page methods with argument passing

Related to ASP.net, in some cases we need to call server side methods using client side javascript functions with Ajax. The most efficient way to implement that facility is called page methods. I have found a very successful Blog by related to implementing this page methods. This blog is a small extension of the above mentioned blog.
In practical situations we may need to pass parameters to the server-side from client-side. How can we do that using the same example described in the above mentioned blog.

Let's assume that we need to add two numbers. The numbers are going to input by the user via a text input in HTML.Addition will be done in server-side (by a C# method in ASP.net) after we click a button. (Ajax technology will be used)

  • Define 2 text inputs in HTML

<input id="Text1" type="text" />
<input id="Text2" type="text" />

  • Define a HTML button and calls to a function in the onclick event

<input id="Button1" type="button" value="button" onclick="inputNum()"/>

  • Define a ASP.net script manager in client-side (just drag and drop the controller from the tool box)

<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="True" EnablePartialRendering="true"> </asp:ScriptManager>

  • Define following functions in the client-side using Javascript. (Here I use an array to pass the two numbers as arguments to the server-side method)

function inputNum() {

            var nums = new Array();
            nums[0] = document.getElementById("Text1").value;
            nums[1] = document.getElementById("Text2").value;
            GetInputNumFromServer(nums);
        }

        function GetInputNumFromServer(numsArray) {
            PageMethods.GetSum(numsArray, OnSuccess, OnError);

            return false;
        }

        function OnSuccess(response) {
            alert(response);
        }
        function OnError(error) {
            alert(error);
        }



  • Define the C# method in the server-side. (You have to use the System.Web.Services reference)

 [WebMethod]
        public static int GetSum(int[] arr)
        {
            return arr[0]+arr[1];
        }



That's All.

Monday, November 11, 2013

Debug your Android app without connecting the USB cable

It is annoying to debug an Android application with your device by connecting an USB cable. We are going to know a handy method to debug your app with your device via Wi-Fi without the USB. Let's know it step-by-step. I have done this successfully with Windows and Android 4.0.0.

No need to be ROOTED


1) You have to connect your device with the PC via Wi-Fi
If you have no wireless router and you need to connect your device with the PC via a Wi-Fi adhoc, then you have to convert your PC to a Wi-Fi hot-spot. There is a free and easy application for windows.(For Linux this will be not necessary)
http://www.mhotspot.com/downloadm.html

2) Follow the below Blog by LeoLink®
http://tech.leolink.net/2012/11/use-adb-wifi-without-rooting-for.html
(You have to change the directory of your CMD to "platform-tools" at "sdk" folder)

**Sometimes connection can be lost. Again check the IP address of the device and connect with
adb connect IP ADDRESS

A Simple method to connect your Android phone with PC localhost via Wi-Fi

Especially when we are developing Android applications, we may need to connect our Android application with our personal computer's local host for the testing purposes. The most convenient method to connect both devices is using Wi-Fi. But it is some what difficult to connect Android phones with a Wi-Fi enabled PC via a Ad-Hoc connection without using a separate software.
There is a more simple way to connect your Android phone and PC via Wi-Fi. To use that method your phone need to have the option called "Portable Hotspot" which is used to share your phone's internet connection with other devices via Wi-Fi.
Turn on the "Portable Hotspot" and connect your PC via Wi-Fi. Then open the Command Prompt of your PC and check the "Wireless LAN adapter wireless network connection" information using "ipconfig" command. Then identify the IPv4 address of it.
By using that IP address you can connect with PC's local-host through your Android phone. To check whether phone can access or not, just type the PC's IP address at your phone's web browser's address bar. If the connection is established successfully, you will be able to see welcome screen of your local-host.
Now, it is obvious that you can use that IP with your android applications to connect them with the PC's localhost.     

Thursday, August 22, 2013

RPC program with input parameters and a return value

We will create a RPC (Remote Procedure Calling) program with C which is something advance than 'Hello World'. But it is still simple to understand. In a program like 'Hello World' we cannot learn how to pass parameters or return a value using protocol definitions because those are not required for a simple printing program.
With this program administrator can store any kind of message or notice for other users in the network. Low level user can access to the admin's messages or notices with their client computers by calling to the server computer. Notices can be stored in a simple text file in .txt format. When client requests the service by passing its particular user name and password, server reads the particular text file and return text to the client. We will see step by step how we can develop our simple program.

1. Define the protocol :-
 All our stuff should start with defining the protocol file or .x file.

 struct credintials{
 char uname[200];
 char pwd[200];
};

program NOTICE_PROG{

 version NOTICE_VERS{
 string NOTICE(credintials)=1;
 }=1;

}=0x33674131; 


In the protocol file in RPC we have to define particular input parameters, return type, program name, version and a program number.
In RPC we have to organize all individual parameters in to one data structure and pass as input parameters. In this case we have defined two char arrays to pass user name and the password from the user.
First column of the ninth line defines the return type of the program. This program should return a string which will be read from a text file. Even though in C we don't have a data type called 'string' but a char array, IDL has the key word 'string' for set of characters.
In the third column of the ninth line we have included 'credintials' as a input parameter which we defined as a structure.
Then we have to save this file with .x extension. In this case I save this as notice.x

2. To simply create a RPC program, we need a external program called 'RPC gen' which can automatically generate header, stubs, Makefile and server, client code templates. If you are using ubuntu it is already installed in your system. If you are working with windows, you have to install it.(How ever I recommend you to use ubuntu environment for this task.)
Then you have to check whether all the required libraries are installed. If not you have to install them. To check the availability of those libraries with terminal

>rpcinfo

3. Then we have to run our note.x file with rpcgen and generate the above mentioned files. Just simply type below command in the linux terminal.

>rpcgen -a -C notice.x

Set of files will be genarated as mentioned below :-
Makefile.notice
notice.h
notice_client.c
notice_server.c
notice_clnt.c
notice_xdr.c
notice_svc.c

4. For the ease of commanding you can rename Makefile.notice to Makefile. Makefile includes set of terminal commands related to compiling our RPC program.

5. Then simply type in terminal as

>make

That will compile the program and generate another new set of files as mentioned below :-
notice_client.o
notice_server.o
notice_clnt.o
notice_xdr.o
notice_svc.o
notice_client
notice_server

6. Now you have successfully completed a sketch of a RPC program. Since notice_client and notice_server executable files are already generated, we can execute them by giving following terminal commands.

To start the server program
>sudo ./notice_server

Open another terminal window and run client program
>./notice_client localhost

You will be informed that the connection failed since we have not code the program yet. But already we have the auto generated basic structure of the client and server program as notice_client.c and notice_server.c

7. Now we will code the notice_client.c file as follows. 
#include "notice.h"


void
notice_prog_1(char *host,char *uname,char *pwd)//changed get additional parameters username and password
{
 CLIENT *clnt;
 char * *result_1;
 credintials  notice_1_arg;

#ifndef DEBUG
 clnt = clnt_create (host, NOTICE_PROG, NOTICE_VERS, "udp");
 if (clnt == NULL) {
  clnt_pcreateerror (host);
  exit (1);
 }
#endif /* DEBUG */
 strcpy(notice_1_arg.uname, uname); //set the user name and passwords to the char pointers in the structure
 strcpy(notice_1_arg.pwd, pwd); //set the user name and passwords to the char pointers in the structure

 result_1 = notice_1(&notice_1_arg, clnt); //pass the values to the notice_1() in notice_server.c
 if (result_1 == (char **) NULL) {
  clnt_perror (clnt, "call failed");
 }else{
  printf("Output is : %s\n",*result_1); //print the returned string from the notice_server.c
 }
#ifndef DEBUG
 clnt_destroy (clnt);
#endif  /* DEBUG */
}


int
main (int argc, char *argv[])
{
 char *host;
 char *uname; //Defined char pointer
 char *pwd; //Defined char pointer

 if (argc < 2) {
  printf ("usage: %s server_host\n", argv[0]);
  exit (1);
 }
 host = argv[1];
 uname=argv[2]; //get the username as a command line argument
 pwd=argv[3];   //get the password as a command line argument
 
 notice_prog_1 (host,uname,pwd); //pass all gathered variables to the notice_porog_1 method as parameters 
exit (0);
}


8. Now we will change the notice_server.c file as follows

#include "notice.h"
#include  <string.h>//Additional header file has been included since we uses string functions in our server program

char * getData1();
char * getData2();
char * getData3();
char * getData4();

char **
notice_1_svc(credintials *argp, struct svc_req *rqstp)
{

 printf("Responses to the client");

 static char * result;
 //int authentication=100;

/*Program code for authentication process for 4 individual clients*/
 int authenticUname;
 int authenticPwd;

 int authenticUname1;
 int authenticPwd1;

 int authenticUname2;
 int authenticPwd2;

 int authenticUname3;
 int authenticPwd3;
 
 authenticUname=strcmp(argp->uname,"udara");
 authenticPwd=strcmp(argp->pwd,"123");

 authenticUname1=strcmp(argp->uname,"nimal");
 authenticPwd1=strcmp(argp->pwd,"456");

 authenticUname2=strcmp(argp->uname,"sarath");
 authenticPwd2=strcmp(argp->pwd,"789");

 authenticUname3=strcmp(argp->uname,"kamal");
 authenticPwd3=strcmp(argp->pwd,"147");
 
 
 if(authenticUname==0 && authenticPwd==0){
  result=getData1();
 }else if(authenticUname1==0 && authenticPwd1==0){
  result=getData2();
 }else if(authenticUname2==0 && authenticPwd2==0){
  result=getData3();
 }else if(authenticUname3==0 && authenticPwd3==0){
  result=getData4();
 }else{
  result="Unauthenticated";
 }
 

 return &result;
}


char * getData1(){
 FILE *input;
 input=fopen("notice1.txt","r");
 char *text2;
 char text[1000];
 text2=fgets(text,999,input);
 //strcpy(dest, src);

 
 
 return text2;

}

char * getData2(){
 FILE *input;
 input=fopen("notice2.txt","r");
 char *text2;
 char text[1000];
 text2=fgets(text,999,input);
 //strcpy(dest, src);

 
 
 return text2;

}

char * getData3(){
 FILE *input;
 input=fopen("notice3.txt","r");
 char *text2;
 char text[1000];
 text2=fgets(text,999,input);
 //strcpy(dest, src);

 
 
 return text2;

}

char * getData4(){
 FILE *input;
 input=fopen("notice4.txt","r");
 char *text2;
 char text[1000];
 text2=fgets(text,999,input);
 //strcpy(dest, src);

 
 
 return text2;

}

9. Now we are almost complete. You have to create notice1.txt, notice2.txt, notice3.txt, notice4.txt and include some text.

10. Run make command again and run the client and server program.

Reference :- http://www.cs.rutgers.edu/~pxk/rutgers/notes/rpc/
Source :- https://github.com/udaraseneviratnesmuc/Simple-RPC 

Wednesday, August 14, 2013

Simple RPC Hello World Program

I was given an assignment to create a simple RPC program and run it. After searching the web I found a project from github (https://github.com/JulesWang/helloworld-RPC) by JulesWang. But the problem was I didn't know even to run that simple and user friendly project. Finally I found how to run it in linux platform.
This is how I did it.

1) I downloaded the .zip file from the github and extracted it.

2) I change the directory in my terminal to where I extracted above zip file.

3) According to the given instructions by the creator type following commands on the terminal.

>make
(After execution of that command all the required files will be generated since the project creator has created a makefile including all the commands to generate required files like client, server stubs etc. )

>sudo ./server
(If an error occurred, it means you may have not installed the portmapper. You can check it by >rpcinfo)

>./client localhost
(Type above command in a separate terminal)

4) Hello World output will be generated.