Skip to content

Instantly share code, notes, and snippets.

View yatmsu's full-sized avatar
:octocat:

Yasuhiko Katoh yatmsu

:octocat:
  • Tokyo, Japan
  • 20:09 (UTC +09:00)
View GitHub Profile
@yatmsu
yatmsu / hello.rb
Last active January 27, 2018 12:16
メモメモ
puts "俺もgistデビューだ!"
@yatmsu
yatmsu / unicorn
Last active December 16, 2015 06:48 — forked from shapeshed/unicorn
#!/bin/sh
set -e
# Example init script, this can be used with nginx, too,
# since nginx and unicorn accept the same signals
# Feel free to change any of the following variables for your app:
TIMEOUT=${TIMEOUT-60}
APP_ROOT=/path/to/your/app/current
PID=$APP_ROOT/tmp/pids/unicorn.pid
ENVIRONMENT=production
@yatmsu
yatmsu / Gemfile
Created February 17, 2014 03:51
Gemfile(ginza.rb 08)
source 'https://rubygems.org'
ruby '2.0.0'
gem 'grape'
gem 'newrelic-grape'
gem 'rails', '4.0.1'
gem 'newrelic_rpm'
gem 'unicorn'
@yatmsu
yatmsu / 0_reuse_code.js
Created February 20, 2014 03:05
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@yatmsu
yatmsu / application_form_builder.rb
Created January 25, 2015 08:31
app/forms/application_form_builder.rb
class ApplicationFormBuilder < ActionView::Helpers::FormBuilder
def select_genders(options = {}, html_options = {})
select :gender, [ [ 'male', 'male' ], [ 'fmale', 'fmale' ] ], options, html_options
end
end
@yatmsu
yatmsu / application_form_builder_spec.rb
Last active September 15, 2015 15:02
spec/forms/application_form_builder_spec.rb
require 'rails_helper'
RSpec.describe ApplicationFormBuilder do
describe '#select_genders' do
let(:user) { User.create(name: 'name', gender: 'male') }
let(:builder){ ApplicationFormBuilder.new :user, user, ActionView::Base.new, {} }
it {
expect(builder.select_genders).to eq '<select name="user[gender]" id="user_gender"><option selected="selected" value="male">male</option>
@yatmsu
yatmsu / application_controller.rb
Last active August 29, 2015 14:15
app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
private
# ActionMailerのdefault_url_optionsを変更する
def set_default_url_options; ActionMailer::Base.default_url_options[:host] = request.host_with_port end
end
class UsersController < ApplicationController
before_action :set_user, only: [:show, :edit, :update, :destroy]
before_action :set_default_url_options, only: [:create, :update]
@yatmsu
yatmsu / yo.thor
Last active December 3, 2015 23:59
yo.thor
require 'thor'
class Gist < Thor
desc 'yo', 'gist sample task'
def yo
puts 'hey!'
end
end