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
# make sure we have some | |
unless Array::some | |
Array::some = (fun) -> #, thisp | |
"use strict" | |
throw new TypeError() unless this? | |
thisp = undefined | |
i = undefined | |
t = Object(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
<!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; |
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
/* | |
* English language translations for use in JavaScript. | |
*/ | |
(function(window, undefined) { | |
if (window.locales === undefined) { | |
window.locales = {}; | |
} | |
window.locales.en = { | |
forms: { |
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 locales/en.js | |
//= require locales/es.js | |
/* | |
* Set a global variable `i18n` that contains the current localization strings. | |
* Locale files create simple objects, we just map it in based on the 'lang' attribute | |
* of the HTML node. | |
*/ | |
(function(window, undefined) { | |
var currentLocale = window.document.documentElement.lang, | |
generalLocale = currentLocale.split('-')[0], |
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
before do | |
session[:csrf] ||= SecureRandom.hex(32) | |
response.set_cookie 'authenticity_token', { | |
value: session[:csrf], | |
expires: Time.now + (60 * 60 * 24 * 180), # that's 180 days | |
path: '/', | |
httponly: true | |
# secure: true # if you have HTTPS (and you should) then enable this |