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
Warming up -------------------------------------- | |
JSON Dump 20.000 i/100ms | |
Marshal Dump 64.000 i/100ms | |
MessagePack Dump 381.000 i/100ms | |
Oj Dump 107.000 i/100ms | |
YAML Dump 1.000 i/100ms | |
Calculating ------------------------------------- | |
JSON Dump 187.571 (±10.1%) i/s - 940.000 in 5.067947s | |
Marshal Dump 611.550 (± 5.7%) i/s - 3.072k in 5.039944s | |
MessagePack Dump 3.945k (± 7.7%) i/s - 19.812k in 5.055238s |
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
# encoding: UTF-8 | |
# frozen_string_literal: true | |
require 'net/http' | |
require 'json' | |
require 'uri' | |
class HTTPDecorator | |
# Timeouts | |
OPEN_TIMEOUT = 10 # in seconds | |
READ_TIMEOUT = 120 # in seconds |
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
<script>proxyCheck = { hostname: '<%= request.host %>', pathname: '<%= request.path %>' };</script> |
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
/* | |
* This is a naive attempt to protect against transparent proxies. | |
* - We pass the request host and path in from Rack and compare it against what JS sees. | |
* - If they don't match, put them where they should be. | |
* | |
*/ | |
(function(location) { | |
if (location.hostname !== proxyCheck.hostname || location.pathname !== proxyCheck.pathname) { | |
/* Use an anchor tag as a parser. */ | |
var redirectParser = document.createElement('a'); |
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
<!doctype html> | |
<html> | |
<head> | |
<meta charset='utf-8'> | |
<meta http-equiv='refresh' content='5'> | |
<title>Temporarily Unavailable</title> | |
<link rel='stylesheet' type='text/css' href='//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.6/css/bootstrap.min.css'> | |
</head> | |
<body> | |
<div class='container'> |
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
# Inside of your Puma configuration file. | |
lowlevel_error_handler do | |
[500, { 'Content-Type' => 'text/html' }, File.open('50x.html')] | |
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
# | |
# A way to require parameters | |
# | |
# get '/', needs: [:id, :action] do | |
# erb :index | |
# end | |
# | |
# Does not modify the parameters available to the request scope. | |
# Raises a RequiredParamMissing error if a needed param is missing | |
# |
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
# | |
# A way to whitelist parameters. | |
# | |
# get '/', allows: [:id, :action] do | |
# erb :index | |
# end | |
# | |
# Modifies the parameters available in the request scope. | |
# Stashes unmodified params in @_params | |
# |
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 'sinatra/base' | |
require 'sinatra/strong-params' | |
class ExampleApp < Sinatra::Base | |
configure do | |
register Sinatra::StrongParams | |
end | |
get '/', allows: [:search] do | |
# Only the 'search' parameter will make it to the execution scope. |
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
return i18n.forms.numberPatternMismatch; |
NewerOlder