skip to main |
skip to sidebar
RSS Feeds
Nope. nothing .. just some random thoughts come to my mind ...
Nope. nothing .. just some random thoughts come to my mind ...
8:16 PM | Thursday, July 26, 2012
Posted by harshadura
Alternative: Revert the full commit
git push -f origin e4f1180e73d8:master
7:43 PM | Monday, July 16, 2012
Posted by harshadura
Directory “c:/wamp/www/”Find and replace ’127.0.0.1′ with ‘All’
#
# 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 127.0.0.1
3:35 PM | Wednesday, July 4, 2012
Posted by harshadura
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("http://23.21.69.166/ralapanawa/RalaWS.php"); 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()); } } }
10:43 PM | Tuesday, July 3, 2012
Posted by harshadura
<?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($status_header);
header('Content-type: ' . $content_type);
echo $body;
}
class RalapanawaAPI {
private $db;
function __construct() {
$this->db = new mysqli('localhost', 'USER', 'PASS', 'ralapanawa');
}
function __destruct() {
$this->db->close();
}
function rala() {
if (isset($_POST["tank_id"]) && isset($_POST["water_level"]) ) {
try{
$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);
$stmt->execute();
$stmt->close();
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);
$stmt->execute();
$stmt->bind_result($depth);
while ($stmt->fetch()) {
break;
}
$stmt->close();
$result = array(
"water_level" => $depth
);
sendResponse(200, json_encode($result));
return true;
}
sendResponse(400, 'Invalid request');
return false;
}
}
$api = new RalapanawaAPI;
$api->rala();
?>
curl -F "rw_app_id=1" -F "code=test" -F "device_id=test" http://www.wildfables.com/promos/
12:31 PM | Sunday, July 1, 2012
Posted by harshadura
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.
pasv_max_port=41000 pasv_min_port=40000 port_enable=YES pasv_enable=YES