Skip to content

Instantly share code, notes, and snippets.

Mathieu Leplatre leplatrem

Block or report user

Report or block leplatrem

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
View utils.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from django.contrib.admin.models import LogEntry, ADDITION, CHANGE, DELETION
from django.contrib.contenttypes.models import ContentType
from django.utils.encoding import force_unicode
from django.forms.models import model_to_dict
def log_addition(request, dbobject, oldobject=None, message=None):
_log_action(request, dbobject, oldobject, ADDITION, message)
@leplatrem
leplatrem / .gitconfig
Created Nov 19, 2014
Git config (exemple)
View .gitconfig
[user]
name = Your Name\n
email = you@email.com
[color]
ui = auto
[color "branch"]
current = yellow reverse
local = yellow
@leplatrem
leplatrem / gist:1415795
Created Dec 1, 2011
Tiles serialization in base64 using django and landez
View gist:1415795
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 Jan 24, 2012
OSM Mirror - Replication Lag
View replag.sh
#!/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 Jan 24, 2012
OSM Mirror - Update
View planet-update.sh
#!/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 Feb 23, 2012
ass2dcl : conversion of ASS subtitles to XML DCSubtitle
View ass2dcl.py
"""
``ass2dcl`` converts subtitles from ASS to DCSubtitle format.
It depends on python3 and `pysub <http://pypi.python.org/pypi/pysubs>`_.
INSTALL
::
@leplatrem
leplatrem / index.html
Created Sep 22, 2012
Django-leaflet working example project
View index.html
{% load leaflet_tags %}
<html>
<head>
{% leaflet_js %}
{% leaflet_css %}
</head>
<body>
<h1>Django-Leaflet</h1>
{% leaflet_map "main" %}
</body>
@leplatrem
leplatrem / app.js
Created Dec 13, 2012
First (very first) try with Backbone and daybed
View app.js
var MushroomSpot = Backbone.Model.extend({
defaults: function() {
return {
mushroom: "Unknown",
area: [0.0, 0.0]
};
},
initialize: function() {
@leplatrem
leplatrem / demo.js
Last active Dec 14, 2015
Leaflet.LayerIndex example
View demo.js
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;
@leplatrem
leplatrem / gist:5317450
Created Apr 5, 2013
Repair South and GeoModel fields SRID
View gist:5317450
find . -name "????_*.py" | xargs sed -i "s/from django.db import models/from django.db import models\nfrom django.conf import settings/"
find . -name "????_*.py" | xargs sed -i "s/'32632'/'%s' % settings.SRID/g"
find . -name "????_*.py" | xargs sed -i "s/srid=32632/srid=settings.SRID/g"
You can’t perform that action at this time.