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
grep VmSwap /proc/*/status | sort -n -k 2 -r | head | |
ps axfu | grep 対象プロセス |
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
cat /proc/meminfo | grep Mem |
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
# 配列の宣言 | |
arr_1 = [1, 2, 3, 4, 5] | |
# 繰り返しの処理 | |
arr_1.each do |arr| | |
puts 'hi' | |
puts arr | |
end | |
# 実行結果 | |
# hi | |
# 1 |
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
# 空のhashを定義 | |
h1 = Hash.new | |
h2 = {} | |
# keyとvalueをセットして定義 | |
# シンボルでも文字列でも定義できる | |
h3 = {a: 1, b: 2, c: 3} | |
h4 = {"a" => 1, "b" => 2, "c" => 3} |
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
h1[:a] = 1 | |
h1[:b] = 2 | |
h1[:c] = 3 | |
puts h1[:b] | |
# 実行結果 | |
# 2 | |
h2["a"] = 4 | |
h2["b"] = 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
h = {a: 1, b: 2, c: 3} | |
puts h.length | |
# 実行結果 | |
# 3 | |
puts h.size | |
# 実行結果 | |
# 3 | |
puts h.count |
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
h = {a: 1, b: 2, c: 3, d: "taro", e: "jiro"} | |
h.delete(:a) | |
puts h | |
# 実行結果 | |
# {:b=>2, :c=>3, :d=>"taro", :e=>"jiro"} | |
h = {a: 1, b: 2, c: 3, d: "taro", e: "jiro"} | |
# valueが数字の値だけを削除します。 | |
h.delete_if{|key, value| value.kind_of?(Integer)} | |
puts h |
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
h1 = { a: 1, b: 2, c: 3 } | |
h2 = { d: "taro", e: "jiro" } | |
h3 = h1.merge(h2) | |
puts h3 | |
# 実行結果 | |
# {:a=>1, :b=>2, :c=>3, :d=>"taro", :e=>"jiro"} |
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
h = {:a => 1, :b => 2, :c => 3, :d => "taro", :e = >"jiro"} | |
puts h.empty? | |
# 実行結果 | |
# false | |
# hashを初期化 | |
h.clear | |
puts h | |
# 実行結果 | |
# {} |
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
h = {:a => 1, :b => 2, :c => 3, :d => "taro", :e => "jiro"} | |
# keyの一覧を取得 | |
puts h.keys | |
# 実行結果 | |
# [:a, :b, :c, :d, :e] | |
# keyがあるかの確認 | |
puts h.key?(:a) | |
# 実行結果 | |
# true |
OlderNewer