Skip to content

Instantly share code, notes, and snippets.

View willnet's full-sized avatar
👶
parenting

Shinichi Maeshima willnet

👶
parenting
View GitHub Profile
Calculating -------------------------------------
erubi v1.9.0 20.994k i/100ms
slim v4.0.1 20.212k i/100ms
haml v5.1.2 11.562k i/100ms
faml v0.8.1 18.360k i/100ms
hamlit v2.10.0 21.497k i/100ms
-------------------------------------------------
erubi v1.9.0 245.242k (± 1.6%) i/s - 1.239M
slim v4.0.1 233.443k (± 2.2%) i/s - 1.172M
class WrapperForKaminari
attr_reader :total_count, :per, :page
delegate_missing_to :@models
def initialize(models:, total_count:, per:, page:)
@models = models
@total_count = total_count
@per = per
@page = page
end
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?('/')
"https://github.com/#{repo_name}.git"
end
source 'https://rubygems.org'
ruby '2.4.2'
gem 'active_decorator'
module M
def call
puts 'M'
super
end
end
class Parent
def call
puts 'Parent'
def suppress_stdout
original_stdout = $stdout
$stdout = File.open(File::NULL, 'w')
result = yield
ensure
$stdout = original_stdout
result
end
module ObjectExt
@willnet
willnet / Dockefile
Created December 17, 2017 16:08
Dockerfile for rvm installed environment
FROM ubuntu:14.04
RUN apt-get update
## Default Packages
RUN apt-get install -y -q ruby1.9.1 ruby1.9.1-dev build-essential
RUN apt-get install -y nano wget links curl rsync bc git git-core apt-transport-https libxml2 libxml2-dev libcurl4-openssl-dev openssl sqlite3 libsqlite3-dev
RUN apt-get install -y gawk libreadline6-dev libyaml-dev autoconf libgdbm-dev libncurses5-dev automake libtool bison libffi-dev
## Ruby
## 感想
全体的に地味
## Adapter
いろいろadapterがある
- db2
- firebird
@willnet
willnet / polymorphic_template.rb
Created September 4, 2017 02:49
rails template for polymorphic association
generate(:model, 'article')
generate(:model, 'event')
generate(:model, 'comment commentable:references{polymorphic}:index')
rake('db:migrate')
insert_into_file 'app/models/article.rb', "has_many :comments, as: :commentable\n", after: "class Article < ApplicationRecord\n"
insert_into_file 'app/models/event.rb', "has_many :comments, as: :commentable\n", after: "class Event < ApplicationRecord\n"
create_file 'db/seeds.rb' do
RUBY_CONFIGURE_OPTS=--with-readline-dir=`brew --prefix readline` rbenv install 2.4.1