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/local/bin/zsh | |
| sqlite_file="$(find $HOME/Library/Application\ Support/Firefox/Profiles/*.default/places.sqlite)" | |
| if [ ! -e "$sqlite_file" ]; then | |
| echo "cannot find sqlite file"; return | |
| fi | |
| sql="SELECT b.title, p.url FROM moz_bookmarks as b, moz_places as p \ | |
| WHERE b.type = 1 \ | |
| AND b.title IS NOT NULL \ |
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 Shell | |
| end | |
| Shell.autoload :Core, './core' # 同ディレクトリのcore.rbを指す | |
| puts "Core is not loaded yet." | |
| puts Shell::Core.new # Coreが必要になる | |
| # => loading core.rb # ここで初めて読まれる | |
| # => core -- initialized | |
| #<Shell::Core:0x007f89998938c8> |
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 C | |
| attr_reader :bind | |
| def initialize(val) | |
| @bind = binding | |
| end | |
| end | |
| c = C.new(999) | |
| c.val | |
| #=> undefined method `val' for #<C:0x007fef31888bc8 @bind=#<Binding:0x007fef31888b78>> (NoMethodError) |
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
| RUBY_VERSION #=> "2.1.2" | |
| def foo; 123 end | |
| def bar(foo = foo) | |
| p foo # => 123 | |
| p foo.class # => Fixnum | |
| end | |
| # Ruby2.2からは警告を出した上で、nilが代入されるようになる | |
| RUBY_VERSION #=> "2.2.0" | |
| def foo; 123 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 'bundler/setup' | |
| require 'socket' | |
| require 'minitest/autorun' | |
| class AssertSamples < Minitest::Test | |
| def test_asserts | |
| # 等しいこと | |
| assert_equal 5, 2 + 3 | |
| # 空(empty?がtrue)であること |
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
| % ex. 1 | |
| local B in | |
| thread | |
| B=true % 1 | |
| end | |
| thread | |
| B=false % 2 | |
| end | |
| if B then % 3 | |
| {Browse yes} % 4 |
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
| source 'https://rubygems.org' | |
| gem 'rspec' |
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
| $ brew install jq |
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
| # https://site1.sbisec.co.jp/ETGate/WPLETmgR001Control?OutSide=on&getFlg=on&burl=search_home&cat1=home&cat2=price&dir=price&file=home_price.html | |
| sbi = { | |
| 0..10 => 150, | |
| 10..20 => 199, | |
| 20..50 => 293, | |
| 50..100 => 525, | |
| 100..150 => 628, | |
| 150..3000 => 994, | |
| 3000..Float::INFINITY => 1050 | |
| } |
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
| value = do_something rescue nil |