Skip to content

Instantly share code, notes, and snippets.

View manticorp's full-sized avatar

Harry Mustoe-Playfair manticorp

View GitHub Profile
manticorp /
Last active September 12, 2023 06:33
Rendering a map from terrarium height map tiles and exporting to 16 bit grayscale PNG

Convert tangram tiles to 16 bit grayscale PNG


  • PHP >7.2
    • Composer
  • Python3
    • numpy
    • cupy (optional)
  • PIL
manticorp / Circles around n locations on a google map.
Created April 20, 2015 06:12
Circles around n locations on a google map (for finding road signs)
<!DOCTYPE html>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<title>Geocoding service</title>
html, body, #map-canvas {
height: 100%;
margin: 0px;
manticorp / PSR2MethodReplace
Created January 31, 2015 10:22
PSR2 Method fixing Replacement Regex
$search = "/( +)((abstract|final)? ?(public|private)? ?(static)?function [^\(]+([^{\n])+)\n+? +?\{/i";
$replace = "$1$2\n$1{";
manticorp / VarDisplay
Last active August 29, 2015 14:13
PHP function for displaying the full contents of a variable - a customisable var_dump
* 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 / Plot for JavaScript
Created May 22, 2013 13:10
Plot function for JavaScript. Basically a wrapper for settings styles and stuff.
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 / Preg match to get ASIN from amazon URL
Created April 8, 2013 11:29
Preg match to get ASIN from amazon URL
$url = "";
$ASIN = $parsed[1];
manticorp / Turn Doctrine Column Defs in Zend to setters and getters
Last active December 15, 2015 06:29
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:
var str = $("#content").html();
var search = /\/\**[\n\r*\*\w @(=}{",)]*\*\/[\r\n\t ]*private *\$(\w*)[ ="\w]*;/g;
var result = str.match(search);
var getFunc;
var setFunc;
manticorp / Pass object to partialLoop Zend framework
Last active December 15, 2015 01:49
Passing a Doctrine entity object to a partial or a partial loop in 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 / is_leap function
Created March 12, 2013 13:47
Function to determing if the year given is a leap year. Defaults to the current year.
function is_leap($year = NULL) {
return checkdate(2, 29, ($year == NULL)? date('Y'):$year); // true if is a leap year
manticorp / csv to array function
Last active December 14, 2015 20:19
A simple function to convert a CSV file to an array:
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)