Skip to content

Instantly share code, notes, and snippets.

View yahonda's full-sized avatar

Yasuo Honda yahonda

View GitHub Profile
class C
class_eval "def throw_syntax_error; eval %(
'abc' + pluralize 'def'
); end", "lib/file.rb", 42
end
c = C.new
c.throw_syntax_error
$ ruby -v
ruby 3.4.0dev (2024-09-10T02:50:49Z master 3db2782748) [x86_64-linux]
```
$ bundle
Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies...
Fetching stringio 3.1.1
Using sqlite3 2.0.4 (was 2.0.0)
/rails/activerecord/lib/arel/collectors/composite.rb:28: warning: the block passed to 'Arel::Collectors::Bind#add_bind' defined at /rails/activerecord/lib/arel/collectors/bind.rb:16 may be ignored
/rails/activesupport/lib/active_support/testing/strict_warnings.rb:35:in 'ActiveSupport::RaiseWarnings#warn': /rails/activerecord/lib/arel/collectors/composite.rb:28: warning: the block passed to 'Arel::Collectors::Bind#add_bind' defined at /rails/activerecord/lib/arel/collectors/bind.rb:16 may be ignored (ActiveSupport::RaiseWarnings::WarningError)
	from /rails/activerecord/lib/arel/collectors/composite.rb:28:in 'Arel::Collectors::Composite#add_bind'
	from /rails/activerecord/lib/arel/visitors/to_sql.rb:761:in 'Arel::Visitors::ToSql#visit_Arel_Nodes_BindParam'
	from /rails/activerecord/lib/arel/visitors/visitor.rb:30:in 'Arel::Visitors::Visitor#visit'
	from /rails/activerecord/lib/arel/visitors/to_sql.rb:654:in 'Arel::Visitors::ToSql#visit_Arel_Nodes_Equality'
	from /rails/activerecord/lib/arel/visitors/vis
  • Run non prepared statement using psql
$ bin/psql -d test
psql (17devel)
Type "help" for help.

test=# \d
                 List of relations
 Schema |         Name         |   Type   |  Owner
--------+----------------------+----------+---------
#!/usr/bin/env ruby

require 'pg'

# Output a table of current connections to the DB
conn = PG.connect( dbname: 'test' )
conn.exec('DROP TABLE IF EXISTS posts')
  • active_record2_non_prepared.rb that disables prepared statement prepared_statements: false
# frozen_string_literal: true

require "bundler/inline"

gemfile(true) do
  source "https://rubygems.org"

  git_source(:github) { |repo| "https://github.com/#{repo}.git" }
@yahonda
yahonda / pg_stat_statements.md
Last active April 4, 2024 23:25
Test pg_stat_statements and "IN" conditions patches

This entry shows the test result of https://www.postgresql.org/message-id/flat/CA%2Bq6zcWtUbT_Sxj0V6HY6EZ89uv5wuG5aefpe_9n0Jr3VwntFg%40mail.gmail.com

Steps to reproduce

  1. Download these 4 patch files
$ wget https://www.postgresql.org/message-id/attachment/154675/v18-0001-Prevent-jumbling-of-every-element-in-ArrayExpr.patch
$ wget https://www.postgresql.org/message-id/attachment/154676/v18-0002-Reusable-decimalLength-functions.patch
$ wget https://www.postgresql.org/message-id/attachment/154677/v18-0003-Merge-constants-in-ArrayExpr-into-groups.patch
@yahonda
yahonda / gist:7f5ee2861ecce0cdfcb422ef8735838a
Last active February 1, 2024 02:52
Rails CI using Ruby master branch

RailsのRuby masterブランチでのCIについて複数回聞かれたのでメモしておきます。

Rails 7.2で予定される変化

Rails CIとRubyバージョン

  • macOS Software Update
  • Install Xcode
  • git config --global user.name "Your Real Name" git config --global user.email me@example.com
  • Connecting to GitHub with SSH
  • ulimit -n 10240 in ~/.zshrc or whatever
  • Install Homebrew /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  • Install libyaml for Ruby 3.2 brew install libyaml
  • Install Ruby 3.2
  • git clone git@github.com:rails/rails.git
mutex_m
drb
base64
git grep 'require "observer"'
git grep 'require "drb"'
git grep 'require "abbrev"'
git grep 'require "observer"'
git grep 'require "getoptlong"'