Skip to content

Instantly share code, notes, and snippets.

View JunichiIto's full-sized avatar

Junichi Ito JunichiIto

View GitHub Profile
context '有効なパラメータの場合' do
before do
@user = attributes_for(:user)
end
it '正しく登録されること' do
expect{
post :create, user: @user
}.to change(User, :count).by(1)
expect(response.status).to eq 302
expect(response).to redirect_to root_path
describe 'Post #create' do
context '有効なパラメータの場合' do
let(:create_user) { -> { post :create, user: attributes_for(:user) } }
it 'リクエストは302 リダイレクトとなること' do
create_user.call
expect(response.status).to eq 302
end
it 'データベースに新しいユーザーが登録されること' do
@JunichiIto
JunichiIto / format_month.rb
Created June 21, 2016 03:46
Dynamically parse and calc month number in text.
require 'minitest/autorun'
require 'date'
class SandboxTest < Minitest::Test
def format_month(text, current_date)
text.gsub(/#\{ *month(?: *([-+]) *(\d+))? *\}/) do
op = Regexp.last_match[1]
val = Regexp.last_match[2]
if op == '+'
(current_date >> val.to_i).month

Because Junichi Ito's post was public, I wanted to translate my answer to Japanese before posting it. Here's my English answer:

Thanks for your comments and your support! I realise we should have done a better job at explaining how we arrived at the pricing.

With Doorkeeper, we’re focused on organisers who hold events on a regular basis, not one off events. This is why we’ve chosen to go with monthly pricing, instead of one a one off fee. We think Doorkeeper already provides you some value when you’re not holding events (people can join your community, you can send them messages), and we want look to how we can provide even more continuous value for communities. If you have any ideas how we could make Doorkeeper more valuable to you even when you’re not holding an event, please let us know.

We chose the smallest plan to have five upcoming events number because we thought it would be the largest number a non professional event organiser would have. We think that ¥1,500 per month is a reasonable price even i

-- https://gist.github.com/natcl/7a5c98aae8b21475caf9
log "start"
property imageFiles : {"jpg", "pef", "dng", "jpeg"}
tell application "Finder"
set MyFolder to folder POSIX file "/Users/your-path/"
set SubFolders to every folder of MyFolder
end tell
repeat with aFolder in SubFolders
@JunichiIto
JunichiIto / fizz_buzz.rb
Created December 13, 2016 01:40
Rubyで書く変なFizzBuzz (Strange FizzBuzz function in Ruby)
fizz_buzz = -> (n) do
f = -> (cond, ans, nxt, n) { n % cond == 0 ? ans : nxt.(n) }.curry
patterns = [[n, n.to_s], [5, 'Buzz'], [3, 'Fizz'], [15, 'Fizz Buzz']]
patterns.inject(nil) { |nxt, (cond, ans)| f.(cond, ans, nxt) }.(n)
end
(1..20).map(&fizz_buzz)
=begin
[
[ 0] "1",
@JunichiIto
JunichiIto / answer.sql
Last active February 6, 2017 22:32
【SQL腕試し問題!】入会者数と退会者数を日付ごとに集計するSQLを書いてくださいの解答例
-- http://qiita.com/jnchito/items/1d21fa3970b3c76bee43
WITH target_dates AS
(SELECT joined_on AS target_date
FROM users
UNION
SELECT left_on AS target_date
FROM users
WHERE left_on IS NOT NULL ),
joined_counts AS
(SELECT joined_on,
@JunichiIto
JunichiIto / answer.sql
Last active February 6, 2017 22:32
【SQL腕試し問題】現在の部署に所属する社員の一覧を取得するSQLを書いて下さいの解答例
-- http://qiita.com/jnchito/items/29e22cc5a73da29f65a3
SELECT
e.id
,e.name
,sh.section_name
,to_char(sh.start_date, 'yyyy/mm/dd') as start_date
FROM
employees e
INNER JOIN
section_histories sh
@JunichiIto
JunichiIto / turbolinks-issue.md
Last active July 6, 2018 07:22
Turbolinksがうまく動かない理由(推測)とその解決策
@JunichiIto
JunichiIto / gist:54f1d0dbb928566f5083b6caf9d8a2b2
Created May 6, 2017 23:28
Syntax error is gone in Ruby 2.4?
➜ ~ ruby -v
ruby 2.3.4p301 (2017-03-30 revision 58214) [x86_64-darwin16]
➜ ~ irb
irb(main):001:0> [].delete 1 { 'NG' }
SyntaxError: (irb):1: syntax error, unexpected '{', expecting end-of-input
[].delete 1 { 'NG' }
^
from /Users/jit/.rbenv/versions/2.3.4/bin/irb:11:in `<main>'
irb(main):002:0> exit
➜ ~ rbenv shell 2.4.1