Skip to content

Instantly share code, notes, and snippets.

@pinglamb
pinglamb / pretty_print.css
Created November 5, 2011 18:22
JSON Pretty Print JS
body { font-family: monospace; font-size: 1.1em; }
ul { margin: 0 0 0 .2em; list-style: none; }
li { padding: 0; margin: 0;}
li:after { content: ','; }
li:last-child:after { content: ''; }
span.object { font-weight: bold; }
span.string, span.string a { color: green; }
@pinglamb
pinglamb / twitter_api.json
Created November 4, 2011 06:39
damn-api Twitter API Spec
{
"host": "api.twitter.com",
"api_groups": [
{
"name": "Timelines",
"apis": [
{
"name": "GET statuses/public_timeline",
"type": "json",
"path": "/1/statuses/public_timeline.json",
@pinglamb
pinglamb / photos_controller.rb
Created November 4, 2011 05:11
Model under multiple api version
class Api::V1::PhotosController < Api::V1::BaseController
class Photo < ::Photo
def to_hash
# ........
end
end
def index
render :json => Api::V1::PhotosController::Photo.all.collect(&:to_hash).to_json
end
@pinglamb
pinglamb / api_spec.json
Created November 2, 2011 15:31
damn-api sample spec
{
"host": ["api.example.com", "api-staging.example.com"],
"headers": { // By default, optional: false
"X-EXAMPLE-DEVICE-TYPE": ["iphone", "android"],
"X-EXAMPLE-DEVICE-UUID": {
"value": "mock",
"optional": true
},
"X-EXAMPLE-APP-ID": ["com.example.iphone.app1", "com.example.iphone.app2", "com.example.android.app1"]
},