奥さんの携帯を機種変更した際のメモ(ソフトバンク)
今月奥さんの携帯を機種変更した際の事をメモしておく。
- Sweety 003PからARROWS A 301Fに変更
- 機種変更はヤマダ電機で実施
- ヤマダ電機店頭で無条件に付加されたオプションはWホワイト、スマートフォン基本パック、Yahoo!プレミアム for SoftBank、UULA
- Wホワイト、Yahoo!プレミアム for SoftBank、UULAは翌日解約
Wホワイトの解約で少し手間取った。
店頭での説明だとカスタマーサポート【157】に電話すればすぐに解約出来るとの事だったが、自動音声のガイドだとWホワイトには未加入ということで、解約出来なかった。
そこで、157 → 4(各種変更手続き) → 9(その他、ご契約内容に関するお問い合わせ)で、カスタマーサポートの人に聞いてみると、Wホワイトへの変更申請中というステータスとのこと(一ヶ月単位での切り替えのためそうなっているだとか)。
ということで、その場で解約を依頼すると、変更申請のキャンセルという形ですぐに対応してもらえた。
PostgreSQLでtimestamp型のデフォルト値を現在時刻にするには
ドットインストールのPostgreSQL入門を勉強中に気づいた事をメモしておく。
「#05 フィールドに制約をつけてみよう」でtimestamp型のデフォルト値を現在時刻にするために以下のように指定していた。
create table posts ( id serial primary key, title varchar(255) not null, body text check(length(body) > 5), is_draft boolean default TRUE, created timestamp default 'now' ★★★ );
しかし、これだとテーブル作成時の時刻がデフォルト値になってしまう。
データをInsertした際の現在時刻をデフォルト値とする場合には以下のように指定する必要がある。
create table posts ( id serial primary key, title varchar(255) not null, body text check(length(body) > 5), is_draft boolean default TRUE, created timestamp default CURRENT_TIMESTAMP ★★★ );
【参考記事】
List of unit testing frameworks for Java
A programmer-oriented testing framework for Java
A Mocking framework that tastes really good
A JUnit extension to perform unit testing with database-driven programs
A Java logging API by means of a simple facade pattern (DbUnit uses SLF4J for logging purposes.).
A relational database management system written in Java
HUBOTのTips(警告"@http() is going to be deprecated in 3.0.0 use @robot.http()"への対処)
HUBOTに最初から含まれているサンプルのスクリプト(math.coffee、pugme.coffee、youtube.coffee等)を利用すると、以下のような警告が出るケースがある。
Hubot> hubot math me 1 + 2 Hubot> [Mon Jul 15 2013 00:22:55 GMT+0900 (JST)] WARNING @http() is going to be deprecated in 3.0.0 use @robot.http() 3 Hubot>
警告が出ている理由はResponseクラスのhttpメソッドを利用しているためである(ResponseクラスのhttpメソッドはHUBOTのバージョン3.0.0で廃止予定と言っている)。
実際に警告を出している場所は以下(response.coffee)。
class Response ... snip ... http: (url) -> @robot.logger.warning '@http() is going to be deprecated in 3.0.0 use @robot.http()' @robot.http(url) module.exports = Response
この警告を消すにはResponseクラスのhttpメソッドを利用する変わりに、Robotクラスのhttpメソッドを利用すれば良い。
具体的には以下のようにmath.coffeeを修正する。
module.exports = (robot) -> robot.respond /(calc|calculate|convert|math|maths)( me)? (.*)/i, (msg) -> # msg.httpの変わりにrobot.httpを使う # msg robot .http('https://www.google.com/ig/calculator') .query hl: 'en' q: msg.match[3] ... snip ...
【備考】
ver 2.6.0以降ではyoutube.coffeeは@robot.http()を利用するように修正されている。また、Responseクラスも警告メッセージを出さないよう修正されている。
How to use Hubot behind a proxy.
You may fail to run a bot which uses http connection with Hubot if you are behind a proxy such as Squid.
Hubot behind a proxy · Issue #287 · github/hubot · GitHub
For example, you'll have following type of error messages when you run "hubot youtube me [search key words]".
events.js:72 throw er; // Unhandled 'error' event ^ Error: connect ECONNREFUSED at errnoException (net.js:900:11) at Object.afterConnect [as oncomplete] (net.js:891:19)
In this case, you might be able to solve the issue to specify proxy address and proxy port in node-scoped-http-client which is one of the wrapper libraries of Node.js's HTTP client and used by Hubot.
How to modify the source code (hubot/node_modules/scoped-http-client/src/lib/index.js) is as follows.
port = this.options.port || ScopedClient.defaultPort[this.options.protocol] || 80; req = (this.options.protocol === 'https:' ? https : http).request({ // port: port, port: 3127, // you have to specify a proxy port. // host: this.options.hostname, host: 'localhost', // you have to specify a proxy server address or hostname. method: method, // path: this.fullPath(), path: 'http://' + this.options.hostname + this.fullPath(), headers: headers, agent: this.options.agent || false });
HUBOTのセットアップメモ
Linux環境(Cent OS 6.4)にHUBOTをセットアップした際のメモ(全てrootで実施)。
【事前準備】
HUBOTの前提となるnode.js、CoffeeScriptをインストールしておく(node.jsと一緒にnpmもインストールされる)。
また、Botで扱うデータを永続化するためにredisもインストールしておく(redisはサーバ起動時に自動起動するようにしておく)。
今回使用したバージョンは以下。
# node -v
v0.10.11
# npm -v
1.2.30
# coffee -v
CoffeeScript version 1.6.3
# redis-server -v
Redis server version 2.4.10 (00000000:0)
【Hubotのインストール】
npmでHUBOTをインストールする。具体的には以下のコマンドを実行。なお、以下の作業は全てrootユーザのホームディレクトリで実行した。
# npm install hubot
IRCと連携させるために、以下のコマンドを実行してIRC Adapterもインストール。
なお、本日時点でインストールされたバージョンはhubot 2.5.5とhubot-irc 0.1.15。
# npm install hubot-irc
【redisによるデータ永続化のための作業】
nodeでredisを利用するために、以下のコマンドを実行する。
# npm install redis
更にHUBOTからredisを使えるようにするため、3rd-partyのhubot scriptsをダウンロードする。
そして、hubot-scripts/src/scripts/redis-brain.coffeeを$HOME/node_modules/hubot/src/scripts配下にコピーする。
# npm install hubot-scripts
【Hubotの起動スクリプトを用意】
HUBOT起動用に以下のようなスクリプトを用意。これを$HOME/node_modules/hubot配下に置く。
#!/bin/sh # runhubot export HUBOT_IRC_NICK="hubot" export HUBOT_IRC_ROOMS="#Test" export HUBOT_IRC_SERVER="127.0.0.1" ./bin/hubot -a irc
あとはこのスクリプトを実行すればHUBOTを起動することが出来る。