なんとかするから、なんとかなる

エンジニア関係のことを書きます

【未完】Bot Framework Composerを使ってみたかった話

はじめに

Bot Framework Composerが新たにプレビューででてきたので、試してみた。 ChatBotをGUIで作れるらしい。Previewなので注意。

リポジトリ

https://github.com/microsoft/BotFramework-Composer

説明など

https://github.com/microsoft/BotFramework-Composer/blob/stable/toc.md

インストール

yarnコマンドを利用する

$ git clone https://github.com/microsoft/BotFramework-Composer.git //クローンしてくる
$ cd BotFramework-Composer/Composer // フォルダ移動
$ yarn install // インストール
$ yarn build // ビルド
$ yarn stratall // 実行

yarn がなれければ

$ brew install yarn

yarn install でこけた時は

error @typescript-eslint/eslint-plugin@2.6.0: The engine "node" is incompatible with this module. Expected version "^8.10.0 || ^10.13.0 || >=11.10.1". Got "10.0.0"
error Found incompatible module.

以下のコマンドで代用

$ yarn --ignore-engines install

または、nodeのバージョンを12.13.0に変更。 .Net Core 2.2をインストール

アクセスする

yarn startall できればローカル環境でアクセスする

http://localhost:3000

動いた。 f:id:hopita:20191109174322p:plain

ボットを作ってみる

  • とりあえず、エコーボットを作るなら、こちらの記事がわかりやすいです。

https://qiita.com/annie/items/93ffbbc2f0981257751e

クラッチでボットを作る

[New] -> [Create from Scrach]

名前と保存場所を決めておく

GreatBot

これでC#のプロジェクトが完成している。

f:id:hopita:20191109174506p:plain

GreaBotMainを開き、ひとまずLUIS等は使わないので、Recognizer TypeはNone。

f:id:hopita:20191109174552p:plain

Triggerの部分で、1つのダイアログを表現する。

ダイアログとはボットの会話のブロック。ダイアログを出し分けることで、様々な機能を盛り込める。

ConversationUpdateではわかりにくいので、挨拶Greetingにしてみる

f:id:hopita:20191109174621p:plain

会話を進めるために、Triggerの下の+ボタンから、[Send a response]を選択。 返信してみる。

ここまできたら、[Start Bot]動作確認。

早速つまづく

Cannot read property 'name' of undefined

yarn やnode, .Net Core のバージョンを合わせても変わらず。

GitHub Issue にて報告されているので、結果を待とう。。。

https://github.com/microsoft/BotFramework-Composer/issues/1541

追記2019/11/12 ワークアラウンドでました。 git cloneにて、master branch を使えば良いらしい。 というわけで、続きを試します。

Macの内蔵マイクが反応しなくなった時の対処法

症状

  • オーディオ設定のマイクは反応している
  • SkypeやSiriなどでマイクが一切反応しない
  • NVRAM CSMやSMCのリセットをしたが治らない
  • com.apple.assistant.plistを削除したが治らない

対処法

  1. 「Audio MIDI 設定」開く
  2. 内蔵マイクを選択
  3. フォーマットを4ch から2ch に変更
  4. 完了!

最後に

skype for business で音声が届かなくなっていました。 相手の声が聞こえるがこちらの声が聞こえない状態です。 調べたのですが2時間くらいかかったので、調査してまとめ。 誰かの役に立てばいいな

matplotlibで目盛りの色を変更する方法

English version is below

はじめに

JupyterNotebookで背景を黒色にしたとき、matplotlibでグラフを描画したら目盛りが見ずらくなってしまいました。 そこで、Pythonのmatplotlibでグラフを描画するときの目盛りの色を変更する方法を紹介

解決方法

とても簡単です。

import matplotlib.pyplot as plt 
 
ax = plt.subplot(111)
for item in ax.get_xticklabels():
    item.set_color("white")
 
for item in ax.get_yticklabels():
    item.set_color("white")

How to change a color of measurement labels in matplotlib

Introduction

This article shows how to change a color of measurement labels in matplotlib.

Solution

It's a simply way to change a color of measurement labels.

import matplotlib.pyplot as plt 
 
ax = plt.subplot(111)
for item in ax.get_xticklabels():
    item.set_color("white")
 
for item in ax.get_yticklabels():
    item.set_color("white")

Swift 4.2 How to get a all values of enum

Introduction

This article shows how to use "CaseIterable" protocol which introduced in Swift4.2.

This protocol can provede all values of enum type. So, I do not need to implement such a property any more.

Before Swift4.2

In Swift4.1 or earlier, When I need an all values of enum types for case sentence or something.

I always implmented this property as below.

enum MyEnum {
    case one
    case two
    case three

    static let allValues = [MyEnum.one, MyEnum.two, MyEnum.three]
}

Using this propery, I could get a number of values of enum or get all values in loop sentence.

In Swift4.2

Now, I can use a CaseIterable Protocol.

I just need to declear the protocol when enum property define as below.

enum MyEnum: CaseIterable {
    case one
    case two
    case three
 }

It is very simple way to get an all values or number of values in enum as below.

// Get number of values in enum
MyEnum.allCases.count

// Get an all value in loop sentence
for item in MyEnum.allCases {
    // Do something with item
}

## Wrap up! This protocol give me an great solution for using enum. Let's use it and never imple such a propery any more!

Reference

CaseIterable - Swift Standard Library | Apple Developer Documentation

Swift4.2 列挙型Enumで全ての要素を取得する

English version below

はじめに

オブジェクトの状態を定義など、いろいろと便利な列挙型Enumですが、この度Swift4.2で新しい機能が追加されていました。

この記事にはSwift 4.2からの新機能、列挙型Enumから全ての要素を取得する方法を紹介します。

今まででは

Swift4.1以前では列挙型Enumを取得するとき、次のようにやっていたと思います。

enum MyEnum {
    case one
    case two
    case three

    static let allValues = [MyEnum.one, MyEnum.two, MyEnum.three]
}

allValuesのような配列を宣言することで、全要素数を取得したりfor-in文で回したりすることができました。

Swift4.2からは

今回Swift4.2からはCaseIterableプロトコルが追加されました。

このプロコトルを使うと先ほどの列挙型は次のように定義できます。

enum MyEnum: CaseIterable {
    case one
    case two
    case three
 }

とてもシンプルになりました。

使い方は次の通りです。

// 要素数を取得する
MyEnum.allCases.count

// for-in で回す
for item in MyEnum.allCases {
    // Do something with item
}

終わりに

結構便利なプロコトルが今回追加されました。

ぜひ使っていきましょう。

参考URL

CaseIterable - Swift Standard Library | Apple Developer Documentation

iOS How to solve the build error related with "CommonCrypto" on Xcode10

Introduction

This article shows how to solve the build error related with "CommonCrypto" on Xcode10.

After updating the Xcode to version10, I faced on the error messages as below.

The CommonCrypto was imported by cocoapods in my case.

Redefinition of module "CommonCrypto"
error: could not build Objective-C module 'YOUR_MODULE'

Solution

Remove the "CommonCrypto" folder included in {YOUR_MODULE}.

It seems that the "CommonCypto" module is included in standard library on Xcode10.