postfixでメールが送信されない
Apr 11 20:03:28 localhost postfix/smtp[12713]: 22E9C10C063F: to=<sc@gmail.com>, relay=gmail-smtp-in.l.google.com[2404:6800:4008:c01::1a]:25, delay=1, delays=0.12/0.01/0.37/0.54, dsn=5.7.1, status=bounced (host gmail-smtp-in.l.google.com[2404:6800:4008:c01::1a] said: 550-5.7.1 [2001:e42:103:2:153:121:91:20] Our system has detected that this 550-5.7.1 message does not meet IPv6 sending guidelines regarding PTR records 550-5.7.1 and authentication. Please review 550-5.7.1 https://support.google.com/mail/?p=ipv6_authentication_error for more 550 5.7.1 information. w9si2966434pfi.224 - gsmtp (in reply to end of DATA command))
設定を変更します。
// /etc/postfix/main.cf # Enable IPv4, and IPv6 if supported #inet_protocols = all inet_protocols = ipv4
postfixでめちゃくちゃハマりました。
参考
英語を勉強している
シリコンバレーから帰ってきて1ヶ月経ちました。今英語を勉強しています。
やっていること
実際にやっていることは主に3つです。
- Skype英会話
- TEDの音読
- 海外ドラマを英語字幕で見る
Skype英会話
数人に意見を聞くと以下のサービスが上がりました
- langrich
- rarejob
- DMM英会話
- qqenglish
この中からどれをするか迷いましたが、「qqenglishは品質がいい」との意見を貰ったので自分はqqenglishにしました。
qqenglishには2つのプランがあって、自分は1日1回の月会費制を選んで毎日やっています。月6200円です。
- ポイント制で1日何回もレッスンできる
- 1日1回の月会費制
レッスンは1回25分で、指定されたテキストをこなします。25分はあっという間です。
レッスンの予約についてですが、上は何日も先のレッスンを空きがある限り予約できて、下は予約は1レッスンのみなのでその日のレッスンが終わらないと次のレッスンを予約できません。
土日は予約が殺到するので取りにくい時が割とありました。
レッスンにも種類があって、日常英会話やビジネス英会話などがあります。自分はまだ日常英会話しか受けていません。
TEDの音読
英語の勉強には早口で音読するのがいいとのアドバイスをもらったので音読もしています。
なるべく短い方が練習になると思ったので3分のTEDスピーチを選びました。
Derek Sivers: How to start a movement | TED Talk | TED.com
社会活動の起こし方
Renny Gleeson: 404, the story of a page not found | TED Talk | TED.com
404ページの物語
Damon Horowitz: Philosophy in prison | TED Talk | TED.com
刑務所の中の哲学
Richard St. John: 8 secrets of success | TED Talk | TED.com
成功のための8つのこと
Marcin Jakubowski: Open-sourced blueprints for civilization | TED Talk | TED.com
文明の設計をオープンソース化する取り組みについて
Derek Sivers: Keep your goals to yourself | TED Talk | TED.com
ゴールは黙っておこう
音読の流れは、
これをだいたい1日30分くらいしています。
電車の中など移動時間はTEDを聴いています。
海外ドラマを英語字幕で見る
hulu契約しました。
最初フレンズを見ていたのですが英語字幕がないので今はHEROESを見ています。話のテンポが少し遅いですが楽しめています。45分ドラマは少し長く感じます。やはり30分ドラマが丁度いいです。
英語字幕のないフレンズを見ているときはネットに落ちてるスクリプトを見ながら日本語字幕で見ていました。とてもめんどくさかったです。
成果
もちろん、以前より英語を聞き取れるようになりました。話せるようにもなりました。発音も良くなりました。
ですが最近少し慣れてきて手詰まりを感じています。やはり1日6時間とか人と英語を話す時間がないとなかなか厳しいみたいです。
手っ取り早いのは英語圏に住むという事を痛感しています。
参考
grant打つとAccessDenied
rootユーザーで入ってgrant打ってもAccess Deniedされます。
mysql> GRANT ALL ON *.* TO test@’00.00.00.00' IDENTIFIED BY ‘ppaappaa'; ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
何が何だか分からずに途方に暮れていましたが、mysql_updateすればいいようです。
[root@localhost ~]# mysql_upgrade -u root -p Enter password: Looking for 'mysql' as: mysql Looking for 'mysqlcheck' as: mysqlcheck Running 'mysqlcheck with default connection arguments Running 'mysqlcheck with default connection arguments keirinjuku_db.keirinjuku OK mysql.columns_priv OK mysql.db OK mysql.event OK mysql.func OK mysql.general_log OK mysql.help_category OK mysql.help_keyword OK mysql.help_relation OK mysql.help_topic OK mysql.host OK mysql.ndb_binlog_index OK mysql.plugin OK mysql.proc OK mysql.procs_priv OK mysql.servers OK mysql.slow_log OK mysql.tables_priv OK mysql.time_zone OK mysql.time_zone_leap_second OK mysql.time_zone_name OK mysql.time_zone_transition OK mysql.time_zone_transition_type OK mysql.user OK Running 'mysql_fix_privilege_tables'... OK
これで無事にgrant文を打つことができました。
mysqlを5.5にあげた時は要注意だそうです。
参考
Rubyのキーワード引数にハッシュを指定
作ったgemのメンテナンスをしています。
キーワード引数でハッシュを引数にしたかったのですが、ActionView::Template::Error (unknown keyword: url):が出て辛かったのでメモします。
最初はこうしていました:
#以下で宣言 def render_geo(url: {}, high_accuracy: false, timeout: 8000, maximum_age: 2000, watch: false) render_url = self.controller_name + "/" render_url += url[:url][:action] unless url[:url][:action].nil? render partial: "/geo/get_geo", locals: {url: render_url, high_accuracy: high_accuracy, timeout: timeout, maximum_age: maximum_age, watch: watch} end #以下で使用 <%= render_geo(:url => {:controller => "users"}) %>
イメージとして、form_forのurlを指定するようにしたかったです。
ハッシュは最後
ハッシュを引数にしたいときは引数の最後にキーワードを置かなくてはいけないみたいです。
宣言部を以下のようにしました:
def render_geo(high_accuracy: false, timeout: 8000, maximum_age: 2000, watch: false, **url)
ハッシュの指定は**urlのようにしなければいけないのですね。
参考
n対nの関連
Railsでn対n関連を実装します。
現在1対nの関連を持ったTagテーブルとArticleテーブルをn対nの関連に変更します。
ここでは中間テーブルを作成しない方法で実装します。
has_and_belongs_to_many
各モデルにhas_and_belongs_to_manyを追加します。
class Article < ActiveRecord::Base has_and_belongs_to_many :tags end class Tag < ActiveRecord::Base has_and_belongs_to_many :articles end
関連付け
関連付けはマイグレーションファイルで行います。
キー指定は必要なくなるのでarticle_idとtag_idは必要なくなります。ですので削除します。
$ rails g migration remove_article_id_from_tags article_id:integer $ rails g migration remove_tag_id_from_articles tag_id:integer
以下のコマンドでマイグレーションファイルを生成します。
$ rails g migration create_articles_tags
こんな感じでActiveRecord::Associations::CollectionProxyクラスのオブジェクトとして関連付けが形成されます。
irb(main):001:0> Article.first.tags Article Load (0.4ms) SELECT `articles`.* FROM `articles` ORDER BY `articles`.`id` ASC LIMIT 1 Tag Load (0.4ms) SELECT `tags`.* FROM `tags` INNER JOIN `articles_tags` ON `tags`.`id` = `articles_tags`.`tag_id` WHERE `articles_tags`.`article_id` = 1 => #<ActiveRecord::Associations::CollectionProxy [#<Tag id: 1, name: nil, description: nil, created_at: "2016-04-04 05:05:54", updated_at: "2016-04-04 05:05:54", article_id: nil>]>
出たエラー
マイグレーションファイルでの関連付けを忘れていて以下のエラーが出ました
irb(main):008:0* Article.first.tags Article Load (0.9ms) SELECT `articles`.* FROM `articles` ORDER BY `articles`.`id` ASC LIMIT 1 Mysql2::Error: Table 'development.articles_tags' doesn't exist: SHOW FULL FIELDS FROM `articles_tags` ActiveRecord::StatementInvalid: Mysql2::Error: Table 'development.articles_tags' doesn't exist: SHOW FULL FIELDS FROM `articles_tags`