Last active
August 29, 2015 14:06
-
-
Save tkawa/4bb75fff5a760f399d30 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coupled | |
(1..100).each do |i| | |
answer = HTTP.get("/v1/fizzbuzz?number=#{i}") | |
puts answer | |
end | |
# decoupled | |
root = HTTP.get_root | |
answer = root.link('first').follow | |
puts answer | |
while answer.link('next').present? | |
answer = answer.link('next').follow | |
puts answer | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div> | |
My name is Bob Smith | |
but people call me Smithy. | |
Here is my home page: | |
<a href="http://www.example.com">www.example.com</a> | |
I live in Albuquerque, NM and work as an engineer | |
at ACME Corp. | |
</div> | |
<div itemscope itemtype="http://schema.org/Person"> | |
My name is <span itemprop="name">Bob Smith</span> | |
but people call me <span itemprop="nickname">Smithy</span>. | |
Here is my home page: | |
<a href="http://www.example.com" itemprop="url">www.example.com</a> | |
I live in Albuquerque, NM and work as an <span itemprop="title">engineer</span> | |
at <span itemprop="affiliation">ACME Corp</span>. | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var user = document.getItems('http://schema.org/Person')[0]; | |
var name = user.properties['name'][0].itemValue; | |
alert('Hello ' + name + '!'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%div{itemscope: true, itemtype: 'http://schema.org/ItemList', itemid: notes_url, data: {main_item: true}} | |
- @notes.each do |note| | |
= link_to note.text.truncate(20), note, | |
rel: 'item', itemprop: 'hasPart' | |
= form_for Note.new do |f| | |
= f.text_field :text | |
= f.submit rel: 'create' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"uber": { | |
"version": "1.0", | |
"data": [{ | |
"url": "http://www.example.com/notes", | |
"name": "Collection", | |
"data": [ | |
{ "name": "hasPart", "rel": "item", "url": "/notes/1" }, | |
{ "name": "hasPart", "rel": "item", "url": "/notes/2" }, | |
{ "rel": "create", "url": "/notes", "action": "append", | |
"model": "note%5Btext%5D={text}" }, | |
{ "rel": "profile", "url": "/assets/note.alps"} | |
] | |
}] | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%div{itemscope: true, itemtype: 'http://schema.org/Article', itemid: note_url(@note), data: {main_item: true}} | |
%span{itemprop: 'articleBody'}= @note.text | |
%span{itemprop: 'datePublished'}= @note.published_at | |
%span{itemprop: 'dateCreated'}= @note.created_at | |
%span{itemprop: 'dateModified'}= @note.updated_at | |
= form_for @note, method: :put do |f| | |
= f.text_field :text | |
= f.submit rel: 'update' | |
= button_to 'Destroy', @note, method: :delete, rel: 'delete' | |
= button_to 'Publish', publish_note_path(@note), rel: 'publish' unless @note.published? | |
= link_to 'Next note', note_path(@note.next), rel: 'next' if @note.next | |
= link_to 'Prev note', note_path(@note.prev), rel: 'prev' if @note.prev | |
= link_to 'Collection of Note', notes_path, rel: 'collection', itemprop: 'isPartOf' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"uber": { | |
"version": "1.0", | |
"data": [{ | |
"url": "http://www.example.com/notes/1", | |
"name": "Article", | |
"data": [ | |
{ "name": "articleBody", "value": "First note's text" }, | |
{ "name": "datePublished", "value": null }, | |
{ "name": "dateCreated", "value": "2014-09-11T12:00:31+09:00" }, | |
{ "name": "dateModified", "value": "2014-09-11T12:00:31+09:00" }, | |
{ "name": "isPartOf", "rel": "collection", "url": "/notes" }, | |
{ "rel": "update", "url": "/notes/1", "action": "replace", | |
"model": "note%5Btext%5D={text}" }, | |
{ "rel": "delete", "url": "/notes/1", "action": "remove" }, | |
{ "rel": "publish", "url": "/notes/1/publish", "action": "append" }, | |
{ "rel": "next", "url": "/notes/2" }, | |
{ "rel": "profile", "url": "/assets/note.alps" } | |
] | |
}] | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PeopleController < ApplicationController | |
before_action :set_message, only: %i(show edit update destroy) | |
include Hypermicrodata::Rails::HtmlBasedJsonRenderer | |
... | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.person{itemscope: true, itemtype: 'http://schema.org/Person', | |
itemid: person_url(@person), data: {main_item: true}} | |
.media | |
.media-image.pull-left | |
= image_tag @person.picture_path, alt: '', itemprop: 'image' | |
.media-body | |
%h1.media-heading | |
%span{itemprop: 'name'}= @person.name | |
= link_to 'collection', people_path, rel: 'collection' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"image": "/assets/bob.png", | |
"name": "Bob Smith", | |
"isPartOf": "/people", | |
"_links": { | |
"self": { "href": "http://www.example.com/people/1" }, | |
"type": { "href": "http://schema.org/Person" }, | |
"collection": { "href": "/people" }, | |
"profile": { "href": "/assets/person.alps" } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment