Skip to content

Instantly share code, notes, and snippets.

@necojackarc
necojackarc / active_job_retry_controlable.rb
Last active June 30, 2021 13:20
To enable ActiveJob to control retry
module ActiveJobRetryControlable
extend ActiveSupport::Concern
DEFAULT_RETRY_LIMIT = 5
attr_reader :attempt_number
module ClassMethods
def retry_limit(retry_limit)
@retry_limit = retry_limit
@necojackarc
necojackarc / search_commit_msg
Created November 6, 2015 10:32
Getting commit massage samples script powered by http://commit-m.minamijoyo.com/
#!/usr/bin/env ruby
require "net/http"
require "uri"
require "nokogiri"
params = { keyword: ARGV.join("\s") }
uri = URI.parse("http://commit-m.minamijoyo.com/commits/search")
uri.query = URI.encode_www_form(params)
@necojackarc
necojackarc / text_file_pager.rb
Created November 1, 2015 14:04
You can get batches of lines from text files.
class TextFilePager
DEFAULT_BATCH_SIZE = 1000
def initialize(file_path, skip_header: false, delete_line_break: false)
@file_path = file_path
@skip_header = skip_header
@delete_line_break = delete_line_break
end
def batch_line(batch_size: DEFAULT_BATCH_SIZE)
AllCops:
TargetRubyVersion: ~
Include:
- '**/Rakefile'
- '**/config.ru'
Exclude:
- 'vendor/**/*'
- 'bin/*'
- 'config/**/*'
- 'db/**/*'