Skip to content

Instantly share code, notes, and snippets.

View arika's full-sized avatar
🍡 ☕️ 🍰 ☕️ ☕️ ☕️ ☕️

akira yamada arika

🍡 ☕️ 🍰 ☕️ ☕️ ☕️ ☕️
View GitHub Profile
@arika
arika / groonga_rails_log.rb
Last active February 22, 2021 08:20
select_rails_log.rbでGroongaで出力したのを検索する https://gist.github.com/arika/61a79110d4677683d05989e9e2ed2d66
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'rroonga'
require_relative 'select_rails_log' if $0 == __FILE__
class GroongaIndex
REFERENCE_COLUMNS = {
http_status: 'HttpStatuses',
http_method: 'HttpMethods',
@arika
arika / Dockerfile
Last active April 29, 2020 07:17
mrubyのLinux/macOS向けクロスビルドのためのDockerfile(素のmrubyをビルドするだけならcurlとlibssl-devはたぶんいらない)
FROM debian:buster
ENV OSX_CROSS_PATH=/osxcross
COPY --from=dockercore/golang-cross:1.13.10 "${OSX_CROSS_PATH}/." "${OSX_CROSS_PATH}/"
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update -qq && apt-get install -y -q --no-install-recommends \
bison \
clang \
curl \
@arika
arika / Rakefile
Created April 28, 2020 03:29
mrbgemのためのRakefile
# frozen-string-literal: true
vendor_dir = "#{__dir__}/vendor"
ENV['MRUBY_ROOT'] = "#{vendor_dir}/mruby"
ENV['MRUBY_CONFIG'] = "#{__dir__}/build_config.rb"
namespace :mruby do
if ENV['LOAD_MRUBY_RAKEFILE']
load "#{ENV['MRUBY_ROOT']}/Rakefile"
else
# frozen_string_literal: true
require 'ostruct'
require 'open3'
require 'shellwords'
# 小さなコマンドをテストするためのヘルパーモジュール
#
# 内部で他のコマンドを呼び出すのが主となる10〜20行程度の小さなシェルスクリプト
# やRubyなどのスクリプトを主なテスト対象とする。
#!/usr/bin/env ruby
# rubocop-daemon-wrapper.rb
require 'rubygems'
if $0 == __FILE__
bin_dir = Gem::Specification.find_by_name('rubocop-daemon')&.bin_dir
abort 'rubocop-daemon.gem not found' unless bin_dir
ENV['RUBYOPT'] = "-r #{File.expand_path(__FILE__).sub(/\.rb\z/, '')}"
exec(File.join(bin_dir, '../bin/rubocop-daemon-wrapper'), *ARGV)
@arika
arika / bm_read_lines.rb
Last active October 13, 2019 08:30
benchmark read lines and scan lines
# frozen_string_literal: true
require "benchmark"
require "strscan"
def open_file(filename = "development.log")
File.open(filename, "r") do |io|
yield io
end
end
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
# 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 November 29, 2018 03:40
Test::Unitのtestやsetup/cleanup/teardownのプロファイルをとる(Rails編)
# 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?,
require 'ostruct'
require 'anbt-sql-formatter/formatter'
module PrettyPrintSql
module ActiveRecord
def ppsql
to_sql.tap {|sql| ::PrettyPrintSql.pp(sql) }
end
end