Skip to content

Instantly share code, notes, and snippets.

@barnabywalters
barnabywalters / opd.js
Last active December 21, 2015 23:09
Original Post Discovery minimal client side implementation. Requires promisejs (HTTP) and bean (events)
// Original post discovery (in progress)
var noteForms = document.querySelectorAll('.note-post-form');
if (noteForms.length > 0) {
for (var i = 0;i < noteForms.length;i++) {
var form = noteForms[i];
var inReplyToField = form.querySelector('.in-reply-to');
bean.on(inReplyToField, 'blur', function(event) {
var url = event.target.value;
// TODO: Start loading indicator
promise.get('/services/original-post', {'url': url}).then(function (error, text, xhr) {
@barnabywalters
barnabywalters / notes.web
Last active December 20, 2015 20:09
Rough ideas for a gherkin-like environment for writing web applications. Things in parentheses are comments. `do some name` triggers the 'some name' signal defined by `on some name`
on GET /notes
fetch the 20 most recent notes filtered by tag
show as h-feed
on GET /notes/new
the user must be an admin
show autofilled note-form
on GET /notes/{id}
fetch note
@barnabywalters
barnabywalters / input.html
Last active December 17, 2015 21:18
Test case for microformats-2 e-* p-* HTML injection potential security hole
<span class="h-thing">
<span class="e-content">&lt; Things &gt; &amp;</span>
</span>
<span class="h-thing">
<span class="p-content">&lt; Things &gt; &amp;</span>
</span>
{
"alternates": [
{
"url": "http://example.org",
"rel": "home",
"media": "screen",
"hreflang": "en"
}
],
"rels":
<?php
namespace BarnabyWalters\Rest;
use Symfony\Component\Routing\Matcher\UrlMatcher as Matcher;
/**
* UrlMatcher
*
* A subclass of Symfony’s UrlMatcher which strips the extension from incoming
<?php
$render = function ($_path, $data) {
extract($data);
unset($data);
require $_path;
};
ob_start();
$render($_path, $data);
@barnabywalters
barnabywalters / style.css
Created September 5, 2012 19:22
em based responsive line lengths with cascading breakpoints and stuff
/*
* The basic idea:
* No more "mobile first", just take up the entire browser width when
* optimum line length gets near viewport width.
*/
body
{
width: 100%;
}
<xml id="skufilterbrowse" class="slide">
<productcatalog><labels><label key="skuset.deliverypolicyurl">Delivery policy content URL</label><label key="price.save">Save</label><label key="skuset.seemoredetails">See more details</label><label key="price.additionaloffers">Additional Offers</label><label key="price.freeitem">Includes Free Item*</label><label key="price.instsaving">Instant Savings</label><label key="skuset.eddieseedetails">See details </label><label key="price.rebateurl">RebateURL</label><label key="skuset.freedelivery">FREE SHIPPING, plus 5% back for Rewards Members</label><label key="price.printableCoupons">Click here for Printable Coupon</label><label key="price.value">Value</label><label key="skuset.eddieshipdetails">Estimated to arrive no later than </label><label key="price.qty">Qty.</label><label key="price.chooseyouritems">Choose your Items</label><label key="price.true">true</label><label key="skuset.clearancemessage">&lt;strong&gt;CLEARANCE ITEM:&lt;/strong&gt; </label><label key="price
@barnabywalters
barnabywalters / note.yaml
Created June 8, 2014 22:33
Example YAML of one of my notes
id: 4DtGgd
author:
type: h-card
url: 'http://waterpigs.co.uk'
photo: 'http://photos.waterpigs.co.uk/photos/custom/201210/5d5a4d-Facing-Down_100x100xCR.jpg'
name: 'Barnaby Walters'
name: 'Just added some more tunes to http://www.waterpigs.co.uk/wpsm/ — As far as I can tell, it''s the largest collection of hurdy gurdy sheet music on the web! #folkmusic #hurdygurdy #abc'
content: "<p>Just added some more tunes to <a class=\"auto-link\" href=\"http://www.waterpigs.co.uk/wpsm/\">http://www.waterpigs.co.uk/wpsm/</a> — As far as I can tell, it's the largest collection of hurdy gurdy sheet music on the web! <a rel=\"tag\" href=\"/tags/folkmusic\">#folkmusic</a> <a rel=\"tag\" href=\"/tags/hurdygurdy\">#hurdygurdy</a> <a rel=\"tag\" href=\"/tags/abc\">#abc</a></p>\n"
published: '2011-09-16T16:41:38+00:00'
updated: null
@barnabywalters
barnabywalters / authorization.php
Last active August 29, 2015 14:01
indieauth client/server setup code
<?php
// Create a micropub client app — allows users to log in and authorize this app to make requests on their behalf to,
// e.g. a micropub endpoint, authenticates requests based on remember-me cookie.
// $dataToCookie and $dataFromCookie map between the array of information about the current user and the string value
// stored in the remember-me cookie
//
// Adds routes:
// /login
// /authorize