Skip to content

Instantly share code, notes, and snippets.

View adactio's full-sized avatar

Jeremy Keith adactio

View GitHub Profile
@adactio
adactio / Look ahead pre-parser test
Last active December 19, 2015 15:09
I'd like to know if browsers that have a "look ahead" pre-parser for images will start downloading foo.png ...even if they support svg.
<!DOCTYPE html>
<title>Test</title>
<object data="foo.svg" type="image/svg+xml">
<img src="foo.png">
</object>
@adactio
adactio / webmention.php
Last active March 16, 2024 22:15
Minimum viable webmention in PHP.
<?php
# Licensed under a CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
# http://creativecommons.org/publicdomain/zero/1.0/
if (!isset($_POST['source']) || !isset($_POST['target'])) {
header($_SERVER['SERVER_PROTOCOL'] . ' 400 Bad Request');
exit;
}
@adactio
adactio / webmention-form.html
Last active December 9, 2017 23:33
The form I put at the end of every blog post I make so that you can ping my webmention endpoint with your response.
<form method="post" action="/webmention">
<p>Have you published a response to this?
<label for="webmention-source">Let me know the <abbr title="Uniform Resource Locator">URL</abbr></label>:
</p>
<input type="url" name="source" id="webmention-source">
<input type="hidden" name="target" value="https://adactio.com/journal/6495/">
<input type="submit" value="Ping!">
</form>
@adactio
adactio / postforms.js
Created March 2, 2014 23:42
Show a progress bar when a form is submitted (and prevent more than one submission per document).
/*
Show a progress element for any form submission via POST.
Prevent the form element from being submitted twice.
*/
(function (win, doc) {
'use strict';
if (!doc.querySelectorAll || !win.addEventListener) {
// doesn't cut the mustard.
return;
}
<?php
# Licensed under a CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
# http://creativecommons.org/publicdomain/zero/1.0/
function postToTwitter($data=array()) {
require_once 'OAuth.php';
$consumerKey = 'XXXX';
<?php
# Licensed under a CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
# http://creativecommons.org/publicdomain/zero/1.0/
$labels = array(
"What’s on your mind?",
"Hey Joe, what do you know?",
"Speak your brains",
"Share what you know",
@adactio
adactio / oEmbed.php
Last active November 7, 2015 10:22
<?php
# Licensed under a CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
# http://creativecommons.org/publicdomain/zero/1.0/
function getEmbedCode($url="",$maxwidth=320) {
$return = '';
$providers = array(
<?php
# Licensed under a CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
# http://creativecommons.org/publicdomain/zero/1.0/
function postToFlickr($data=array()) {
$api_key = 'XXX';
$api_secret = 'XXXX';
$auth_token = 'XXXX';
@adactio
adactio / checkbox-slider.html
Created October 1, 2014 18:26
Display a checkbox as a slider.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Checkbox</title>
<style>
body {
background-color: #fff;
color: #000;
@adactio
adactio / micropub.php
Last active January 20, 2023 16:09
Minimal micropub endpoint.
<?php
# Licensed under a CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
# http://creativecommons.org/publicdomain/zero/1.0/
$mysite = 'https://adactio.com/'; // Change this to your website.
$token_endpoint = 'https://tokens.indieauth.com/token';
$_HEADERS = array();
foreach(getallheaders() as $name => $value) {