Skip to content

Instantly share code, notes, and snippets.

@sotoz
sotoz / libxmlerrors.php
Created February 25, 2016 09:24
Show broken xml errors with php
<?php
libxml_use_internal_errors(true);
$sxe = simplexml_load_string("<?xml version='1.0'><broken><xml></broken>");
if ($sxe === false) {
echo "Failed loading XML\n";
foreach(libxml_get_errors() as $error) {
echo "\t", $error->message;
}
}
?>
@sotoz
sotoz / getdirections.js
Last active March 2, 2016 09:37
Google maps geolocation get directions
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=123&sensor=false&language=el"></script>
<script>
var directionsDisplay;
var directionsService = new google.maps.DirectionsService();
function initialize() {
directionsDisplay = new google.maps.DirectionsRenderer();
var mapOptions = {
zoom: 9,
mapTypeId: google.maps.MapTypeId.ROADMAP,