Skip to content

Instantly share code, notes, and snippets.

View aaronpk's full-sized avatar

Aaron Parecki aaronpk

View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@aaronpk
aaronpk / xoxo.geojson
Created September 5, 2016 23:30
sample route for testing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
{
"secret": "1234abcd",
"source": "http://rhiaro.co.uk/2015/11/1446953889",
"target": "http://aaronparecki.com/notes/2015/11/07/4/indiewebcamp",
"post": {
"type": "entry",
"author": {
"name": "Amy Guy",
"photo": "http://webmention.io/avatar/rhiaro.co.uk/829d3f6e7083d7ee8bd7b20363da84d88ce5b4ce094f78fd1b27d8d3dc42560e.png",
"url": "http://rhiaro.co.uk/about#me"
<?php
$wgExtensionFunctions[] = "relWebmention";
$wgExtensionCredits['parserhook'][] = array(
'name' => 'Rel Webmention',
'author' => 'Aaron Parecki http://aaronparecki.com',
'description' => 'Adds <nowiki><link rel="webmention"></nowiki> tag to advertise a Webmention endpoint on every page',
'url' => 'https://gist.github.com/aaronpk/7de5b63c58bc00e9e2cda434432ed0d3'
);
function relWebmention()
<?php
$html = '<html><body><a href="http://example.com">example</a></body></html>';
$lookfor = 'http://example.com';
$doc = new DOMDocument();
libxml_use_internal_errors(true); # suppress parse errors and warnings
$body = mb_convert_encoding($html, 'HTML-ENTITIES', mb_detect_encoding($html));
@$doc->loadHTML($body, LIBXML_NOWARNING|LIBXML_NOERROR);
libxml_clear_errors();
{
"uid": "twitter::kylewmahan",
"name": "@kylewmahan on Twitter",
"service": {
"name": "Twitter",
"photo": "https://abs.twimg.com/favicons/favicon.ico",
"url": "https://twitter.com/"
},
"user": {
"name": "Kyle Mahan",
ssh -R 6080:localhost:80 tunnlr.xyz
<?php
$input = json_decode(file_get_contents('php://input'));
if($input && property_exists($input, 'items') && count($input->items)) {
$item = $input->items[0];
$url = $item->permalinkUrl;
$ch = curl_init('https://telegraph.p3k.io/webmention');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
@aaronpk
aaronpk / post.txt
Last active January 16, 2016 18:47
the html content of the article has an img tag with a relative URL to "cat.jpg" and there is also a file in the request called "cat.jpg"
POST /micropub HTTP/1.1
Content-type: multipart/form-data; boundary=1884ea44ff5ec7421c3becf56820d9e0
Authorization: Bearer xxxxxxxxxx
--1884ea44ff5ec7421c3becf56820d9e0
Content-Disposition: form-data; name="h"
entry
--1884ea44ff5ec7421c3becf56820d9e0
Content-Disposition: form-data; name="content[html]"
import serial
ser = serial.Serial('/dev/ttyUSB0', 9600, 8, serial.PARITY_NONE, serial.STOPBITS_ONE)
print("turning tv off")
ser.write("801s!000\x0D")
print("reading reply")
response = ser.read(4)
print("%s" % response)