Skip to content

Instantly share code, notes, and snippets.

@mlebkowski
Last active February 6, 2020 19:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mlebkowski/f89cf00a7716c183bb7bb622ee4e333b to your computer and use it in GitHub Desktop.
Save mlebkowski/f89cf00a7716c183bb7bb622ee4e333b to your computer and use it in GitHub Desktop.
Polish IT Conferences
<?php
require 'vendor/autoload.php';
define('DATA_URL', 'https://raw.githubusercontent.com/cezarypiatek/polish-it-conferences/master/%s.md');
$years = [date('Y'), strftime('%Y', strtotime('next year'))];
$data = implode("\n", array_map(function ($year) {
return @file_get_contents(sprintf(DATA_URL, $year));
}, $years));
preg_match_all('/
^\|
\s* (?P<name>[^|]+?) \s*\|
\s* (?P<city>[^|]+?) \s*\|
\s* (?P<date_start>\d\d\d\d-\d\d-\d\d) (?:[ ]-[ ](?P<date_end>\d\d\d\d-\d\d-\d\d))? \s*\|
\s* \[[^]]+\]\((?P<link>https?:\/\/[^)]+)\) \s*\|
\s* [^|]* \s*\|
\s* (?P<category>[^|]+?) \s*\|
/xm', $data, $conferences, PREG_SET_ORDER);
$vCalendar = array_reduce($conferences, function ($calendar, $c) {
$event = new \Eluceo\iCal\Component\Event();
$event
->setDtStart(new \DateTime($c['date_start']))
->setDtEnd(new \DateTime($c['date_end'] ?: $c['date_start']))
->setNoTime(true)
->setSummary($c['name'])
->setLocation($c['city'])
->setCategories(array_map('trim', explode(',', $c['category'])))
->setDescription($c['link'])
->setDescriptionHTML(sprintf('<a href="%1$s">%1$s</a>', $c['link']));
$calendar->addComponent($event);
return $calendar;
}, new \Eluceo\iCal\Component\Calendar('conferences.narzekasz.pl'));
echo $vCalendar->render();
EXECUTABLES = php aws curl awk
K := $(foreach exec,$(EXECUTABLES),\
$(if $(shell which $(exec)),,$(error "No $(exec) in PATH")))
all: vendor app.php
php app.php > conferences.ical
aws s3 cp --acl public-read --content-type "text/calendar" conferences.ical s3://polish-it-conferences/conferences.ical --profile polish-it-conferences
vendor: composer composer.json composer.lock
./composer install
composer.json:
./composer req eluceo/ical
composer:
curl -s https://composer.github.io/installer.sig > composer-setup.sig
curl -s https://getcomposer.org/installer > composer-setup.php
awk '{print $$0 " composer-setup.php"}' composer-setup.sig | sha384sum --check
php composer-setup.php --quiet
rm composer-setup.*
mv composer.phar composer
app.php:
curl -s 'https://gist.githubusercontent.com/mlebkowski/f89cf00a7716c183bb7bb622ee4e333b/raw/app.php' > app.php
clean:
rm -fr composer.json composer.lock composer vendor/ app.php conferences.ical
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment