go-example-webserver@Snappy Unbuntu Core On RaspberryPi2
前回の続き
webserverでパッケージ検索
(RaspberryPi2)ubuntu@localhost:~$ snappy search webserver Name Version Summary go-example-webserver 1.0.9 go-example-webserver xkcd-webserver 0.6 xkcd-webserver system-status.victor 1.0.10 System status web portal
go-example-webserverインストール
(RaspberryPi2)ubuntu@localhost:~$ sudo snappy install go-example-webserver Installing go-example-webserver Starting download of go-example-webserver 3.06 MB / 3.06 MB [========================================================================================] 100.00 % 89.10 KB/s Done Starting download of icon for package 40.35 KB / 40.35 KB [======================================================================================] 100.00 % 74.90 KB/s Done Name Date Version Developer ubuntu-core 2015-09-25 2 ubuntu go-example-webserver 2015-11-08 1.0.9 canonical hello-world 2015-11-08 1.0.18 canonical webdm 2015-11-08 0.9.4 sideload pi2 2015-09-25 0.16 canonical
http://サーバーIP:8081 にアクセスすればみれる。
READMEにビルド方法書いてあるけど、goインストールしないとダメ。
他所でビルドして、このサーバーに持ってきて動くかす方が楽そう。
RaspberryPiの中に入ってゴリゴリ書くのは違うと思う。
パッケージ削除の練習
(RaspberryPi2)ubuntu@localhost:~$ sudo snappy remove go-example-webserver Removing go-example-webserver Waiting for go-example-webserver_webserver_1.0.9.service to stop.
Snappy Ubuntu Core@Raspberry Pi 2
MacでSnappy Ubuntu を microSDカードに書いてRaspberry Pi 2にインストールした。
snappy コマンドを使ってみた。
用意したもの
- RaspberryPi2 Model B
- スマホ用ACアダプタ 5V2A
- microUSBケーブル
- SDカード16GB ※8GBあれば十分、速い方がいいかも。ddコマンドですごく時間がかかる
- MacBook (LANポートあり) ※無くても問題なし
- MacBook Air ※基本使ってるのはこっち
OSインストール
インストール方法は以下の通り。
Raspberry Pi 2 | Ubuntu developer portal
$ diskutil list /dev/disk0 # ~ 省略 ~ /dev/disk1 # ~ 省略 ~ /dev/disk2 #: TYPE NAME SIZE IDENTIFIER 0: FDisk_partition_scheme *15.9 GB disk2 1: Windows_FAT_32 NO NAME 15.9 GB disk2s1
ドキュメントだとDOS_FAT_32になってるけどWindows_FAT_32で問題ない。
$ dela diskutil unmountDisk /dev/disk2 Unmount of all volumes on disk2 was successful
microSDカードに書き込み開始
$ sudo dd if='/Users/dela/Downloads/ubuntu-15.04-snappy-armhf-rpi2.img' of='/dev/rdisk2' load: 3.26 cmd: dd 1305 uninterruptible 0.18u 5.78s 56808+0 records in 56807+0 records out 29085184 bytes transferred in 161.721234 secs (179848 bytes/sec)
3.9GBあるのでかなり時間がかかる。
誤ってddを途中で止めてしまった場合はそのままddするとエラー
> sudo dd if='/Users/dela/Downloads/ubuntu-15.04-snappy-armhf-rpi2.img' of='/dev/rdisk2' dd: /dev/rdisk2: Resource busy
もう一度unmountDiskするとやり直せる
$ diskutil unmountDisk /dev/disk2 Unmount of all volumes on disk2 was successful $ sudo dd if='/Users/dela/Downloads/ubuntu-15.04-snappy-armhf-rpi2.img' of='/dev/rdisk2' load: 3.26 cmd: dd 1305 uninterruptible 0.18u 5.78s
進捗の確認は場合、 MacはCtrl + t で見れる
load: 1.45 cmd: dd 1305 uninterruptible 9.68u 313.88s 2763732+0 records in 2763731+0 records out 1415030272 bytes transferred in 37413.624032 secs (37821 bytes/sec)
すごく待ったわりに、しれっと終わる
7617187+0 records in 7617187+0 records out 3899999744 bytes transferred in 55525.879951 secs (70238 bytes/sec)
microSDカードをRaspberryPiに差し込む。
HDMIケーブルでディスプレイに写す。
ACアダプタ差し込んで起動する。
懐かしい嬉しさ。
ssh
自分のCoregaルーターの設定のせいですんなりsshできなかった。
ルーターの管理画面で無線アクセスポイント設定 / アクセス制限で無線端末間通信と無線‐有線間端末通信をどちらも有効にしたらsshできた。
原因の切り分けにLANポートありのMacBookが役立った。
ルーターを介さずに、インターネット共有を有効にして、
共有する接続経路: Wifi, 相手のコンピューターが使用するポート: Ethrnet にすればRaspberryPiにsshできたので、すぐルーターが怪しいと絞り込めた。
そもそも以下で他のマシーン出てこないのがおかしい
$ arp -a
ubuntuユーザーでログインできる。passwordは直感的にubuntuって打ったら入れた。ですよねー
ssh ubuntu@192.168.1.27 ubuntu@192.168.1.27's password: Welcome to Ubuntu 15.04 (GNU/Linux 4.2.0-1008-raspi2 armv7l) * Documentation: https://help.ubuntu.com/ Welcome to snappy Ubuntu Core, a transactionally updated Ubuntu. * See https://ubuntu.com/snappy It's a brave new world here in snappy Ubuntu Core! This machine does not use apt-get or deb packages. Please see 'snappy --help' for app installation and transactional updates. Last login: Sun Nov 8 13:21:12 2015 from 192.168.2.1
snappy コマンド
snappy --helpで何ができるか把握
OS情報の確認
(RaspberryPi2)ubuntu@localhost:~$ snappy info release: ubuntu-core/15.04/stable architecture: armhf frameworks: webdm apps: hello-world.canonical
間違えても教えてくれる。普通ですね、はい
(RaspberryPi2)ubuntu@localhost:~$ snappy version Unknown command `version', did you mean `versions'?
snappy versionsはそのうち使わなくなるみたい
(RaspberryPi2)ubuntu@localhost:~$ snappy versions The "versions" command is no longer available. Please use the "list" command instead to see what is installed. The "list -u" (or "list --updates") will show you the available updates and "list -v" (or "list --verbose") will show all installed versions.
インストールされてパッケージの確認
(RaspberryPi2)ubuntu@localhost:~$ snappy list Name Date Version Developer ubuntu-core 2015-09-25 2 ubuntu webdm 2015-11-08 0.9.4 sideload pi2 2015-09-25 0.16 canonical
パッケージ検索
(RaspberryPi2)ubuntu@localhost:~$ snappy search hello-world Name Version Summary glowapi.vtuson 0.1.2 PiGlow RestAPi hello-dbus-fwk 1.0.2 hello-dbus-fwk hello-world 1.0.18 hello-world (forks not shown: 2) spi-test.pedronis 0.3 spi-test saythis 1.3 saythis say 1.4 say Use --show-all to see all available forks.
パッケージインストール
(RaspberryPi2)ubuntu@localhost:~$ sudo snappy install hello-world Installing hello-world Starting download of hello-world 21.60 KB / 21.60 KB [====================================================================================>_] 100.00 % 82.01 KB/s Done Starting download of icon for package 33.77 KB / 33.77 KB [======================================================================================] 100.00 % 68.73 KB/s Done Name Date Version Developer ubuntu-core 2015-09-25 2 ubuntu hello-world 2015-11-08 1.0.18 canonical webdm 2015-11-08 0.9.4 sideload pi2 2015-09-25 0.16 canonical
パッケージが増えたのを確認するのは以下
(RaspberryPi2)ubuntu@localhost:~$ snappy list Name Date Version Developer ubuntu-core 2015-09-25 2 ubuntu hello-world 2015-11-08 1.0.18 canonical webdm 2015-11-08 0.9.4 sideload pi2 2015-09-25 0.16 canonical
お試し実行。もちろんevilでしょう
(RaspberryPi2)ubuntu@localhost:~$ hello-world.#tabキー hello-world.echo hello-world.env hello-world.evil hello-world.sh hello-world.showdev hello-world.usehw (RaspberryPi2)ubuntu@localhost:~$ hello-world.evil Hello Evil World!
そして週末が終わってた。
gem install sinatra ~ Symbol not found: _SSLv2_client_method ~ @OS X
sinatraをインストールしようとしたら以下のエラー
$ gem install sinatra ERROR: Loading command: install (LoadError) dlopen(/Users/dela/.rbenv/versions/2.2.2/lib/ruby/2.2.0/x86_64-darwin14/openssl.bundle, 9): Symbol not found: _SSLv2_client_method Referenced from: /Users/dela/.rbenv/versions/2.2.2/lib/ruby/2.2.0/x86_64-darwin14/openssl.bundle Expected in: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib in /Users/dela/.rbenv/versions/2.2.2/lib/ruby/2.2.0/x86_64-darwin14/openssl.bundle - /Users/dela/.rbenv/versions/2.2.2/lib/ruby/2.2.0/x86_64-darwin14/openssl.bundle ERROR: While executing gem ... (NoMethodError) undefined method `invoke_with_build_args' for nil:NilClass
rubyを再インストールする
$ sudo rbenv install 2.2.2
再度 sinatra install
$ sudo gem install sinatra Password: Fetching: rack-protection-1.5.3.gem (100%) Successfully installed rack-protection-1.5.3 Fetching: tilt-2.0.1.gem (100%) Successfully installed tilt-2.0.1 Fetching: sinatra-1.4.6.gem (100%) Successfully installed sinatra-1.4.6 Parsing documentation for rack-protection-1.5.3 Installing ri documentation for rack-protection-1.5.3 Parsing documentation for tilt-2.0.1 Installing ri documentation for tilt-2.0.1 Parsing documentation for sinatra-1.4.6 Installing ri documentation for sinatra-1.4.6 Done installing documentation for rack-protection, tilt, sinatra after 272 seconds 3 gems installed
Apache2.4 build from source@OS X
Apache 2.4がOS Xですんなりビルドできなかった。
発生したエラーと解決方法をメモ。
wget http://apache.mirrors.pair.com/httpd/httpd-2.4.17.tar.gz tar xvzf httpd-2.4.17.tar.gz cd httpd-2.4.17 ./configure #ここでエラー
XCode -> Open Develop Tool -> More Developer Tools -> Command Line Toolsは最新にしておいた。
エラー 1
checking whether the C compiler works... no configure: error: C compiler cannot create executables
エラー 2
configure: error: in `/Users/dela/Documents/develop/ab/httpd-2.4.17': configure: error: C preprocessor "/Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.10.xctoolchain/usr/bin/cc -E" fails sanity check
対処 2
シンボリックリンクを貼る
sudo ln -s /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/ /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.10.xctoolchain
これでmakeまで動いて、./supportにabやapachectlができた。
Translate Shell + sayコマンドで喉が痛くても外国人と話せるよ@OS X
10分の立ち話で消費されるカロリーは体重60kgの場合19kcal
消費カロリー早見表|活動量計カロリズム|株式会社タニタ
10分のタイピングで消費されるカロリーは男性の場合9kcal
『執筆,デスクワーク,タイピング』の消費カロリー|運動・生活活動の消費カロリー |エクササイズ | ダイエットナビ | CLUB Panasonic
無駄な会話に自らのカロリー消費を最小限にしたい、風邪などで喉が痛くて話せない
そんなときはsayコマンドですね
$ say "正気ですか?"
translate-shellで外国語にも対応します
Translate Shell
translate-shell インストール
$ brew install gawk $ wget git.io/trans $ chmod +x trans
翻訳して音声出力
$ ./trans -b "病気ですよ" | say
どんどん使ってこ
追記:
sayコマンドいらなかった
$ ./trans -p おやすみ
追記2
man say すると便利な使い方がわかった。ファイルを指定できたり、声の種類を変えたり、サーバーに送信できたりする
$ cat message.txt I Love You. $ say -v Alex -f message.txt
追記3
Translate API https://developers.google.com/translate/.なのでお金払わないとダメ
"Is there any free quota? No, the Google Translate API is only available as a paid service."
Translate API FAQ - Translate API — Google Cloud Platform
$ trans 'こんにちわ' [ERROR] Null response. [ERROR] Oops! Something went wrong and I can't translate it for you :(
追記4
一定時間経って復活した?と思ったけど、IP変わったからブロックされなくなった1回目っていうだけで、2回目以降Null
$ trans -b 'おはよう' good morning
Go 1.5 gxui install & sample
cd Downloads/glew-1.12.0/ make sudo make install go get github.com/google/gxui go get github.com/golang/freetype/truetype go get github.com/go-gl-legacy/gl go get -u github.com/go-gl/glfw/v3.1/glfw go get -u github.com/goxjs/glfw go get -u github.com/goxjs/gl cd src/github.com/google/gxui/samples/polygon/ go run main.go
makeやgo get -u github.com/go-gl/glfw/v3.1/glfwあたりでエラーを吐くけど、コードは落としてこれてて動く