This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cnt =0 | |
inputs = [] | |
while str = STDIN.gets | |
inputs << str.to_i | |
end | |
inputs.each do |i| | |
inputs2 = inputs.dup | |
inputs2.delete(i) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
env_check() { | |
if [ -n "$SLAVE_DB_NAME" ] && \ | |
[ -n "$SLAVE_DB_USER" ] && \ | |
[ -n "$SLAVE_DB_PASSWORD" ] && \ | |
[ -n "$SLAVE_DB_HOST" ] && \ | |
[ -n "$DB_NAME" ] && \ | |
[ -n "$DB_USER" ] && \ | |
[ -n "$DB_PASSWORD" ] && \ | |
[ -n "$DB_HOST" ] && \ | |
[ -n "$RAILS_ENV" ]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright 2015 Google Inc. All Rights Reserved. | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app/controller/articles_controller.rb | |
class ArticlesController < ApplicationController | |
before_action :set_article, only: [:show, :edit, :update, :destroy] | |
def show | |
end | |
def edit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#echo "export RSPEC_ENABLE=0" >> ~/.bashrc | |
should_run_rspec(){ | |
echo "You Should Run RSPEC Test" | |
sed -i 's/export RSPEC_ENABLE=0/export RSPEC_ENABLE=1/g' ~/.bashrc | |
} | |
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD)" | |
check_file() { | |
for var in $changed_files |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#app/models/user.rb | |
def self.find_for_twitter_oauth(auth, signed_in_resource=nil) | |
user = User.where(:provider => auth.provider, :uid => auth.uid).first | |
unless user | |
user = User.create(user_nickname: auth.info.nickname, | |
provider: auth.provider, | |
uid: auth.uid, | |
email: User.create_unique_email, | |
password: Devise.friendly_token[0,20] | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create | |
@article = current_user.articles.build(article_params) | |
if @article.valid? | |
@article.save! | |
case params[:ope][:cmd] | |
when 'publish' | |
@article.publish! | |
puts "hi this is publish zone" | |
flash[:success] = '記事を公開しました。' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
include AASM | |
aasm do | |
state :draft, :initial => true | |
state :published | |
#event :publish, before: ->{ self.published_at = Time.now } do | |
event :publish do | |
transitions :from => :draft, :to => :published |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
= bootstrap_form_for(@article, layout: :horizontal) do |f| | |
= f.text_field :title, autofocus: true | |
= f.text_area :body_source, rows: 20 | |
.form-group | |
.col-sm-offset-2.col-sm-10 | |
= f.button '下書きを保存', name: 'ope[cmd]', value: 'save', class: 'btn btn-lg btn-default' | |
- if @article.draft? | |
= f.button '公開する', name: 'ope[cmd]', value: 'publish', class: 'btn btn-lg btn-default' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.wrap { | |
width: 500px; | |
margin: 0 auto; | |
} | |
.btn-holder { | |
text-align: center; | |
margin: 10px 0 10px 0; | |
} | |
#calendar table { | |
border-collapse: collapse; |
OlderNewer