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/model/query.rb |
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のnameはUNIQ制約がない | |
users = names.uniq.map do |name| | |
User.new(name: name) | |
end | |
# BULK INSERTが挿入する前のIDを取得し、+1する | |
before_id = User.last.try(:id).to_i + 1 | |
# BULK INSERTでデータを挿入 | |
User.import users |
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
SELECT * FROM posts FOR UPDATE |
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
$ vim /usr/local/etc/mackerel-agent.conf | |
# ファイルの最下部に追加 | |
# command = "ruby <開発したプラグインのファイル場所>" | |
======================================== | |
[plugin.metrics.hogehoge] | |
command = "/Users/yn-misaki/.rbenv/shims/ruby /Users/yn-misaki/dev/mackerel_plugin/hogehoge.rb" | |
======================================== |
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
ALTER TABLE テーブル名 ADD INDEX インデックス名(カラム名); |
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
if [ -e 'ファイル名' ]; then | |
# ファイル/フォルダが存在していれば、ファイル/フォルダを削除するなど | |
rm ファイル名 | |
fi |
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
# rbenv+ruby-buildでインストール | |
$ rbenv install 2.2.4 | |
# rbenv+ruby-buildでインストール(rubyのドキュメントをインストールしない) | |
$ CONFIGURE_OPTS="--disable-install-rdoc" rbenv install 2.2.4 | |
# rbenv+rubyをソースからビルド(rubyのドキュメントをインストールしない) | |
$ sh ruby_install.sh | |
# ruby_install.sh という名前のシェルを作ります。↓中身はこちら | |
================================================================== |
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
# 通常のインストール | |
$ nodebrew install <version> | |
# install-binaryを使ってインストール | |
$ nodebrew install-binary <version> | |
# 【並列化】install-binaryを使ってインストール | |
# 今回はマシンのコア数が2なので2を指定します。 | |
$ MAKE_OPTS="-j <Core>" nodebrew install-binary <version> |
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
# LaunchAgentsにシンボリックリンクを張る | |
$ ln -sfv /usr/local/opt/mackerel-agent/*.plist ~/Library/LaunchAgents | |
# 設定ファイルを読み込む | |
$ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mackerel-agent.plist | |
# jobを開始 | |
$ launchctl start homebrew.mxcl.mackerel-agent |
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
$ npm update react-datetime |
NewerOlder