memo.xight.org

日々のメモ

macOS High Sierra + homebrew + MacTeX

Summary

macOS 10.13 High Sierra で TeX 環境の構築。

homebrew, brewcask で ghostscirpt, imagemagick, mactex をインストール

$ brew install ghostscript imagemagick
$ brew cask install mactex
$ sudo chown -R USERNAME:admin /usr/local/texlive

mactexをアップデート

$ tlmgr update --self --all

texmf.cnf を作成

$ mkdir /usr/local/texlive/texmf-local/web2c
$ vi /usr/local/texlive/texmf-local/web2c/texmf.cnf

texmf.cnf

shell_escape_commands = \
bibtex,bibtex8,bibtexu,upbibtex,biber,\
kpsewhich,\
makeindex,mendex,texindy,\
mpost,upmpost,\
repstopdf,epspdf,extractbb

日本語フォント対応

$ git clone https://github.com/texjporg/cjk-gs-support.git
$ cd cjk-gs-support
$ ./cjk-gs-integrate-macos.pl --cleanup
cjk-gs-integrate: reading font database ...
cjk-gs-integrate [WARNING]: Cannot find cjkgs-morisawa-extra.dat, skipping!
cjk-gs-integrate: searching for Ghostscript resource
cjk-gs-integrate: going to clean up /usr/local/share/ghostscript/9.23/Resource
cjk-gs-integrate: cleaning up all links, snippets and cidfmap.local ...
cjk-gs-integrate: removing cidfmap.local from cidfmap file ...
cjk-gs-integrate: removing snippets and cidfmap.aliases for font aliases ...
cjk-gs-integrate: removing cidfmap.aliases from cidfmap file ...
cjk-gs-integrate: finished
$ ./cjk-gs-integrate-macos.pl --link-texmf --fontdef-add=./database/cjkgs-macos-highsierra.dat --force
cjk-gs-integrate: reading font database ...
cjk-gs-integrate [WARNING]: Cannot find cjkgs-morisawa-extra.dat, skipping!
cjk-gs-integrate: checking for files ...
cjk-gs-integrate: searching for Ghostscript resource
cjk-gs-integrate: output is going to /usr/local/share/ghostscript/9.23/Resource
cjk-gs-integrate: generating links and snippets for CID fonts ...
cjk-gs-integrate: generating links, snippets and cidfmap.local for non-CID fonts ...
cjk-gs-integrate: Removing link /usr/local/texlive/texmf-local/fonts/truetype/cjk-gs-integrate/batang.ttc due to --force!
cjk-gs-integrate: Removing link /usr/local/texlive/texmf-local/fonts/truetype/cjk-gs-integrate/Dengb.ttf due to --force!
cjk-gs-integrate: Removing link /usr/local/texlive/texmf-local/fonts/truetype/cjk-gs-integrate/Dengl.ttf due to --force!
cjk-gs-integrate: Removing link /usr/local/texlive/texmf-local/fonts/truetype/cjk-gs-integrate/Deng.ttf due to --force!
cjk-gs-integrate: Removing link /usr/local/texlive/texmf-local/fonts/truetype/cjk-gs-integrate/gulim.ttc due to --force!
cjk-gs-integrate: Removing link /usr/local/texlive/texmf-local/fonts/truetype/cjk-gs-integrate/HGRGE.TTC due to --force!
cjk-gs-integrate: Removing link /usr/local/texlive/texmf-local/fonts/truetype/cjk-gs-integrate/HGRSMP.TTF due to --force!
cjk-gs-integrate: Removing link /usr/local/texlive/texmf-local/fonts/truetype/cjk-gs-integrate/HGRME.TTC due to --force!
cjk-gs-integrate: Removing link /usr/local/texlive/texmf-local/fonts/truetype/cjk-gs-integrate/HGRSGU.TTC due to --force!
cjk-gs-integrate: Removing link /usr/local/texlive/texmf-local/fonts/truetype/cjk-gs-integrate/msgothic.ttc due to --force!
cjk-gs-integrate: Removing link /usr/local/texlive/texmf-local/fonts/truetype/cjk-gs-integrate/msmincho.ttc due to --force!
cjk-gs-integrate: Removing link /usr/local/texlive/texmf-local/fonts/truetype/cjk-gs-integrate/malgunsl.ttf due to --force!
cjk-gs-integrate: Removing link /usr/local/texlive/texmf-local/fonts/truetype/cjk-gs-integrate/malgunbd.ttf due to --force!
cjk-gs-integrate: Removing link /usr/local/texlive/texmf-local/fonts/truetype/cjk-gs-integrate/malgun.ttf due to --force!
cjk-gs-integrate: Removing link /usr/local/texlive/texmf-local/fonts/truetype/cjk-gs-integrate/meiryo.ttc due to --force!
cjk-gs-integrate: Removing link /usr/local/texlive/texmf-local/fonts/truetype/cjk-gs-integrate/meiryob.ttc due to --force!
cjk-gs-integrate: Removing link /usr/local/texlive/texmf-local/fonts/truetype/cjk-gs-integrate/msjhbd.ttf due to --force!
cjk-gs-integrate: Removing link /usr/local/texlive/texmf-local/fonts/truetype/cjk-gs-integrate/msjh.ttf due to --force!
cjk-gs-integrate: Removing link /usr/local/texlive/texmf-local/fonts/truetype/cjk-gs-integrate/msyh.ttf due to --force!
cjk-gs-integrate: Removing link /usr/local/texlive/texmf-local/fonts/truetype/cjk-gs-integrate/msyhbd.ttf due to --force!
cjk-gs-integrate: Removing link /usr/local/texlive/texmf-local/fonts/truetype/cjk-gs-integrate/msyhl.ttf due to --force!
cjk-gs-integrate: Removing link /usr/local/texlive/texmf-local/fonts/truetype/cjk-gs-integrate/mingliu.ttc due to --force!
cjk-gs-integrate: Removing link /usr/local/texlive/texmf-local/fonts/truetype/cjk-gs-integrate/STHUPO.TTF due to --force!
cjk-gs-integrate: Removing link /usr/local/texlive/texmf-local/fonts/truetype/cjk-gs-integrate/STLITI.TTF due to --force!
cjk-gs-integrate: Removing link /usr/local/texlive/texmf-local/fonts/truetype/cjk-gs-integrate/STXINGKA.TTF due to --force!
cjk-gs-integrate: Removing link /usr/local/texlive/texmf-local/fonts/truetype/cjk-gs-integrate/STXINWEI.TTF due to --force!
cjk-gs-integrate: Removing link /usr/local/texlive/texmf-local/fonts/truetype/cjk-gs-integrate/STZHONGS.TTF due to --force!
cjk-gs-integrate: Removing link /usr/local/texlive/texmf-local/fonts/truetype/cjk-gs-integrate/simhei.ttf due to --force!
cjk-gs-integrate: Removing link /usr/local/texlive/texmf-local/fonts/truetype/cjk-gs-integrate/simsun.ttf due to --force!
cjk-gs-integrate: Removing link /usr/local/texlive/texmf-local/fonts/truetype/cjk-gs-integrate/YuGothM.ttf due to --force!
cjk-gs-integrate: Removing link /usr/local/texlive/texmf-local/fonts/truetype/cjk-gs-integrate/yumindb.ttf due to --force!
cjk-gs-integrate: Removing link /usr/local/texlive/texmf-local/fonts/truetype/cjk-gs-integrate/yuminl.ttf due to --force!
cjk-gs-integrate: Removing link /usr/local/texlive/texmf-local/fonts/truetype/cjk-gs-integrate/yumin.ttf due to --force!
cjk-gs-integrate: adding cidfmap.local to cidfmap file ...
cjk-gs-integrate: generating snippets and cidfmap.aliases for font aliases ...
cjk-gs-integrate: adding cidfmap.aliases to cidfmap file ...
cjk-gs-integrate: finished

dvipdfmxのためのmapファイルを作成する


$ git clone https://github.com/texjporg/jfontmaps.git
$ cd jfontmaps
$ kpsewhich -var-value=TEXMFHOME
/Users/username/Library/texmf
$ make
$ make install
mkdir -p /Users/username/Library/texmf/doc/fonts/ptex-fontmaps
cp ./README /Users/username/Library/texmf/doc/fonts/ptex-fontmaps/
mkdir -p /Users/username/Library/texmf/fonts/cmap/ptex-fontmaps
cp cmap/* /Users/username/Library/texmf/fonts/cmap/ptex-fontmaps/
mkdir -p /Users/username/Library/texmf/fonts/map/dvipdfmx/ptex-fontmaps
cp -r maps /Users/username/Library/texmf/fonts/map/dvipdfmx/ptex-fontmaps/
mkdir -p /Users/username/Library/texmf/fonts/misc/ptex-fontmaps
cp database/*.dat /Users/username/Library/texmf/fonts/misc/ptex-fontmaps/
mkdir -p /Users/username/Library/texmf/scripts/ptex-fontmaps
ls script/* | grep -v updmap-otf.sh | xargs -I % cp % /Users/username/Library/texmf/scripts/ptex-fontmaps/
mkdir -p /Users/username/Library/texmf/source/ptex-fontmaps/script
cp script/updmap-otf.sh /Users/username/Library/texmf/source/ptex-fontmaps/script
mkdir -p /Users/username/Library/texmf/source/ptex-fontmaps/tools
cp tools/* /Users/username/Library/texmf/source/ptex-fontmaps/tools/
$ mktexlsr
mktexlsr: Updating /usr/local/texlive/2018/texmf-config/ls-R...
mktexlsr: Updating /usr/local/texlive/2018/texmf-dist/ls-R...
mktexlsr: Updating /usr/local/texlive/2018/texmf-var/ls-R...
mktexlsr: Updating /usr/local/texlive/texmf-local/ls-R...
mktexlsr: Done.

ヒラギノをPDFに埋め込み

$ kanji-config-updmap-sys --jis2004 hiragino-highsierra-pron
Setting up ... ptex-hiragino-highsierra-pron.map
Creating new config file /usr/local/texlive/2018/texmf-config/web2c/updmap.cfg
updmap will read the following updmap.cfg files (in precedence order):
  /usr/local/texlive/2018/texmf-config/web2c/updmap.cfg
  /usr/local/texlive/2018/texmf-dist/web2c/updmap.cfg
updmap may write changes to the following updmap.cfg file:
  /usr/local/texlive/2018/texmf-config/web2c/updmap.cfg
dvips output dir: "/usr/local/texlive/2018/texmf-var/fonts/map/dvips/updmap"
pdftex output dir: "/usr/local/texlive/2018/texmf-var/fonts/map/pdftex/updmap"
dvipdfmx output dir: "/usr/local/texlive/2018/texmf-var/fonts/map/dvipdfmx/updmap"

updmap is creating new map files
using the following configuration:
  LW35 font names                  : URWkb (/usr/local/texlive/2018/texmf-dist/web2c/updmap.cfg)
  prefer outlines                  : true (/usr/local/texlive/2018/texmf-dist/web2c/updmap.cfg)
  texhash enabled                  : true
  download standard fonts (dvips)  : true (/usr/local/texlive/2018/texmf-dist/web2c/updmap.cfg)
  download standard fonts (pdftex) : true (/usr/local/texlive/2018/texmf-dist/web2c/updmap.cfg)
  jaEmbed replacement string       : hiragino-highsierra-pron (/usr/local/texlive/2018/texmf-config/web2c/updmap.cfg)
  jaVariant replacement string     : <empty> (/usr/local/texlive/2018/texmf-config/web2c/updmap.cfg)
  scEmbed replacement string       : arphic (/usr/local/texlive/2018/texmf-dist/web2c/updmap.cfg)
  tcEmbed replacement string       : arphic (/usr/local/texlive/2018/texmf-dist/web2c/updmap.cfg)
  koEmbed replacement string       : baekmuk (/usr/local/texlive/2018/texmf-dist/web2c/updmap.cfg)
  create a mapfile for pxdvi       : false (default)

Scanning for LW35 support files  [  3 files]
Scanning for MixedMap entries    [ 44 files]
Scanning for KanjiMap entries    [ 11 files]
Scanning for Map entries         [272 files]

Generating output for dvipdfmx...
Generating output for ps2pk...
Generating output for dvips...
Generating output for pdftex...

Files generated:
  /usr/local/texlive/2018/texmf-var/fonts/map/dvips/updmap:
	   15796 2018-05-07 16:22:20 builtin35.map
	   21269 2018-05-07 16:22:20 download35.map
	 2477037 2018-05-07 16:22:21 psfonts_pk.map
	 2737932 2018-05-07 16:22:21 psfonts_t1.map
	 2731344 2018-05-07 16:22:20 ps2pk.map
		  14 2018-05-07 16:22:22 psfonts.map -> psfonts_t1.map
  /usr/local/texlive/2018/texmf-var/fonts/map/pdftex/updmap:
	 2731351 2018-05-07 16:22:22 pdftex_dl14.map
	 2729686 2018-05-07 16:22:22 pdftex_ndl14.map
		  15 2018-05-07 16:22:22 pdftex.map -> pdftex_dl14.map
  /usr/local/texlive/2018/texmf-var/fonts/map/dvipdfmx/updmap:
	   10906 2018-05-07 16:22:20 kanjix.map

Transcript written on "/usr/local/texlive/2018/texmf-var/web2c/updmap.log".
updmap: Updating ls-R files.

TexShopの削除とbrewcask から最新版をインストール

$ sudo rm /Applications/TeXShop.app
$ brew cask install texshop

TeXShopの環境設定

TeXShop Preferences - Sources - Set Default Values から "upTeX (ptex2pdf)" を選択

定期的なアップデート

$ tlmgr update --self --all

Reference

TeX Wiki - macOS 10.13 High Sierra / macOS 10.12 Sierra / OS X 10.11 El Capitan への対応
https://texwiki.texjp.org/?TeX%20Live%2FMac#elcapitan

JupyterLab + Docker

Summary

JupyterLab Betaがリリースされた。
dockernize してパスワード作成スクリプトを作っておいた。

Reference

github - xight - jupyterlab-docker
https://github.com/xight/jupyterlab-docker

github - jupyterlab - jupyterlab
https://github.com/jupyterlab/jupyterlab

via

Jupyter - 2018-02-20 - JupyterLab is Ready for Users
https://blog.jupyter.org/jupyterlab-is-ready-for-users-5a6f039b8906

Publickey - 2018-03-01 - オープンソースのWebIDE「JupyterLab」がベータ公開
http://www.publickey1.jp/blog/18/webidejupyterlabpythonrscala.html

APFS + Mobile Time Machine (local snapshot) のスナップショットを削除する

Summary

ファイルを削除しても、ローカルストレージの容量が増えない。
macOS High Sierra から導入された APFS + Mobile Time Machine が原因。
ローカルストレージに空き容量があると、自動的にTime Machine Backup を作成してくれる。

ローカルストレージのスナップショットを確認

% tmutil listlocalsnapshots /
com.apple.TimeMachine.2018-02-28-140507
com.apple.TimeMachine.2018-02-28-153416
com.apple.TimeMachine.2018-02-28-163003
com.apple.TimeMachine.2018-02-28-172959
com.apple.TimeMachine.2018-02-28-183043
com.apple.TimeMachine.2018-02-28-193048
com.apple.TimeMachine.2018-02-28-203043
com.apple.TimeMachine.2018-02-28-220300


ローカルのスナップショットを個別に削除

% tmutil deletelocalsnapshots 2018-02-28-203043


ローカルのスナップショットをまとめて削除

% tmutil thinlocalsnapshots / 99999999999 (大きな数値)


使用前後の比較


tmutil thinlocalsnapshots 前

Filesystem      Size  Used Avail Use% Mounted on
/dev/disk1s1    895G  862G   30G  97% /


tmutil thinlocalsnapshots 後

Filesystem      Size  Used Avail Use% Mounted on
/dev/disk1s1    895G  579G  313G  65% /


Reference

Apple - サポート - Time Machine のローカルスナップショットについて
https://support.apple.com/ja-jp/HT204015

stack overflow - APFS Container Resize error code is 49153
https://stackoverflow.com/questions/46424915/apfs-container-resize-error-code-is-49153

plenv + cpanm + chalow

Summary

plenv install 5.26.1
plenv global 5.26.1
curl -L https://cpanmin.us | perl - App::cpanminus
cpanm CGI --local-lib=vendor
cpanm HTML::Template --local-lib=vendor
cpanm URI --local-lib=vendor
cpanm Jcode --local-lib=vendor
cd path/to/chalow
./chalow

Deep Learning を利用してモックアップの画像からHTMLとCSSを生成する

Summary

モックアップ画像とHTML, CSSのセットを使って学習。

Reference

FloydHub Blog - 2018-01-09 - Turning Design Mockups Into Code With Deep Learning
https://blog.floydhub.com/Turning-design-mockups-into-code-with-deep-learning/

GitHub - emilwallner/Screenshot-to-code-in-Keras
https://github.com/emilwallner/Screenshot-to-code-in-Keras

CloudFrunt - a tool for identifying misconfigured CloudFront domains

Summary

CloudFrunt is a tool for identifying misconfigured CloudFront domains.

CloudFrunt は誤って設定されたCloudFrontドメインを特定するためのツールです。

For CloudFront in particular, most AWS customers with a single distribution can protect themselves by adding a wildcard domain (such as *.disloops.com) to the "Alternate Domain Names (CNAMEs)" field.

CNAME にワイルドカードを追加することで防ぐことが可能。

Reference

disloops - 2018-01-02 - CloudFront Hijacking
https://disloops.com/cloudfront-hijacking/

GitHub - disloops / cloudfrunt
https://github.com/disloops/cloudfrunt

カスタムドメインの GitHub Pages + CloudFlare で HTTPS を使う

Summary

GitHub Pages で運用している ill-formed.com, well-formed.org をHTTPS対応させた。

1. CloudFlare でドメイン名を入力

CloudFlare - Add Websites

2. DNSレコードを確認

CloudFlare - Verify DNS Records
"Continue" をクリック

3. プランを選択

CloudFlare - Select a plan
"Free Website" を選択

4. ネームサーバの変更

CloudFlare - Change Your Nameservers
指定されたネームサーバに変更する

5. ネームサーバの変更待ち

CloudFlare - Change Your Nameservers
ネームサーバの変更が CloudFlare 側で確認できるまではこのような画面に。

6. Crypto タブからHTST 対応

CloudFlare - Crypto
Always use HTTPS, HTTP Strict Transport Security (HSTS) の設定を行う。

Reference

Qiita - superbrothers - 2016-06-05 - カスタムドメインの GitHub Pages で HTTPS を使う
https://qiita.com/superbrothers/items/95e5723e9bd320094537

Debian Stretch に PHP5.6 と PHP7.0 を共存させる

Summary

Debian StretchのオフィシャルリポジトリにはPHP5.6が含まれていない。
packages.sury.org のPHP5.6のパッケージを利用して、PHP5.6, PHP7.0 の環境を共存させたい。

sury.orgのgpgキーを追加

$ sudo apt-get install apt-transport-https
$ curl https://packages.sury.org/php/apt.gpg | sudo apt-key add -

- /etc/apt/sources.list.d/deb.sury.org.list
[src]
deb https://packages.sury.org/php/ stretch main


php5.6, php7.0のインストール

$ sudo apt-get update
$ sudo apt-get install php5.6-cli php5.6-fpm php7.0-cli php7.0-fpm


/etc/nginx/site-available/site-with-php7.0

server {
	listen 8870 default_server;
	listen [::]:8870 default_server;
	server_name _;
	root /var/www/site-with-php7.0;
	index index.php;
	location / {
		include snippets/fastcgi-php.conf;
		fastcgi_pass unix:/run/php/php7.0-fpm.sock; # adjust for the listen setting discussed above
	}
}

/etc/nginx/site-available/site-with-php5.6

server {
	listen 8856 default_server;
	listen [::]:8856 default_server;
	server_name _;
	root /var/www/site-with-php5.6;
	index index.php;
	location / {
		include snippets/fastcgi-php.conf;
		fastcgi_pass unix:/run/php/php5.6-fpm.sock; # adjust for the listen setting discussed above
	}
}

シンボリックリンクの作成, nginxの再起動

$ ln -s ../sites-available/site-with-php5.6 /etc/nginx/sites-enabled
$ ln -s ../sites-available/site-with-php7.0 /etc/nginx/sites-enabled
$ systemctl reload nginx.service


via

pehapkari.cz - 2017-03-27 - Multiple PHP versions, the easy way
https://pehapkari.cz/blog/2017/03/27/multiple-php-versions-the-easy-way/

/dev/log がなくなった場合の対応

Summary

/dev/log が見つからないエラーが発生…。

logger: socket /dev/log: No such file or directory

/run/systemd/journal/dev-log から /dev/log にシンボリックリンクを作成

sudo ln -s /run/systemd/journal/dev-log /dev/log


Reference

askubuntu - 2016-11-18 - Ubuntu Lost /dev/log symlink?
https://askubuntu.com/questions/850848/ubuntu-lost-dev-log-symlink