Skip to content

Instantly share code, notes, and snippets.

View flyinva's full-sized avatar

Sylvain flyinva

  • Rennes
View GitHub Profile
@flyinva
flyinva / airbreizh_data.sh
Last active February 23, 2019 00:06
AirBreizh JSON data filter
#!/bin/bash
[[ "$TRACE" ]] && set -x
get_data() {
local mesure="$1"
local day="now"
curl --silent "http://data.airbreizh.asso.fr/geoserver/airbreizh_mes_bretagne_horaire_poll_princ/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=mes_bretagne_horaire_:mes_bretagne_horaire_$mesure&outputFormat=application%2Fjson&CQL_FILTER=date_debut%20like%20%27$(date -d"$day" +%d%%2f%m%%2f%Y)%25%27" | jq --raw-output --arg mesure $mesure '.features[] | select(.properties.valeur != null) | "airbreizh."+.properties.code_station+"."+ $mesure +" "+(.properties.valeur|tostring)+" "+(.properties.date_debut|strptime("%d/%m/%Y %H:%M") | mktime | tostring)' | nc -q0 localhost 2003
}
@flyinva
flyinva / get_meteo.sh
Last active August 29, 2015 14:23
Décryptage de la météo
#/bin/bash
curl http://www.meteo-france.mobi/ws/getDetail/france/462010.json \
| | jq '.result.previsions | map(.)[] | select(.jour<3) | select( .moment=="matin" or .moment=="midi" or .moment=="soir") | {"date": .date, "jour": .jour, "moment": .moment, "description": .description, "vent": {"direction": .directionVent, "vitesse": .vitesseVent, "rafales": .forceRafales}, "temperatures": {"min": .temperatureMin, "max": .temperatureMax}, "indiceUV": .indiceUV, "probaPluie": .probaPluie }'
@flyinva
flyinva / get_weather.sh
Last active August 29, 2015 14:23
Get weather condition from http://openweathermap.org
#!/bin/bash
city="$1"
curl --silent "http://api.openweathermap.org/data/2.5/weather?q=$city&units=metric" \
| jq --argfile wind ~/.config/wind.json \
'{"city": .name, "updated": .dt, "sunrise": .sys.sunrise, "sunset":.sys.sunset, "temperature": .main.temp, "wind": {"speed": (.wind.speed*3.6|floor), "direction": $wind[((.wind.deg+11.25)/22.5)|floor]}}' \
| sed -r 's/(.*:) ([0-9]{10,}),/echo -n "\1: " ; date "+%Y-%m-%d %H:%M:%S" -d"@\2"/e' \
> $city.json
@flyinva
flyinva / pluie.sh
Last active August 29, 2015 14:22
Un bout de shell pour savoir s'il va pleuvoir
#
# © 2015 Flyinva
# https://github.com/flyinva https://twitter.com/flyinva
# License WTFPL
#
function get_json_cities_pluie {
city="$1"
wget --quiet --output-document=- \
@flyinva
flyinva / GeoJSON from EXIF
Last active April 16, 2020 20:19
Create a GeoJSON file from EXIF data
exiftool -n -g -json \
-imagewidth \
-imageheight \
-composite:gpslatitude \
-composite:gpslongitude \
*jpg \
| jq --compact-output --arg urlBase http://mysite.net/myphotos/ \
'{
"type": "FeatureCollection",
"features":