Skip to content

Instantly share code, notes, and snippets.

View nikukyugamer's full-sized avatar
🍣
🍻

Osamu Takiya nikukyugamer

🍣
🍻
View GitHub Profile
@nikukyugamer
nikukyugamer / boot_metabase.sh
Created January 14, 2019 08:42
A script for booting Metabase
#!/bin/bash -xe
export MB_DB_TYPE=mysql
export MB_DB_DBNAME=metabase
export MB_DB_PORT=3306
export MB_DB_USER=USERNAME
export MB_DB_PASS=PASSWORD
export MB_DB_HOST=localhost
export MB_JETTY_PORT=12345
@nikukyugamer
nikukyugamer / production.rb
Created May 22, 2018 08:07
config/deploy/production.rb
set :stage, :production
set :branch, :master
set :deploy_to, '/opt/FOOBAR'
set :rails_env, 'production'
server 'SEVER_ADDRESS(NAME)', user: 'USERNAME', roles: %w{web app db}
set :ssh_options, {
keys: [File.expand_path('USER_KEY')]
}
set :unicorn_pid, "#{shared_path}/tmp/pids/unicorn.production.pid"
set :unicorn_config_path, "#{release_path}/config/unicorn.production.rb"
@nikukyugamer
nikukyugamer / development.rb
Created May 22, 2018 08:06
config/deploy/development.rb
set :stage, :development
set :branch, :development
set :deploy_to, '/opt/FOOBAR'
set :rails_env, 'development'
server 'SEVER_ADDRESS(NAME)', user: 'USERNAME', roles: %w{web app db}
set :ssh_options, {
keys: [File.expand_path('USER_KEY')]
}
set :unicorn_pid, "#{shared_path}/tmp/pids/unicorn.development.pid"
set :unicorn_config_path, "#{release_path}/config/unicorn.development.rb"
@nikukyugamer
nikukyugamer / deploy.rb
Last active May 23, 2018 08:10
my config/deploy.rb
lock '3.10.2'
set :application, 'APP_NAME'
set :repo_url, 'REPO_URI'
set :linked_dirs, %w(log tmp/pids tmp/cache tmp/sockets bundle) # public は微妙なので場合に応じて
set :rbenv_type, :user # :system(/usr/local/rbenv) or :user(~/.rbenv)
set :rbenv_ruby, '2.5.1'
set :linked_files, ['config/master.key']
@nikukyugamer
nikukyugamer / Capfile
Created May 22, 2018 07:56
my Capfile
require "capistrano/setup"
require "capistrano/deploy"
require "capistrano/scm/git"
install_plugin Capistrano::SCM::Git
require "capistrano/rbenv"
require "capistrano/rails"
require "capistrano3/unicorn"
require "capistrano/rails/console"
require 'capistrano/yarn'
Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r }
@nikukyugamer
nikukyugamer / todo_after_rails_new.md
Last active May 24, 2018 07:43
TODO after rails new

bundle exec rails...

$ bundle exec rails generate rspec:install
$ bundle exec rails generate sidekiq:worker Hard
$ bundle exec cap install
$ bundle exec rails webpack:install
@nikukyugamer
nikukyugamer / unicorn.rb
Last active May 19, 2018 06:15
unicorn.rb with Capistrano
# https://github.com/tablexi/capistrano3-unicorn/blob/master/examples/unicorn.rb
worker_processes 2
listen 12345
before_exec do |server|
ENV['BUNDLE_GEMFILE'] = '/var/tmp/foobar/current/Gemfile'
end
shared_path = '/var/tmp/foobar/shared'
@nikukyugamer
nikukyugamer / RailsDefaultGemfile
Last active May 23, 2018 01:50
Gemfile of default on Rails 5.2.0
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.5.0'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.2.0'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
@nikukyugamer
nikukyugamer / rails_new_options.md
Last active May 26, 2018 00:21
rails new options for me

とりあえずの結論

$ bundle exec rails new . --skip-test --skip-bundle --skip-puma --skip-coffee --database=mysql --webpack=vue
  • Gemfile は上書きしない

注意点

  • Gemfile$ bundle init したものではなく自分用に作った Gemfile に置き換える
@nikukyugamer
nikukyugamer / post_to_chatwork_with_faraday.rb
Created May 19, 2018 03:13
Post to ChatWork with Faraday
require 'faraday'
connection = Faraday.new
connection.post do |request|
request.url 'https://api.chatwork.com/v2/rooms/YOUR_ROOM_ID/messages'
request.headers['X-ChatWorkToken'] = 'YOUR CHATWORK TOKEN'
request.body = { body: '[info][title]ここにタイトルが入る[/title]ここに本文が入る[/info]' }
end