Skip to content

Instantly share code, notes, and snippets.

View jleppert's full-sized avatar

Johnathan jleppert

  • San Francisco, CA
View GitHub Profile
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;
}
@jleppert
jleppert / tpl.js
Created November 17, 2010 05:27
Simple jQuery Templating based on John Resig's Micro Templating
(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);
@jleppert
jleppert / gist:1157301
Created August 19, 2011 16:46
add widget from within another widget example
<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
},
for (var i = 1; i <= 3; i++) {
setTimeout(function() { console.log(i); }, 0);
}
for (var i = 1; i <= 3; i++) {
(function(i) {
setTimeout(function() { console.log(i); }, 0);
}(i));
}
var count = function(tree) {
var location = tree,
elements = 0;
if(location !== null) {
elements++;
elements += count(location.left);
elements += count(location.right);
}
@jleppert
jleppert / xyz_vs_tms.md
Last active October 13, 2015 18:38 — forked from tmcw/xyz_vs_tms.md
The difference between XYZ and TMS tiles and how to convert between them

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.

@jleppert
jleppert / gist:db8707826ce77a3ec4d61ddf68e42603
Created December 1, 2016 01:54
postgres lat/lon projection functions
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;