Skip to content

Instantly share code, notes, and snippets.

Avatar

Barnaby Walters barnabywalters

View GitHub Profile
View nasty-hproduct.html
<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 Jun 8, 2014
Example YAML of one of my notes
View note.yaml
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 Aug 29, 2015
indieauth client/server setup code
View authorization.php
<?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
@barnabywalters
barnabywalters / h-event.html
Created May 4, 2014
php-mf2 dt-* <data class="value"> parse demonstration
View h-event.html
<div class="h-event">
<span class="dt-start">
<data class="value" value="2013-01-01">first day of 2013</data> at
<data class="value" value="21:00">nine in the evening</data>
</div>
@barnabywalters
barnabywalters / .gitignore
Last active Aug 29, 2015
An attempt at making a Composer-compatible repository in a gist
View .gitignore
.DS_Store
composer.phar
/vendor/
View nominatim.php
<?php
// where $app is a silex/pimple container — this could easily be rewritten as an ordinary function though
// example usage: list($location, $err) = $app['nominatim.reverse']([-1.125, 3.526])
function nameForLocation(array $location, $fallback='Unknown Location') {
if (isset($location['name'])) return $location['name'];
if (isset($location['street-address']) and isset($location['region']))
return "{$location['street-address']}, {$location['region']}";
@barnabywalters
barnabywalters / FifoQueue.php
Last active Dec 30, 2015
Taproot post-storage code as of 2013-12-08. Working live on waterpigs.co.uk, probably a little too rusty/specific for convenient use elsewhere but maybe of interest. storage.php is basic functional library — currently it depends on symfony/yaml for post serialisation but that can be replaced with any function capable of serializing an array stru…
View FifoQueue.php
<?php
namespace Taproot;
use SplQueue;
class FifoQueue extends SplQueue {
protected $capacity;
public function __construct($capacity) { $this->capacity = $capacity; }
View autolinkHashtags.php
<?php
/**
* Given a string and a baseurl, finds all hashtags matching
* `#[\-_a-zA-Z0-9]+` and wraps them in an `a` element with `rel=tag` set
* and a `href` of baseurl + '/' + tagname without the #.
*/
function autolinkHashtags($text, $baseUrl) {
$baseUrl = rtrim($baseUrl, '/');
@barnabywalters
barnabywalters / template.php
Created Nov 21, 2013
Dumbest PHP template rendering function ever
View template.php
<?php
function renderTemplate($template, array $__templateData = array()) {
$render = function ($__path, $render=null) use ($__templateData) {
ob_start();
extract($__templateData);
unset($__templateData);
include __DIR__ . '/../templates/' . $__path . '.php';
return ob_get_clean();
};
@barnabywalters
barnabywalters / barnabywalters.json
Created Nov 7, 2013
HTML from https://twitter.com/barnabywalters, parsed using indieweb/php-mf2-shim as of 2012-11-07
View barnabywalters.json
{
"rels": {
"shortcut": [
"https:\/\/abs.twimg.com\/favicons\/favicon.ico"
],
"icon": [
"https:\/\/abs.twimg.com\/favicons\/favicon.ico"
],
"canonical": [
"https:\/\/twitter.com\/BarnabyWalters"
You can’t perform that action at this time.