2016年8月29日月曜日

linuxコマンド file1にある、file2にない行を抽出する方法

例えばfile1に以下の内容があります。
line1
line2
line3

file2に以下の内容があります。

line1
line4
line5
file1にある、file2にない行を抽出したい。つまり次の結果が期待しています。

line2
line3

次のコマンドを使えば、目的を果たせます。file2とfile1両方そーと済み
grep -v -f file2 file1


2016年7月2日土曜日

chrome plugin開発時に、console.logの出力方法

アドレスバーに、以下を入力してアクセス
chrome-extension://ID/popup.html
 開いたら、後他の通常画面と同じくdebugツールを使えばconsole.logの出力が見えます。

2016年7月1日金曜日

Protractorでセッションをクリアできないときの対策

以下のスクリプトでセッションをクリアしてみたら、
browser.executeScript('localStorage.clear();');
 思うようにクリアしてくれない、

 理由はpageちゃっとロード完了できていなかったみたい

以下のソースを使えばその問題を解消できます。



  function getWindowLocation() {
    return window.location;
  }

  function clearStorage() {
    window.sessionStorage.clear();
    window.localStorage.clear();
  }

  return browser.executeScript(getWindowLocation).then(function(location) {
    // NB If no page is loaded in the scneario then calling clearStorage will cause exception
    // so guard against this by checking hostname (If no page loaded then hostname == '')
    if (location.hostname.length > 0) {
      return browser.executeScript(clearStorage);
    }
    else {
      return Promise.resolve();
    }
  });