Skip to content

Instantly share code, notes, and snippets.

@jonm
jonm / xhtml_api_example.html
Created Nov 25, 2010
Sample document using XHTML for hypermedia APIs.
View xhtml_api_example.html
<!-- quick demo of XHTML API style -->
<html>
<body>
<div class="dvr">
<p>This div (and all it contains), represents a DVR set-top box. Some parts, like this text, may be
ignored by programmatic clients. A client can recognize it by its @class attribute. The general
convention here is one of inclusion rather than position, and clients make a lot of use of the
"//" (descendent) XPath operator rather than the "/" (child) operator.</p>
<!-- by the next form's @class I can recognize this is what I use to assign a friendly name.
@jonm
jonm / shallow-vs-deep.html
Created Dec 8, 2011
Shallow vs. deep representations in XHTML Hypermedia APIs
View shallow-vs-deep.html
<html>
<body>
<!-- the following div is a sample representation of a 'car' domain object; it can be identified as
such by the presence of 'car' in its @class. In this case, the car has two attributes, a make
and a model, and both are included right here. This is what I call a deep/complete/concrete
representation. -->
<div id="car123" class="car">
<span class="make">Ford</span>
<span class="model">Mustang</span>
</div>
@jonm
jonm / json-nowhitespace.txt
Created Jul 10, 2012
JSON example with whitespace removed
View json-nowhitespace.txt
{"contacts":[{"lastname":"Moore","firstname":"Jon"},{"lastname":"Simpson","firstname":"Homer"}]}
@jonm
jonm / HTML-nowhitespace.txt
Created Jul 10, 2012
HTML version without whitespace
View HTML-nowhitespace.txt
<html><body><ol class="contacts"><li><span class="firstname">Jon</span><span class="lastname">Moore</span></li><li><span class="firstname">Homer</span><span class="lastname">Simpson</span></li></ol></body></html>
@jonm
jonm / gist:3080485
Created Jul 10, 2012
Sample Twitter JSON response
View gist:3080485
[{"created_at":"Tue Jul 10 01:42:10 +0000 2012","id":222505965281488898,"id_str":"222505965281488898","text":"We will be performing #D3 maintenance Tuesday, July 10 beginning at 5am PDT: http:\/\/t.co\/2jr91xDu","source":"\u003ca href=\"http:\/\/www.radian6.com\" rel=\"nofollow\"\u003eRadian6 \u003c\/a\u003e","truncated":false,"in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"in_reply_to_user_id":null,"in_reply_to_user_id_str":null,"in_reply_to_screen_name":null,"user":{"id":174307074,"id_str":"174307074","name":"BlizzardCS","screen_name":"BlizzardCS","location":"Irvine CA and Austin TX","description":"Blizzard Entertainment North America Customer Support","url":"http:\/\/blizzard.com\/support\/","protected":false,"followers_count":220559,"friends_count":32,"listed_count":2008,"created_at":"Tue Aug 03 16:26:52 +0000 2010","favourites_count":0,"utc_offset":-28800,"time_zone":"Pacific Time (US & Canada)","geo_enabled":true,"verified":false,"statuses_count":12121,"lang":"en","contributors_enabled":f
@jonm
jonm / gist:3080489
Created Jul 10, 2012
Twitter sample XML response
View gist:3080489
<?xml version="1.0" encoding="UTF-8"?>
<statuses type="array">
<status>
<created_at>Tue Jul 10 01:42:10 +0000 2012</created_at>
<id>222505965281488898</id>
<text>We will be performing #D3 maintenance Tuesday, July 10 beginning at 5am PDT: http://t.co/2jr91xDu</text>
<source>&lt;a href=&quot;http://www.radian6.com&quot; rel=&quot;nofollow&quot;&gt;Radian6 &lt;/a&gt;</source>
<truncated>false</truncated>
<in_reply_to_status_id></in_reply_to_status_id>
<in_reply_to_user_id></in_reply_to_user_id>
@jonm
jonm / gist:3081067
Created Jul 10, 2012
HTML version of Twitter
View gist:3081067
<html>
<body>
<ol class="statuses">
<li class="status" id="222505965281488898" data-retweet-count="3">
<date class="created_at">Tue Jul 10 01:42:10 +0000 2012</date>
<p class="text">We will be performing #D3 maintenance Tuesday, July 10 beginning at 5am PDT: http://t.co/2jr91xDu</p>
<span class="source">&lt;a href="http://www.radian6.com" rel="nofollow"&gt;Radian6 &lt;/a&gt;</span>
<div class="user profile-use-background-image geo-enabled following" id="174307074" data-followers-count="220560"
data-profile-background-color="C0DEED" data-profile-text-color="333333"
data-profile-link-color="0084B4" data-profile-sidebar-fill-color="C0DEED"
@jonm
jonm / gist:3122100
Created Jul 16, 2012
Retrieve and edit a text/uri-list
View gist:3122100
GET /favorites HTTP/1.1
User-Agent: curl/7.16.4 (i386-apple-darwin9.0) libcurl/7.16.4 OpenSSL/0.9.7l zlib/1.2.3
Host: www.example.com
Accept: text/uri-list;q=1.0, */*;q=0.9
...
HTTP/1.1 200 OK
Date: Mon, 16 Jul 2012 10:38:12 GMT
Content-Type: text/uri-list; charset=utf-8
@jonm
jonm / gist:3548446
Created Aug 31, 2012
Sample list represented as application/atom+xml
View gist:3548446
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>Example Atom List</title>
<link rel="self" href="http://www.example.com/list"/>
<!-- note that we can provide hints of other list media types
supported by this server by providing links with the
link relation "alternate" and filling in the @type
attribute on them -->
<link rel="alternate" href="http://www.example.com/list" type="text/uri-list"/>
<updated>2003-12-13T18:30:02Z</updated>
@jonm
jonm / gist:3548629
Created Aug 31, 2012
Sample list represented as text/html
View gist:3548629
<html>
<head></head>
<body>
<ul>
<!-- HTML5 microdata would also be possible here, to give
more semantic structure, but the below is essentially
an HTML version of text/uri-list -->
<li><a href="http://www.example.com/raindrops-on-roses"></a></li>
<li><a href="http://www.example.com/whiskers-on-kittens"></a></li>
<li><a href="http://www.example.com/doorbells"></a></li>