Skip to content

Instantly share code, notes, and snippets.

@taketo1113
taketo1113 / ERROR: Failed to build gem native extension.md
Last active September 18, 2024 15:18
ERROR: Failed to build gem native extension (macOS 14.7 / ruby-build 20240917)

ERROR: Failed to build gem native extension

Environment

  • Mac mini (Apple M1)
  • OS: macOS 14.7
  • ruby: ruby 3.3.4 (2024-07-09 revision be1089c8ec) [arm64-darwin23]
  • ruby-build: ruby-build 20240917 (homebrew)

Error Details: gem install

# Gemfile
@taketo1113
taketo1113 / Benchmark OpenStruct.md
Last active September 7, 2024 07:56
Benchmark OpenStruct (ostruct)

Benchmark OpenStruct (ostruct)

It is benchmarks about OpenStruct.

The ostruct gem warn bellow message with Warning[:performance] = true

OpenStruct use is discouraged for performance reasons

ruby/ostruct#56

Benchmark Env

  • Mac mini (Apple M1)
@taketo1113
taketo1113 / README: Output csv file with Shift JIS.md
Last active November 9, 2021 07:03
Output csv file with Shift JIS using csb gem
@taketo1113
taketo1113 / README: Rails HostAuthorization setting to Allow any hosts.md
Created August 1, 2020 02:18
Rails HostAuthorization setting to Allow any hosts

Rails HostAuthorization setting to Allow any hosts

  • config
Rails.application.config.hosts << /.*/
  • env
    • rails 6.0.3.2
@taketo1113
taketo1113 / README: vue component per form controls.md
Last active March 4, 2020 04:02
vue component per form controls

Design Pattern to create vue component per form controls

Background

Rails MPA + Vue.js

Files

  • Rails View: app/views/views/_form.slim
  • Vue SFC: components/equipment_form/
    • index.js
  • EquipmentFormDeviceId.vue
@taketo1113
taketo1113 / pundit_nested_headless_policies.md
Last active December 21, 2018 08:46
Pundit Nested Headless policies

Pundit Nested Headless policies

# app/policies/hoge/dashboard_policy.rb
class Hoge::DashboardPolicy < Struct.new(:user, :dashboard)
  # ...
end
@taketo1113
taketo1113 / Replace 'be_success' to 'be_successful'.md
Created May 11, 2018 02:13
Fix 'DEPRECATION WARNING: The success? predicate is deprecated and will be removed in Rails 6.0. Please use successful?'
  • Error
DEPRECATION WARNING: The success? predicate is deprecated and will be removed in Rails 6.0. Please use successful?
  • Sample code
  # deprecated
  expect(response).to be_success
 
@taketo1113
taketo1113 / request_macros.rb
Last active March 2, 2018 01:12
Rails Request Spec Sample
# spec/support/request_macros.rb
module RequestMacros
def request_login_user
before(:each) do
@loginuser = FactoryBot.create(:login_user)
post user_session_path, params: { user: { email: @loginuser.email, password: @loginuser.password } }
follow_redirect!
end
end
end
@taketo1113
taketo1113 / Usage Committee.md
Last active January 1, 2018 14:11
Usage Committee

Usage Committee

Gemfile

  gem 'committee'
  gem 'committee-rails'
@taketo1113
taketo1113 / Replace 'factory_girl' to 'factory_bot'.md
Last active February 4, 2021 03:07
Replace 'factory_girl' to 'factory_bot'

Replace 'factory_girl' to 'factory_bot'

  • edit Gemfile
gem 'factory_bot_rails'
  • gem install
$ bundle install