Skip to content

Instantly share code, notes, and snippets.

View thash's full-sized avatar
🌵
⭐️ ⭐️ ⭐️ ⭐️ ⭐️

Takuya Hashimoto thash

🌵
⭐️ ⭐️ ⭐️ ⭐️ ⭐️
View GitHub Profile
#!/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 \
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>
@thash
thash / binding.rb
Last active August 29, 2015 14:17
AllAbout 031
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)
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
@thash
thash / asserts.rb
Last active August 29, 2015 14:15
AllAbout 029 minitest/TDD
require 'bundler/setup'
require 'socket'
require 'minitest/autorun'
class AssertSamples < Minitest::Test
def test_asserts
# 等しいこと
assert_equal 5, 2 + 3
# 空(empty?がtrue)であること
@thash
thash / ctmcp4.11.oz
Last active August 29, 2015 14:14 — forked from sekia/ctmcp4.11.oz
% ex. 1
local B in
thread
B=true % 1
end
thread
B=false % 2
end
if B then % 3
{Browse yes} % 4
source 'https://rubygems.org'
gem 'rspec'
@thash
thash / brew.sh
Last active August 29, 2015 14:13
$ brew install jq
@thash
thash / s.rb
Created January 6, 2015 18:17
SBI証券, MONEX, カブコム 現物株売買手数料比較
# 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
}
value = do_something rescue nil