garbagetown

個人の日記です

cygwin で rails する

職場のウインドーズrails したいんだけどコマンドプロンプトが大嫌いなのでイバラの道とは知りつつ cygwinrails してみた。

なお、過去の経験上、生の cygwinrails どころか ruby を入れるだけで二人月くらい掛かるので、昨年からもともと ruby が入っている gnupack に oh-my-zsh を入れて使っている。

以下、作業ログ。いつか誰か (三ヶ月後の自分を含む) がググるかもしれないので、長いけどエラーログもすべて貼る。

gem

ruby は 2.2.2 が入っていた。意識低めなので今のところ rbenv は使わない。

gem が入っていなかったので apt-cyg でさくっとインストールする。

$ ruby -v
ruby 2.2.2p95 (2015-04-13 revision 50295) [i386-cygwin]

$ gem -v
zsh: command not found: gem

$ apt-cyg install rubygems
(snip)
Package ruby-rdoc installed
Package ca-certificates is already installed, skipping
Package cygwin is already installed, skipping
Package rubygems installed

$ gem -v
2.4.8

rails

どうせどこかで失敗するんだろうなと予感しつつ rails を入れたら、お馴染みの nokogiri でコケた。

$ gem install rails -v 4.2.2
(snip)
Fetching: nokogiri-1.6.7.2.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing rails:
        ERROR: Failed to build gem native extension.

    /usr/bin/ruby.exe -r ./siteconf20160121-1180-1s3cu4.rb extconf.rb
checking if the C compiler accepts ... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=/usr/bin/$(RUBY_BASE_NAME)
        --help
        --clean
/usr/share/ruby/2.2.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
        from /usr/share/ruby/2.2.0/mkmf.rb:571:in `block in try_compile'
        from /usr/share/ruby/2.2.0/mkmf.rb:522:in `with_werror'
        from /usr/share/ruby/2.2.0/mkmf.rb:571:in `try_compile'
        from extconf.rb:80:in `nokogiri_try_compile'
        from extconf.rb:87:in `block in add_cflags'
        from /usr/share/ruby/2.2.0/mkmf.rb:619:in `with_cflags'
        from extconf.rb:86:in `add_cflags'
        from extconf.rb:336:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in /home/.gem/ruby/gems/nokogiri-1.6.7.2 for inspection.
Results logged to /home/.gem/ruby/extensions/x86-cygwin/nokogiri-1.6.7.2/gem_make.out

ざっと調べて libxml2, libxslt, libxml2-devel, libxslt-devel を入れてみても駄目。

$ apt-cyg install libxml2 libxslt libxml2-devel libxslt-devel
(snip)
Package libxml2-devel is already installed, skipping
Package libxslt is already installed, skipping
Package zlib-devel is already installed, skipping
Package libxslt-devel installed

$ gem install rails -v 4.2.2
(snip)
Building native extensions.  This could take a while...
ERROR:  Error installing rails:
        ERROR: Failed to build gem native extension.

    /usr/bin/ruby.exe -r ./siteconf20160121-4560-flmffc.rb extconf.rb
checking if the C compiler accepts ... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=/usr/bin/$(RUBY_BASE_NAME)
        --help
        --clean
/usr/share/ruby/2.2.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
        from /usr/share/ruby/2.2.0/mkmf.rb:571:in `block in try_compile'
        from /usr/share/ruby/2.2.0/mkmf.rb:522:in `with_werror'
        from /usr/share/ruby/2.2.0/mkmf.rb:571:in `try_compile'
        from extconf.rb:80:in `nokogiri_try_compile'
        from extconf.rb:87:in `block in add_cflags'
        from /usr/share/ruby/2.2.0/mkmf.rb:619:in `with_cflags'
        from extconf.rb:86:in `add_cflags'
        from extconf.rb:336:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in /home/.gem/ruby/gems/nokogiri-1.6.7.2 for inspection.
Results logged to /home/.gem/ruby/extensions/x86-cygwin/nokogiri-1.6.7.2/gem_make.out

ログを確認すると /usr/lib/gcc/i686-pc-cygwin/4.9.2/../../../../i686-pc-cygwin/bin/ld: -lgmp が見つかりません とのことだったので、libgmp-devel を入れたら無事に rails が入った。

$ apt-cyg install libgmp-devel
(snip)
Package gmp installed
Package cygwin is already installed, skipping
Package libgmp-devel installed

$ gem install rails -v 4.2.2
(snip)
Done installing documentation for rack, concurrent-ruby, sprockets, nokogiri, loofah, rails-html-sanitizer, rails-deprecated_sanitizer, rails-dom-testing, rack-test, actionview, actionpack, sprockets-rails, thor, railties, bundler, arel, activemodel, activerecord, globalid, activejob, mime-types, mail, actionmailer, rails after 397 seconds
24 gems installed

が、パスが通っていなかったので .zshrc に home/bin を追加。

$ rails -v
zsh: command not found: rails

$ /home/bin/rails -v
Rails 4.2.2

$ vi ~/.zshrc
$ tail -1 ~/.zshrc
export PATH=$PATH:/home/bin

$ source ~/.zshrc
$ rails -v
Rails 4.2.2

sqlite3

雑に作った rails アプリケーションに bundle install したら今度は sqlite3 で失敗。

$ bundle install --without production
(snip)
Installing sqlite3 1.3.9 with native extensions

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /home/.gem/ruby/gems/sqlite3-1.3.9/ext/sqlite3
/usr/bin/ruby.exe -r ./siteconf20160121-2500-vm72n8.rb extconf.rb
checking for sqlite3.h... no
sqlite3.h is missing. Try 'port install sqlite3 +universal',
'yum install sqlite-devel' or 'apt-get install libsqlite3-dev'
and check your shared library search path (the
location where your sqlite3 shared library is located).
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=/usr/bin/$(RUBY_BASE_NAME)
        --with-sqlite3-dir
        --without-sqlite3-dir
        --with-sqlite3-include
        --without-sqlite3-include=${sqlite3-dir}/include
        --with-sqlite3-lib
        --without-sqlite3-lib=${sqlite3-dir}/lib
        --enable-local
        --disable-local

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /home/.gem/ruby/extensions/x86-cygwin/sqlite3-1.3.9/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /home/.gem/ruby/gems/sqlite3-1.3.9 for inspection.
Results logged to /home/.gem/ruby/extensions/x86-cygwin/sqlite3-1.3.9/gem_make.out

sqlite3 と libsqlite3-devel を入れたら動いた。

$ apt-cyg install sqlite3
(snip)
Package sqlite3-vfslog requires the following packages, installing:
cygwin libsqlite3_0
Package cygwin is already installed, skipping
Package libsqlite3_0 is already installed, skipping
Package sqlite3-vfslog installed
Package sqlite3 installed

$ apt-cyg install libsqlite3-devel
(snip)
Package libsqlite3-devel requires the following packages, installing:
libsqlite3_0 cygwin
Package libsqlite3_0 is already installed, skipping
Package cygwin is already installed, skipping
Package libsqlite3-devel installed

$ bundle install --without production
Fetching gem metadata from https://rubygems.org/..........
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
(snip)
Bundle complete! 17 Gemfile dependencies, 75 gems now installed.
Gems in the group production were not installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.

以上。

English conversation with 140-character limit is hard for Japanese

This post is an English translation of http://garbagetown.hatenablog.com/entries/2016/01/08 . *1

Background

While I was watching Building Microservices with Spring Boot LiveLessons (Video Training), I noticed that I can see the usage examples by executing curl start.spring.io without parameters.

f:id:garbagetown:20160108005810p:plain

I didn't know how to display the usage examples, although I knew that I can create an application using curl with parameters such as curl start.spring.io -d style=web .

I had tweeted about that because I thought it was very useful, then Stephane Nicoll(@snicoll) gave me a mention.

I couldn't express what I wanted to say in 140 chars because I'm not good at English, so I told him that I'll write that in this blog post.

What I wanted to say was...

I think it's better if how to use curl was on Spring Boot Reference Guide where Spring Boot beginners refer at first.

Having said that, however, I think it's not a big problem because I think most of users use Spring Initializr UI or STS rather than using curl to generate Spring Boot applications.

I'm sorry that I might have Stephane confused.

P.S.

  • Spring Boot makes Java fun again. Thanks!
  • I love Belgian beer, so I want to visit Belgium some day.
  • I need to study English :-(

Edit on 12 Jan, 2016

Spring Boot Reference Guide has been improved. Thanks Stéphane!

*1:My friend, @xxputaxx helps me to write this English post. Thanks!!

日本人に 140 文字の英会話は難しい

英語版http://garbagetown.hatenablog.com/entries/2016/01/10 に書きました。 *1

経緯

Building Microservices with Spring Boot LiveLessons (Video Training) を観ていたら、パラメータを付けずに curl start.spring.io と実行すると使い方が表示されることを知った。

f:id:garbagetown:20160108005810p:plain

curl start.spring.io -d style=web のように、パラメータを付けてアプリケーションを作成できることは知っていたけど、使い方が表示できることは知らなかった。

これは便利だなと思ってツイートしたら、 Stéphane Nicoll(@snicoll) が mention をくれた。

"usage の表示方法をどこかに書いておいた方がいい?" という内容だと思うんだけど、自分の英語が下手くそで話が噛み合わなかったので、"140 文字じゃ伝えられないのでブログに書く" と待ってもらうことにした。

言いたかったこと

  • Spring Initializr の Web UI や STS でも Spring Boot アプリケーションを作成できるので、ユーザの多くはこれらを使うと思う
  • curl を使うユーザは少ないので、ドキュメントに書いていなくても大きな問題ではない
  • curl を使ってアプリケーションを作成できることは素晴らしいので、Spring Boot を始めるユーザが最初に目を通す Spring Boot Reference Guide に書いてあると、より良いとも思う

二点目と三点目で逆のことを言ったのが良くなかった。混乱させて申し訳ない。

追伸

  • Spring Boot のおかげで Java がまた楽しくなった。ありがとう!
  • ベルギービールが大好きなので、いつかベルギーに行ってみたい
  • 英語を勉強します...

2016/01/12 追記

Spring Boot Reference Guide を改善してもらいました。ありがとう Stéphane!

*1:英語版を書くに当たって鬼軍曹 @xxputaxx のご指導を賜りました。ありがとうございました!

Docker と Redis と Spring

TL; DR

  • 職場のウインドーズでも spring-boot したい
    • spring-security したい
    • spring-session したい
  • ウインドーズに redis を入れる気はないので docker で入れる
    • docker-machine 便利

Docker Toolbox

下記 URL を参考に Docker Toolbox をインストールする。インストーラをダウンロードしてデフォルトのまま Enter を連打すればいい。

Docker

公式ドキュメントのメンテナンスが追い付いていないようで、書いてある通りにやってもうまくいかない、と言うかそもそも書いてある通りに実行できないので、勘と経験と度胸で進める。

まずは docker ホストを作る。ウインドーズはネイティブで docker ホストを実行できないので、Docker Toolbox に含まれる VirtualBox 上に docker ホストを立てる。この作業を簡単にしてくれるのが docker-machine コマンドで、例えば dev という名前の docker ホストは次のようにして作る。

c:\TEMP>docker-machine create --driver virtualbox dev
Running pre-create checks...
(dev) Default Boot2Docker ISO is out-of-date, downloading the latest release...
(dev) Latest release for github.com/boot2docker/boot2docker is v1.9.1
(dev) Downloading C:\Users\yu-umezawa\.docker\machine\cache\boot2docker.iso from https://github.com/boot2docker/boot2doc
ker/releases/download/v1.9.1/boot2docker.iso...
(dev) 0%....10%....20%....30%....40%....50%....60%....70%....80%....90%....100%
Creating machine...
(dev) Copying C:\Users\yu-umezawa\.docker\machine\cache\boot2docker.iso to C:\Users\yu-umezawa\.docker\machine\machines\
dev\boot2docker.iso...
(dev) Creating VirtualBox VM...
(dev) Creating SSH key...
(dev) Starting VM...
Waiting for machine to be running, this may take a few minutes...
Machine is running, waiting for SSH to be available...
Detecting operating system of created instance...
Detecting the provisioner...
Provisioning with boot2docker...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
Checking connection to Docker...
Docker is up and running!
To see how to connect Docker to this machine, run: docker-machine env dev

docker-machine ls で docker ホストを一覧できる。

c:\TEMP>docker-machine ls
NAME   ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER   ERRORS
dev    -        virtualbox   Running   tcp://192.168.99.100:2376           v1.9.1

作成した docker ホストに対して docker コマンドを実行するために、docker コマンドが参照する環境変数に docker ホストの情報を設定する。docker-machine env コマンドで設定すべき環境変数を確認できるので、出力された通りに設定する。

c:\TEMP>docker-machine env --shell cmd dev
SET DOCKER_TLS_VERIFY=1
SET DOCKER_HOST=tcp://192.168.99.100:2376
SET DOCKER_CERT_PATH=C:\Users\yu-umezawa\.docker\machine\machines\dev
SET DOCKER_MACHINE_NAME=dev
REM Run this command to configure your shell:
REM     FOR /f "tokens=*" %i IN ('docker-machine env --shell cmd dev') DO %i

c:\TEMP>SET DOCKER_TLS_VERIFY=1
c:\TEMP>SET DOCKER_HOST=tcp://192.168.99.100:2376
c:\TEMP>SET DOCKER_CERT_PATH=C:\Users\yu-umezawa\.docker\machine\machines\dev
c:\TEMP>SET DOCKER_MACHINE_NAME=dev

お約束の Hello World が正常に実行できることを確認する。

c:\TEMP>docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world

b901d36b6f2f: Pull complete
0a6ba66e537a: Pull complete
Digest: sha256:8be990ef2aeb16dbcb9271ddfe2610fa6658d13f6dfb8bc72074cc1ca36966a7
Status: Downloaded newer image for hello-world:latest

Hello from Docker.
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker Hub account:
 https://hub.docker.com

For more examples and ideas, visit:
 https://docs.docker.com/userguide/

Redis

docker の準備が整ったので、docker ホスト上で redis を実行するコンテナを起動する。指定しているオプションの詳細は下記の通り。

  • --name でコンテナに任意の名前を付ける
  • -d でデーモンとして起動する
  • -p で docker ホストの 6379 番ポートに対するアクセスを redis コンテナの同じく 6379 番ポートにフォワードする
c:\TEMP>docker run --name redis -d -p 6379:6379 redis
Unable to find image 'redis:latest' locally
latest: Pulling from library/redis

9ee13ca3b908: Pull complete
23cb15b0fcec: Pull complete
52a374d9c478: Pull complete
(snip)
Digest: sha256:7dfb86a89af97d915fbde39a91c87a0bf55d76f9fc979b89bfa05a5671f851c2
Status: Downloaded newer image for redis:latest
4101734092f09f3057433e02fdef26306c6ab501d602be2b7efc793f0ec48815

docker ps で docker コンテナを一覧できる。

c:\TEMP>docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
4101734092f0        redis               "/entrypoint.sh redis"   6 seconds ago       Up 5 seconds        0.0.0.0:6379->6379/tcp   redis

Spring

web, security, session, redis を追加した Spring Boot アプリケーションを作る。急にコマンドプロンプトではなく cygwin で作業しているが気にしない。

$ mkdir test && cd $_

$ curl https://start.spring.io/starter.tgz -d style=web -d style=security -d style=session -d style=redis -d name=test | tar -zxvf -
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 49996  100 49936  100    60  38051     45  0:00:01  0:00:01 --:--:-- 42318
mvnw
.mvn/
.mvn/wrapper/
src/
src/main/
src/main/java/
src/main/java/com/
src/main/java/com/example/
src/main/resources/
src/main/resources/static/
src/main/resources/templates/
src/test/
src/test/java/
src/test/java/com/
src/test/java/com/example/
.mvn/wrapper/maven-wrapper.jar
.mvn/wrapper/maven-wrapper.properties
mvnw.cmd
pom.xml
src/main/java/com/example/TestApplication.java
src/main/resources/application.properties
src/test/java/com/example/TestApplicationTests.java

TestApplication にいろいろ追加してセッション情報を Redis で管理する Web アプリケーションにする。

package com.example;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.session.data.redis.config.annotation.web.http.EnableRedisHttpSession;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication
@RestController
@EnableRedisHttpSession
public class TestApplication extends WebSecurityConfigurerAdapter {

    @RequestMapping("/")
    public String index() {
        return "Hello, Spring Boot!";
    }

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.httpBasic().and().authorizeRequests().anyRequest().authenticated();
    }

    public static void main(String[] args) {
        SpringApplication.run(TestApplication.class, args);
    }
}

application.properties にデフォルトパスワードと docker ホストのアドレスを設定する。

security.user.password=password
spring.redis.host=192.168.99.100

アプリケーションが正常に起動することを確認する。Redis に繋がらないと起動時点で例外が発生してコケる。何度もコケた。

$ mvn spring-boot:run
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building test 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
(snip)
[INFO] --- spring-boot-maven-plugin:1.3.1.RELEASE:run (default-cli) @ demo ---

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.3.1.RELEASE)
(snip)
2016-01-05 15:58:15.195  INFO 7440 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2016-01-05 15:58:15.201  INFO 7440 --- [           main] com.example.TestApplication              : Started TestApplication in 2.838 seconds (JVM running for 5.199)

localhost:8080 にアクセスすると spring-security の機能で Basic 認証ダイアログが表示されるので、ユーザ名に user を、パスワードに application.properties に指定した password を入力する。

これでセッション情報が Redis に書き込まれるので、docker exec コマンドで redis コンテナに入って確認する。また急にコマンドプロンプトで作業しているが気にしない。

c:\TEMP>docker exec -it redis bash
root@4101734092f0:/data# redis-cli

127.0.0.1:6379> keys *
1) "spring:session:expirations:1451979000000"
2) "spring:session:sessions:25c0619f-1dbf-422e-bd8e-85c9650f1073"
3) "spring:session:sessions:e27ff8dc-a3cf-4bc6-9093-b506600cc3bb"

セッション情報が二つあるのは、未認証状態で favicon を取得した時のものと、認証後にアクセスした時のものっぽい。ひとまずここまででやりたいことは大体できた。

2016/01/20 修正。セッション情報が二つあるのは、セッション偽装対策のために認証前後で JSESSIONID が変わるためだった。

おまけ

flushdb で redis 上のデータを削除することができる。

127.0.0.1:6379> flushdb
OK
127.0.0.1:6379> keys *
(empty list or set)

MNP 備忘録

TL;DR

  • softbank から auMNP した
  • 月々の携帯電話料金が約 5,800 円から、一年目は約 1,800 円、二年目は約 2,800 円になった
  • iPhone 4S から iPhone 6S に機種変更した
  • 持つべきものは情強友人 a.k.a. MNP 乞食

動機

未来を生きるために Hulu か Netflix を契約したいけど家庭内稟議を通すために費用を捻出する必要があるので携帯電話料金を節約したいとツイートしたところ、こういう話が大好物の友人たちからざくざく情報が集まり MNP を検討することに。

計画

自分が softbank で妻が docomo で自宅の回線は B フレッツに Nifty という体たらくだったので、

  • 二台同時に auMNP
  • iPhone 6 以降と Android
  • 本体一括ゼロ円
  • 高額キャッシュバック
  • au ひかりにしてスマートバリュー適用

と方針を定めて twitter#MNP #au #一括0円 などと検索していたら良さそうな情報を発見。この手のツイートはすぐに消えるので画像添付。

f:id:garbagetown:20151228104554p:plain

特典と条件の意味がよく分からなかったので電凸確認したところ

  • キャッシュバックの内訳は以下のとおり。
    • 56,000 円を口座振込
      • 自分は下取り端末が iPhone 4S 16GB なので 8,000 円減額で 48,000 円
    • 3,000 円 x 2 をプリベイド au wallet カードにチャージ
  • かえる割スーパーは以下から選択可能。自分は前者を選択
    • 1,000 円 x 12 ヶ月 x 2 台を月々の支払いから減額
    • au wallet に 12,000 円ずつチャージ
  • au オプションは以下すべて 30 日間無料、月を跨げば解約可能
    • au スマートパス、うたパス、ブックパス、ビデオパス、アニメパス、ディズニーパス
    • KKBOX

ということで、有料オプションの解約さえ忘れなければ問題なさそう。au ひかりも併せて確認すると

  • モバワンから 10,000 円キャッシュバック
  • プロバイダを Biglobe にすると Biglobe から 11,000 円キャッシュバック
  • B フレッツ、Nifty の解約違約金も Biglobe が最大 10,000 円まで負担

とのことで、こちらも悪くない条件。全体的にキャッシュバック額はそこそこだけど iPhone 6S 64GB が魅力的なので決断。

実行

以下、必要なものを準備して店頭で手続きする。

  • 妻の同意
    • 月々の支払いが減り、娘の習い事の費用に回せる点などを情熱を持って説明
  • 身分証明書
  • クレジットカード
  • 振込口座情報
  • MNP 予約番号
    • 情弱なので電話で取得したら一時間くらいつながらなかった。情強はネットで取得するらしい
  • 下取り端末
    • iPhoneiTunes でバックアップ。Android は SD カードにコピー
    • 端末初期化は店頭で本人確認のもと行ってくれる

なお、委任状は不可で契約者本人が来店しなければならない。印鑑と現金は一応準備したけど必要なかった。実際の手続きは店側が au ひかりの一括請求手続きにちょっと手間取ったこともあって全体で三時間くらい掛かった。

評価

今回のような動機で MNP してみて分かったこと、感じたこと。

  • 情報が多過ぎてつらい
    • 情強の友人たちから助言をもらえてラッキーだった
    • 条件のいい情報が早めに見つかってラッキーだった
  • 準備不足
    • 自分も妻も解約月ではなかったので違約金が発生した
    • 端末下取りが条件のため急いでバックアップしなければならなかった
  • キャリア変更
    • ざっくり想定していたよりも全体の費用を抑えることができた
    • Twitter/Facebook/LINE 時代にキャリアメールは必要ない
    • 回線品質も問題ないどころか 4G になって快適
  • 機種変更
    • iPhone 4S 16GB から iPhone 6S 64 GB への変更は三階級特進くらいのインパク
    • iOS のバージョンさえ合わせれば問題もなく復元できた
    • touch ID の精度と速度がすごい
    • LINE など iPhone 4S ではかなり重かったアプリがさくさく動く

以前に iPhone 欲しさに docomo から softbankMNP したときは選択肢がなかったので気楽だったけど、今回はずいぶん事情が違った。

改善

二年後に MNP バブルが続いているかは不明だけど、以下を改善したい。

  • 定期的に情報収集する
    • キャッシュバック額などの相場感を持つ
    • MNVO も検討できるよう各種サービスを把握する
  • 定期的にバックアップする
    • キャリア、端末に依存せずにインターネットサービスを活用する
  • 違約金など不要な費用を抑える
    • Google カレンダーに解約月アラートを毎年くり返しで登録した

まとめ

Twitter/Facebook/LINE でコミュニケーションを取り、各社から iPhone が発売されている現在において、キャリアにこだわる理由はないので積極的に MNP した方がいいとは思うけど、決して健全とは言えない経済に加担しているイメージがあって個人的には人生が虚しいので、MNP 乞食などしなくても携帯電話利用料を安く抑えられる世界になってほしいと思いました。

あと友人宅で体験してみたところ Hulu/Netflix より Apple Music のほうが自分の人生に必要だったので、節約した費用で Apple Music を契約します。

TED日本語 - ジェニフェアー・シニア: 幸福は親には高すぎるハードル | デジタルキャスト

すばらしい。

育児に対する漠然とした不安や、時には頭を抱えたくなるほどの煩わしさ、そしてそれを補って余りある幸福感の正体と、なにを目的として育児に取り組むべきかを情熱的に説いてくれています。

f:id:garbagetown:20151205094608p:plain

すべてのエンジニアが伴侶と子宝に恵まれ、仕事と育児と趣味の狭間でもがき苦しみますように。

TED日本語 - クリス・ハドフィールド: 宇宙で目が見えなくなり学んだ事は | デジタルキャスト

おもしろかった。

f:id:garbagetown:20151125232900p:plain

Netflix 社が障害に備えるために人工的に障害を起こし続ける話を思い出しました。