Skip to content

Instantly share code, notes, and snippets.

Avatar
⌨️
Pocke is typing...

Masataka Pocke Kuwabara pocke

⌨️
Pocke is typing...
View GitHub Profile
@pocke
pocke / open-releases.rb
Created Jul 15, 2022
Open all rails/rails release between specified versions
View open-releases.rb
# Usage:
# # Open all releases between 6.1 and 7.0
# $ ruby open-releases.rb 6.1 7.0
tags = `git tag`.lines(chomp: true).map { _1[/^v(.+)$/, 1] }.compact.map { Gem::Version.new _1 rescue nil }.compact
s, e = ARGV.map { Gem::Version.new _1 }
vs = tags.select { s < _1 && _1 <= e }
vs.each do |v|
View emojitable.txt
:grinning: 😀
:grin: 😁
:joy: 😂
:rofl: 🤣
:rolling_on_the_floor_laughing: 🤣
:smiley: 😃
:smile: 😄
:sweat_smile: 😅
:laughing: 😆
:satisfied: 😆
View steep-playground.rb
require 'tmpdir'
require 'pathname'
Dir.mktmpdir('steep-playground-') do |dir|
dir = Pathname(dir)
dir.join('Steepfile').write(<<~END)
target :test do
signature "."
check "test.rb"
end
View model_from_schema.rake
namespace :model_from_schema do
desc 'Generate model files from db schema'
task gen: :environment do
module ModelGenerator
Models = {}
module Evaluator
module_function
def create_table(table_name, *)
@pocke
pocke / parser-ractor.rb
Last active Sep 13, 2021
Run parser gem on a Ractor
View parser-ractor.rb
require 'parser/current'
class Parser::Lexer
methods.grep(/^lex_en/).each do |m|
if m.end_with?('=')
singleton_class.undef_method m
else
v = __send__ m
singleton_class.undef_method m
eval <<~RUBY
View list_gems_with_test_files.rb
# Print gems that contains `test_files` in gemspec with disk consumed order.
#
# Usage:
# bundle install --path /path/to/somewhere
# cd /path/to/somewhere/ruby/VERSION/gems
# ruby THIS_SCRIPT.rb
#
# Pro tip: The following links are useful when you open a PR to remove test_files.
# * https://github.com/rubygems/guides/issues/90
# * https://github.com/rubygems/bundler/pull/3207
@pocke
pocke / invert_where.rb
Created Apr 28, 2021
`invert_where` inverts all where clause (dangerous!)
View invert_where.rb
# frozen_string_literal: true
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
# Activate the gem you are reporting the issue against.
@pocke
pocke / rbs
Created Nov 1, 2020
invalid new type introducing
View rbs
class C
def self.new: (String) -> untyped
end
class C2 < C
end
module M
def initialize: (String, Integer) -> void
end
@pocke
pocke / ractor-by-thread.rb
Created Sep 18, 2020
Implement ractor by Thread
View ractor-by-thread.rb
using Module.new {
refine ThreadGroup do
attr_accessor :fake_ractor
end
}
class FakeRactor
def initialize(*args, name: nil, &block)
@name = name
@incoming = Thread::Queue.new
View bitjourney-querly.yaml
rules:
- id: sample.delete_all
pattern:
- delete_all
- update_all
message: |
これらはvalidationやcallbackをスキップするので危険かもしれません。
justification:
- どうしても高速に update/destroy したい場合