Skip to content

Instantly share code, notes, and snippets.

@theseer
theseer / nullable-test.php
Last active Oct 2, 2019
Is this working as expected?? (PHP 7.4 required)
View nullable-test.php
<?php
class foo {
private ?string $bar = null;
public function __construct(?string $val) {
$this->bar = $val;
}
View sample.php
<?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 Mar 24, 2019
What happend to the `If-Modified-Since` header?
View confused.md

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 Dec 18, 2015
Redirect to the first attached file of the latest release
View download-redirect.php
<?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);
View keybase.md

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:

View xpointer res in manual
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