unhurried

コンピュータ関連ネタがほとんど、ときどき趣味も…

アメリカで使用できるスマートフォン

海外赴任が決まり、アメリカに1年ほど滞在することになりました。 色々と持っていくものを整理していますが、現在使っているスマートフォンがかなり年季が入っているので、 買い替えるついでに現地の通信キャリアにも対応したものにしようと思い、色々と調べてみました。

まとめ

主な通信キャリアのバンド(周波数)

AT&T T-Mobile US Verizon Sprint
3G 2/5 2/4 - (CDMA) - (CDMA)
LTE 17(M)/4/2/(5) 4(M)/2/17 13(M)/4(S)/2 25(M)/26/41

※ M:メインバンド、S:サブバンド
※ 3GはUMTS(W-CDMA)のみを対象として調査

端末ごとの対応バンド

  • Docomo端末が共通で対応するバンド
    • 3G: 1/5/6/19
    • LTE: 1/3/19/21
      ※ 3G フォーマプラスは6/19バンド
      LTE 21バンドは一部の端末のみ
  • Nexus 5X
    • 3G: 1/2/4/5/6/8/9/19
    • LTE: 1/2/3/4/5/7/8/9/17/18/19/20/26/28
  • Zenfone2
    • 3G: 1/2/5/6/8
    • LTE: 1/2/3/4/5/6/8/9/18/19/28
  • Zenfone go
    • 3G: 1/2/5/6/8/19
    • LTE: 1/3/5/6/7/8/9/18/19/28
  • Zenfone Max
    • 3G: 1/2/5/6/8/19
    • LTE: 1/3/5/6/8/9/18/19/28
  • ZTE Blade V580
    • 3G: 1/6/8/19
    • LTE: 1/3/4/19
  • Moto X Play
    • 3G: 1/2/5/6/8/9/19
    • LTE: 1/3/5/7/8/19/20/28/38/40/41
  • Huawei P9 lite
    • 3G: 1/5/6/8/19
    • LTE: 1/3/5/7/8/19/28

参考

AngularJSでCSVファイルを出力する

管理画面などでよく見るCSVエクスポート機能ですが、たいていはサーバーサイドでCSVファイルを生成してブラウザにダウンロードさせる、という方法で実装されていると思います。 今回はクライアントサイドで編集したデータをダウンロードする必要があったため、クライアントで完結してCSVファイルを出力する方法を調べてみました。

ポイント

  • Blob API(HTML5)でCSVデータをBlobオブジェクトに変換する。
    • Internet Expolorerでは、Blobをwindow.navigator.msSaveBlob(IE独自API)で出力する。
    • その他のブラウザでは、a要素のdownload属性にファイル名、href属性にBlobで生成した値を指定する。

実装例(AngularJS Service)

(function() {
    'use strict';

    angular
        .module('app')
        .service('CsvExporter', CsvExporter);

    /** @ngInject */
    function CsvExporter($window) {
        this.export = function(object, keys) {

            // Serialize a header.
            var content = keys.join(',') + "\n";
            // Serialize rows.
            angular.forEach(object, function(properties){
                var row = '';
                angular.forEach(keys, function(key, index){
                    if (index != 0) { row += ','; }
                    if (properties[key]) { row += properties[key]; }
                });
                content += (row + "\n");
            });

            // Convert text to blob object with Blob API.
            var blob = new Blob([ content ], { "type" : "text/csv" });

            // For Internet Expolorer
            if ($window.navigator.msSaveBlob) { 
                $window.navigator.msSaveBlob(blob, "export.csv"); 

            // For other browsers
            } else {
                var link = $window.document.getElementById("csv_exporter");

                if (link == null) { 
                    link = $window.document.createElement("a");
                    link.setAttribute("id", "csv_exporter");
                    link.setAttribute("style", "display:none;");
                    link.setAttribute("download", "export.csv");
                }

                link.setAttribute("href", $window.URL.createObjectURL(blob));
                link.click();
            }
        };
    }
})() 

DOM操作(a要素の追加)

  • AngularJSではDirectiveの利用が推奨されますが、今回はファイル出力のために一時的にa要素を追加するため直接DOMを操作しています。 (ただし、$window Serviceを通してdocumentを参照するようにしています。)
  • angular.element(jQuery/jqLite)を利用した場合は下記のように記述できます。
var link = angular.element("#csv_exporter");

if (link.length == 0) { 
    link = angular.element("<a>");
    link.attr("id", "csv_exporter");
    link.attr("style", "display:none;");
    link.attr("download", "export.csv");
}

link.attr("href", $window.URL.createObjectURL(blob));
link[0].click();

参考

MVNOでの転送電話サービス

つい最近DMM mobileにMNPで乗りかえました。が、届いたSIMが翌日に読み取り不良になるという問題が起きました。すぐにSIM再発行をしたものの、到着まで電話を受け取れないのは痛いところです。

調べてみたところ、DMM mobileをはじめMVNO各社も転送電話サービス(通話を他の電話番号に転送する機能)は無料で利用できるところが多いようです。NTTドコモの回線を利用しているMVNOの場合は、2つの方法で設定ができます。

契約している電話番号から設定する。

↓の電話番号に発信します。

  • 1429:各種設定
  • 1421:開始
  • 1420:停止

契約している電話番号以外から設定する

一般電話、docomo携帯電話、公衆電話から設定できます。(IP電話や他社携帯電話からは設定できないので、今回は公衆電話で設定しました。)

  • 090-310-1429:各種設定
  • 090-310-1421:開始
  • 090-310-1420:停止

※ 設定に必要なネットワーク暗唱番号はDMMモバイルの場合、コールセンターで設定できます。

参考

https://www.nttdocomo.co.jp/service/transfer/usage/

なぜ、あなたの仕事は終わらないのか

マイクロソフトの中島聡さんの著書「なぜ、あなたの仕事は終わらないのか」を読みました。

なぜ、あなたの仕事は終わらないのか スピードは最強の武器である

なぜ、あなたの仕事は終わらないのか スピードは最強の武器である

感想

重い仕事はなかなか気分が乗らなくて、午前中の頭の冴えている時間にだらだらと簡単な仕事をしてしまった。
このくらいあれば終わるだろうと、ぎりぎりのタイミングでその仕事に着手した結果、思ったより手こずって結局間に合わなかった。

これらが自分に当てはまるという方におすすめの書籍です。

本書で提案されているのは「仕事を依頼されたときに、見積もりという名目で最初の2割の時間全力で取り組んで、8割を完成させる。」というシステム開発で言うところのプロトタイピングのような仕事の進め方です。

私は仕事の工数見積もりを依頼されたときに、どう計算したものかと悩むことが多いのですが、本書のようにやってみなければわからないと割り切って、まず全力で取り組んでみる、というのは新鮮に感じます。

本書にはその他にも、人生を成功に導くための仕事との付き合い方といった、単なる時間術に留まらないノウハウが、著者の経験の紹介とともに詰め込まれており、とても参考になり、おもしろく読めました。

携帯各社のSIMロック解除対応まとめ

近々に海外へ行く予定があるので、今使っているスマホに海外SIMを差して使えるか調べていました。 ついでにその他キャリアについても調べたので、簡単にまとめてみます。

docomo

au

SoftBank

Y!mobile

angular-datatablesの使い方

angular-datatablesの使い方(導入まで)をまとめました。

依存ライブラリをインストールする。(手動追加する場合)
  • jQuery、DataTables、AngularJS、angular-datatablesをhtmlからリンクする。
  • ソート方向を表すアイコンを表示するためにDataTablesのimageディレクトリもコピーすると良い。(例では lib/dataTables/images に保存している。)
<script src="./lib/jquery/js/jquery.min.js"></script>
<script src="./lib/dataTables/js/jquery.dataTables.min.js"></script>
<link rel="stylesheet" href="./lib/dataTables/css/jquery.dataTables.min.css">
<script src="./lib/angular/js/angular.min.js"></script>
<script src="./lib/angular-datatables/js/angular-datatables.min.js"></script>
<link rel="stylesheet" href="./lib/angular-datatables/css/angular-datatables.min.css">
html:tableタグにディレクティブ(属性)とバインド変数を指定する。
ディレクティブ バインド変数   
datatabales (angular-datatablesを適用する)   
dt-options DataTablesのオプション   
dt-column-defs 行の定義(静的な表に利用する)   
dt-column 行の定義(動的に生成する表に利用する)
<table 
    datatable=""
    dt-options="dtOptions"
    dt-column-defs="dtColumnDefs"
    dt-column="dtColumn"
    class="row-border hover">
    <thead><tr>
        <th>A</th>
        <th>B</th>
    </tr></thead>
    <tr>
        <td>1</td>
        <td>bbb</td>
    </tr>
    <tr>
        <td>2</td>
        <td>aaa</td>
    </tr>
</table>
js:バインド変数に値を設定する。
$scope.dtOptions = DTOptionsBuilder.newOptions();
$scope.dtColumnDefs = [
    // 1列目を数字としてソートする。
    DTColumnDefBuilder.newColumnDef(0).withOption("sType", "num"),
];
$scope.dtColumn = [];

Waltzing With Bears

In this post, I will introduce "Waltzing with Bears" (Tom DeMarco and Timothy Lister) briefly.

Summary

  • Valuable projects always have uncertainty (risks).
  • Derivery date and cost tend to be estimated by summing up only planned tasks at the beginning of a project, so delay and cost overrun often happens.
  • It is necessary to provide the orderer with probability distribution diagram (risk diagram) of derivery date and cost which takes into account possibility and effect of risks.
  • To manage risks, continue following actions during the project.
    • Examination -> Estimation of possibility and effect -> Planning mitigation measures and crisis responses -> Monitoring
  • Incremental development is compatible with risk management because it requires to prioritize components.

Impression

From my previous experiences, derivery date and cost of first planning are not achieved much more than they are achieved. Every time we fail to achieve them, we discuss insufficient or unexpected things, and discuss what is necessary to improve next. However how many times we repeat this cycle, results remains same as before, and these discussions gradually lose substance.

Taking into account risks in a project feels new to me. This is probably because my company often denies having leeway. If we see risks as probability, it would make sense.

What is important is to consider the effect of failing to achieve derivery date or cost. (Whether it would spoil the project or just need apology.) we should take care of risks according to objective of derivery date and cost.