Skip to content

Instantly share code, notes, and snippets.

View rummelonp's full-sized avatar
🐈‍⬛
ニャーン

Kazuya Takeshima rummelonp

🐈‍⬛
ニャーン
View GitHub Profile
@rummelonp
rummelonp / default_params_helpers.rb
Created August 8, 2014 11:09
RSpec 3 で default_params
module DefaultParamsHelpers
extend ActiveSupport::Concern
included do
let(:default_params) { {} }
alias_method_chain :process, :default_params
end
private
if defined? BetterErrors
require 'better_errors/repl/pry'
class BetterErrors::REPL::Pry::Output
def print(*args)
args.each { |arg| @buffer << arg.chomp }
end
end
end
@rummelonp
rummelonp / _rspec
Created July 24, 2014 13:18
rspec コマンドの zsh 補完
#compdef rspec
# ------------------------------------------------------------------------------
# Description
# -----------
#
# Completion script for Ruby on Rails (http://rubyonrails.org/).
#
# ------------------------------------------------------------------------------
# Authors
# -------
@rummelonp
rummelonp / .rspec
Created July 24, 2014 08:40
RSpec 3 用の spec_helper.rb の雛形的な
--color
--require spec_helper
@rummelonp
rummelonp / horizontal_split_nyan.rb
Created March 26, 2014 09:59
ActiveRecord で水平分割されてるの楽に扱うやつ
module HorizontalSplitNyan
def self.const_missing(const_name)
klass = Class.new(ActiveRecord::Base)
klass.table_name = "horizontal_split_nyans_#{const_name.to_s.downcase}"
const_set(const_name, klass)
end
def self.build(&block)
relations = table_classes.map { |c| c.instance_eval(&block) }
sql = relations.map { |r| r.to_sql }.join(' UNION ')
醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴
醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴響画醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴
醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴夢愛画夢画糖醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴
醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴夢夢夢夢糖夢糖買鬱醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴
醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴躍夢夢夢夢夢夢夢夢画醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴
醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴画夢夢夢糖画糖夢糖買躍醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴
醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴画糖夢夢命土宙夢夢画糖醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴
醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴躍買夢夢夢山勺画夢夢糖画醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴
醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴襲愛夢糖夢愛命響夢夢糖鐘醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴
醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴夢夢夢夢夢響糖夢夢糖鐘醴醴醴醴醴醴醴醴醴醴醴醴醴糖買鬱醴醴醴醴醴醴醴醴醴醴醴醴醴醴醴
@rummelonp
rummelonp / grape.rb
Created March 20, 2014 08:03
Grape でファイル分ける
# app/api/users.rb
class Users < Grape::API
format :json
get do
# returns users
end
get ':id' do
# returns user
@rummelonp
rummelonp / _berks
Created March 14, 2014 21:24
Berkshelf の zsh 補完
#compdef berks
# ------------------------------------------------------------------------------
# Description
# -----------
#
# Completion script for Berkshelf (http://berkshelf.com/).
#
# ------------------------------------------------------------------------------
# Authors
# -------
@rummelonp
rummelonp / routing_matchers.rb
Created March 10, 2014 16:10
RSpec の Routing のテストの出力綺麗にするやつ
module RSpec::Rails::Matchers
module RoutingMatchers
class RouteToMatcher
def description
method, path = @actual.first
expected = @expected.dup
to = "#{expected.delete(:controller)}##{expected.delete(:action)}"
str = "route #{method.upcase} \"#{path}\" to \"#{to}\""
if expected.any?
str << " with parameter #{expected.inspect}"
@rummelonp
rummelonp / mozjpeg_install.sh
Created March 7, 2014 15:53
mozjpeg を自前でコンパイルした上で homebrew 管理下に置く
brew install autoconf
brew install automake
brew install libtool
brew install nasm
brew install apple-gcc42
cd /usr/local/src/
git clone [email protected]:mozilla/mozjpeg.git
cd mozjpeg/
git checkout v1.0