Skip to content

Instantly share code, notes, and snippets.

View Bertware's full-sized avatar

Bertware Bertware

View GitHub Profile
@Bertware
Bertware / ValidateLCDepartures.php
Last active November 28, 2017 15:16
Validate LinkedConnections departures against departures found in the irail.be API.
<?php
// example call: ValidateLCDepartures.php station=0088xxxxx (where 0088xxxxx is a station ID)
parse_str(implode('&', array_slice($argv, 1)), $_GET);
$station = $_GET['station'];
// Get current datetime
$datetime = new DateTime();
@Bertware
Bertware / Interrail Hafas Configuration.properties
Created December 11, 2017 00:13
Interrail (Hafas) configuration properties for the android app
# Wenn von Vorgängerversion verschieden werden alle daten gelöscht.
DATA_VERSION=4
# Server
BASE_QUERY=demo.hafas.de/bin/pub/std40
# Per GET zu schickende URL-Parameter
GETPARAMS=ld,checksum,mic,mac
# Suchmethode
@Bertware
Bertware / station_en.json
Created December 11, 2017 00:16
HAFAS train stations in Europe
This file has been truncated, but you can view the full file.
{
"Stations": [
{
"Code": "ATAAB",
"Name": "Wien Mitte (At)",
"Enabled": "1",
"Synoniem": "Vienna",
"Query": "Wien Mitte (At) Vienna"
},
{
@Bertware
Bertware / arrivals.txt
Last active February 10, 2018 18:34
NMBS Mobile API Endpoints
POST http://www.belgianrail.be/jp/sncb-nmbs-routeplanner/mgate.exe HTTP/1.1
User-Agent: SNCB/302240 (Android_8.0.0) Dalvik/2.1.0 (Linux; U; Android 8.0.0; HTC 10 Build/OPR1.170623.027)
Content-Type: application/json;charset=UTF-8
Host: www.belgianrail.be
Connection: Keep-Alive
Accept-Encoding: gzip
Content-Length: 650
{"auth":{"aid":"sncb-mobi","type":"AID"},"client":{"id":"SNCB","name":"NMBS","os":"Android 8.0.0","type":"AND","ua":"SNCB/302240 (Android_8.0.0) Dalvik/2.1.0 (Linux; U; Android 8.0.0; HTC 10 Build/OPR1.170623.027)","v":302240},"formatted":false,"lang":"nld","svcReqL":[{"cfg":{"polyEnc":"GPA"},"meth":"StationBoard","req":{"date":"20180210","getPasslist":false,"getTrainComposition":false,"jnyFltrL":[{"mode":"BIT","type":"PROD","value":"11101111111111"}],"maxJny":50,"stbLoc":{"lid":"A=1@O=Brussel-Zuid@X=4336531@Y=50835707@U=80@L=008814001@B=1@p=1510534428@n=ac.1=GA@","name":"Brussel-Zuid","type":"S"},"time":"192234","type":"ARR"}}],"ver":"1.11"}
HTTP/1.1 200 OK
@Bertware
Bertware / vrtnu_scraper.php
Created March 21, 2018 13:13
Quick-and-dirty PHP script to Scrape information on all available episodes from vrtnu.be. create a json representation for each page, and a list which puts everything together
<?php
function file_put_contents_rec($file, $data)
{
$file = ltrim($file, '/');
$folder = substr($file, 0, -1 * strlen(basename($file)));
if (!is_dir($folder)) {
// dir doesn't exist, make it
mkdir($folder, 0777, true);
}
@Bertware
Bertware / Aantal_vertrekken.eps
Last active June 20, 2019 18:41
Master thesis scripts and intermediary results
%!PS-Adobe-3.0 EPSF-3.0
%%BoundingBox: 0 0 567 340
%%Pages: 0
%%Creator: LibreOffice 5.1
%%Title: none
%%CreationDate: none
%%LanguageLevel: 2
%%EndComments
%%BeginProlog
%%BeginResource: procset SDRes-Prolog 1.0 0
@Bertware
Bertware / splitGtfs.php
Last active October 17, 2018 13:30
Split GTFS files into one file per transport operator
<?php
const GTFS_PATH = '/tmp/gtfs/';
const TARGET_DIR = './splitGtfs/';
@mkdir(GTFS_PATH);
@mkdir(TARGET_DIR);
if (! file_exists(GTFS_PATH . "sweden.zip")){
echo 'getting GTFS...';
@Bertware
Bertware / heatmap-vt-sj.html
Last active December 6, 2018 13:33
Linked Connections to isochrone or heatmap map
<!Doctype html>
<html prefix="dct: http://purl.org/dc/terms/
rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns#
foaf: http://xmlns.com/foaf/0.1/
og: http://ogp.me/ns#">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>LC2Heat</title>
@Bertware
Bertware / eat.html
Last active December 18, 2018 11:53
Liveboard, Train and Earliest Arrival Time demos based on Linked Connections
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Linked Connections Trains</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
<style>
tr:first-of-type {
background-color: #c7292933 !important;
@Bertware
Bertware / gtfsToStationsLd.php
Last active November 20, 2018 16:19
Prototype PHP script to convert a GTFS archive into a
<?php
/**
* Ćreate a stations list, agencies list, stations list per agency, stops files from GTFS.
* Due to a lack of time this doesn't output 100% valid linked data (yet), but it's good enough for now
*
* Free to use, adapt, modify, redistribute however you want at your own responsibility.
*
* Requirements:
* php-zip