Skip to content

Instantly share code, notes, and snippets.

View derhuerst's full-sized avatar

Jannis R derhuerst

View GitHub Profile
@weiland
weiland / readme.md
Last active February 10, 2024 07:41
EurostarTrainsWifi
@derhuerst
derhuerst / _.md
Last active September 26, 2024 13:17
curl-based HTTP mirroring script

curl-based HTTP mirroring script

This is a script that creatively uses the curl CLI to download an HTTP resource (colloquially "file"); It saves time & bandwidth whenever possible, but not at the expense of correctness.

  • Compares ETags to make sure that an unchanged resource is not transfered again, but a changed resource always is.
  • Requests a CE-coded (a.k.a. compressed, e.g. gzipped) representation of the resource, falling back to the "regular" one.
  • Supports continuation, using conditional requests, but in contrast to the -C - curl flag works with CE-coded responses, and falls back to a "full body" request.

People asked me: Why not use wget for this?

// http://cdwifi.cz/portal/api/timetable/connexion/current?locale=en_GB
{
"id": 515,
"name": "IC 515 Pendolino",
"line": null,
"connexionTimes": [
{
"id": 353,
"timeArrival": null,
"timeDeparture": "2022-05-13T14:27:00+02:00",
@weiland
weiland / circulation.jsonc
Created April 27, 2022 10:02
wifi.normandie.fr in-train Wifi
// https://wifi.normandie.fr/router/api/train/circulation
{
"number": "3105",
"circulationCode": "66979ae819749c3a785adc4e657a3fbe",
"origin": {
"name": "Paris Saint-Lazare",
"code": "OCE87384008"
},
"destination": {
"name": "Le Havre",
// https://onboard.sbb.ch/api/v2/content?tag=versioned_flavour_config&tag=v3&lang=en&r=1649759266348&contentType=mpd
[
{
"id": "flavour_config_sbb_v3",
"contentType": "versioned_flavour_config",
"domain": [
"staging-auth.sbb.gomedia.io",
"sbb.mst.gonet",
"test-sbb.mst.gonet",
"sbb.stg.gonet",
@weiland
weiland / info.jsonc
Last active February 10, 2024 07:46
portalefrecce.it (InTrain Wifi 🇮🇹)
// https://www.portalefrecce.it/BobHttpLogger/status/train
// somtimes comes as XML or JSON
{
"BobStatus": {
"Train": {
"Id": "9653",
"Token": "IhRbCoYDMQDm0OVbZbIqXw==",
"MealStatus": "on"
}
}
@roehrt
roehrt / transit_network_germany.csv
Last active May 6, 2022 18:56
Edge list of Germany's transit network (including metropolitan to far-distance transit) weighted by minimum journey time in seconds. This edge list is neither 100 % complete nor official. Based on data from DELFI (2022) and stop data from Deutsche Bahn (2020, https://data.deutschebahn.com/dataset/data-haltestellen.html).
evaA evaB min_duration
8000001 8000084 1560
8000001 8000207 2160
8000001 8000208 2040
8000001 8000404 180
8000001 8000406 120
8000001 8002806 780
8000001 8003363 2220
8000001 8070704 120
8000002 8000170 3840
@kevinkub
kevinkub / incidence.js
Last active December 4, 2024 22:48
COVID-19 Inzidenz-Widget für iOS innerhalb Deutschlands 🇩🇪
// Licence: Robert Koch-Institut (RKI), dl-de/by-2-0
class IncidenceWidget {
constructor() {
this.previousDaysToShow = 31;
this.apiUrlDistricts = (location) => `https://services7.arcgis.com/mOBPykOjAyBO2ZKk/arcgis/rest/services/RKI_Landkreisdaten/FeatureServer/0/query?where=1%3D1&outFields=RS,GEN,cases7_bl_per_100k,cases7_per_100k,BL&geometry=${location.longitude.toFixed(3)}%2C${location.latitude.toFixed(3)}&geometryType=esriGeometryPoint&inSR=4326&spatialRel=esriSpatialRelWithin&returnGeometry=false&outSR=4326&f=json`
this.apiUrlDistrictsHistory = (districtId) => `https://services7.arcgis.com/mOBPykOjAyBO2ZKk/ArcGIS/rest/services/Covid19_hubv/FeatureServer/0/query?where=IdLandkreis%20%3D%20%27${districtId}%27%20AND%20Meldedatum%20%3E%3D%20TIMESTAMP%20%27${this.getDateString(-this.previousDaysToShow)}%2000%3A00%3A00%27%20AND%20Meldedatum%20%3C%3D%20TIMESTAMP%20%27${this.getDateString(1)}%2000%3A00%3A00%27&outFields=Landkreis,Meldedatum,AnzahlFall&outSR=4326&f=json`
this.stateToAbbr = {
@simonkuhn
simonkuhn / geo.vcl
Last active January 7, 2022 12:16
Fastly VCL for geoip json output
sub vcl_recv {
#FASTLY recv
# We don't do other methods
if (req.method != "GET") {
return(error);
}
# Handle IPv4 or IPv6 provided in url path (nothing extraneous allowed, perform basic matching)
if (req.url.path ~ "^/([a-f0-9:.]+)$") {
set client.geo.ip_override = re.group.1;
@katef
katef / plot.awk
Last active November 20, 2024 23:27
#!/usr/bin/awk -f
# This program is a copy of guff, a plot device. https://github.com/silentbicycle/guff
# My copy here is written in awk instead of C, has no compelling benefit.
# Public domain. @thingskatedid
# Run as awk -v x=xyz ... or env variables for stuff?
# Assumptions: the data is evenly spaced along the x-axis
# TODO: moving average