Skip to content

Instantly share code, notes, and snippets.

Harry Mustoe-Playfair manticorp

Block or report user

Report or block manticorp

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@manticorp
manticorp / Circles around n locations on a google map.
Created Apr 20, 2015
Circles around n locations on a google map (for finding road signs)
View Circles around n locations on a google map.
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<title>Geocoding service</title>
<style>
html, body, #map-canvas {
height: 100%;
margin: 0px;
@manticorp
manticorp / PSR2MethodReplace
Created Jan 31, 2015
PSR2 Method fixing Replacement Regex
View PSR2MethodReplace
<?php
$search = "/( +)((abstract|final)? ?(public|private)? ?(static)?function [^\(]+([^{\n])+)\n+? +?\{/i";
$replace = "$1$2\n$1{";
@manticorp
manticorp / VarDisplay
Last active Aug 29, 2015
PHP function for displaying the full contents of a variable - a customisable var_dump
View VarDisplay
<?php
/**
* Recursively iterates over $var, displaying each
* property/variable contained within
* @param mixed $var Variable of any type
* @param boolean $displayTypes Whether to display the types along with values
* @param integer $depth private var for telling how deep we are
* @return null always returns null
*/
@manticorp
manticorp / Plot for JavaScript
Created May 22, 2013
Plot function for JavaScript. Basically a wrapper for settings styles and stuff.
View Plot for JavaScript
Plot = function (e) {
this.toCenter = function () {
d = Math.min(this.elm.width, this.elm.height);
mLR = Math.floor((document.documentElement.clientWidth - d) / 2);
mTB = Math.floor((document.documentElement.clientHeight - d) / 2);
this.setMargins(mTB, mLR, mTB, mLR);
this.position(Math.floor((document.documentElement.clientWidth - d) / 2), Math.floor((document.documentElement.clientHeight - d) / 2), true)
};
this.setDimensions = function (x, y) {
y = this.checkVar(y, x, false);
@manticorp
manticorp / Preg match to get ASIN from amazon URL
Created Apr 8, 2013
Preg match to get ASIN from amazon URL
View Preg match to get ASIN from amazon URL
$url = "http://www.amazon.co.uk/dp/B003YGQP6A";
preg_match('/\/([a-zA-Z0-9]{10})/',$url,$parsed);
$ASIN = $parsed[1];
@manticorp
manticorp / Turn Doctrine Column Defs in Zend to setters and getters
Last active Dec 15, 2015
This gist turns doctrine vars in zend framework to their respective set and get function. Just put your column definitions into a #content container and the returned functions will be put in the #result container. Working jsfiddle: http://jsfiddle.net/Manticorp/Sm5PM/11/
View Turn Doctrine Column Defs in Zend to setters and getters
var str = $("#content").html();
var search = /\/\**[\n\r*\*\w @(=}{",)]*\*\/[\r\n\t ]*private *\$(\w*)[ ="\w]*;/g;
$("#content").html("");
var result = str.match(search);
var getFunc;
var setFunc;
@manticorp
manticorp / Pass object to partialLoop Zend framework
Last active Dec 15, 2015
Passing a Doctrine entity object to a partial or a partial loop in Zend framework
View Pass object to partialLoop Zend framework
//You can pass objects to partials, just pass them in an array:
$this->partial('mypartial.phtml', array('topic' => $topic'))
//The partial helper will take the keys of that array and create view vars out of them, so you can access it like this from within the partial:
<td><?= $this->topic->getDescription() ?></td>
//If you want to use objects with a partial loop, you can call setObjectKey() on the partialLoop helper and pass in an array of objects:
@manticorp
manticorp / is_leap function
Created Mar 12, 2013
Function to determing if the year given is a leap year. Defaults to the current year.
View is_leap function
function is_leap($year = NULL) {
return checkdate(2, 29, ($year == NULL)? date('Y'):$year); // true if is a leap year
}
@manticorp
manticorp / csv to array function
Last active Dec 14, 2015
A simple function to convert a CSV file to an array:
View csv to array function
function csv_to_array($filename='', $delimiter=',',$header = NULL)
{
if(!file_exists($filename) || !is_readable($filename))
return FALSE;
$data = array();
if (($handle = fopen($filename, 'r')) !== FALSE)
{
while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
{
@manticorp
manticorp / Simple timing class with iteration, max, min, averaging for benchmarking.
Last active Dec 14, 2015
A simple timing class. It's fairly self explanatory. It allows you set 'checks' and then print a list of those checks.It also supports iterations, so if you want to benchmark code fairly you can use the iterator function to do so.Simply set up a normal for loop, wrap it with startIteration and stopIteration, call the setIteration method with the…
View Simple timing class with iteration, max, min, averaging for benchmarking.
<!-- styles for the timer -->
<style>
body{margin:0;padding:0}.manticorp-timing-container{font-family:'Helvetica Neue',Helvetica,Arial,sans-serif}.manticorp-timing-container table{border-collapse:collapse;border:3px solid #555}.manticorp-timing-container tr:first-child td,.manticorp-timing-container tr:first-child th{text-align:center;border-bottom:2px solid #555}
.manticorp-timing-container tr:first-child:hover td,.manticorp-timing-container tr:first-child:hover th{background:#efefef}.manticorp-timing-container tr:hover td,.manticorp-timing-container tr:hover th{background:#ddd}.manticorp-timing-container td,.manticorp-timing-container th{padding:.4em 1em;-webkit-transition:background .06s;transition:background .06s;border-left:1px solid #555}
.manticorp-timing-container th{text-align:right;background:#efefef}.manticorp-timing-container .manticorp-timing-time{font-family:'Courier New',Courier,'Lucida Sans Typewriter','Lucida Typewriter',monospace}
.manticorp-timing-container .manticorp-timing-title{font-fam
You can’t perform that action at this time.