Last active
February 6, 2020 19:45
-
-
Save mlebkowski/f89cf00a7716c183bb7bb622ee4e333b to your computer and use it in GitHub Desktop.
Polish IT Conferences
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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