Categories
Uncategorized

グーグルスプレッドシートで乗り換え時間をApps Scriptで調べる

乗り換え時間をたくさん調べたかったのでGoogle Apps Scriptを書きました。スプレッドシートのメニューのツール→スクリプト エディタから以下のスクリプトを入力

function getDirectionTimeInSec(origin, destination) {
  var now = new Date();
  var finder = Maps.newDirectionFinder()
    .setOrigin(origin)
    .setDestination(destination)
    .setDepart(now)
    .setMode(Maps.DirectionFinder.Mode.TRANSIT);
  var directions = finder.getDirections();
  if (directions.routes.length == 0) {
    throw "no route";
  }
  var route = directions.routes[0];
  if (route.legs.length == 0) {
    throw "no leg";
  }
  var time = route.legs[0].duration.value;
  Logger.log("time = " + time);
  return time;
}

function getDirectionTimeInMin(origin, destination) {
  return Math.ceil(getDirectionTimeInSec(origin, destination) / 60);
}

function debugGetDirectionTime() {
  return getDirectionTimeInMin("Shibuya", "Shinjuku");
}

スプレッドシートからは以下のように使います

Categories
Uncategorized

BitnamiのWordPressが起動しなくなった時の話

Google Compute Engineのディスクが足りなくなったので、リサイズして再起動したら、WordPressが立ち上がりませんでした(泣)。

$ sudo /opt/bitnami/ctlscript.sh restart

するとApacheがport 80をlistenできなくて起動できてませんでした。

$ sudo netstat -tulpn

で80をlistenしてるApacheをkillして、もう一度

$ sudo /opt/bitnami/ctlscript.sh restart

したら、無事起動しました。よかった。

Categories
Uncategorized

Apple ID の確認コードが通らずサインインできない話

所有デバイスに表示される6桁の2ファクタ番号を入れてもなぜか認識されず、SMSで確認コードを送っても認識せず、途方にくれた。

ChromeでなくてSafari使ったらすんなり入れた。

こういうの難しい。

Categories
Uncategorized

#Legoでガンダム

Categories
Uncategorized

Let’s EncryptをBitnamiのWordPressインスタンスで使う

BitnamiのWordPressインスタンスをGCPで使っています。Let’s EncryptでHTTPSにしようと思い、このドキュメントですべて解決しました。

Categories
Uncategorized

IIJmioひかりのIPv6 (IPoE)をGoogle Nest WiFiと使った話

家でIIJmioひかりを使っています。IPv6のオプション(IPv6 IPoE)が今無料で試せるので使ってみたので、まとめました。

結論

速度は速くなった。IPv6にもなったけど、Double-NatではIPv6にならなかった。

詳しい経緯

家ではGoogle WiFiを3台使っています(今はGoogle Nest WiFiという名前になりました)。3台でメッシュネットワークを作ることでWiFiの届かない場所をなくせます。残念ながらGoogle WiFiはIPoEを使えません。そこで、IPoEが使えるルーターを買うことにしました。

長くなるので簡単に書くとNECの PA-WG2600HP3 がおすすめです。もう一台、IO-Dataの WN-AX2033GR2 も試しましたが、PA-WG2600HP3 の方がかなり遅いです。速度は以下の通りです。

IPoEルーターには満足いったのですが、何をどうがんばってもGoogle WiFiにつなげたスマホなどがIPv6で通信できませんでした。ちなみに、以下のようなネットワークになってます。

光モデム -> PA-WG2600HP3 -> Google WiFi -> スマホ

いろいろ調べてたらGoogle WiFiがIPv6を使えるためには64ビット未満のプレフィックスを貰う必要があり、IIJmioはひかり電話の契約なしだと64ビットのプレフィックスになることがわかりました。

ということで、Google WiFiはIPv6になりませんでしたが、速度は速くなったので満足です。

Categories
Uncategorized

HISの変なSIMのAPN設定で困った話

変なSIMというSIMがHISから売られています。私は、これを買ってオーストラリアに行った際に使ってきました。

1. 説明書通りでは動かなかった

最初のハマりポイントはAPN設定が説明書通りではなかったことです。答えから言うとアプリに表示されているAPNを使えば大丈夫です。

この時のスクリーンショットでは3gnetが正しいです。マニュアルにはchktということになってました。マニュアルが古くなっていたのか、理由は不明ですが、気をつけて下さい。

APN設定が空

私はGoogleのPixel 3を使ってます。OSはAndroid 9 (pie)です。他の環境では違うかもしれませんが、変なSIMを有効化するとAPN設定のページが空になってました。有効化前に設定したものはでてきません。私の今のAPN設定は以下のようになってます。

空ですが慌てずに、変なSIMアプリに表示されるAPNを追加して下さい。上のスクリーンショットのメニューから追加できます。アプリから変なSIMを無効化すると、APNのリストはもとに戻ります。

まとめ

問題はありましたが、結果的には無事接続できました。また使いたいと思います。

Categories
Uncategorized

Site Kit plugin for WordPress

GoogleのSite KitプラグインのBetaプログラムが開始されました。まだ私は導入していませんが、公開されたらインストールして、ブログ記事にしたいと思います。

Categories
Uncategorized

AMP Plugin and Latex

It seems AMP plugin shows raw Latex expression.  For example, I have this page which uses Latex as of now.  The latest AMP plugin is version 1.0-RC2.  Really hoping it will be fixed 🙂

Update on Dec 10, 2018 AMP plugin reached 1.0! However, the Latex problem didn’t fix.  Instead, I found WP QuickLatex plugin fixes the problem.

Update on Dec 18, 2020, WP QuickLatex plugin creates AMP errors (it is possible that I misused the plugin), I started using AMP MathML, the native MathML for AMP, instead.

Categories
Uncategorized

Marginalizing out Normal-Wishart Prior of multivariate Normal distribution for Bayesian inference

I found my old notes, and writing this post based on the notes for record.

The goal of this particular note is to marginalize out the parameters of multivariate Normal distribution using Normal-Wishart conjugate prior. This is useful for Bayesian inference for Gaussian distribution.

First of all, let me derive the joint distribution of observation as follows,

where D is the number of dimensions and Z is the partition function of Wishart distribution, i.e.,

The marginal distribution, by marginalizing out the mu and omega, is

I have omitted the detail of the derivation of (2) from (1). But, the following equations are useful to derive (2) from (1)