I wrote this up here: http://blog.steveklabnik.com/posts/2012-02-27-hypermedia-api-reading-list
This file contains hidden or 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
| def find_and_replace_in_source_files(find, replace) | |
| extensions = %w[.rhtml .rxml .erb .builder .rb .css .js .rake] | |
| files = Dir["**/*"] | |
| files.each do |file_name| | |
| next if (file_name =~ /^vendor/) || !extensions.include?(File.extname(file_name)) | |
| text = File.open(file_name, 'r'){ |file| file.read } | |
| changed = text.gsub!(find, replace) | |
| File.open(file_name, 'w'){|file| file.write(changed)} if changed | |
| end |
You're right, I think, about there being an inverse relationship between power and readability in code.
I strongly, strongly disagree with this. Mostly because 'readability' is entirely subjective. For certain audiences, things can be more powerful and more readable at the same time.
For example, let's examine a case in Ruby, that also pertains to Haskell: Symbol#to_proc. A new Rubyist may write some code that looks like this:
[1,2,3,4,5].each {|number| number.to_s}
However, a more experienced Rubyist will write this code like this:
This file contains hidden or 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
| # Metaprogramming rots your brain. | |
| # First I wrote this: | |
| Data = Struct.new(:title) | |
| data.collect{|datum| Data.new(datum["title"])} | |
| # Then I decided I didn't want to make a huge list of attributes, so I decided to use an | |
| # OpenStruct, and ended up doing this: |
This file contains hidden or 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
| require 'hateoas' | |
| class Maze | |
| include Hateoas::MediaType | |
| media_type "application/vnd.amundsen.maze+xml" | |
| serialization :xml | |
| element :maze, |
This file contains hidden or 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
| <!DOCTYPE html> | |
| <html> | |
| <head><title>SEARCH</title></head> | |
| <body> | |
| <form method="GET" action="/results"> | |
| <input type="text" name="q" /> | |
| <input type="submit" /> | |
| </form> | |
| </body> | |
| </html> |
This file contains hidden or 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
| Hypermedia designs scale better, are more easily changed and promote decoupling | |
| and encapsulation, with all the benefits those things bring. On the downside, | |
| it is not necessarily the most latency-tolerant design, and caches can get stale | |
| if you're not careful. It may not be as efficient on an individual request level | |
| as other designs. |
This file contains hidden or 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
| Foreward | |
| About This Project | |
| Hypermedia API | |
| Web Worship | |
| Hypermedia Benefits in Plain Language | |
| Linking | |
| Hypertext | |
| Programming The Media Type (COMING SOON) | |
| The Design Process an Overview | |
| Building the W3CLove API |
This file contains hidden or 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
| [redacted] is real good at making me angry. | |
| the argumentation lacks any show of willingness to try to empathize | |
| with those that whole differing view points, or who may be impacted | |
| negatively by the behavior in question. | |
| Why is he defending dick jokes, moreover, why is he defending people | |
| that make dick jokes; why does he make dick jokes. I feel like, by | |
| asking those three questions, I am currently at a more powerful point | |
| for real understanding than he is, because he is |
This file contains hidden or 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
| require 'rubygems' | |
| require 'bundler/setup' | |
| require 'webmachine' | |
| require 'webmachine/adapters/rack' | |
| require './shoes' | |
| Shoes = Webmachine::Application.new do |app| | |
| app.routes do | |
| add ["css", "*"], PublicResources |