Skip to content

Instantly share code, notes, and snippets.

Martijn van der Ven Zegnat

View GitHub Profile
Zegnat /
Last active Mar 14, 2019
Simple script for accessing the contents of an encrypted andOTP backup.

andOTP Decrypt

Simple script for accessing the contents of an encrypted andOTP backup. As long as Sodium is available this does not require any dependencies outside of PHP.

This was written as a replacement for [asmw/andOTP-decrypt][], which I found a little annoying to get going and depends on several external packages. (Hold! Was PHP easier than Python here? Oh my!)


To decrypt and write to a JSON file:

Zegnat / Innertext.php
Last active Oct 19, 2018
🏃🐉 Run. Here be dragons.
View Innertext.php
namespace Zegnat\Innertext;
class Innertext
const LF = "\n";
const CRLF = "\r\n";
Zegnat / authdiag.php
Last active Aug 7, 2018
Upload to a web server on an accessible path. Navigate to it in the browser. Copy the URL from the address bar and paste it in the form. Run the test to see if your server gets Authorization headers!
View authdiag.php
ini_set('display_errors', 1);
$auth = filter_input(
array('options' => array('regexp' => '@^authtest_\d+$@'))
Zegnat / martijnsclock.1s.php
Created May 15, 2018
BitBar ( plugin for a variable drop-down of time zones. Also does unix epoch time, and copying of ISO timestamps to the clipboard.
View martijnsclock.1s.php
$now = new \DateTimeImmutable(null, new \DateTimeZone('UTC'));
$copy = getopt('c:');
if (count($copy) > 0) {
// Make sure to use the local /bin/echo executable, exec() runs sh and native echo
// may not do what you expect.
exec('/bin/echo -n ' . escapeshellarg($copy['c']) . ' | pbcopy', $devnull, $status);
Zegnat /
Last active Jun 5, 2018
Setting up an offline Micropub testing environment, combining 3 separate PHP projects!

Testing Micropub, completely offline, with nanopub, Selfauth, and Mintoken.

this setup should be done in a directory that is being served at http://offlinepub.test/. When done, it should be possible to point a Micropub client at that URL and post.

IMPORTANT: This does not lead to a production safe setup. The tokens DB is put in a public directory, the APP_KEY for Selfauth is made known through this post, etc. But for offline testing, all should be good.

Zegnat / example.php
Created Apr 24, 2018
Example of using a PSR-7 library to parse an incoming request that contains one or more `photo` uploads.
View example.php
use \Nyholm\Psr7\Factory\ServerRequestFactory;
// Use the (draft) PSR-17 Factory to create our PSR-7 Request object:
$incomingRequest = ServerRequestFactory::createServerRequestFromGlobals();
// Check for uploaded files on the Request object.
// @see
$files = $incomingRequest->getUploadedFiles();
View article-example.html
<!-- HTML5 example article, with mf2 instead of, -->
<article class="h-entry">
<h1 class="p-name">The Very First Rule of Life</h1>
<p><time class="dt-published" datetime="2009-10-09">3 days ago</time></p>
<data class="u-url" value="?comments=0"></data><!-- <link> isn’t valid here, use <data>. -->
<p>If there's a microphone anywhere near you, assume it's hot and
sending whatever you're saying to the world. Seriously.</p>
Zegnat / microformat.schema.json
Last active Mar 10, 2019
JSON Schema for Microformats
View microformat.schema.json
"$schema": "",
"type": "object",
"properties": {
"type": { "$ref": "#/definitions/types" },
"properties": { "$ref": "#/definitions/properties" },
"children": {
"type": "array",
"items": { "$ref": "#" }
View KnownValetDriver.php
class KnownValetDriver extends BasicValetDriver
public function serves($sitePath, $siteName, $uri)
return is_file($sitePath . '/version.known');
public function isStaticFile($sitePath, $siteName, $uri)
Zegnat / gist:f5c3806c6be0ea5244359833acbf96a3
Created Dec 14, 2017
wget (like my browser) fails to get the file, but cURL does just fine.
View gist:f5c3806c6be0ea5244359833acbf96a3
$ wget
--2017-12-14 17:00:18--
Resolving, 2a04:4e42:14::403
Connecting to||:443... connected.
HTTP request sent, awaiting response... 404 Not Found
2017-12-14 17:00:18 ERROR 404: Not Found.
$ curl -O
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
You can’t perform that action at this time.