Skip to content

Instantly share code, notes, and snippets.

View leplatrem's full-sized avatar

Mathieu Leplatre leplatrem

View GitHub Profile
@leplatrem
leplatrem / app.py
Created October 11, 2011 09:22
Simple Flask-couchdb demo
import simplejson
from flask import Flask, g, request
from couchdb.design import ViewDefinition
import flaskext.couchdb
app = Flask(__name__)
"""
CouchDB permanent view
@leplatrem
leplatrem / gist:1415767
Created December 1, 2011 10:47
Leaflet Offline Tiles using SQL Storage
/*
* L.TileLayer.LocalCache : A tile layer using SQL Storage, if available.
*/
L.TileLayer.LocalCache = L.TileLayer.extend({
options: {
minZoom: 0,
maxZoom: 18,
tileSize: 256,
subdomains: 'abc',
@leplatrem
leplatrem / gist:1415795
Created December 1, 2011 10:53
Tiles serialization in base64 using django and landez
import base64
from StringIO import StringIO
from django.http import HttpResponse
from django.utils import simplejson
from easydict import EasyDict as edict
from landez import TilesManager
from . import app_settings
@leplatrem
leplatrem / replag.sh
Created January 24, 2012 11:05
OSM Mirror - Replication Lag
#!/bin/bash
# Script by MapOSMatic
# (Maxime Petazzoni)
STATE=${HOME}/replication_-_15mn/osmosis/last.state.txt
rep=`cat ${STATE} |\
grep 'timestamp' |\
awk '{split($0, a, "="); print a[2]}' |\
@leplatrem
leplatrem / planet-update.sh
Created January 24, 2012 11:07
OSM Mirror - Update
#!/bin/sh
# Script by MapOSMatic
# (Maxime Petazzoni)
LOG_FILE="/home/osm/replication_-_15mn/planet-update.log"
PID_FILE="/home/osm/replication_-_15mn/planet-update.pid"
OSM2PGSQL="/usr/bin/osm2pgsql"
OSM2PGSQL_STYLE="/usr/share/osm2pgsql/default.style"
@leplatrem
leplatrem / ass2dcl.py
Created February 23, 2012 09:47
ass2dcl : conversion of ASS subtitles to XML DCSubtitle
"""
``ass2dcl`` converts subtitles from ASS to DCSubtitle format.
It depends on python3 and `pysub <http://pypi.python.org/pypi/pysubs>`_.
INSTALL
::
@leplatrem
leplatrem / capture.js
Created April 5, 2012 13:02
Casper.js screenshot with optional POST and data
var casper = require("casper").create({
viewportSize: {width: 1600, height: 1200},
//verbose: true,
//logLevel: 'debug',
onError: function(self, m) { // Any "error" level message will be written
console.log('FATAL:' + m); // on the console output and PhantomJS will
self.exit(); // terminate
},
});
@leplatrem
leplatrem / index.html
Created September 22, 2012 11:53
Django-leaflet working example project
{% load leaflet_tags %}
<html>
<head>
{% leaflet_js %}
{% leaflet_css %}
</head>
<body>
<h1>Django-Leaflet</h1>
{% leaflet_map "main" %}
</body>
@leplatrem
leplatrem / app.js
Created December 13, 2012 12:37
First (very first) try with Backbone and daybed
var MushroomSpot = Backbone.Model.extend({
defaults: function() {
return {
mushroom: "Unknown",
area: [0.0, 0.0]
};
},
initialize: function() {
@leplatrem
leplatrem / demo.js
Last active December 14, 2015 16:29
Leaflet.LayerIndex example
L.Map.include(L.LayerIndexMixin);
var map = L.map('map');
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png').addTo(map);
map.fitWorld();
map.addControl(new L.Control.Information());
for (var i=0; i<5000; i++) {
var lat = Math.random() * 170 - 85
, lng = Math.random() * 350 - 175;