This file contains hidden or 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
| [:aa, :bb, :cc].map(&:to_s) #=> ["aa", "bb", "cc"] |
This file contains hidden or 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
| class Hash | |
| def values_classify | |
| inject({}) do |options, (key, value)| | |
| options[key] = value.class | |
| options | |
| end | |
| end | |
| def values_classify! | |
| replace(self.values_classify) |
This file contains hidden or 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
| [:aa, :bb, :cc].map(&:to_s) #=> ["aa", "bb", "cc"] | |
| {:aa => 'aa', :bb => 'bb'}.map(&:to_s) #=> ["aaaa", "bbbb"] | |
| ary = {:aa => 'aa', :bb => 'bb'}.map do |key, value| | |
| [key.to_s, value] | |
| end | |
| Hash[ary] #=> {"bb"=>"bb", "aa"=>"aa"} |
This file contains hidden or 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
| mtr --report apple.com | |
| HOST: **** Loss% Snt Last Avg Best Wrst StDev | |
| 1.|-- pocketwifi.home 20.0% 10 335.4 85.9 9.1 335.4 109.8 | |
| 2.|-- em60-254-194-5.emobile.ad 20.0% 10 364.8 138.8 55.4 364.8 101.9 | |
| 3.|-- em60-254-194-61.emobile.a 0.0% 10 302.4 139.1 43.4 328.0 101.4 | |
| 4.|-- 218.231.128.37.ep.eaccess 10.0% 10 394.6 146.3 45.3 394.6 120.2 | |
| 5.|-- 211.14.193.161 0.0% 10 391.4 170.7 52.1 391.4 104.5 | |
| 6.|-- 113.157.229.13 10.0% 10 151.1 128.6 58.3 232.2 66.6 | |
| 7.|-- otejbb204.kddnet.ad.jp 20.0% 10 197.8 147.7 55.9 236.1 62.0 | |
| 8.|-- pajbb002.kddnet.ad.jp 10.0% 10 382.2 265.6 164.3 397.2 90.6 |
This file contains hidden or 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
| require 'rake' | |
| task :create do | |
| p 'created' | |
| end | |
| task :create_all do | |
| Rake::Task['create'].invoke | |
| end |
This file contains hidden or 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
| require 'rake' | |
| def create | |
| if @sub | |
| p "created" | |
| else | |
| p 'cant cleated' | |
| end | |
| end |
This file contains hidden or 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
| require 'rake' | |
| def create | |
| if @sub | |
| p "created" | |
| else | |
| p 'cant cleated' | |
| end | |
| end |
This file contains hidden or 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 press(op) | |
| title = op[:title] || 'no title' | |
| body = op[:body] || 'none' | |
| print %Q{ | |
| Title: #{title} | |
| ---------------- | |
| #{body} | |
| } | |
| end |
This file contains hidden or 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
| #!/usr/bin/env ruby | |
| #-- | |
| # set.rb - defines the Set class | |
| #++ | |
| # Copyright (c) 2002-2008 Akinori MUSHA <[email protected]> | |
| # | |
| # Documentation by Akinori MUSHA and Gavin Sinclair. | |
| # | |
| # All rights reserved. You can redistribute and/or modify it under the same | |
| # terms as Ruby. |
This file contains hidden or 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
| [2] pry(main)> require 'active_support/all' | |
| => true | |
| [3] pry(main)> 30.days.ago | |
| => 2012-02-27 17:14:49 +0900 | |
| [4] pry(main)> 1.months.ago | |
| => 2012-02-28 17:14:58 +0900 | |
| [5] pry(main)> 1.hours | |
| => 3600 | |
| [6] pry(main)> 1.hours.ago | |
| => 2012-03-28 16:15:11 +0900 |