Skip to content

Instantly share code, notes, and snippets.

View labocho's full-sized avatar

labocho

View GitHub Profile
@labocho
labocho / backup_config.rb
Last active February 22, 2024 06:32
backup_config.rb
#!/usr/bin/env ruby
require "fileutils"
# rubocop:disable Style/MixinUsage
include FileUtils
# rubocop:enable Style/MixinUsage
CONFIG_FILES = %w(
config/database.yml
config/mail.yml
AllCops:
Exclude:
- bin/*
- node_modules/**/*
NewCops: enable
Layout/CaseIndentation:
EnforcedStyle: end
Layout/EndAlignment:
@labocho
labocho / ff_on_apple_music.md
Last active October 26, 2023 09:16
Apple Music にある Final Fantasy シリーズのサウンドトラック等
@labocho
labocho / text_builder.rb
Last active March 8, 2023 04:58
Plain text template helper for Rails
# メール文面向けにプレーンテキストを生成する
#
# t = TextBuilder.new
#
# t << "Variables"
# t.indent {
# t.map(["foo", "bar", "baz"]) {|v|
# t << v
# }
# }
@labocho
labocho / a_valid_argument.rb
Last active March 7, 2023 08:26
RSpec matcher for validating argument by block
RSpec::Matchers.define :a_valid_argument do
match {|actual| block_arg.call(actual) }
end
#!/usr/bin/env ruby
# PS5 版 FF14 にマクロをコピペするための支援スクリプトです。
# 1. PS リモートプレイで操作しマクロ入力欄でキャレットが点滅する状態にする
# 2. マクロをクリップボードにコピー
# 3. pbpaste | paste-to-ps5 実行
# 4. 通知音がなるたびに△ボタンを押す
require "open3"
def osascript(script, *args)
require "logger"
$stdout.sync = true
logger = Logger.new($stdout)
logger.formatter = -> (severity, datetime, _progname, message) {
{
severity: severity,
time: datetime.to_i,
}.merge(message).to_json + "\n"
}
module StrictAccessor
# replace `(Array|Hash)#[]` with `fetch` recursively
def self.strictify(o)
case o
when Array
o.map {|e| strictify(e) }.extend(self)
when Hash
o.each_with_object({}) {|(k, v), h| h[k] = strictify(v) }.extend(self)
else
o
@labocho
labocho / adding_active_job_example.rb
Last active November 4, 2021 09:29
Adding ActiveJob job for resque without activejob gem
#!/usr/bin/env ruby
#
# Adding ActiveJob job without activejob gem example.
# For job class like:
# class FooJob < ApplicationJob
# queue_as :foo
#
# def perform(a, b)
# puts a, b
# end