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
w00t ! |
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
## awesomeness | |
[:get, :post, :put, :delete, :render, :request].each do |action| | |
eval %Q{ | |
def before_#{action} | |
yield |
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
require 'resolv' | |
require 'memcached' | |
module Rack | |
module JSONP | |
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
location ~* \.(json)$ { | |
default_type "application/json"; | |
# enable xss, and use "callback" | |
xss_get on; | |
xss_callback_arg callback; | |
# get data from memcached, proxy if not found | |
set memcached_key $key; | |
memcached_pass $uri; |
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
render :json => @something.to_json, :callback => params[:callback] |
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
>> @something.to_json | |
=> {"foo": "bar"} | |
>> params[:callback] | |
=> "aoeu" | |
>> render :json => @something.to_json, :callback => params[:callback] | |
=> aoeu({"foo": "bar"}) |
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
@something = Rails.cache.fetch("some_key") { Something.find("data") } | |
render :json => @something.to_json, :callback => params[:callback] |
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
location ~* \.(json)$ { | |
set memcached_key $key; | |
memcached_pass $uri; | |
echo_location_async /json_available; | |
error_page 404 @proxy; | |
} | |
location /json_available { | |
echo_duplicate 1 "$arg_callback("; | |
echo_location_async "/json_memcached"; |
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
aoeu |
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
puts "lol" |
OlderNewer