This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # `where` 句に渡す値はRuby Worldでcastされていてもいいんじゃないのか、と思ったので意見が聞きたいです。 | |
| # | |
| # いま、ARのカラムに暗号化を噛ませるgemを書いているのだけど、入力値が変換されずにクエリなるので、暗号化/復号化したクエリの値が一致せず辛い。 | |
| # 可能であれば、AR::Type::XXX#castでserialize時に値をcastしたい | |
| # Boolean/Decimalなどはserialize時に一切castしない `def serialize(value); value end` | |
| # Current: castされないため、入力値をそのままクエリに投げている | |
| User.attribute(:id, :boolean) | |
| User.where(id: 'string').to_sql #=> SELECT `users`.* FROM `users` WHERE `users`.`id` = 'string' | |
| User.where(id: true).to_sql #=> SELECT `users`.* FROM `users` WHERE `users`.`id` = TRUE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Database | |
| def initialize | |
| @value = 0 | |
| end | |
| def read | |
| io_blocking { @value } | |
| end | |
| def write(value) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Database | |
| def initialize | |
| @mutex = Mutex.new | |
| @value = 0 | |
| end | |
| def read | |
| io_blocking { @value } | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Automata | |
| class Error < StandardError; end | |
| class InvalidTransition < Error; end | |
| attr_reader :current_state | |
| def initialize(initial_state:, &block) | |
| @initial_state = initial_state | |
| @current_state = nil | |
| @events = {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| neovimをnodenvと併用したときのバグを発見してしまった。 | |
| vim-jpに投げるか、放置するかどうしようかなー | |
| ```neovim/0.2.2_1/share/nvim/runtime/autoload/provider/node.vim | |
| 25c25,31 | |
| < let args = [provider#node#Prog()] | |
| --- | |
| > let args = ['node'] | |
| > | |
| > if !empty($NVIM_NODE_HOST_DEBUG) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| begin | |
| require 'bundler/inline' | |
| rescue LoadError | |
| $stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler' | |
| raise | |
| end | |
| gemfile(true) do | |
| source 'https://rubygems.org' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # .pryrc | |
| show_backtrace = Class.new(Pry::ClassCommand) do | |
| IGNORE_PATHS = %w[ | |
| /pry | |
| /byebug | |
| ].freeze | |
| match 'show-backtrace' | |
| description 'Filter the caller locations' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # create_table :users do |t| | |
| # t.integer :uuid, null: false | |
| # t.index :uuid, unique: true | |
| # end | |
| class User < ApplicationRecord; end | |
| User.transaction do | |
| User.find_by(uuid: 1) #=> nil | |
| # ここで別transactionにて |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # frozen_string_literal: true | |
| require "bundler/inline" | |
| gemfile(true) do | |
| source "https://rubygems.org" | |
| git_source(:github) { |repo| "https://github.com/#{repo}.git" } | |
| gem "rails", '~> 6.0.0' |