Skip to content

Instantly share code, notes, and snippets.

View edigiacomo's full-sized avatar

Emanuele Di Giacomo edigiacomo

  • ARPAE-SIMC
  • Italy
View GitHub Profile
@edigiacomo
edigiacomo / copr-simc-stable-latest-version.py
Created September 26, 2024 10:14
Script Python per ottenere le versioni dei pacchetti del SIMC pubblicati su Copr
import functools
import requests
import dnf
def get_package_version_from_repo(owner, project, chroot, package_name):
repo_url = f"https://download.copr.fedorainfracloud.org/results/{owner}/{project}/{chroot}"
# Creare una base per la transazione dnf
@edigiacomo
edigiacomo / mistral_dbadb_insert.py
Last active March 18, 2020 16:10 — forked from pat1/mistral_format_converter.py
Examples for Mistral observational data ingestion flows
# Legge messaggi in BUFR o JSON da stdin e li salva in un dbadb
# Utilizzo: mistral_dbadb_insert.py [BUFR|JSON] DBADSN
#
# Author: Emanuele Di Giacomo <[email protected]>
# License: GPLv2+
import argparse
import sys
import dballe
@edigiacomo
edigiacomo / m_notmuch.sh
Last active December 10, 2020 23:35
notmuch module for lbdb
#!/usr/bin/bash -posix
# -*-sh-mode-*-
# Copyright (C) 2018 Emanuele Di Giacomo <[email protected]>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
@edigiacomo
edigiacomo / urls.py
Created August 30, 2016 14:16
Music videos directed by Michel Gondry and Spike Jonze on Youtube
import urllib.request
import urllib.parse
import re
from SPARQLWrapper import SPARQLWrapper, JSON
sparql = SPARQLWrapper("http://dbpedia.org/sparql")
sparql.setQuery("""
SELECT ?songName WHERE {
?song dct:subject ?subj .
@edigiacomo
edigiacomo / mapserver-wind.map
Last active March 23, 2016 15:00
Simple MapServer file for uv (wind) raster data.
# Wind barbs for uv raster data.
#
# The symbol "windbarb" has two barbs. The symbol should be split in multiple symbols and
# the raster layer should have multiple CLASS with EXPRESSION: each CLASS will use the right
# number of barbs.
#
# Note: the uv values of the input file `out.tiff` are between 0 and 1.
MAP
IMAGETYPE PNG
OUTPUTFORMAT
@edigiacomo
edigiacomo / img2tiff.sh
Last active February 26, 2016 09:37
Convert ENVI file with 52 bands in 52 GeoTIFF with color table
#!/bin/bash
print_help()
{
echo "Usage: $0 ENVI_FILE OUTPUTDIR"
echo ""
echo "Convert a 52 band ENVI file in 52 GeoTiff files with colortable"
}
if [[ "$1" == "-h" || "$1" == "--help" ]]
@edigiacomo
edigiacomo / allerta-comuni.py
Last active January 28, 2016 14:17
Allerta comuni
# encoding: utf-8
#
# Crea un GeoJSON dei comuni a partire dal raster di precipitazione in cui
# aggiunge i seguenti attributi alle feature:
# - preci_count: numero di celle nel comune
# - preci_sum: somma della precipitazione nel comune
# - preci_max: massima precipitazione nel comune
# - preci_threshold_50mm_count: numero di celle nel comune che superano i 50mm
# - preci_threshold_50mm_alert: "green" se nessuna cella supera i 50mm,
# "yellow" se la superano meno di dieci, "red" se la superano 10 o più
@edigiacomo
edigiacomo / geodjango-postgis-raster-to-png.py
Last active May 9, 2022 04:31
Django view that converts a RasterField to PNG
from django.http import HttpResponse
from django.db.models import BinaryField, Func, F, Value, CharField
from .models import MyModel
def view_png(request):
"""Return a PostGIS raster as a PNG image."""
# MyModel is a django model with a RasterField named "rast".
# Note: ST_AsGdalRaster can reproject the data,
@edigiacomo
edigiacomo / arkimet-rescan-archived-section.sh
Last active October 8, 2015 13:43
Rescan archived section in arkimet dataset
#!/bin/bash
trap cleanup EXIT
cleanup()
{
[[ -n "$tmpdir" ]] && rm -rf $tmpdir
}
show_help()
@edigiacomo
edigiacomo / calcolo-giorni-lavorati-as-2015-16.py
Last active January 29, 2016 19:12
Calcolo dei giorni lavorati durante l'A.S. 2015-16 per il Comune di Pesaro
from datetime import date, timedelta
import calendar
def daterange(start, end, step=timedelta(days=1)):
d = start
while d <= end:
yield d
d += step