Skip to content

Instantly share code, notes, and snippets.

Johnathan jleppert

View GitHub Profile
@jleppert
jleppert / gist:db8707826ce77a3ec4d61ddf68e42603
Created Dec 1, 2016
postgres lat/lon projection functions
View gist:db8707826ce77a3ec4d61ddf68e42603
CREATE OR REPLACE FUNCTION worldSize (maxZoom int, tileSize int)
RETURNS int AS $$
DECLARE
size int;
BEGIN
size := power(2, maxZoom) * tileSize;
RETURN size;
END;
$$ LANGUAGE plpgsql;
@jleppert
jleppert / xyz_vs_tms.md
Last active Oct 13, 2015 — forked from tmcw/xyz_vs_tms.md
The difference between XYZ and TMS tiles and how to convert between them
View xyz_vs_tms.md

The difference between XYZ and TMS tiles and how to convert between them

Lots of tile-based maps use either the XYZ or TMS scheme. These are the maps that have tiles ending in /0/0/0.png or something. Sometimes if it's a script, it'll look like &z=0&y=0&x=0 instead. Anyway, these are usually maps in Spherical Mercator.

Good examples are OpenStreetMap, Google Maps, MapBox, MapQuest, etc. Lots of maps.

Most of those are in XYZ. The best documentation for that is slippy map tilenames on the OSM Wiki, and Klokan's Tiles a la Google.

View gist:2273956
var count = function(tree) {
var location = tree,
elements = 0;
if(location !== null) {
elements++;
elements += count(location.left);
elements += count(location.right);
}
View gist:1448277
for (var i = 1; i <= 3; i++) {
(function(i) {
setTimeout(function() { console.log(i); }, 0);
}(i));
}
View gist:1448221
for (var i = 1; i <= 3; i++) {
setTimeout(function() { console.log(i); }, 0);
}
@jleppert
jleppert / gist:1157301
Created Aug 19, 2011
add widget from within another widget example
View gist:1157301
<script type="text/javascript">
// init the framework with the first widget on the page
extole.init({
host: 'playstation.net.ph',
widgets: [{
name: 'myfirstwidget',
lightBox: {
fixed: true,
modal: true
},
@jleppert
jleppert / tpl.js
Created Nov 17, 2010
Simple jQuery Templating based on John Resig's Micro Templating
View tpl.js
(function($) {
var tpl_cache = {};
var fn_cache = {};
$.fn.tmpl = function(tpl, data, cb, fn, kd) {
var cb = typeof(cb) == 'function' ? cb : null;
var fn = fn || 'html';
return this.each(function() {
doTpl(tpl, data, $(this), cb, fn, kd);
View errorHandler.js
var jQueryBind = $.fn.bind;
$.fn.bind = function( type, data, fn ) {
// mousemove.slider hack to prevent sticky slider
// mousemove.draggable hack to prevent sticky modal
if ( !fn && data && typeof data == 'function' && type != 'mousemove.slider' && type != 'mousemove.draggable' )
{
fn = data;
data = null;
}
You can’t perform that action at this time.