• 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30

 参考にしている書籍にあわせてGHCiのプロンプトを変更するために、ホームディレクトリに下記のように .ghci ファイルを作成しました。

sh>>
$ cat -n .ghci
1 :set prompt "ghci> "
<<--

これでGHCiを起動してみます。

sh>>
$ ghci
GHCi, version 6.10.4: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer ... linking ... done.
Loading package base ... linking ... done.
*** WARNING: /home/akanuma/.ghci is writable by someone else, IGNORING!
Prelude>
<<--

すると設定ファイル .ghci がオーナー以外のユーザからも書き込み可能になっているということで無視されてしまいました。ファイルのパーミッションを変更して再度起動してみます。

sh>>
$ ls -l .ghci
-rw-rw-r-- 1 akanuma akanuma 21 6月 18 13:27 .ghci
$ chmod 644 .ghci
$ ls -l .ghci
-rw-r--r-- 1 akanuma akanuma 21 6月 18 13:27 .ghci
$ ghci
GHCi, version 6.10.4: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer ... linking ... done.
Loading package base ... linking ... done.
ghci>
<<--

今度は設定ファイルが読み込まれ、プロンプトがデフォルトの "Prelude>" から "ghci>" に変わりました。

posted by akanuma akanuma on Mon 18 Jun 2012 at 13:32 with 0 comments

Scalaを勉強しなおすために、まずHaskellを勉強してからの方がScalaを理解しやすいという話を聞いたので、Haskellの勉強を始めることにしました。ということでまずはHaskellのコンパイラ、GHC(The Glasgow Haskell Compiler)をインストールしました。yumであっさりインストールできてしまいました。

sh>>

yum install ghc

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile

  • base: ftp.iij.ad.jp
  • epel: ftp.tsukuba.wide.ad.jp
  • extras: ftp.iij.ad.jp
  • remi: rpms.famillecollet.com
  • updates: ftp.iij.ad.jp
    Setting up Install Process
    Resolving Dependencies
    --> Running transaction check
    ---> Package ghc.x86_64 0:6.10.4-3.el5 set to be updated
    --> Processing Dependency: gmp-devel for package: ghc
    --> Processing Dependency: libgmp.so.3()(64bit) for package: ghc
    --> Running transaction check
    ---> Package gmp.x86_64 0:4.1.4-10.el5 set to be updated
    ---> Package gmp-devel.x86_64 0:4.1.4-10.el5 set to be updated
    --> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================
Package Arch Version Repository Size

Installing:
ghc x86_64 6.10.4-3.el5 epel 43 M
Installing for dependencies:
gmp x86_64 4.1.4-10.el5 base 201 k
gmp-devel x86_64 4.1.4-10.el5 base 569 k

Transaction Summary

Install 3 Package(s)
Upgrade 0 Package(s)

Total download size: 44 M
Is this ok [y/N]: y
Downloading Packages:
(1/3): gmp-4.1.4-10.el5.x86_64.rpm | 201 kB 00:00
(2/3): gmp-devel-4.1.4-10.el5.x86_64.rpm | 569 kB 00:00
(3/3): ghc-6.10.4-3.el5.x86_64.rpm | 43 MB 00:07

Total 5.5 MB/s | 44 MB 00:08
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : gmp 1/3
Installing : gmp-devel 2/3
Installing : ghc 3/3

Installed:
ghc.x86_64 0:6.10.4-3.el5

Dependency Installed:
gmp.x86_64 0:4.1.4-10.el5 gmp-devel.x86_64 0:4.1.4-10.el5

Complete!
<<--

コマンドが存在することを確認します。

sh>>

which ghci

/usr/bin/ghci

which ghc

/usr/bin/ghc
<<--

バージョンの確認。

sh>>

ghc --version

The Glorious Glasgow Haskell Compilation System, version 6.10.4
<<--

対話モードで起動してみます。

sh>>

ghci

GHCi, version 6.10.4: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer ... linking ... done.
Loading package base ... linking ... done.
Prelude>
Prelude> :q
Leaving GHCi.

<<--

ひとまずコンパイラのインストールは問題なくできたようです。

posted by akanuma akanuma on Mon 18 Jun 2012 at 13:24 with 0 comments

 Perl と cpanm がインストールされて入れば、Catalystをインストールするには cpanm Ctalyst::Devl を実行するだけでOK。

sh>>
$ cpanm Catalyst::Devel
!
! Can't write to /usr/lib/perl5/site_perl/5.8.8 and /usr/bin: Installing modules to /home/akanuma/perl5
! To turn off this warning, you have to do one of the following:
! - run me as a root or with --sudo option (to install to /usr/lib/perl5/site_perl/5.8.8 and /usr/bin)
! - Configure local::lib your existing local::lib in this shell to set PERL_MM_OPT etc.
! - Install local::lib by running the following commands
!
! cpanm --local-lib=~/perl5 local::lib && eval 500 500perl -I ~/perl5/lib/perl5/ -Mlocal::lib)
!
--> Working on Catalyst::Devel
Fetching http://www.cpan.org/authors/id/B/BO/BOBTFISH/Catalyst-Devel-1.37.tar.gz ... OK
Configuring Catalyst-Devel-1.37 ... OK
==> Found dependencies: Test::Fatal, Catalyst::Plugin::ConfigLoader, MooseX::Emulate::Class::Accessor::Fast, Starman, File::ChangeNotify, File::ShareDir, Config::General, Catalyst, MooseX::Daemonize, Moose, namespace::autoclean, Catalyst::Plugin::Static::Simple, Template, Module::Install, Catalyst::Action::RenderView, namespace::clean
--> Working on Test::Fatal
Fetching http://www.cpan.org/authors/id/R/RJ/RJBS/Test-Fatal-0.010.tar.gz ... OK
Configuring Test-Fatal-0.010 ... OK
==> Found dependencies: Try::Tiny
~~~ 以下略 ~~~
<<--

posted by akanuma akanuma on Sun 17 Jun 2012 at 22:49 with 0 comments

CentOS上からgithubを使えるようにしたので作業内容をメモ。

まずはyumでgitをインストールします。ちなみにCentOSのバージョンは5.8です。

sh>>

yum install git

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile

  • base: rsync.atworks.co.jp
  • epel: ftp.iij.ad.jp
  • extras: rsync.atworks.co.jp
  • remi: rpms.famillecollet.com
  • updates: rsync.atworks.co.jp
    Setting up Install Process
    Resolving Dependencies
    --> Running transaction check
    ---> Package git.x86_64 0:1.7.4.1-1.el5 set to be updated
    --> Processing Dependency: perl-Git = 1.7.4.1-1.el5 for package: git
    --> Processing Dependency: rsync for package: git
    --> Processing Dependency: perl(Error) for package: git
    --> Processing Dependency: perl(Git) for package: git
    --> Running transaction check
    ---> Package perl-Error.noarch 1:0.17010-1.el5 set to be updated
    ---> Package perl-Git.x86_64 0:1.7.4.1-1.el5 set to be updated
    ---> Package rsync.x86_64 0:3.0.6-4.el5_7.1 set to be updated
    --> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================
Package Arch Version Repository Size

Installing:
git x86_64 1.7.4.1-1.el5 epel 4.5 M
Installing for dependencies:
perl-Error noarch 1:0.17010-1.el5 epel 26 k
perl-Git x86_64 1.7.4.1-1.el5 epel 28 k
rsync x86_64 3.0.6-4.el5_7.1 base 347 k

Transaction Summary

Install 4 Package(s)
Upgrade 0 Package(s)

Total download size: 4.9 M
Is this ok [y/N]: y
Downloading Packages:
(1/4): perl-Error-0.17010-1.el5.noarch.rpm | 26 kB 00:00
(2/4): perl-Git-1.7.4.1-1.el5.x86_64.rpm | 28 kB 00:00
(3/4): rsync-3.0.6-4.el5_7.1.x86_64.rpm | 347 kB 00:00
(4/4): git-1.7.4.1-1.el5.x86_64.rpm | 4.5 MB 00:00

Total 4.1 MB/s | 4.9 MB 00:01
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : perl-Error 1/4
Installing : rsync 2/4
Installing : git 3/4
Installing : perl-Git 4/4

Installed:
git.x86_64 0:1.7.4.1-1.el5

Dependency Installed:
perl-Error.noarch 1:0.17010-1.el5 perl-Git.x86_64 0:1.7.4.1-1.el5 rsync.x86_64 0:3.0.6-4.el5_7.1

Complete!
<<--

続いてgithubのヘルプページを参考にして環境設定。
まずはコミット時に使うユーザ名とメールアドレスを設定します。

sh>>
$ git config --global user.name "h-akanuma"
$ git config --global user.email "hiroaki.akanuma@gmail.com"
<<--

メールアドレスは正しいメールアドレスを設定する必要はなくて、コミットを識別するためのものなので、user@server のような形にしてどこからのコミットかを判別できるようにしても良いらしいです。

次はパスワードのキャッシュ設定。リモートサーバにアクセスするたびにパスワードを入力しなくても良いように、パスワードをキャッシュする設定をします。また、デフォルトのキャッシュの有効期限は15分間なので、とりあえず1時間に変更しておきます。

sh>>
$ git config --global credential.helper cache
$ git config --global credential.helper 'cache --timeout=3600'
<<--

これだけでひとまず全体的な設定は終了なので、ブラウザでgithubにアクセスして新しくリポジトリを作成します。

そして再びCentOS上での作業です。バージョン管理対象にするディレクトリを作成して初期化します。

sh>>
$ mkdir PerlTools
$ cd PerlTools/
$ git init
Initialized empty Git repository in /home/akanuma/scripts/PerlTools/.git/
<<--

バージョン管理したいファイルを作成し、ローカルリポジトリにコミットします。

sh>>
$ cp ../cut_time.pl .
$ ls -la
合計 16
drwxrwxr-x 3 akanuma akanuma 4096 6月 10 00:29 .
drwxrwxr-x 3 akanuma akanuma 4096 6月 10 00:28 ..
drwxrwxr-x 7 akanuma akanuma 4096 6月 10 00:28 .git
-rw-rw-r-- 1 akanuma akanuma 1336 6月 10 00:29 cut_time.pl
$
$ git add cut_time.pl
$ git commit -m 'Script for cutting file content by time range'
[master (root-commit) a677816] Script for cutting file content by time range
1 files changed, 75 insertions(+), 0 deletions(-)
create mode 100644 cut_time.pl
<<--

そしてローカルリポジトリへのコミット内容をgithubへpushします。

sh>>
$ git remote add origin https://github.com/h-akanuma/PerlTools.git
$ git push origin master
Username:
Password:
Counting objects: 3, done.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 757 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/h-akanuma/PerlTools.git

  • [new branch] master -> master
    <<--

これでgithubへコミット内容が反映されました。
他のリポジトリのForkはまだやっていないのでまたそのうち。

posted by akanuma akanuma on Sun 10 Jun 2012 at 00:54 with 0 comments

Linux上でファイル名が文字化けする場合があります。

sh>>
$ ls result.log.*
result.log.Fri
result.log.Thu
result.log.??
result.log.??
result.log.??
<<--

こうなると普通にファイル名を指定して操作することができません。

sh>>
$ wc -l 'result.log.??'
wc: result.log.??: No such file or directory
<<--

この場合はlsの出力結果をnkfで変換して正しいファイル名を確認します。

sh>>
$ ls result.log.* | nkf -e
result.log.Fri
result.log.Thu
result.log.金
result.log.土
result.log.木
<<--

確認したファイル名を指定することでファイルが操作できます。

sh>>
$ wc -l result.log.金
409 result.log.金
<<--

posted by akanuma akanuma on Fri 8 Jun 2012 at 09:12 with 1 comment