Exploring how to place navigational and other meta concerns in a JSON API.
Mandates that there will always be a "values" key in the collection hash.
// This is a collection of boats
"boats": {
1.8.7 :001 > ["asdf"].to_s | |
=> "asdf" | |
1.9.3p125 :001 > ["asdf"].to_s | |
=> "[\"asdf\"]" |
def is_binary_data? | |
( self.count( "^ -~", "^\r\n" ).fdiv(self.size) > 0.3 || self.index( "\x00" ) ) unless empty? | |
end |
require 'benchmark' | |
require 'psych' | |
require 'yaml' | |
data = [ 1 , { "hello hello" => "moo moo", :aaa => [] } ] * 100 | |
yaml = YAML.dump(data) | |
time = Benchmark.realtime { 10000.times { YAML.load(yaml) }} | |
puts "Time #{YAML}: #{time}" |
redis> lpush foo 1 | |
(integer) 1 | |
redis> lpush foo 2 | |
(integer) 2 | |
redis> lpush foo 3 | |
(integer) 3 | |
redis> lpop foo | |
"3" | |
redis> llen foo | |
(integer) 2 |
POST /forums/{id}/entries.{format} | |
curl -v -u {email_address}:{password} https://{subdomain}.zendesk.com/forums/{id}/entries.json \ | |
-H "Content-Type: application/json" -H "Accept: application/json" -X POST \ | |
-d '{"entry": {"title": "My Entry", "body": "This is an entry. It belongs to a forum"}}' | |
Or pass the forum_id in the request body: | |
POST /entries.{format} |
This gist shows 2 failing runs. One where sending 17K requests, | |
the second sending 2 x 8500 hits. Both fail. | |
morten@pokker ~$ ab -c 100 -n 17000 http://0.0.0.0:9000/wibble | |
This is ApacheBench, Version 2.3 <$Revision: 655654 $> | |
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ | |
Licensed to The Apache Software Foundation, http://www.apache.org/ | |
Benchmarking 0.0.0.0 (be patient) |
require 'rubygems' | |
require 'eventmachine' | |
require 'evma_httpserver' | |
module Simpleton | |
include EventMachine::HttpServer | |
def self.run | |
EventMachine::run do | |
EventMachine::start_server('0.0.0.0', 9000, self) |