中野智文のブログ

データ・マエショリストのメモ

Windows 用 github ツールにて、the repository does not seem to exist anymore

背景

Windowsgithub ツールで、次のようなエラーが出た。

the repository does not seem to exist anymore you may not have access or it may have been deleted or renamed

もちろん、そのようなリポジトリは実際存在する。

なぜか?

原因と解決

自分の場合は、github の権限の設定忘れだった。

チームの以下の設定を、

Repository permissions

Choose default permissions for user roles.
Organization members

を ”Wrie” 以上に設定する。

Windows10 に WSL を入れようとして、The term 'Enable-WindowsOptionalFeature' is not recognized …

背景

Windows 10 に WSL を入れようとして、

PS C:\Program Files\PowerShell\6.0.2> Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
Enable-WindowsOptionalFeature : The term 'Enable-WindowsOptionalFeature' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows- ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : ObjectNotFound: (Enable-WindowsOptionalFeature:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

みたいなエラーが出たあなた。

www.atmarkit.co.jp

や、

Windows Subsystem for Linux - Wikipedia

の通りに正しくやったのに。納得がいかない。

解決法

Windowsの機能の有効化または無効化」の中から、「Windows Subsystem for Linux」にチェックを入れて、再起動。

で、「Windowsの機能の有効化または無効化」は「コントロールパネル」にあるらしいのだが、その「コントロールパネル」が見つからなかったりするのはお約束。

東京以外のおすすめAWSリージョン

背景

東京リージョンは応答時間は早いけど、応答時間がどうでもいいなら、もっと安いリージョンがいい。 もう少し欲を言うと、AWSの最新のサービスが利用できるところがいい。 さらに欲を言うと、それでも応答時間が早いほうがいい。

リージョン比較

安いリージョン

qiita.com

によると、安いのは、us-east-1(ヴァージニア)か、us-west-2(オレゴン)だそうで。 ただちょっと古いのが気になる。us-east-2(オハイオ)も安い気がする。

最新技術

現時点で SageMaker が使える

現時点で Fargate が使える

https://aws.amazon.com/jp/about-aws/whats-new/2018/03/aws-fargate-platform-version-1-1/

その他

https://aws.amazon.com/jp/about-aws/global-infrastructure/regional-product-services/

たまにオレゴンしかないものものあるが、ヴァージニア優勢な感じ。

応答時間

qiita.com

地図上では西海岸の方が近いイメージだけど、そうらしい。

まとめ

us-east-1(バージニア北部)を使おう。

Windows PowerShell の OpenSSH でパスワードを正しく入れてもログインできない。

背景

Windows PowerShell の OpenSSH でパスワードを正しく入れてもログインできない。

原因

-v オプションをつけることで原因を見つけることができた。

read_passphrase: can't open /dev/tty: No such file or directory

入力を ' /dev/tty' から取ろうとしているけど、Windowsにそんなものはない。

~/.ssh/id_rsa.pub などを転送してやれば、パスワード入力が省略でき回避できるかもしれない。 でもそれって、結局 scp でパスワード聞かれることだよね?

issue には上がっている。

github.com

最新版で解決したの? いえ、解決していないでしょ。

WSLを入れることにしたのでした。

参考

github.com

AWSのMFAが灰色で有効にできない→一応解決

背景

AWSの「MFAの管理」が灰色で有効にできない。なぜなのか?

解決

灰色で有効にできない謎は未解決だが、一応できたのでメモ。

同じページのIAM リソース のユーザーをクリック。 自分の名前を見つけ出しクリック。 認証情報のタブをクリック。 すると、MFA デバイスの割り当てというところの右側に鉛筆のアイコンがあるのでクリック。

あとは通常のMFAの割り当てと同じ。

何か設定がおかしいのだろうけど、とりあえずできた。

BigQuery で base64 から uuid の形式へ変換する

背景

BigQuery で base64 から uuid への変換をUDFを使って行おうと思ったのでメモ。

経緯

atob さえあればそれほど大変ではないはず。ところが、 Google Developers Blog: Breaking the SQL Barrier: Google BigQuery User-Defined Functions によると、

Note that not all JavaScript functionality supported in the browser is available in BigQuery. For example, anything related to the browser DOM is unsupported, including Window and Document objects, and any functions that require them, such as atob() / btoa().

だそうで、面倒なことに。

解決

次の stack overflow の関数を拝借して解決…

create temp function base64_uuid(str string)
returns string
language js as """

  // [https://stackoverflow.com/questions/44836246]
  var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  function InvalidCharacterError(message) {
    this.message = message;
  }
  InvalidCharacterError.prototype = new Error;
  InvalidCharacterError.prototype.name = 'InvalidCharacterError';
  // decoder                                                                                                                                                                                                                                                                              
  // [https://gist.github.com/1020396] by [https://github.com/atk]                                                                                                                                                                                                                        
  atob = function (input) {
    var str = String(input).replace(/[=]+$/, ''); // #31: ExtendScript bad parse of /=                                                                                                                                                                                                    
    if (str.length % 4 == 1) {
      throw new InvalidCharacterError("'atob' failed: The string to be decoded is not correctly encoded.");
    }
    for (
      // initialize result and counters                                                                                                                                                                                                                                                   
      var bc = 0, bs, buffer, idx = 0, output = '';
      // get next character                                                                                                                                                                                                                                                               
      buffer = str.charAt(idx++);
      // character found in table? initialize bit storage and add its ascii value;                                                                                                                                                                                                        
      ~buffer && (bs = bc % 4 ? bs * 64 + buffer : buffer,
        // and if not first of each 4 characters,                                                                                                                                                                                                                                         
        // convert the first 8 bits to one ascii character                                                                                                                                                                                                                                
        bc++ % 4) ? output += String.fromCharCode(255 & bs >> (-2 * bc & 6)) : 0
    ) {
      // try to find character in table (0-63, not found => -1)                                                                                                                                                                                                                           
      buffer = chars.indexOf(buffer);
    }
    return output;
  };
  
try {
  bin = atob(str);
  // [https://stackoverflow.com/questions/39460182/]
  h = bin.split('').map(function(b) {
    return ('0' + b.charCodeAt(0).toString(16)).slice(-2);
  });
  
  return [h[0],h[1],h[2],h[3],'-',h[4],h[5],'-',h[6],h[7],'-',h[8],h[9],'-',h[10],h[11],h[12],h[13],h[14],h[15]].join('')
} catch(e) {
  return ''
}
""";


select base64_uuid("1/DhINolQvadQcBOL4itew==")