Skip to content

Instantly share code, notes, and snippets.


Taka necojackarc

View GitHub Profile
View .rubocop.yml
TargetRubyVersion: ~
- '**/Rakefile'
- '**/'
- 'vendor/**/*'
- 'bin/*'
- 'config/**/*'
- 'db/**/*'
necojackarc / text_file_pager.rb
Created Nov 1, 2015
You can get batches of lines from text files.
View text_file_pager.rb
class TextFilePager
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
def batch_line(batch_size: DEFAULT_BATCH_SIZE)
necojackarc / search_commit_msg
Created Nov 6, 2015
Getting commit massage samples script powered by
View search_commit_msg
#!/usr/bin/env ruby
require "net/http"
require "uri"
require "nokogiri"
params = { keyword: ARGV.join("\s") }
uri = URI.parse("")
uri.query = URI.encode_www_form(params)
necojackarc / active_job_retry_controlable.rb
Last active Jun 30, 2021
To enable ActiveJob to control retry
View active_job_retry_controlable.rb
module ActiveJobRetryControlable
extend ActiveSupport::Concern
attr_reader :attempt_number
module ClassMethods
def retry_limit(retry_limit)
@retry_limit = retry_limit
View Delete all merged branches except for ones you want to

Easy to check which branches will be deleted by removing at the bottom of | sh :)

git branch -r --merged master | sed -e 's#origin/#:#g' | egrep -v 'master|release|ADD BRANCH NAMES YOU WANT TO LEAVE' | sed 's/^/git push origin'/g | sh
necojackarc / Use ActiveModelSerializers inside
Last active Mar 28, 2017
How to Use ActiveModelSerializers inside Jbuilder
View Use ActiveModelSerializers inside


ActiveModelSerializers (AMS) is often said "an alternative to Jbuilder", but AMS is a kind of decorator which knows only how to serialize the target objects. On the other hand, Jbuilder is a library for the view of MVC.

So, it's a bit tough with only AMS to compose complex JSONs like this:

 "users": [
necojackarc / Control Maintenance Mode (Render 503) by Env Vars with
Last active Feb 10, 2018
How to Control Maintenance Mode (Render 503) by Env Vars with Rails
View Control Maintenance Mode (Render 503) by Env Vars with

Environment variables

MAINTENANCE_MODE When "true", your Rails app runs as maintenance mode
ALLOWED_IPS Set IP addresses you allow to access your Rails app when maintenance mode


necojackarc / Install Matplotlib with Tk on
Last active Apr 13, 2017
How to Install Matplotlib with Tk Backend on openSUSE
View Install Matplotlib with Tk on

Matplotlib's default background is agg, which doesn't have GUI. It means that show() doesn't show any plots on GUI.

That will never show any window, your matplotlib is configured to use agg, which is no gui version of output. Install a gui backend like python-matplotlib-qt4, python-matplotlib-tk and try again.

So, let's configure Matplotlib to use TkAgg, which is really easy to set up:

necojackarc / Deploy Hubot with
Last active Apr 24, 2017
How to Deploy Hubot with OpsWorks
View Deploy Hubot with


  1. Create a new custom cookbook for Hubot
  2. Create a Node.js stack and an app on OpsWorks
  3. Set the recipe in "Deploy" section

Custom Cookbook for Hubot

Put two files as below:

  • hubot/recipes/deploy.rb
  • hubot/templates/default/bin_hubot.erb
necojackarc / _json_ld_breadcrumbs.html.erb
Last active Nov 6, 2017
Render breadcrumbs in JSON-LD with Breadcrumbs On Rails
View _json_ld_breadcrumbs.html.erb
<!-- app/views/layouts/_json_ld_breadcrumbs.html.erb -->
<script type="application/ld+json">
<%= render_breadcrumbs builder: Breadcrumbs::JsonLdBuilder %>