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
# example(it)内でローカル変数を宣言する | |
describe 'convert_hash_syntax' do | |
it '=>が:に置き換わる' do | |
old_syntax = <<~TEXT | |
{ | |
:name => 'Alice', | |
:age => 20, | |
:gender => :female | |
} | |
TEXT |
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
FROM ruby:2.4.2 | |
ENV RAILS_ENV development | |
ENV APP_ROOT /var/www | |
WORKDIR $APP_ROOT | |
RUN apt-get update | |
RUN apt-get install -y nodejs npm | |
RUN gem install rails -v 5.1.2 |
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
$ sudo apt-get update | |
$ sudo apt-get install postgresql-9.5 | |
パッケージリストを読み込んでいます... 完了 | |
依存関係ツリーを作成しています | |
状態情報を読み取っています... 完了 | |
E: パッケージ postgresql-9.5 が見つかりません | |
E: 正規表現 'postgresql-9.5' ではパッケージは見つかりませんでした |
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
The difference between the request time and the current time is too large. |
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
<?php | |
// mbstrposの誤判定 | |
$keyword2 = 'DEF'; | |
$text2 = 'DEFghi'; | |
// 含まれていないと判定される | |
// mb_strposの戻り値が'0'の場合、誤判定するため | |
// mb_strposの判定は'==='で行うこと | |
if (mb_strpos($text2, $keyword2) == false) { |
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
<?php | |
$keyword_uppercase = 'XYZ'; | |
$keyword_lowercase = 'xyz'; | |
$text1 = 'abcXYZ'; | |
// mb_striposの挙動 | |
// 大文字は文字は含まれていると判定される | |
if (mb_stripos($text1, $keyword_uppercase) === false) { |
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
<?php | |
$keyword_uppercase = 'XYZ'; | |
$keyword_lowercase = 'xyz'; | |
$text1 = 'abcXYZ'; | |
$text2 = 'abcXYZabcXYZ'; | |
// mb_strposの挙動 | |
// 大文字は文字は含まれていると判定される |
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
array = [nil, 1, 2, 3, nil] | |
# nilを削除して計算 | |
p array.compact.inject(&:+) # 6 |
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
field = [[1,2],[3,4]] | |
# 連結 | |
# 12 | |
# 34 | |
field.each { |f| puts f.join("")} |
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
[user|~]$ cd /etc/nginx/conf.d/ | |
[user|conf.d]$ sudo vi xxx.conf #xxxは自分のアプリケーション名でファイル名変更 |