Skip to content

Instantly share code, notes, and snippets.

View hachi8833's full-sized avatar
😀

Shozo Hatta hachi8833

😀
View GitHub Profile
@st0012
st0012 / debugging_challenge.md
Last active August 29, 2022 07:35
Debugging Challenge

Introduction

This challenge tests if you can locate the cause of a Rails issue in 5 iterations (script execution). Although it's a Rails issue, prior knowledge on Rails is not required.

The 5 iterations limit may feel constraining, but it is intentional. If you can't locate the cause within the limitation, that's totally fine.

After the challenge, there's a simple questionnaire. If you can answer the questions, it'll help me prepare my talk for RubyKaigi. Any feedback will be appreciated 🙏

I recommend allocating 1.5 hr for the challenge and the questions

@yahonda
yahonda / ruby31onrails.md
Last active April 9, 2024 20:46
Ruby 3.1 on Rails

Ruby 3.1 on Rails

Actions required to use Ruby 3.1.0 with Rails

Rails 7.0.Z

  • Rails 7.0.1 is compatible with Ruby 3.1.0.
  • Rails 7.0.1 addes net-smtp, net-imap and net-pop gems as Action Mailbox and Action Mailer dependency, you do not need to add them explicitly in your application Gemfile anymore.
  • thor 1.2.1 has been released. You will not see DidYouMean::SPELL_CHECKERS.merge deprecate warnings anymore.

Rails 6.1.Z

  • Use Rails 6.1.5 to support database.yml with aliases and secrets.yml with aliases.
@alpaca-tc
alpaca-tc / stripped_string.rb
Last active May 31, 2021 07:29
空白を除去するString型
class StrippedString < ActiveModel::Type::String
# 左右の空白を除去した文字列クラス
#
# @param [Object] value
#
# @return [String, nil]
def cast(value)
super(value)&.strip&.presence
end
@alpaca-tc
alpaca-tc / boolean_validator.rb
Created May 23, 2021 13:17
値がtrue/falseのいずれかであることをテスト
# validates :column_name, boolean: true のように使う
class BooleanValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
return if value.is_a?(TrueClass) || value.is_a?(FalseClass)
record.errors.add(attribute, :not_boolean)
end
end
@kakutani
kakutani / reading-polished-ruby-translation.md
Last active November 3, 2021 14:06
Polished Ruby Programming翻訳査読書(のようなもの)

"Polished Ruby Programming" by Jeremy Evans

-- Build better software with more intuitive, maintainable, scalable, and high-performance Ruby code

「Rubyの磨きかた -- わかりやすくてメンテナンスしやすい、スケール可能で高性能なRubyコードでソフトウェアを上手につくろう」みたいな感じ?

https://www.packtpub.com/product/polished-ruby-programming/9781801072724

  • Publication date: June 2021
  • Publisher: Packt
  • Pages: 381
@khash
khash / component.html.erb
Last active March 5, 2023 05:48
Dropdown Component with ViewComponents, TailwindCSS and Stimulus
<!-- app/components/dropdown/component.html.erb -->
<div class="relative inline-block text-left" data-controller="dropdown--component">
<div>
<button type="button"
class="inline-flex justify-center w-full rounded-md border border-gray-300 shadow-sm px-4 py-2 bg-white text-sm font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-gray-100 focus:ring-indigo-500"
data-action="click->dropdown--component#toggleMenu"
aria-haspopup="true"
aria-expanded="true">
<%= @title %>
<!-- Heroicon name: solid/chevron-down -->
@shyouhei
shyouhei / gist:63d91a7934f31ef08e08ef4f23d0a30b
Created August 29, 2020 14:26
フルタイムでオープンソース・ソフトウェアを開発すると開発者にはどういう変化が訪れるか(個人の感想レベル)

フルタイムでオープンソース・ソフトウェアを開発すると開発者にはどういう変化が訪れるか(個人の感想レベル)

高給に耐えるという謎の感覚が涵養される

特に何もやってあげてないのに他人(法人だけどさ)から何百万何千万のお金が何年もとめどなく注ぎ込まれてきたら、怖くないですか?

オープンソース・ソフトウェアの開発者だけで給料をもらうというのは、まさにこの現象が発生してくるわけ。それまでもこれからも、ずっとオープンソース・ソフトウェアの開発者はやってきたし、やっていくわけでしょう。そんなの会社があってもなくても、別にやることなんて変わらないじゃない。じゃあなんで、ある時から急にかなりの金額が振り込まれてきてしまうんだ?しかもあからさまに物価上昇を上回る結構なハイペースで昇給していく。やっていることは一切何も変わってないのに!

この状況に適応するまでにはいささかの時間を要しました。根が小心者なので。

@azu
azu / git-2.26.1-README.md
Last active January 22, 2022 21:54
Gitの認証情報を奪い取れるGit 2.26.0以下にある脆弱性について

Git 2.26.0以下にある脆弱性

Git 2.26.0以下*1には、細工したリポジトリをgit cloneしたときに、 そのユーザーのCredential(たとえばGitHub.comをcloneするときに使う認証情報)を奪い取れる脆弱性があります。

📝 取得できる認証情報は credential.helper の設定に依存する

既にPoC(検証するためのコード)もあり、結構簡単なので是非Gitを2.26.1以上にアップデートしましょう。 git submoduleを使うと見た目ではわかりにくい攻撃もできるので、「気をつける」では回避は難しいです。

@yunusemredilber
yunusemredilber / _form.html.erb
Last active April 11, 2024 09:57
Auto Growing text-area [Stimulus] [Rails]
<!-- Some form -->
<div data-controller="auto-grow-textarea">
<%= form.text_area :body, cols: 20, row: 2, placeholder: 'Bir yorum yazın...', class:'form-control', data: { action: 'input->auto-grow-textarea#resize', target: 'auto-grow-textarea.input' } %>
</div>
<!-- Some form continued -->
@hytdsh
hytdsh / 気になった箇所.md
Last active October 21, 2019 03:33
railstutorial.jp の Rails 5.1(第4版) の気になった箇所

1章冒頭の本文「この章のおもちゃのアプリ (toy_app)」の箇所は一部の書体が斜体になっている。また"toy_app"のフォントスタイルが前後の段落の"hello_app"や"sample_app"と一致していない。

1.1.2本文の「例えば、サンプルアプリケーションproduction.rbの設定ファイルは」の箇所は、原文の「the sample application」については直後に示されるパス表記が"/home/ec2-user/environment/sample_app/"であることから日本語訳としては"sample_app"を当てて、全体として語順を整え「例えば、sample_appの設定ファイルproduction.rbは」とするのが好ましいように思われる。

1.3.3本文の「2.2.2では、このtoyアプリを使って」の「この」は不要と思われる。原文では"toy app"とあるが、これを"toy_app"とし「2.2.2では、toy_appを使って」とすることで文章の見通しが良くなるように思われる。 同じ段落に「サンプルアプリケーションでは、MVCの3つの要素をすべて扱いします。」という箇所があるが、まず「すべて扱いします。」は誤記と思われる。また"サンプルアプリケーション"の箇所は原文では"sample app"となっており、文脈的には"sample_app"と表記した上で「sample_appでは、MVCの3つの要素を」とするほうが文章の見通しが良くなるように思われる。

2章全般で sample_app を示す単語として「サンプルアプリケーション」を用いているが、読者にとっては hello_app も toy_app も sample_app も全て「サンプル」アプリケーションと言えるので、表記上の区別をつける方が良いように思われる。

2.2.2本文の「このようなマッピングするコードは」は「このようなマッピングをするコードは」とする方が好ましい。