Skip to content

Instantly share code, notes, and snippets.

☕️
🍡 ☕️ 🍰 ☕️ ☕️ ☕️ ☕️

akira yamada arika

☕️
🍡 ☕️ 🍰 ☕️ ☕️ ☕️ ☕️
Block or report user

Report or block arika

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@arika
arika / bm_read_lines.rb
Last active Oct 13, 2019
benchmark read lines and scan lines
View bm_read_lines.rb
# frozen_string_literal: true
require "benchmark"
require "strscan"
def open_file(filename = "development.log")
File.open(filename, "r") do |io|
yield io
end
end
View auto_correct.rb
require "yaml"
require "json"
require "tempfile"
module RuboCopAutoCollrect
class << self
def run_all!(targets, *cop_names, commit_log_format:, fixup_commit_log_format:)
plan(targets, *cop_names).each do |cop_name|
run!(targets, cop_name, commit_log_format: commit_log_format)
end
View start_rubocop.rb
# frozen_string_literal: true
require 'yaml'
require 'json'
require 'tempfile'
if ARGV.include?('-h') || ARGV.include?('--help')
<<~HELP.display
Usage: #{$0} [-r extension ...] [-- targets...]
@arika
arika / test_unit_profiling_for_rails.rb
Last active Nov 29, 2018
Test::Unitのtestやsetup/cleanup/teardownのプロファイルをとる(Rails編)
View test_unit_profiling_for_rails.rb
# test/test_helper.rbに書く
module TestProfiling
module TestCase
def run(result)
data = {
name: method_name,
owner_name: self.class.name,
source_location: method(method_name).source_location,
passed: passed?,
View pretty_print_sql.rb
require 'ostruct'
require 'anbt-sql-formatter/formatter'
module PrettyPrintSql
module ActiveRecord
def ppsql
to_sql.tap {|sql| ::PrettyPrintSql.pp(sql) }
end
end
@arika
arika / .spring.rb
Last active Aug 3, 2018
auto stop spring server
View .spring.rb
module DotSpringRb
MONITOR_INTERVAL = 10*60
SERVER_KEEP_PERIOD = 30*60
module_function
def env
@env ||= Spring::Env.new
end
@arika
arika / .vimrc
Last active Apr 27, 2018
https://github.com/janko-m/vim-test のtest-unit対応 .vim/autoload/test/ruby/testunit.vim (rails.vimとminitest.vimからのコピペ)
View .vimrc
let test#runners = {'Ruby': ['TestUnit']}
View select_rails_log.rb
#!/usr/bin/env ruby
require 'time'
require 'pp'
require 'optparse'
require 'ostruct'
request_id_regexp = /\h{8}-\h{4}-\h{4}-\h{4}-\h{12}/ # Rails 5.x
LOG_REGEXP = /\A., \[(?<time>\S+) #(?<pid>\d+)\] *(?<severity>\S+) -- :(?: \[(?<reqid>#{request_id_regexp})\])? (?<log>.*)/
ANSI_ESCAPE_SEQ_REGEXP = /\e\[(?:\d{1,2}(?:;\d{1,2})?)?[mK]/
View mini_magick_debug.rb
require 'shellwords'
class MiniMagickCommandExecutionTrace
OUTPUT = $stderr
TERM = {
green: "\e[32m",
red: "\e[31m",
yellow: "\e[33m",
reset: "\e[m",
}.freeze
View to_rouge.rb
# Usage:
#
# RUBYOPT='-r ./to_rouge' RI_ROUGE=monokai.sublime \
# ri --format=rouge Class.methods
require 'rdoc'
require 'rouge'
module RDoc
class Markup
You can’t perform that action at this time.