image

  • フォト Amazonギフト券
    ※この時計の時刻は、閲覧しているパソコンのものであり、必ずしも正確な時間とは限りません

検索

最近のトラックバック

無料ブログはココログ

« 2008-08-02 | トップページ | 2008-08-04 »

2008-08-03

2008-08-03

ruby で gmail へ添付ファル付きメールを送る

- http://mac-memo.blogspot.com/2008/02/rubygmail.html                                                                               
   > Macメモ: RubyでGMAILにメール
の記事の ruby コードを試してみた。
問題なく 日本語メールも送れた。すばらしい!

mail-address, password を config.yaml で設定するなどの変更をしてみた。

$ cat config.yaml.template
gmail_address: xxxxxx@gmail.com
gmail_pass: xxxxxx

$ cat sendmail.rb

# See  http://mac-memo.blogspot.com/2008/02/rubygmail.html
#      > Macメモ: RubyでGMAILにメール

require 'net/smtp'
require 'rubygems'
require 'tlsmail'
require 'kconv'
require 'base64'
require 'yaml'

$KCODE = 'utf8'

# mail_address="xxxxxx@gmail.com"
# password='xxxxxx'
# GMAIL アドレス、パスワードを config.yaml に設定する                                                                     
config_file = 'config.yaml'
config = YAML.load_file(config_file)
mail_address = config["gmail_address"]
password = config["gmail_pass"]

def send_with_attach(mail_address, password, from_address, to_address, mail_subject, mail_text, file_path)

  port=587
  helo_domain="gmail.com"
  smtp_host="smtp.gmail.com"
  smtpserver = Net::SMTP.new(smtp_host, port)
  smtpserver.enable_tls(OpenSSL::SSL::VERIFY_NONE)

  encoded = [File.open(file_path).readlines.join('')].pack('m')

  message = <<EndOfMail
From: #{from_address}
To: #{to_address}
Date: #{ Time::now.strftime("%a, %d %b %Y %X %z")}
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary=\"boundary_string_by_landscape_mail\"
X-Mailer: imput.rb
Subject: #{mail_subject}

--boundary_string_by_landscape_mail
Content-Type: text/plain; charset=\"ISO-2022-JP\"
Content-Transfer-Encoding: 7bit

#{mail_text.tojis}

--boundary_string_by_landscape_mail
Content-Type: application/octet-stream; name=#{ file_path}
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename=#{ File.basename(file_path)}

#{ encoded}

--boundary_string_by_landscape_mail--
EndOfMail

  smtpserver.start('gmail.com', mail_address, password, :login) do |smtp|
    smtp.send_message message, from_address, to_address
  end
end

from_address = mail_address
to_address = mail_address
subject = 'TEST'
message = "This is TEST.\テストです。"
file_path = File.basename(ARGV[0])

send_with_attach(mail_address, password, from_address, to_address, subject, message, file_path)

「夜と星と風の物語」- 星の王子さま を観た

Photobg

- http://www.t1010.jp/html/calender/2008/106/106.htm#
> *THEATRE1010*:  「夜と星と風の物語」- 星の王子さま -
を土曜日に当日券で観た。当日券の列には10 人ほど並んだ。
お陰さまで 12列 15番という ほぼ中央の席を取れた。

舞台装置/照明がとても美しい。また衣装の色も。
別役作品によく出てくる電信柱の代わりに、頭から墜落した飛行機?
背景の星、月、赤いパラソル、線路のない駅、キャラバンからはぐれた商人とラクダ、天体望遠鏡...
どれも素敵だ。

演奏は生の楽器と人間パーカッション。これもすばらしい。
すばらしい内容の舞台なのに すこし空き席があったようで もったいない。

劇場は北千住。
ここも今回初めて行った。商業ビルの10F, 11F が劇場になっている。

7月31日がサンテグジュペリの命日だったようです。
となりの方が 時々 靴を鳴らしてリズムをとるのでその音が気になってしょうがなかった。
# こういう方には初めて遭遇した。

SEC の XBRL データの取得

SEC ( http://www.sec.gov/ ) で公開される アメリカの XBRL データを ダウンロードする ruby スクリプトを書いてみた。
公開データの追加状況は RSS で取得できるので、それを読んで新しいデータをダウンロードするようにした。
http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi/trunk/Edinet/tools/sec/read-rss.rb?rev=26&root=ruby-xbrl&view=auto

こんな感じに使う。

$ ruby read-rss.rb X    // 不正パラメータを指定して簡易ヘルプを表示させた
usage: ruby read-rss.rb [n]
     n: SEC の n 日以内の新しい XBRL ダータをダウンロードする。
        指定省略した場合 7
     データは ./Archies/edgar/... に保存される。

$ ruby read-rss.rb 10
downlaod 2 corp(s)
AMEDISYS INC : 100% |oooooooooooooooooooooooooooooooooooooooo| ETA:  00:00:00
SAFEWAY INC (: 100% |oooooooooooooooooooooooooooooooooooooooo| ETA:  00:00:00
$
$ tree  // ダウンロードデータを確認
.
|-- Archives
|   `-- edgar
|       `-- data
|           |-- 86144
|           |   `-- 000119312508160373
|           |       |-- 0001193125-08-160373.txt
|           |       |-- d8k.htm
|           |       |-- swy-20080614.xml
|           |       |-- swy-20080614.xsd
|           |       |-- swy-20080614_cal.xml
|           |       |-- swy-20080614_lab.xml
|           |       `-- swy-20080614_pre.xml
|           `-- 896262
|               `-- 000119312508160221
|                   |-- 0001193125-08-160221.txt
|                   |-- amed-20080630.xml
|                   |-- amed-20080630.xsd
|                   |-- amed-20080630_cal.xml
|                   |-- amed-20080630_lab.xml
|                   |-- amed-20080630_pre.xml
|                   |-- d8k.htm
|                   `-- g42936tx1logo.jpg
`-- read-rss.rb

« 2008-08-02 | トップページ | 2008-08-04 »

mokuji

2013年12月
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        

google

  • twitter
  • __
  • _
    Googleボットチェッカー

合わせて読む

  • 合わせて読む
    フィードメーター - katoy: cocolog あわせて読みたい

リンク