Skip to content

Instantly share code, notes, and snippets.

<?php declare(strict_types = 1);
namespace test;
use DOMDocument;
use Templado\Engine\SimpleSnippet;
use Templado\Engine\SnippetListCollection;
use Templado\Engine\Templado;
require __DIR__ . '/vendor/autoload.php';
@theseer
theseer / confused.md
Created March 24, 2019 16:36
What happend to the `If-Modified-Since` header?

If-Modified-Since, PHP CLI Server and Firefox

Explanation

When sending the cache control header Cache-Control: no-cache, must-revalidate along with a Last-Modified timestamp, the browser is required to send along an If-Modified-Since header for the next request to the same URL.

The server then is entitled to return HTTP/1.1 304 Not modified in case the content didn't change and the stored copy may still be used.

Sample Code

@theseer
theseer / download-redirect.php
Created December 18, 2015 14:58
Redirect to the first attached file of the latest release
<?php
error_reporting(0);
ini_set('display_errors', false);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.github.com/repos/<user>/<project>/releases');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, '<project> release redirector');
$releasesRAW = curl_exec($ch);
curl_close($ch);

Keybase proof

I hereby claim:

  • I am theseer on github.
  • I am theseer (https://keybase.io/theseer) on keybase.
  • I have a public key whose fingerprint is BEEB 9AED 51C2 8445 FAB1 4222 8DDB 46C4 EA2E BCDC

To claim this, I am signing this object:

DE:
theseer@nyda ~/storage/php/phpdoc $ grep 'class.datetime' /tmp/dump-manual.xml
<phpdoc:classref xmlns:phpdoc="http://php.net/ns/phpdoc" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" xml:id="class.datetime">
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.datetime')/db:refentry/db:refsect1[@role='description']/descendant::db:destructorsynopsis[not(@role='procedural')])">
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.datetimeinterface')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[@role='oop'])"/>
<phpdoc:classref xmlns:phpdoc="http://php.net/ns/phpdoc" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" xml:id="class.datetimezone">
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.datetimezone')/db:refentry/db:refsect1