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
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
<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> | |
<title>Busines Profile</title> | |
<link rel='stylesheet' type='text/css' href='http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.0.0/css/bootstrap.min.css'> | |
</head> | |
<body> | |
<div class='container' ng-app='business-profile' ng-controller='main'> | |
<div class='row'> | |
<div class='col-sm-1'></div> |
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
# include | |
# depends on some, a shim for which can be found at https://gist.github.com/l3ck/6418548 | |
if "function" isnt typeof Array::include | |
Array::include = (sought_value) -> | |
"use strict" | |
# throw on null | |
throw new TypeError("Array.prototype.include called on null or undefined") if null is this or "undefined" is typeof this | |
@some (element, index, array) -> |
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
# Avoid `console` errors in browsers that lack a console. | |
(-> | |
method = undefined | |
noop = noop = -> | |
methods = ["assert", "clear", "count", "debug", "dir", "dirxml", "error", "exception", "group", "groupCollapsed", "groupEnd", "info", "log", "markTimeline", "profile", "profileEnd", "table", "time", "timeEnd", "timeStamp", "trace", "warn"] | |
length = methods.length | |
console = (window.console = window.console or {}) | |
while length-- | |
method = methods[length] |
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
# max | |
if "function" isnt typeof Array::max | |
Array::max = -> | |
"use strict" | |
# throw on null | |
throw new TypeError("Array.prototype.max called on null or undefined") if null is this or "undefined" is typeof this | |
Math.max.apply null, this |
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
# reduce from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce | |
if "function" isnt typeof Array::reduce | |
Array::reduce = (callback, opt_initialValue) -> | |
"use strict" | |
# At the moment all modern browsers, that support strict mode, have | |
# native implementation of Array.prototype.reduce. For instance, IE8 | |
# does not support strict mode, so this check is actually useless. | |
throw new TypeError("Array.prototype.reduce called on null or undefined") if null is this or "undefined" is typeof this | |
throw new TypeError(callback + " is not a function") if "function" isnt typeof 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
# Production steps of ECMA-262, Edition 5, 15.4.4.19 | |
# Reference: http://es5.github.com/#x15.4.4.19 | |
# from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map | |
unless Array::map | |
Array::map = (callback, thisArg) -> | |
T = undefined | |
A = undefined | |
k = undefined | |
throw new TypeError(" this is null or not defined") unless this? |
NewerOlder