Skip to content

Instantly share code, notes, and snippets.

View zainaali's full-sized avatar

Zain Ali zainaali

  • Lahore Punjab, Pakistan
View GitHub Profile
@zainaali
zainaali / area.php
Created February 21, 2018 08:01
Calculating area of a polygon drawn on google map
<div class="controls">
<div class="span1 four"><a id="editPoly" class="tracing-control active" title="This is the drawing/tracing tool. Work with this tool to create your outlines."><i class="fa fa-lg fa-pencil icon-pencil icon-large"></i><br>Trace</a></div>
<div class="span1 four"><a id="moveMap" class="tracing-control" title="Click here to move the map. Or click and drag when in Tracing mode."><i class="fa fa-lg fa-arrows icon-move icon-large"></i><br>Edit</a></div>
<div class="span1 four"> <a id="undoDrawing" class="tracing-control" title="Did your tracing not turn out? Click here to undo your last outline."><i class="fa fa-lg fa-undo icon-undo icon-large"></i><br>Undo</a>
</div>
</div>
<?php $yard_size = $_POST['yard_size'];?>
<input type="hidden" name="yard_size" id="yard_size" value="<?php $yard_size?>">
<div id="map" style="display: block; width: 100%; height: 500px;"></div>
@zainaali
zainaali / city.js
Last active February 21, 2018 07:41
Extract city from google autocomplete address api
autocomplete.addListener('place_changed', function() {
var place = autocomplete.getPlace();
//Extract city from autocomplete address api
var city;
for(var a = 0; a < place.address_components.length; a += 1) {
var addressObj = place.address_components[a];
for(var b = 0; b < addressObj.types.length; b += 1) {
if (addressObj.types[b] === 'locality') {
city = addressObj.long_name; // confirm that this is the country name
//console.log(addressObj.long_name); // confirm that this is the country name
@zainaali
zainaali / country.js
Last active February 21, 2018 07:42
Extract country from google autocomplete address api
autocomplete.addListener('place_changed', function() {
var place = autocomplete.getPlace();
//Extract country from autocomplete address api
var country;
for(var c = 0; c < place.address_components.length; c += 1) {
var locality = place.address_components[c];
for(var d = 0; d < locality.types.length; d += 1) {
if (locality.types[d] === 'country') {
country = locality.long_name; // confirm that this is the country name
}
@zainaali
zainaali / links.php
Created January 18, 2018 17:25
find links in a string and replace them with actual html link tags
@zainaali
zainaali / functions.php
Created December 21, 2017 15:24
wp_nav_menu change sub-menu class name
<?php
function new_submenu_class($menu) {
$menu = preg_replace('/ class="sub-menu"/','/ class="yourclass" /',$menu);
return $menu;
}
add_filter('wp_nav_menu','new_submenu_class');
?>
@zainaali
zainaali / calculator.html
Last active December 19, 2017 07:31
Angular Js Pool water calculator
<!DOCTYPE html>
<html>
<!-- CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<!-- JS -->
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.3/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.3/angular-animate.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.3/angular-messages.js"></script>
<!--