Skip to content

Instantly share code, notes, and snippets.

View pocke's full-sized avatar
⌨️
Pocke is typing...

Masataka Pocke Kuwabara pocke

⌨️
Pocke is typing...
View GitHub Profile
@pocke
pocke / monkey.rb
Created April 8, 2024 16:34
Get core exts
module Monkey
extend self
MODULE_NAME = Module.instance_method(:name)
MODULE_SINGLETON_CLASS_P = Module.instance_method(:singleton_class?)
MODULE_SINGLETON_CLASS = Module.instance_method(:singleton_class)
MODULE_INSTANCE_METHODS = Module.instance_method(:instance_methods)
MODULE_INSTANCE_METHOD = Module.instance_method(:instance_method)
CLASS_ATTACHED_OBJECT = Class.instance_method(:attached_object) rescue nil
IS_A = Object.instance_method(:is_a?)
@pocke
pocke / git-coauthor
Last active January 25, 2024 07:27
Add GitHub's Co-authored-by to the latest commit from account name
#!/usr/bin/env bash
USAGE="Usage: git coauthor USERNAME
It adds the specified user as Co-authored-by into the latest commit.
Example:
$ git coauthor pocke"
:grinning: 😀
:grin: 😁
:joy: 😂
:rofl: 🤣
:rolling_on_the_floor_laughing: 🤣
:smiley: 😃
:smile: 😄
:sweat_smile: 😅
:laughing: 😆
:satisfied: 😆
@pocke
pocke / videos.csv
Created June 22, 2023 04:01
RubyKaigi 2023 video list CSV
title link
[JA] The future vision of Ruby Parser / Yuichiro Kaneko @spikeolaf https://www.youtube.com/watch?v=IhfDsLx784g&list=PLbFmgWm555yYvWS7VGTFipF7ckduvSeT-&index=2&pp=iAQB
[EN] RuboCop's baddest cop / Genadi Samokovarov @gsamokovarov https://www.youtube.com/watch?v=n-D9uPOo_kc&list=PLbFmgWm555yYvWS7VGTFipF7ckduvSeT-&index=3&pp=iAQB
[EN] Generating RBIs for dynamic mixins with Sorbet and Tapioca / Emily Samp @egiurleo https://www.youtube.com/watch?v=UpbVZ4Gqk3c&list=PLbFmgWm555yYvWS7VGTFipF7ckduvSeT-&index=4&pp=iAQB
[JA] Make Regexp#match much faster / Hiroya FUJINAMI @makenowjust https://www.youtube.com/watch?v=IbMFHxeqpN4&list=PLbFmgWm555yYvWS7VGTFipF7ckduvSeT-&index=5&pp=iAQB
[EN] Understanding the Ruby Global VM Lock by observing it / Ivo Anjo @KnuX https://www.youtube.com/watch?v=rI4XlFvMNEw&list=PLbFmgWm555yYvWS7VGTFipF7ckduvSeT-&index=6&pp=iAQB
[JA] develop chrome extension with ruby.wasm / Yuma Sawai @aaaa777 https://www.youtube.com/watch?v=A2ziP8V9muE&list=PLbFmgWm555yYvWS7VGTFipF7ckduvSeT-&inde
# Devise
extension ApplicationController (Devise)
def current_user: () -> User
end
class DeviseController < ApplicationController
end
class Devise::SessionsController < DeviseController
@pocke
pocke / open-releases.rb
Created July 15, 2022 07:00
Open all rails/rails release between specified versions
# 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|
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
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 September 13, 2021 10:07
Run parser gem on a Ractor
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
# 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