Skip to content

Instantly share code, notes, and snippets.

View adactio's full-sized avatar

Jeremy Keith adactio

View GitHub Profile
<?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",
<?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';
@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;
}
@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 / 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 / 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 / placeholderFromDatalist.js
Created August 12, 2012 15:54
Generate a placeholder attribute from the datalist associated with that input.
(function(win,doc) {
if (doc.querySelectorAll) {
var inputs = doc.querySelectorAll('input[list]'),
total = inputs.length;
for (var i=0; i<total; i++) {
var input = inputs[i],
id = input.getAttribute('list'),
list = doc.getElementById(id),
options = list.getElementsByTagName('option'),
amount = options.length,
@adactio
adactio / lettering.html
Created January 26, 2012 11:35
A quick'n'dirty way of doing some lettering.js stuff without jQuery.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Test</title>
<style>
.slogan span:nth-child(odd) {
color: red;
}
</style>
</head>
@adactio
adactio / mediaquerycolums.html
Created January 12, 2012 16:55
Multiple columns dependent on media queries that test for height as well as width.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Media Query Multiple Columns</title>
<meta name="viewport" content="width=device-width, intial-scale=1">
<style>
@media all and (min-width: 40em) and (min-height: 36em) {
[role="main"] {
-webkit-column-count: 2;
@adactio
adactio / twitter-user-stylesheet.css
Created December 14, 2011 23:56
CSS rules to hide "Trending Topics" and "Who To Follow" on new new Twitter.
[data-component-term="trends"] *,
[data-component-term="user_recommendations"] * {
display: none !important;
}