Skip to content

Instantly share code, notes, and snippets.

View leplatrem's full-sized avatar

Mathieu Leplatre leplatrem

View GitHub Profile
/*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@leplatrem
leplatrem / 0.md
Last active April 26, 2024 21:56
notes for Bug 1563226
@leplatrem
leplatrem / wmo2geojson.py
Last active December 4, 2023 13:01
Convert list of WMO weather stations to GeoJSON
import csv
import json
def dms2latlng(value):
"""
Degres Minutes Seconds to Decimal degres
"""
degres, minutes, seconds = value.split()
seconds, direction = seconds[:-1], seconds[-1]
@leplatrem
leplatrem / upload.py
Created November 10, 2023 10:11
Upload file to Remote Settings in Python
import json
import os
import sys
import uuid
import mimetypes
import requests
filepath = sys.argv[1]
@leplatrem
leplatrem / simple.py
Last active October 12, 2023 11:33
Batched producer/consumer
import asyncio
import async_timeout
import concurrent.futures
import random
import time
async def produce(queue, n):
for x in range(n):
# produce an item
@leplatrem
leplatrem / yourapp
Last active September 24, 2023 23:01
gunicorn virtualenv init.d script (could be simpler with upstart)
#! /bin/bash
### BEGIN INIT INFO
# Provides: yourapp
# Required-Start: nginx
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: The main django process
# Description: The gunicorn process that receives HTTP requests
# from nginx
@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',

Github Actions Matrix Debug

Goal: Implement the matrix expansion behaviour in matrix_combinations() function, following the official Github Actions documentation.

Run tests:

pytest main.py
@leplatrem
leplatrem / index.html
Last active January 13, 2023 16:32
passwords
<!DOCTYPE html><html><head><title></title><meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" /><style type='text/css'>
body {
font-family:'Helvetica';
letter-spacing:-5px;
background:#000;
background-size:100%;
color:#fff;
margin:0;
padding:0;
font-weight:bold;
CREATE OR REPLACE FUNCTION SimplifyEdgeGeom(atopo varchar, anedge int, maxtolerance float8)
RETURNS float8 AS $$
DECLARE
tol float8;
sql varchar;
BEGIN
tol := maxtolerance;
LOOP
sql := 'SELECT topology.ST_ChangeEdgeGeom(' || quote_literal(atopo) || ', ' || anedge
|| ', ST_Simplify(geom, ' || tol || ')) FROM '