Skip to content

Instantly share code, notes, and snippets.

View matthieucan's full-sized avatar

Matthieu Caneill matthieucan

View GitHub Profile
@matthieucan
matthieucan / plot-python-sloc-pep8.sh
Created September 26, 2019 20:13
Plots python source lines of code (as counted by sloccount) and PEP8 warnings (as reported by flake8) over time.
#!/bin/bash
# Copyright 2019 Matthieu Caneill
# Licensed unter WTFPL <http://www.wtfpl.net/txt/copying/>
# Plots python source lines of code (as counted by sloccount) and PEP8
# warnings (as reported by flake8) over time.
# It is meant to be used in a git repository.
# Usage:
@matthieucan
matthieucan / osm.js
Created July 22, 2014 13:50
OSM Layer to render modified maps (transparent water, white land)
var OSMLayer = new OpenLayers.Layer.OSM('OSM Map', null, {
eventListeners: {
tileloaded: function(evt) {
var ctx = evt.tile.getCanvasContext();
if (ctx) {
var imgd = ctx.getImageData(0, 0, evt.tile.size.w, evt.tile.size.h);
var pix = imgd.data;
for (var i = 0, n = pix.length; i < n; i += 4) {
if (pix[i] == 181 && pix[i+1] == 208 && pix[i+2] == 20
@matthieucan
matthieucan / debian-feel-good.sh
Created July 15, 2014 13:42
generates sfl shinken debian/ folders
#!/bin/bash
#This is the sfl-shinken-plugins directory
DIR=$(pwd)
# prevents grep from adding line numbers, etc
export GREP_OPTIONS=""
version=$(date +%Y.%m.%e.%H.%M)
@matthieucan
matthieucan / djangotemplate_openlayers.html
Created July 2, 2014 14:10
Django template (to adapt!) to use OpenLayers.js with the locate_ip filter (https://gist.github.com/matthieucan/540ca40d5e4d2c1783ba)
{% load foo_tags %}
<style type="text/css">
/* this is done to prevent a conflict with bootstrap */
#mapOpenLayers img { max-width: none; }
</style>
<div id="mapOpenLayers" style="height: 600px;"></div>
<script src="{% url media path="external/openlayers/lib/OpenLayers.js" %}"></script>
<script>
@matthieucan
matthieucan / djangotag_locateip.py
Last active August 29, 2015 14:03
Django template filter to transform an IP address into GPS coordinates (for e.g. OpenLayers.js)
# Copyright 2014 Matthieu Caneill
# Consider this equivalent to public domain, feel free to use it the way you want.
# pip install python-geoip
# pip install python-geoip-geolite2
import socket
from geoip import geolite2
@register.filter("locateip")

Keybase proof

I hereby claim:

  • I am matthieucan on github.
  • I am matthieu (https://keybase.io/matthieu) on keybase.
  • I have a public key whose fingerprint is 721D 82EF 4102 FBEE 4EC0 164F 83E7 EA66 9A19 CB94

To claim this, I am signing this object: