Firefox Geolocater is a great for playing with fake geolocations. You can add geolocations as you wish and check how your Firefox browser take each of those locations as your current location. The plugin is very useful for developers who are building GIS web applications. You can download it here.
Firefox Geolocater is a great for playing with fake geolocations. You can add geolocations as you wish and check how your Firefox browser take each of those locations as your current location. The plugin is very useful for developers who are building GIS web applications. You can download it here.
| Google Map Multiple WayPoints |
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script type="text/javascript">
var myRouter = {
map_: null,
directionsHelper_: null,
stores: [
{name: "Thalawa Station", location: new google.maps.LatLng(8.231796, 80.348333)},
{name: "Maho Station", location: new google.maps.LatLng(7.8228, 80.2778)},
{name: "Mirigama Station", location: new google.maps.LatLng(7.242555, 80.126472)},
{name: "Veyangoda Station", location: new google.maps.LatLng(7.153015, 80.058488)},
{name: "Gampaha Station", location: new google.maps.LatLng(7.093543, 79.993703)}
],
calcRoute: function() {
var waypts = [];
for (var i in this.stores) {
waypts.push({
location: this.stores[i].location,
stopover:true
});
}
var request = {
//origin: new google.maps.LatLng(8.344216, 80.410917),
origin: "Anuradhapura Railway Station",
destination: "Colombo Fort Railway Station",
waypoints: waypts,
optimizeWaypoints: true,
travelMode: google.maps.DirectionsTravelMode.DRIVING
};
var _SELF = this;
this.directionsHelper_.route(request, function(response, status) {
if (status == google.maps.DirectionsStatus.OK) {
_SELF.directionsDisplay_.setDirections(response);
return;
}
console.log('Directions Status: ' + status);
});
},
init: function(mapid) {
this.directionsHelper_ = new google.maps.DirectionsService();
this.directionsDisplay_ = new google.maps.DirectionsRenderer();
var center = new google.maps.LatLng(8.344216, 80.410917);
var myOptions = {
zoom:7,
mapTypeId: google.maps.MapTypeId.ROADMAP,
center: center
}
this.map_ = new google.maps.Map(document.getElementById(mapid), myOptions);
this.directionsDisplay_.setMap(this.map_);
this.calcRoute();
}
};
$(document).ready(function() {
myRouter.init('map');
});
</script>
<style type="text/css">
#map {
height: 500px;
width: 600px;
border: 1px solid #000;
}
</style>
</head>
<body>
<div id="map"></div>
</body>
</html>
![]() |
| MySQL Time Duration |
You may want to check whether a particular date has passed using start date, time duration and current date when the target date is not physically stored.
For clarity, consider a db table schema as follows.
For clarity, consider a db table schema as follows.
+-----------+--------------------------+------------------+ | event_id | start_time | duration_seconds | +-----------+--------------------------+------------------+ | 005 |'2014-10-1 12:13:08' | 86400 | +-----------+--------------------------+------------------+
Here `duration_seconds` is stored using integers. If TIME is used, there 's a limit for 24 hrs.
If you want to get only adverts that have not expired, you will run a query like this.
SELECT * FROM `events` WHERE TIME_TO_SEC(timediff(now(),start_time))<=`duration_seconds`;
![]() |
| HTTP Cache |
HTTP Cache can be troublesome during development in some occasions specially in developing and testing web services, testing endpoints. We can use PHP headers to prevent and disable HTTP cache.
header("Content-Type: application/json");
header("Expires: 0");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
Other than the above, there are other techniques of prevent browser caching. ![]() |
| CodeIgniter |
class FlashMessage {
public static function render() {
if (!isset($_SESSION['my_my_messages'])) {
return null;
}
$my_messages = $_SESSION['my_messages'];
unset($_SESSION['my_messages']);
return implode('<br/>', $my_messages);
}
public static function add($message) {
if (!isset($_SESSION['my_messages'])) {
$_SESSION['my_messages'] = array();
}
$_SESSION['my_messages'][] = $message;
}
}
<?php
$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', YOUR_.PEM_FILE);
stream_context_set_option($ctx, 'ssl', 'passphrase', YOUR_PASSPHRASE);
$fp = stream_socket_client(
'ssl://gateway.sandbox.push.apple.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT, $ctx);
if (!$fp) {
exit("Failed to connect: $err $errstr
");
}
echo 'Connected to APN
';
// Create the payload body
$body['aps'] = array(
'badge' => +1,
'alert' => 'Testing push notifications',
'sound' => 'new_wall_paper.wav',
'action-loc-key' => 'OK'
);
$payload = json_encode($body);
for ($i = 0; $i < count($tokens); $i++) {
$msg = chr(0) . pack('n', 32) . pack('H*', $tokens [$i]) . pack('n', strlen($payload)) . $payload;
fwrite($fp, $msg, strlen($msg));
}
echo "Completed sending messages";
fclose($fp);
?>
Subscribe to:
Posts (Atom)







