Skip to content

Instantly share code, notes, and snippets.

View martinharder's full-sized avatar
😄

Martin Harder martinharder

😄
  • Berlin, Germany
View GitHub Profile
@martinharder
martinharder / age.js
Last active November 4, 2020 22:44
Wie alt bin ich heute, wie alt ist mein... Ein Widget für Scriptable. // How old am I today? How old is my... A widget for Scriptable.
// Deutsche Version
const params = args.widgetParameter ? args.widgetParameter.split(',') : null;
const dateString = params && params.length > 0 ? params[0].trim() : null;
const name = params && params.length === 2 ? params[1].trim() : null;
function calculateDateValues(dateString) {
const dob = new Date(dateString);
const now = new Date(Date.now());
const totalDays = daysBetween(dob, now);
@martinharder
martinharder / icu.js
Last active October 10, 2022 12:52
COVID-19 Intensivbettenbelegung. Ein Widget für Scriptable
const newCasesApiUrl = `https://services7.arcgis.com/mOBPykOjAyBO2ZKk/arcgis/rest/services/DIVI_Intensivregister_Landkreise/FeatureServer/0/query?f=json&where=1%3D1&returnGeometry=false&spatialRel=esriSpatialRelIntersects&outFields=*&orderByFields=Anteil_betten_frei%20desc&resultOffset=0&resultRecordCount=4000&resultType=standard&cacheHint=true`;
/* Bundesland-ID:
Baden-Württemberg: 8
Bayern: 9
Berlin: 11
Brandenburg: 12
Bremen: 4
Hamburg: 2
Hessen: 6
@martinharder
martinharder / incidence.js
Last active November 22, 2020 21:56 — forked from kevinkub/incidence.js
COVID-19 Inzidenz-Widget für iOS innerhalb Deutschlands 🇩🇪
// Licence: Robert Koch-Institut (RKI), dl-de/by-2-0
const newCasesApiUrl = `https://services7.arcgis.com/mOBPykOjAyBO2ZKk/arcgis/rest/services/RKI_COVID19/FeatureServer/0/query?f=json&where=NeuerFall%20IN(1%2C%20-1)&returnGeometry=false&spatialRel=esriSpatialRelIntersects&outFields=*&outStatistics=%5B%7B%22statisticType%22%3A%22sum%22%2C%22onStatisticField%22%3A%22AnzahlFall%22%2C%22outStatisticFieldName%22%3A%22value%22%7D%5D&resultType=standard&cacheHint=true`;
const incidenceUrl = (location) => `https://services7.arcgis.com/mOBPykOjAyBO2ZKk/arcgis/rest/services/RKI_Landkreisdaten/FeatureServer/0/query?where=1%3D1&outFields=GEN,last_update,cases,cases7_per_100k&geometry=${location.longitude.toFixed(3)}%2C${location.latitude.toFixed(3)}&geometryType=esriGeometryPoint&inSR=4326&spatialRel=esriSpatialRelWithin&returnGeometry=false&outSR=4326&f=json`
const saveIncidenceLatLon = (location) => {
let fm = FileManager.iCloud()
let path = fm.joinPath(fm.documentsDirectory(), "covid19latlon.json")
fm.w