ert-runnerが動かなかったのでとりあえず動かす方法
Macでcask exec ert-runnerを動かすとなぜかCan not load file: subst-kscとなってうまく起動できない。これはMacの古いEmacs(Emacs22)を起動してしまうからうまくいかないわけで。
cask exec ert-runner # Can not load file: subst-ksc # M-: emacs-version RET => "22.1.1"
.cask/24.3.1/elpa/ert-runner-20140610.729/bin/ert-runner
を見たところとりあえず書き換えたら動いた。
--- ert-runner1 2014-08-07 15:37:39.000000000 +0900 +++ ert-runner 2014-08-07 15:36:26.000000000 +0900 @@ -3,9 +3,18 @@ ERT_RUNNER="$(dirname $(dirname $0))/ert-runner.el" if [[ -n "$INSIDE_EMACS" ]]; then - ERT_RUNNER_EMACS="emacs" + if [[ `uname -s` =~ Darwin ]]; then + ERT_RUNNER_EMACS=/Applications/Emacs.app/Contents/MacOS/Emacs + else + ERT_RUNNER_EMACS=emacs + # ERT_RUNNER_EMACS="emacs" + fi else - ERT_RUNNER_EMACS="${EMACS:-emacs}" + if [[ `uname -s` =~ Darwin ]]; then + ERT_RUNNER_EMACS=/Applications/Emacs.app/Contents/MacOS/Emacs + else + ERT_RUNNER_EMACS=emacs + fi fi function has_option {
あまりにも適当に書きすぎてるからどうにかしたい。issueを出すべきか、他の方法を探すべきか。とりあえずメモしておく。
Macが異様に重かったのが改善した
これを実行してFinderのplistを削除したら治った。
rm ~/Library/Preferences/com.apple.finder.plist && killall Finder
herokuのリモートの見つけ方
なかなかないと思うけど、herokuのリモートの名前を取得する方法がわからなくて困った。Githubからpullしてたからremoteが消えたんやろうか?
とりあえずメモっとく。
やり方
結論としては、こういう風にやればいい。
$ heroku login $ heroku apps === My Apps apps-citadel-2222 apps-twisted-weald-3333
これでアプリを名を確認して、リモートを追加する。
git remote add heroku git@heroku.com:apps-twisted-weald-3333.git git push heroku master
結論を先に書いて、このあとはインストールや実行結果を絡めて書いておく。
詳細
heroku toolbeltをインストールしておく。
まずはherokuにログインする。
$ heroku login Enter your Heroku credentials. Email: example@example.com Password (typing will be hidden): Authentication successful.
適当なやつは無いか探すためにheroku --helpを見る。
$ heroku --help Usage: heroku COMMAND [--app APP] [command-specific-options] Primary help topics, type "heroku help TOPIC" for more details: addons # manage addon resources apps # manage apps (create, destroy) auth # authentication (login, logout) config # manage app config vars domains # manage custom domains logs # display logs for an app ps # manage dynos (dynos, workers) releases # manage app releases run # run one-off commands (console, rake) sharing # manage collaborators on an app Additional topics: certs # manage ssl endpoints for an app drains # display syslog drains for an app fork # clone an existing app git # manage git for apps help # list commands and display help keys # manage authentication keys labs # manage optional features maintenance # manage maintenance mode for an app members # manage membership in organization accounts orgs # manage organization accounts pg # manage heroku-postgresql databases pgbackups # manage backups of heroku postgresql databases plugins # manage plugins to the heroku gem regions # list available regions stack # manage the stack for an app status # check status of heroku platform twofactor # update # update the heroku client version # display version
heroku appsが自分の管理しているアプリを表示してくれそうなので、実行してみる
$ heroku apps === My Apps apps-citadel-2222 apps-twisted-weald-3333
うまいこと表示された。
(herokuの命名ルールは知らないのでそれっぽい名前にしてる。名前はUltima Onlineから)
自分が設定したい名前がapps-twisted-weald-3333といことが分かったから、そこをremoteに追加する。
git remote add heroku git@heroku.com:apps-twisted-weald-3333.git
あとはpushするだけ。
$ git push heroku master Fetching repository, done. Counting objects: 20, done. Delta compression using up to 4 threads. Compressing objects: 100% (15/15), done. Writing objects: 100% (15/15), 2.28 KiB | 0 bytes/s, done. Total 15 (delta 6), reused 0 (delta 0) -----> Ruby app detected -----> Compiling Ruby/Rack -----> Using Ruby version: ruby-2.0.0 -----> Installing dependencies using 1.6.3 Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment Fetching gem metadata from https://rubygems.org/.......... Fetching additional metadata from https://rubygems.org/.. Using rack 1.5.2 Using eventmachine 1.0.3 Using tilt 1.4.1 Using daemons 1.1.9 Using bundler 1.6.3 Installing rack-protection 1.5.3 Installing sinatra 1.4.5 Installing thin 1.6.2 Your bundle is complete! Gems in the groups development and test were not installed. It was installed into ./vendor/bundle Bundle completed (4.77s) Cleaning up the bundler cache. Removing thin (1.5.1) Removing bundler (1.3.2) Removing sinatra (1.1.0) ###### WARNING: You have not declared a Ruby version in your Gemfile. To set your Ruby version add this line to your Gemfile: ruby '2.0.0' # See https://devcenter.heroku.com/articles/ruby-versions for more information. -----> Discovering process types Procfile declares types -> web Default types for Ruby -> console, rake -----> Compressing... done, 13.2MB -----> Launching... done, v13 http://apps-twisted-weald-3333.herokuapp.com/ deployed to Heroku To git@heroku.com:apps-twisted-weald-3333.git ef0822f..213339b master -> master
これでherokuにpushができて、LingrBotを動かすことができた。
追記2014/09/08
コマンドの修正
git remote add heroku git@githubheroku.com:apps-twisted-weald-3333.git
github.comじゃなくて、heroku.comだった。参考にしてできなかった人は申し訳ありません。
gistのメモ
gistで書いたプログラムのメモ
第一回 オフラインリアルタイムどう書くの参考問題
自分用マインドマップのサーチプログラム
Emacs Lispのヘッダ・フッタ挿入スクリプト
gitのpost-receiveの例
パスカルの三角形
Emacs Lispで文字列の要素のアクセス
このコードを実行したかった。
(map 'string #'(lambda (x y) (char "01234567890ABCDEF" (mod (+ x y) 16))) '(1 2 3 4) '(10 9 8 7)) ;; => "AAAA"
これだとchar関数がないですって怒られる。このcharは、Common Lispの文字列の要素アクセスになる。この対応するEmacs Lispで文字列の要素アクセスの方法を探してたけど、なかなかわからない。でもなんとか見つけた。
さすがkiwanamiさんである。
これによるとcharはarefを使って代替すればいいことがわかる
Ruby | Common Lisp | Emacs Lisp |
s[i] s.slice(i) |
(char s i) | (aref s i) |
なので実行コードはcharをarefにすればいいだけである。
(map 'string #'(lambda (x y) (aref "01234567890ABCDEF" (mod (+ x y) 16))) '(1 2 3 4) '(10 9 8 7)) ;; => "AAAA"
おかげで解決できました。
po4a-gettextizeをインストールしたことのメモ
po4a-gettixtizeをインストールしようと思ってやってみたらエラーに見舞われた。
メモのために手順とかを書いておく。
詳細にログとか書きたかったけど誤ってコンソールを消してしまってあまりログが残ってない。
インストール
↓でpo4a-gettextizeをダウンロードする。
https://alioth.debian.org/frs/?group_id=30267
ダウンロードししてREADMEを見てみると、
perl Build.PL ./Build ./Build install
という風にするって書いてある。まず
- perl Build.PL
- ./Build
をやってみる。
たしか./Buildをやったときに、gettextやらSGMLSなどを先にインストールして下さいと言われる。言われた通りにそこら辺をインストールしていく。やっていくうちに問題が発生した。
まずgettext
brew install gettext type xgettext #-> xgettext not found
えっ…。多分gettext自体は先にあってうまくリンク出来なかったのかも。なので強制的にリンクする。
brew link --force gettext
次にSGMLSのインストール作業のとき。
./Build installdeps
で依存関係をインストールしてくれるってのを./Buildのときに言われたのでコマンドを実行する。
$ ./Build installdeps Checking optional dependencies: Install SGMLS? [y ]y Reading '/Users/OginoRyo/.cpan/Metadata' Database was generated on Tue, 10 Jun 2014 20:41:02 GMT Running install for module 'SGMLS' Running make for D/DM/DMEGG/SGMLSpm-1.03ii.tar.gz Checksum for /Users/OginoRyo/.cpan/sources/authors/id/D/DM/DMEGG/SGMLSpm-1.03ii.tar.gz ok Package comes with a Makefile and without a Makefile.PL. We'll try to build it with that Makefile then. CPAN.pm: Building D/DM/DMEGG/SGMLSpm-1.03ii.tar.gz Could not read metadata file. Falling back to other methods to determine prerequisites if [ ! -d /usr/local/lib/perl5/SGMLS ]; then\ mkdir /usr/local/lib/perl5/SGMLS; \ chmod a+x /usr/local/lib/perl5/SGMLS; \ fi mkdir: /usr/local/lib/perl5: No such file or directory chmod: /usr/local/lib/perl5/SGMLS: No such file or directory make: *** [/usr/local/lib/perl5/SGMLS] Error 1 DMEGG/SGMLSpm-1.03ii.tar.gz /usr/bin/make -- NOT OK 'YAML' not installed, will not store persistent state Running make test Can't test without successful make Running make install Make had returned bad status, install seems impossible
/usr/local/lib/perl5 ディレクトリがなくてエラーになるらしい。自分はperlをインストールすることで解決したはず。
Perlのダウンロード
wget http://www.cpan.org/src/5.0/perl-5.20.0.tar.gz tar zxvf perl-5.20.0.tar.gz
cd perl-5.18.0 ./configure.gnu --prefix=/usr/local/perl5 make make test make install
解決のキモとしては、prefixを/usr/local/perl5にしたことだろうか?
あとは
./Build installdeps
をするか、
$ cpan
cpan> install SGMLS
をすればSGMLSをインストールできる。
でも、もしかしたらmkdir /usr/local/lib/perl5だけで解決したかもしれない。
あとは
./Build install
を実行すると、po4a-gettextizeをインストールすることができる。
C++で単一の繰り返し文字列を作る
RubyやHaskellでは特定の文字を繰り返して、繰り返し文字列を作るやり方は知ってる。だけどC++で単一の文字の繰り返した文字列を取得する方法はわからなかったのでメモする。
#include <string> #include <iostream> int main(){ std::string str(5, 'x'); std::cout << str; } /* xxxxx */
書き方は第一引数にくり返す回数を設定して、第二引数にくり返す文字を設定すればいい。
詳しく書くと、
// str::string(size_type count, charT ch); // std::string(いくつ生成するか, 生成する文字); std::string str(5, 'x');
という風になる。