by shigemk2

当面は技術的なことしか書かない

memo quickrun-timeout-seconds

quickrun-timeout-secondsについてのメモ。

こういう設定にしておいて、

(setq quickrun-timeout-seconds 5)

こういうプログラムをemacs-quickrunで実行したときに、

from time import sleep
sleep(10)
print "hoge"

途中で以下のようなメッセージが出てプログラムは終了する。これは期待したとおりの挙動。

Error running timer ‘quickrun--kill-process’: (buffer-read-only #<buffer *quickrun*>)

でもmatplotlibでグラフを表示したときに、本来ならずっと動いていて欲しいのにquickrun-timeout-secondsの設定した時間でプログラムが終了してしまうという挙動を発見した。まあそんなものか。

(setq quickrun-timeout-seconds nil)

matplotlibをpyenvで使おうとしたときのRuntimeError

  • Python 2.7.11(pyenv)
  • matplotlib 2.2.2
import matplotlib.pyplot as plt

x = [1, 2, 3, 4, 5]
y = [5, 4, 3, 2, 1]

plt.plot(x, y)
plt.show()

無邪気にpyenvでmatplotlibを動かそうとしたら、以下のようなエラーに見舞われた。

RuntimeError: Python is not installed as a framework. The Mac OS X backend will not be able to function correctly if Python is not installed as a framework. See the Python documentation for more information on installing Python as a framework on Mac OS X. Please either reinstall Python as a framework, or try one of the other backends. If you are using (Ana)Conda please install python.app and replace the use of 'python' with 'pythonw'. See 'Working with Matplotlib on OSX' in the Matplotlib FAQ for more information.

ググったら同じトラブルに巻き込まれた人をQiitaでいっぱい見たけど、解決方法しか書いていなくて出典もSOだったから原因がどうなっているのかよくわからなかった。

エラーログをよく読むと、 See 'Working with Matplotlib on OSX' in the Matplotlib FAQ って書いてあるから、こっちを調べてみた。

https://matplotlib.org/faq/osx_framework.html

https://matplotlib.org/faq/usage_faq.html

以下わかったこと。

  • OSXでmatplotlib使おうとする場合フレームワークビルドが使えるかどうかをチェックしている
  • OSXの場合pyenv (Ana)Conda virtualenvを使おうとすると、フレームワークとしてインストールされていないと描画が失敗する
  • エラーログにも書いてあるけど、↑のリンクのFAQに沿ってPythonを入れ直すか、pythonwを使うようにすること

AWS Bitnami AMI

  • WPとかのCMSをAWS上でサクッと構築したいってなったときにbitnamiを使っており、メモ。
    • bitnamiで構築できるAMI一覧
    • RedmineとかMagentoとかGravとかもだいたいこんなかんじ
    • 説明書。ApacheとかMySQLとかを一括起動/停止するスクリプトがサーバーの中に入っていて、使い方はだいたいここに書いてある

初期パスワード

  • ユーザー名 user
    • マネジメントコンソールのシステムログか、もしくは/var/log/syslogにパスワードが書かれてる ランダム文字列生成。

https://docs.bitnami.com/aws/faq/starting-bitnami-aws/find_credentials/

version_compare

  • 最初のバージョンが 2 番目のバージョンより小さい場合に -1、 同じ場合に 0、そして 2 番目のバージョンのほうが小さい場合に 1
<?php
echo version_compare ( "5.5", "5.6" ); // -1

http://php.net/manual/ja/function.version-compare.php

ソースコードを読んでみても、ただ文字列を比較しているだけではない感じ。 php-src/versioning.c at PHP-7.2 · php/php-src · GitHub

なお、WPのuser access managerプラグインでWPのバージョン比較でもこの関数が使われており、じゃっかん :thinking_face:

user-access-manager/user-access-manager.php at master · GM-Alex/user-access-manager · GitHub

imports context: unrecognized import path "context"

imports context: unrecognized import path "context"

go get しててこんなエラーが出たら、Golangのバージョンが低すぎるから、おとなしく公式からtar.gzを落としてバージョンをあげよう めんどくさいからって yumとかapt-getとかでパッケージをインストールしても低いやつしか入らない

(goofysで同じのが出た)