#NGK2014B でやるはずだったLT

まぁ、未稿だし

ごめんなさい。書き上げてないです。m(_ _)m
そもそも、書き始めたのが木曜日くらい。orz

コード、書いてないし

金融機関のCSVファイルと言えば、半角カナ混じりのsjisがデフォ。
半日くらい戦った挙句、伝統のnkf先生に丸投げしましたが。

N Network
K Kanji
F Filter

ですよ。間違っても、

N 何なの???
K こんなの!?
F 振っておけ(nkf先生にw)

ではありませんからww

どのみち

土下座コースなんですがねー。喜んで土下座しますよ!(キリッ

CygwinなRVMにreadlineを入れようとするとパッチが当たらない

エラーメッセージは

$ rvm pkg install readline
Fetching readline-5.2.tar.gz to /home/shingo/.rvm/archives
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 1989k  100 1989k    0     0  62929      0  0:00:32  0:00:32 --:--:--  123k
100 1989k  100 1989k    0     0  61992      0  0:00:32  0:00:32 --:--:-- 61992Extracting readline-5.2.tar.gz to /home/shingo/.rvm/src
Applying patch '/home/shingo/.rvm/patches/readline-5.2/shobj-conf.patch'...
Configuring readline in /home/shingo/.rvm/src/readline-5.2.
Compiling readline in /home/shingo/.rvm/src/readline-5.2.
Installing readline to /home/shingo/.rvm/usr
Fetching readline-6.2.tar.gz to /home/shingo/.rvm/archives
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 2224k  100 2224k    0     0  28754      0  0:01:19  0:01:19 --:--:--  119k
100 2224k  100 2224k    0     0  28599      0  0:01:19  0:01:19 --:--:-- 28599Extracting readline-6.2.tar.gz to /home/shingo/.rvm/src
Applying patch '/home/shingo/.rvm/patches/readline-6.2/patch-shobj-conf.diff'...
ERROR: Error running 'patch -p0 -f < /home/shingo/.rvm/patches/readline-6.2/patch-shobj-conf.diff', please read /home/shingo/.rvm/log/readline/patch.log
ERROR: Patch /home/shingo/.rvm/patches/readline-6.2/patch-shobj-conf.diff did not apply cleanly... back to the patching board :(

とかなります。

当てようとしていたパッチは

Mac OS X(darwin)向けのやつだったんで、~/.rvm/patches/readline-6.2/patch-shobj-conf.diffの中身は


全行削除!

再ビルドすると

平和に完了しましたw

$ rvm pkg install readline
Fetching readline-5.2.tar.gz to /home/shingo/.rvm/archives
Extracting readline-5.2.tar.gz to /home/shingo/.rvm/src
Applying patch '/home/shingo/.rvm/patches/readline-5.2/shobj-conf.patch'...
Configuring readline in /home/shingo/.rvm/src/readline-5.2.
Compiling readline in /home/shingo/.rvm/src/readline-5.2.
Installing readline to /home/shingo/.rvm/usr
Fetching readline-6.2.tar.gz to /home/shingo/.rvm/archives
Extracting readline-6.2.tar.gz to /home/shingo/.rvm/src
Applying patch '/home/shingo/.rvm/patches/readline-6.2/patch-shobj-conf.diff'...
Configuring readline in /home/shingo/.rvm/src/readline-6.2.
Compiling readline in /home/shingo/.rvm/src/readline-6.2.
Installing readline to /home/shingo/.rvm/usr

RVMをCygwin環境で使ってみる

依存パッケージ

gem install rvmしたあとの初期設定

普段はgemのインストール結果に表示されるコマンドコピペで行けるんだけど、できない子のCygwinではここを見ろのURL

を見て、下記のコマンドを打ってあげた。

$ bash < <(curl -sk https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
Cloning into rvm...
remote: Counting objects: 5767, done.
remote: Compressing objects: 100% (2764/2764), done.
remote: Total 5767 (delta 3781), reused 4076 (delta 2259)
Receiving objects: 100% (5767/5767), 1.97 MiB | 220 KiB/s, done.
Resolving deltas: 100% (3781/3781), done.

  RVM:  Shell scripts enabling management of multiple ruby environments.
  RTFM: https://rvm.beginrescueend.com/
  HELP: http://webchat.freenode.net/?channels=rvm (#rvm on irc.freenode.net)

Installing RVM to /home/shingo/.rvm/
    Correct permissions for base binaries in /home/shingo/.rvm/bin...
    Copying manpages into place.
    Recording config files for rubies.

shingo,

If you have any questions, issues and/or ideas for improvement please
fork the project and issue a pull request.

If you wish to disable the project .rvmrc file functionality, set
rvm_project_rvmrc=0 in either /etc/rvmrc or ~/.rvmrc.

NOTE: To Multi-User installers, please do NOT forget to add your users to the 'rvm'.
  The installer no longer auto-adds root or users to the rvm group. Admins must do this.
  Also, please note that group memberships are ONLY evaluated at login time.
  This means that users must log out then back in before group membership takes effect!

Thank you for using RVM!

I sincerely hope that RVM helps to make your life easier and more enjoyable!!!

  ~Wayne


SYSTEM NOTES:

If you do not wish to enable reading of per-project .rvmrc files, simply set:
        export rvm_project_rvmrc=0
within either your /etc/rvmrc or $HOME/.rvmrc file, then log out and back in.


You _must_ read 'rvm requirements' for additional OS specific requirements for
various rubies, and native-extension gems. Expect failures until those are met!


  You must now complete the install by loading RVM in new shells.

  If you wish to use RVM in an interactive fashion in your shells then
  Place the following line at the end of your shell's loading files
  (.bashrc or .bash_profile for bash and .zshrc for zsh),
  after all PATH/variable settings:

  [[ -s "/home/shingo/.rvm/scripts/rvm" ]] && source "/home/shingo/.rvm/scripts/rvm"  # This loads RVM into a shell session.

  You only need to add this line the first time you install RVM.

  If you are choosing to source RVM into your environment to switch current
  shell environments, be sure to close this shell and open a new one so that
  the RVM functions load.


Installation of RVM to /home/shingo/.rvm/ is complete.

ちなみにncursesを忘れたら

こうなる↓

$ rvm install 1.9.2
/home/shingo/.rvm/scripts/functions/logging: line 8: tput: command not found
/home/shingo/.rvm/scripts/functions/logging: line 8: tput: command not found
Installing Ruby from source to: /home/shingo/.rvm/rubies/ruby-1.9.2-p290, this may take a while depending on your cpu(s)...

/home/shingo/.rvm/scripts/functions/logging: line 8: tput: command not found
/home/shingo/.rvm/scripts/functions/logging: line 8: tput: command not found
ruby-1.9.2-p290 - #fetching
/home/shingo/.rvm/scripts/functions/logging: line 8: tput: command not found
/home/shingo/.rvm/scripts/functions/logging: line 8: tput: command not found
ruby-1.9.2-p290 - #downloading ruby-1.9.2-p290, this may take a while depending on your connection...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (60) SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
More details here: http://curl.haxx.se/docs/sslcerts.html

curl performs SSL certificate verification by default, using a "bundle"
 of Certificate Authority (CA) public keys (CA certs). If the default
 bundle file isn't adequate, you can specify an alternate file
 using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
 the bundle, the certificate verification probably failed due to a
 problem with the certificate (it might be expired, or the name might
 not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use
 the -k (or --insecure) option.
/home/shingo/.rvm/scripts/functions/logging: line 11: tput: command not found
/home/shingo/.rvm/scripts/functions/logging: line 11: tput: command not found
ERROR: There was an error, please check /home/shingo/.rvm/log/ruby-1.9.2-p290/*.log. Next we'll try to fetch via http.
/home/shingo/.rvm/scripts/functions/logging: line 8: tput: command not found
/home/shingo/.rvm/scripts/functions/logging: line 8: tput: command not found
Trying http:// URL instead.
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (60) SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
More details here: http://curl.haxx.se/docs/sslcerts.html

curl performs SSL certificate verification by default, using a "bundle"
 of Certificate Authority (CA) public keys (CA certs). If the default
 bundle file isn't adequate, you can specify an alternate file
 using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
 the bundle, the certificate verification probably failed due to a
 problem with the certificate (it might be expired, or the name might
 not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use
 the -k (or --insecure) option.
/home/shingo/.rvm/scripts/functions/logging: line 11: tput: command not found
/home/shingo/.rvm/scripts/functions/logging: line 11: tput: command not found
ERROR: There was an error, please check /home/shingo/.rvm/log/ruby-1.9.2-p290/*.log
/home/shingo/.rvm/scripts/functions/logging: line 11: tput: command not found
/home/shingo/.rvm/scripts/functions/logging: line 11: tput: command not found
ERROR: There has been an error while trying to fetch the source.
Halting the installation.
/home/shingo/.rvm/scripts/functions/logging: line 11: tput: command not found
/home/shingo/.rvm/scripts/functions/logging: line 11: tput: command not found
ERROR: There has been an error fetching the ruby interpreter. Halting the installation.

~/.curlrcをいぢって、オレオレ証明書を許容してあげないといけない

やってないと、こうなる↓

$ rvm install 1.9.2
Installing Ruby from source to: /home/shingo/.rvm/rubies/ruby-1.9.2-p290, this may take a while depending on your cpu(s)...

ruby-1.9.2-p290 - #fetching
ruby-1.9.2-p290 - #downloading ruby-1.9.2-p290, this may take a while depending on your connection...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (60) SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
More details here: http://curl.haxx.se/docs/sslcerts.html

curl performs SSL certificate verification by default, using a "bundle"
 of Certificate Authority (CA) public keys (CA certs). If the default
 bundle file isn't adequate, you can specify an alternate file
 using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
 the bundle, the certificate verification probably failed due to a
 problem with the certificate (it might be expired, or the name might
 not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use
 the -k (or --insecure) option.
ERROR: There was an error, please check /home/shingo/.rvm/log/ruby-1.9.2-p290/*.log. Next we'll try to fetch via http.
Trying http:// URL instead.
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (60) SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
More details here: http://curl.haxx.se/docs/sslcerts.html

curl performs SSL certificate verification by default, using a "bundle"
 of Certificate Authority (CA) public keys (CA certs). If the default
 bundle file isn't adequate, you can specify an alternate file
 using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
 the bundle, the certificate verification probably failed due to a
 problem with the certificate (it might be expired, or the name might
 not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use
 the -k (or --insecure) option.
ERROR: There was an error, please check /home/shingo/.rvm/log/ruby-1.9.2-p290/*.log
ERROR: There has been an error while trying to fetch the source.
Halting the installation.
ERROR: There has been an error fetching the ruby interpreter. Halting the installation.

~/.curlrcの中身は:

--insecure

makeを入れ忘れると

こうなる↓

$ rvm install 1.9.2
Installing Ruby from source to: /home/shingo/.rvm/rubies/ruby-1.9.2-p290, this may take a while depending on your cpu(s)...

ruby-1.9.2-p290 - #fetching
ruby-1.9.2-p290 - #downloading ruby-1.9.2-p290, this may take a while depending on your connection...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 8604k  100 8604k    0     0  87844      0  0:01:40  0:01:40 --:--:-- 59732
ruby-1.9.2-p290 - #extracting ruby-1.9.2-p290 to /home/shingo/.rvm/src/ruby-1.9.2-p290
ruby-1.9.2-p290 - #extracted to /home/shingo/.rvm/src/ruby-1.9.2-p290
WARN: Patch '' not found.
Fetching yaml-0.1.4.tar.gz to /home/shingo/.rvm/archives
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  460k  100  460k    0     0  60582      0  0:00:07  0:00:07 --:--:-- 97846
Extracting yaml-0.1.4.tar.gz to /home/shingo/.rvm/src
Configuring yaml in /home/shingo/.rvm/src/yaml-0.1.4.
Compiling yaml in /home/shingo/.rvm/src/yaml-0.1.4.
ERROR: Error running 'make ', please read /home/shingo/.rvm/log/ruby-1.9.2-p290/yaml/make.log
Installing yaml to /home/shingo/.rvm/usr
ERROR: Error running 'make install', please read /home/shingo/.rvm/log/ruby-1.9.2-p290/yaml/make.install.log
ruby-1.9.2-p290 - #configuring
ruby-1.9.2-p290 - #compiling
ERROR: Error running 'make ', please read /home/shingo/.rvm/log/ruby-1.9.2-p290/make.log
ERROR: There has been an error while running make. Halting the installation.

まー、何というか


ここまでドツボにはまるとふつーは匙を投げるわなー

Rails3に移行するための最初の一歩

shingo@ubuntu:~/Aptana RadRails Workspace/twitter$ ./search6.rb 
DEPRECATION WARNING: require "activerecord" is deprecated and will be removed in Rails 3. Use require "active_record" instead. (called from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.14/lib/activerecord.rb:2)

えーと、requireする名前が変わってるのを完全に忘れてた。orz

WEB+DB PRESSのバックナンバー読みながらやらないと、しょーもない間違いやらかすなー。

Rails2の最新とRails3の最新を両方入れて、ようやく原因が判明した俺ってバカ??

UbuntuでRails3のexecjsが例外を投げたら

どんなエラー?

こんな具合に例外を投げます。

$ ./script/rails server
/usr/lib/ruby/gems/1.8/gems/execjs-1.2.7/lib/execjs/runtimes.rb:47:in `autodetect': Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)
	from /usr/lib/ruby/gems/1.8/gems/execjs-1.2.7/lib/execjs.rb:5
	from /usr/lib/ruby/gems/1.8/gems/coffee-script-2.2.0/lib/coffee_script.rb:1:in `require'
	from /usr/lib/ruby/gems/1.8/gems/coffee-script-2.2.0/lib/coffee_script.rb:1
	from /usr/lib/ruby/gems/1.8/gems/coffee-script-2.2.0/lib/coffee-script.rb:1:in `require'
	from /usr/lib/ruby/gems/1.8/gems/coffee-script-2.2.0/lib/coffee-script.rb:1
	from /usr/lib/ruby/gems/1.8/gems/coffee-rails-3.1.1/lib/coffee-rails.rb:1:in `require'
	from /usr/lib/ruby/gems/1.8/gems/coffee-rails-3.1.1/lib/coffee-rails.rb:1
	from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.18/lib/bundler/runtime.rb:68:in `require'
	from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.18/lib/bundler/runtime.rb:68:in `require'
	from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.18/lib/bundler/runtime.rb:66:in `each'
	from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.18/lib/bundler/runtime.rb:66:in `require'
	from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.18/lib/bundler/runtime.rb:55:in `each'
	from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.18/lib/bundler/runtime.rb:55:in `require'
	from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.18/lib/bundler.rb:120:in `require'
	from /home/shingo/Aptana RadRails Workspace/twitter_bot/config/application.rb:7
	from /usr/lib/ruby/gems/1.8/gems/railties-3.1.0/lib/rails/commands.rb:52:in `require'
	from /usr/lib/ruby/gems/1.8/gems/railties-3.1.0/lib/rails/commands.rb:52
	from /usr/lib/ruby/gems/1.8/gems/railties-3.1.0/lib/rails/commands.rb:49:in `tap'
	from /usr/lib/ruby/gems/1.8/gems/railties-3.1.0/lib/rails/commands.rb:49
	from ./script/rails:6:in `require'
	from ./script/rails:6
$

どう対処するの?

エラーメッセージにある https://github.com/sstephenson/execjs を見れば、8つある"ExecJS supports these runtimes"のどれかを入れれば良いらしい。最初、therubyracerを入れたがダメだった。

それで、Node.jsを入れてあげる。

$ sudo apt-get install python-software-properties
$ sudo add-apt-repository ppa:chris-lea/node.js
$ sudo apt-get update
$ sudo apt-get install nodejs

これで平和に動きます。

$ ./script/rails server
=> Booting WEBrick
=> Rails 3.1.0 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2011-09-20 11:51:40] INFO  WEBrick 1.3.1
[2011-09-20 11:51:40] INFO  ruby 1.8.7 (2010-08-16) [i686-linux]
[2011-09-20 11:51:45] INFO  WEBrick::HTTPServer#start: pid=9112 port=3000