現役プログラマのWordPressカスタマイズ相談

WordPress(ワードプレス)のお悩み、うまくいかなくてお困りなこと、不具合調査、新規制作依頼まで、ウェブアプリケーションエンジニアがあなたをサポートします。

certbot-autoで「UnicodeDecodeError: 'ascii' codec can't decode byte 0xe8」エラー

f:id:jsaz:20190404230939p:plain

certbot-auto でlet's encrypt の無料SSLを更新する際に下記のようなエラーが発生した

Cert is due for renewal, auto-renewing...
Renewing an existing certificate
Performing the following challenges:
http-01 challenge for <example>.com
Cleaning up challenges
An unexpected error occurred:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe8 in position 5: ordinal not in range(128)
Please see the logfiles in /var/log/letsencrypt for more details.

日本語マルチバイト文字が原因らしい。

SSL関連で日本がは使っていないけど。。。と調べてみると、nginxの設定ファイルが対象とのこと。nginxのconfファイルを見てみるとコメントに日本語があった。

コメントは無くても問題なかったので日本語の行をすべて削除。

再度 sudo certbot-auto を実行すると無事SSLが更新された

参考にさせてもらいました。

troches.jp

MySQLを5.7にする(Laravel migrate SQLSTATE[42000] 問題を解決)

f:id:jsaz:20190324161723p:plain:w480

laravelでマイグレーションすると良く起きる問題。

SQLSTATE[42000]: Syntax error or access violation: 
1071 Specified key was too long; max key length is 767 bytes 
(SQL: alter table users add unique  users_email_unique(email))

原因はmysqlの charaset が utf8mb4 だから。

参考: Laravel5.4以上、MySQL5.7.7未満 でusersテーブルのマイグレーションを実行すると Syntax error が発生する - Qiita

では対処方は?

私は「MySQL5.7にあげる」!

簡単な1つの方法をご紹介

このままの手順でうまくいく!(はず)

続きを読む

WordPressプラグインRinkerの商品検索ができなかった件(自サーバーの環境問題)

f:id:jsaz:20190212234132p:plain:w480

あれ、動かない。。。

Rinkerの商品検索(amazon)が動きません。

amazonトークンやキーはあっている。。。

ソースコード追っかけてみました。

リクエストのURLを抜き出して、ブラウザに貼り付けて実行すると上手くいきます。

怪しいと思い「simplexml_load_string php7」で検索するとSimpleXMLが入っていないことがわかった。

ubuntuのパッケージ検索 https://packages.ubuntu.com/ja/

私のサーバーはphp7.2なので、「php7.2-xml」で検索してみる。

php7.2-xml を入れれば良いらしい

$ sudo apt-get install php7.2-xml
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  php7.2-xml
0 upgraded, 1 newly installed, 0 to remove and 26 not upgraded.
Need to get 107 kB of archives.
After this operation, 456 kB of additional disk space will be used.
Get:1 http://ppa.launchpad.net/ondrej/php/ubuntu bionic/main amd64 php7.2-xml amd64 7.2.14-1+ubuntu18.04.1+deb.sury.org+1 [107 kB]
Fetched 107 kB in 1s (91.8 kB/s)
Selecting previously unselected package php7.2-xml.
(Reading database ... 143503 files and directories currently installed.)
Preparing to unpack .../php7.2-xml_7.2.14-1+ubuntu18.04.1+deb.sury.org+1_amd64.deb ...
Unpacking php7.2-xml (7.2.14-1+ubuntu18.04.1+deb.sury.org+1) ...
Setting up php7.2-xml (7.2.14-1+ubuntu18.04.1+deb.sury.org+1) ...

Creating config file /etc/php/7.2/mods-available/dom.ini with new version

Creating config file /etc/php/7.2/mods-available/simplexml.ini with new version

Creating config file /etc/php/7.2/mods-available/wddx.ini with new version

Creating config file /etc/php/7.2/mods-available/xml.ini with new version

Creating config file /etc/php/7.2/mods-available/xmlreader.ini with new version

Creating config file /etc/php/7.2/mods-available/xmlwriter.ini with new version

Creating config file /etc/php/7.2/mods-available/xsl.ini with new version
Processing triggers for php7.2-fpm (7.2.14-1+ubuntu18.04.1+deb.sury.org+1) ...

こんな感じでインストール完了

無事動くようになりました。 キーなどを疑っていたので無駄に時間を使っちゃいました。

この記事を見ているあなた、お困りなことあればお気軽にご連絡ください!

Flutterの画像縦横比"BoxFit"をソフトバンクホークスのロゴ画像で検証

Flutterで画像を配置した際のサイズを指定に関して

f:id:jsaz:20181224181723p:plain:w480

FlutterでImageを使って画像を表示させる際、

縦横比"BoxFit"がどのようになっているのかを確認したくプログラムを書いてみた。

ドキュメントはコチラ

docs.flutter.io

BoxFitは7つのタイプがあったので、それぞれタイプ名とそのタイプでの画像出力を下記のようなプログラムで検証してみた。

画像はソフトバンクホークスのロゴ画像を一瞬拝借。

※一部ソースは省略。 listViewItems()を呼び出せば確認できる(はず)

ソースコード

// タイプ名とBoxFitのPropertyのクラスを定期
class BoxFitType {
  final String name;
  final BoxFit type;
  BoxFitType({this.name, this.type});
}

// BoxFitType のリストを作成
List<BoxFitType> listBoxFitType = [
  BoxFitType(name: "fill", type: BoxFit.fill),
  BoxFitType(name: "contain", type: BoxFit.contain),
  BoxFitType(name: "cover", type: BoxFit.cover),
  BoxFitType(name: "fitWidth", type: BoxFit.fitWidth),
  BoxFitType(name: "fitHeight", type: BoxFit.fitHeight),
  BoxFitType(name: "none", type: BoxFit.none),
  BoxFitType(name: "scaleDown", type: BoxFit.scaleDown)
];

//-途中省略-

// リストを出力
List<Widget> listViewItems() {
    List<Widget> listWidget = [];

    for (var boxFitType in listBoxFitType) {
      print(boxFitType.name);

      listWidget.add(SizedBox(
        height: 70.0,
        child: Container(
            color: Colors.black38,
            padding: EdgeInsets.all(8.0),
            child: ListTile(
              leading: Image.network(
                  "http://www.softbankhawks.co.jp/pc/_pl_img/footer/logo_footer_l02.png",
                  height: 60.0,
                  width: 60.0,
                  fit: boxFitType.type),
              title: Text(boxFitType.name),
            )),
      ));
    }

    return listWidget;
}

画面

リストにBoxFitTypeをループして出力している。

画像は高さ60、幅60で指定しており、上からfill, contain, cover, fitWidth, fitHeight, none, scaleDownとなっている

f:id:jsaz:20181223234229p:plain:w480

こういう場合は coverを使うべきなのかな。

Android開発 エミュレータ(AVD Manager)のサイズ変更はとても簡単だった

f:id:jsaz:20181219235439p:plain:w360

半年以上Android開発をしていて、今日初めて知りました。

Androidエミュレータのサイズ変更方法に関してです。

なんと設定は不要でした!

  • デフォルトは大きすぎて使い辛い
  • 動画付きで操作説明
  • みんな知ってたのかな?
続きを読む