ohhhh f*ck.... HEREs how Revert back Git Remote Repo into back without pre changes.......!!!

Alternative: Revert the full commit

git push -f origin e4f1180e73d8:master

How to Access localhost Web Service on Android Device over WIFI

Accessing the localhost over the wifi on my android phone was not easy task for me, many configuration needed to done. I am writing these steps which worked for me. These steps are applicable on Windows 7.

Install the Wamp server

This is one of the best server I know to set up local server. If you have installed Apache or any other server then ignore this step.
Download and install Wamp Server from here.

Add New rule for port 80 in Windows Firewall setting

1. Open control panel and select Windows firewall

2. Select Advanced setting from left panel of Windows firewall setting page.

3. Select Inbound Rules from left panel(1), next Select New Rule(2).

4. Select Port and click next

5. Select “Specific local ports” radio button and enter 80 as a port value.

6. Keep Allow the connection unchanged and move to next.

7. Keep Profile options unchanged and click next.

8. Give some nice name to your New rule and click on Finish.

This will enable port 80 access on local network ip.

Edit httpd.conf file of Wamp server to fix 403 error

We need to edit httpd.conf file else we will get 403 forbidden error when we access the localhost through local network ip.

1 .Click on wamp server tray icon

2. OpenApache server sub menu

3. Select httpd.conf

4 .Find this section of configuration in httpd.conf file

Directory “c:/wamp/www/”
# Possible values for the Options directive are “None”, “All”,
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
# Note that “MultiViews” must be named *explicitly* — “Options All”
# doesn’t give it to you.
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
Options Indexes FollowSymLinks
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be “All”, “None”, or any combination of the keywords:
# Options FileInfo AuthConfig Limit
AllowOverride all
# Controls who can get stuff from this server.
# onlineoffline tag – don’t remove
Order Deny,Allow
Deny from all
Allow from
Find and replace ’′ with ‘All’

Find your local network ip

1. open command prompt

2 .type and enter ipconfig command

3. In my case my local area network address is

This is the ip which you need to access your localhost on your android phone over wifi. To test it is working type this ip address in your desktop browser where your localhost server is installed. Browser should display your localhost page successfully. This will assure that this local network ip is now can successfully accessible on your Android phone.
I hope this tutorial will help you too access your localhost over wifi.

Reference : http://www.mobitechie.com/android-2/how-to-access-localhost-on-android-over-wifi

http client using Java to access POST GET methods from a web service

Download Sample Project

package javaapplication1;

import java.util.logging.Logger;
import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.methods.PostMethod;

public class Main {
 private final static Logger LOGGER = Logger.getLogger(Main.class.getName());

 public static void main(String args[]) {
  try {
   PostMethod post = new PostMethod("");
   post.addParameter("tank_id", "kalawewa");
   HttpClient client = new HttpClient();
   int status = client.executeMethod(post);
   String response = post.getResponseBodyAsString();
   LOGGER.info("Request sent! > Reponse : " + response);

  } catch (Exception e) {
   LOGGER.info("Error : " + e.getMessage());

How to write REST Web Services using PHP


function getStatusCodeMessage($status)
    $codes = Array(
        100 => 'Continue',
        101 => 'Switching Protocols',
        200 => 'OK',
        201 => 'Created',
        202 => 'Accepted',
        203 => 'Non-Authoritative Information',
        204 => 'No Content',
        205 => 'Reset Content',
        206 => 'Partial Content',
        300 => 'Multiple Choices',
        301 => 'Moved Permanently',
        302 => 'Found',
        303 => 'See Other',
        304 => 'Not Modified',
        305 => 'Use Proxy',
        306 => '(Unused)',
        307 => 'Temporary Redirect',
        400 => 'Bad Request',
        401 => 'Unauthorized',
        402 => 'Payment Required',
        403 => 'Forbidden',
        404 => 'Not Found',
        405 => 'Method Not Allowed',
        406 => 'Not Acceptable',
        407 => 'Proxy Authentication Required',
        408 => 'Request Timeout',
        409 => 'Conflict',
        410 => 'Gone',
        411 => 'Length Required',
        412 => 'Precondition Failed',
        413 => 'Request Entity Too Large',
        414 => 'Request-URI Too Long',
        415 => 'Unsupported Media Type',
        416 => 'Requested Range Not Satisfiable',
        417 => 'Expectation Failed',
        500 => 'Internal Server Error',
        501 => 'Not Implemented',
        502 => 'Bad Gateway',
        503 => 'Service Unavailable',
        504 => 'Gateway Timeout',
        505 => 'HTTP Version Not Supported'

    return (isset($codes[$status])) ? $codes[$status] : '';

function sendResponse($status = 200, $body = '', $content_type = 'text/html')
    $status_header = 'HTTP/1.1 ' . $status . ' ' . getStatusCodeMessage($status);
    header('Content-type: ' . $content_type);
    echo $body;

class RalapanawaAPI {

    private $db;

    function __construct() {
        $this->db = new mysqli('localhost', 'USER', 'PASS', 'ralapanawa');

    function __destruct() {

    function rala() {

        if (isset($_POST["tank_id"]) && isset($_POST["water_level"]) ) {
                $tank_id = $_POST["tank_id"];
                $water_level = $_POST["water_level"];

                $stmt = $this->db->prepare("INSERT INTO water_level (tankid, Depth) VALUES (?, ?)");
                $stmt->bind_param("ss", $tank_id, $water_level);

                sendResponse(200, 'Water Level Saved!');
                return true;
            } catch (Exception $e) {
                $err = 'Caught exception: '.  $e->getMessage().  "\n";
                sendResponse(200, $err);
                return false;

        if (isset($_POST["tank_id"]) ) {

            $depth = "";
            $tank_id = $_POST["tank_id"];

            $stmt = $this->db->prepare("SELECT Depth FROM water_level WHERE tankid=?");
            $stmt->bind_param("s", $tank_id);

            while ($stmt->fetch()) {

            $result = array(
                "water_level" => $depth
            sendResponse(200, json_encode($result));
            return true;

        sendResponse(400, 'Invalid request');
        return false;


$api = new RalapanawaAPI;


curl -F "rw_app_id=1" -F "code=test" -F "device_id=test" http://www.wildfables.com/promos/



Connecting into EC2 instace using Filezilla FTP

If you don't like commandline tool, you can use Filezilla instead. Download and install Filezilla client.  Lauch Filezilla. Click Edit -> Settings and select SFTP under Connction. Click Add Keyfile to add the private key file you use for putty connection. Click OK.

Click File -> Site Manager, Click New Site, enter your AWS EC2's public DNS or IP in Host field. Choose SFTP, enter ec2-user in User field and click Connect.

Now you are connected to your EC2 instance with FileZilla.

If you still want to set up an FTP server on your AWS EC2. Below are steps to install VSFTP.
  1. login to  your AWS management console.
    • Go to EC2 and click the Security Groups link.
    • Then choose the default group and switch to the inbound tab (at the bottom of the page)
    • Add the port ranges as above (20-21 and 40000-41000) and apply the rule changes
  2. connect to your instance with putty.
  3. login as ec2-user
  4. sudo yum install vsftpd
  5. change the conf file. sudo vi /etc/vsftpd/vsftpd.conf. Add

  6. pasv_max_port=41000

  7. Add an FTP user (see instruction here)
  8. Start the FTP server. service vsftpd start 
Reference : http://lzw-programmingjourney.blogspot.com/2011/12/set-up-ftp-server-on-amazon-aws-ec2.html