Skip to content

Instantly share code, notes, and snippets.

Christian Quest cquest

  • Paris, France
Block or report user

Report or block cquest

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
@cquest
cquest / communes.csv
Created Oct 3, 2019
CSV des communes françaises obtenu par https://overpass-turbo.eu/s/MOT
View communes.csv
We can't make this file beautiful and searchable because it's too large.
ref:INSEE name @lat @lon
75056 Paris 48.8588657 2.3469411
50162 Digosville 49.6318164 -1.5276368
50077 Bretteville 49.6516917 -1.5084320
50296 Maupertus-sur-Mer 49.6568139 -1.4843194
50101 Carneville 49.6577501 -1.4489368
50178 Fermanville 49.6801166 -1.4551308
50539 Saint-Pierre-Église 49.6723729 -1.4023987
50596 Théville 49.6514985 -1.4152740
@cquest
cquest / update.sh
Created Apr 10, 2019
script d'update pour osm2pgsql
View update.sh
if [ ! -f lock ]
then
touch lock
osmupdate -v $(osmconvert update_last.osc.gz --out-timestamp) update.osc.gz \
&& /usr/bin/osm2pgsql --number-processes=4 -a -C 64 -k -m -G -s -S osm2pgsql-choosen.style -d osm --flat-nodes /ssd-nvme/osm2pgsql/flat-nodes.raw --keep-coastlines --tag-transform-script config/activate-relation-type-waterway.lua --prefix=planet_osm update.osc.gz \
&& mv update.osc.gz update_last.osc.gz \
&& echo "timestamp=$(osmconvert update_last.osc.gz --out-timestamp)" > state.txt \
&& touch -t $(osmconvert update_last.osc.gz --out-timestamp | sed 's/[^0-9]//g;s/\([0-9][0-9]\)$/.\1/') state.txt \
&& rm lock
fi
@cquest
cquest / sirene_quotidien.sh
Created Mar 1, 2019
Script bash de récupération d'un CSV de mise à jour quotidien des données SIRENE 2019
View sirene_quotidien.sh
#! /bin/bash
# usage: ./sirene_quotidien.sh 01/02/2019 02/02/2019
# Licence: WTFPL
rm -f cookie
curl -s -c cookie 'http://sirene.fr/sirene/public/verifier-creation-fichier.action' -L \
-F "fichier.caracteristiques.etat.actif=true" \
-F "__checkbox_fichier.caracteristiques.etat.actif=true" \
-F "fichier.caracteristiques.etat.ferme=true" \
-F "__checkbox_fichier.caracteristiques.etat.ferme=true" \
@cquest
cquest / osm_export_2019.sh
Last active Feb 18, 2019
Export limites admin OSM 2019
View osm_export_2019.sh
export SHAPE_ENCODING="UTF-8"
pushd /home/cquest/public_html/openfla/export/
yymmdd=$(date +%Y%m%d)
# export communes (métropole et DOM)
ogr2ogr -f "ESRI Shapefile" -lco ENCODING=UTF-8 -t_srs "EPSG:4326" -overwrite communes-$yymmdd.shp PG:"dbname=osm" -sql "select tags->'ref:INSEE' as insee, name as nom, tags->'wikipedia' as wikipedia, floor(st_area(geography(st_transform(way,4326)))/10000) as surf_ha, way from osm_admin_fr where tags ? 'ref:INSEE' and admin_level='8' and tags->'ref:INSEE'<'98000' and tags->'ref:INSEE' not like '975%'"
zip -9m communes-$yymmdd-shp.zip communes-$yymmdd.* && zip communes-$yymmdd-shp.zip LICENCE.txt communes-descriptif.txt
@cquest
cquest / CA_des_GAFAM.md
Last active Dec 17, 2018
Chiffre d'Affaire des GAFAM d'après données opendata
View CA_des_GAFAM.md
@cquest
cquest / sirene_noms_adresses.sql
Last active Nov 26, 2018
script d'extraction des noms et adresses actuelles et passées des entreprises
View sirene_noms_adresses.sql
-- script d'extraction des noms et adresses actuelles et passées des entreprises
-- et établissements des données historisées de la base SIRENE de l'INSEE
-- vue matérialisée des différents noms des unités légales
CREATE MATERIALIZED VIEW ul_nom AS
SELECT siren, array_agg(distinct(nom)) AS noms FROM
(
SELECT siren, denominationunitelegale AS nom FROM ul_histo
UNION
SELECT siren, denominationusuelle1unitelegale AS nom FROM ul_histo
@cquest
cquest / drupalGmap2json.sh
Last active Oct 13, 2018
Extraction données événements semaine de l'innovation publique
View drupalGmap2json.sh
# extraction et conversion JSON
curl "http://www.modernisation.gouv.fr/la-semaine-de-linnovation-publique/programme/programme-2018" -s \
| grep 'Drupal.settings' \
| sed 's/jQuery.extend(Drupal.settings,//;s/);//' \
| jq .gmap.carte_france.markers \
| sed 's!<div.*src=\\"\(.*\)\\".*alt=.*<div class=\\"inno-ville\\">\(.*\)</div>.*<div class=\\"inno-title\\">\(.*\)</div>.*<div class=\\"inno-dates\\">.*<span>\(.*\)</span><span>\(.*\)</span> </div>.*<div class=\\"inno-more\\">.*<a href=\\"\(.*\)\\">Lire la suite.*!\1", "ville":"\2", "titre":"\3", "date":"\4\5", "url":"http://www.modernisation.gouv.fr\6",!;s!<div.*src=\\"\(.*\)\\" alt=.*<div class=\\"inno-ville\\">\(.*\)</div>.*<div class=\\"inno-title\\">\(.*\)</div>.*inno-date.*<div class=\\"inno-more\\">.*<a href=\\"\(.*\)\\">Lire la suite.*!\1", "ville":"\2", "titre":"\3", "url":"http://www.modernisation.gouv.fr\4",!' \
| jq . \
| sed 's!'"text"!"url_logo"!;s!\\" width.*",!",!' \
| jq .
@cquest
cquest / tilecache.conf
Last active Oct 3, 2019
Exemple de configuration nginx pour installer un cache de tuiles OSM
View tilecache.conf
# conserver les tuiles dans /var/cache, pendant 24h et au maximum 16Go
proxy_cache_path /var/cache/nginx-tilecache levels=1:2 keys_zone=tilecache:100m inactive=24h max_size=16G;
server {
server_name tilecache.mondomaine.tld a.tilecache.mondomaine.tld b.tilecache.mondomaine.tld c.tilecache.mondomaine.tld;
listen 80;
location / {
proxy_pass http://tilecache.openstreetmap.fr;
proxy_cache tilecache;
@cquest
cquest / scoopython.py
Last active Apr 8, 2018
python script to retrieve a user's curated scoops on scoop.it
View scoopython.py
import json
import requests
from bs4 import BeautifulSoup
import sys
scoop = sys.argv[1] # ex: https://www.scoop.it/u/user-login
pages = int(sys.argv[2]) # number of pages to retrieve
for page in range(0, pages):
@cquest
cquest / descoopit.sh
Created Apr 8, 2018
Script de récupération des URL collectés à l'aide de scoop.it
View descoopit.sh
# Script de récupération des URL des contenus collecté dans scoop.it
#
# Usage: sh descoopit.sh url_scoopit nb_pages
#
# Exemple: sh descoopit.sh https://www.scoop.it/u/open-data-france/ 3 > odf.txt
#
# Dépendances: curl, jq, grep, sed
for p in `seq 1 $2`
do
You can’t perform that action at this time.