• 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 ファイルを作成しました。

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

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

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

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

   1  $ ls -l .ghci
   2  -rw-rw-r-- 1 akanuma akanuma 21  6月 18 13:27 .ghci
   3  $ chmod 644 .ghci
   4  $ ls -l .ghci
   5  -rw-r--r-- 1 akanuma akanuma 21  6月 18 13:27 .ghci
   6  $ ghci
   7  GHCi, version 6.10.4: http://www.haskell.org/ghc/  :? for help
   8  Loading package ghc-prim ... linking ... done.
   9  Loading package integer ... linking ... done.
  10  Loading package base ... linking ... done.
  11  ghci>

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

posted by Png akanuma on Mon 18 Jun 2012 at 13:32

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

   1  # yum install ghc
   2  Loaded plugins: fastestmirror
   3  Loading mirror speeds from cached hostfile
   4   * base: ftp.iij.ad.jp
   5   * epel: ftp.tsukuba.wide.ad.jp
   6   * extras: ftp.iij.ad.jp
   7   * remi: rpms.famillecollet.com
   8   * updates: ftp.iij.ad.jp
   9  Setting up Install Process
  10  Resolving Dependencies
  11  --> Running transaction check
  12  ---> Package ghc.x86_64 0:6.10.4-3.el5 set to be updated
  13  --> Processing Dependency: gmp-devel for package: ghc
  14  --> Processing Dependency: libgmp.so.3()(64bit) for package: ghc
  15  --> Running transaction check
  16  ---> Package gmp.x86_64 0:4.1.4-10.el5 set to be updated
  17  ---> Package gmp-devel.x86_64 0:4.1.4-10.el5 set to be updated
  18  --> Finished Dependency Resolution
  19  
  20  Dependencies Resolved
  21  
  22  ========================================================================================================================
  23   Package                      Arch                      Version                           Repository               Size
  24  ========================================================================================================================
  25  Installing:
  26   ghc                          x86_64                    6.10.4-3.el5                      epel                     43 M
  27  Installing for dependencies:
  28   gmp                          x86_64                    4.1.4-10.el5                      base                    201 k
  29   gmp-devel                    x86_64                    4.1.4-10.el5                      base                    569 k
  30  
  31  Transaction Summary
  32  ========================================================================================================================
  33  Install       3 Package(s)
  34  Upgrade       0 Package(s)
  35  
  36  Total download size: 44 M
  37  Is this ok [y/N]: y
  38  Downloading Packages:
  39  (1/3): gmp-4.1.4-10.el5.x86_64.rpm                                                               | 201 kB     00:00
  40  (2/3): gmp-devel-4.1.4-10.el5.x86_64.rpm                                                         | 569 kB     00:00
  41  (3/3): ghc-6.10.4-3.el5.x86_64.rpm                                                               |  43 MB     00:07
  42  ------------------------------------------------------------------------------------------------------------------------
  43  Total                                                                                   5.5 MB/s |  44 MB     00:08
  44  Running rpm_check_debug
  45  Running Transaction Test
  46  Finished Transaction Test
  47  Transaction Test Succeeded
  48  Running Transaction
  49    Installing     : gmp                                                                                              1/3
  50    Installing     : gmp-devel                                                                                        2/3
  51    Installing     : ghc                                                                                              3/3
  52  
  53  Installed:
  54    ghc.x86_64 0:6.10.4-3.el5
  55  
  56  Dependency Installed:
  57    gmp.x86_64 0:4.1.4-10.el5                               gmp-devel.x86_64 0:4.1.4-10.el5
  58  
  59  Complete!

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

   1  # which ghci
   2  /usr/bin/ghci
   3  # which ghc
   4  /usr/bin/ghc

バージョンの確認。

   1  # ghc --version
   2  The Glorious Glasgow Haskell Compilation System, version 6.10.4

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

   1  # ghci
   2  GHCi, version 6.10.4: http://www.haskell.org/ghc/  :? for help
   3  Loading package ghc-prim ... linking ... done.
   4  Loading package integer ... linking ... done.
   5  Loading package base ... linking ... done.
   6  Prelude>
   7  Prelude> :q
   8  Leaving GHCi.
   9  #

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

posted by Png akanuma on Mon 18 Jun 2012 at 13:24

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

   1  $ cpanm Catalyst::Devel
   2  !
   3  ! Can't write to /usr/lib/perl5/site_perl/5.8.8 and /usr/bin: Installing modules to /home/akanuma/perl5
   4  ! To turn off this warning, you have to do one of the following:
   5  !   - run me as a root or with --sudo option (to install to /usr/lib/perl5/site_perl/5.8.8 and /usr/bin)
   6  !   - Configure local::lib your existing local::lib in this shell to set PERL_MM_OPT etc.
   7  !   - Install local::lib by running the following commands
   8  !
   9  !         cpanm --local-lib=~/perl5 local::lib && eval 500 500perl -I ~/perl5/lib/perl5/ -Mlocal::lib)
  10  !
  11  --> Working on Catalyst::Devel
  12  Fetching http://www.cpan.org/authors/id/B/BO/BOBTFISH/Catalyst-Devel-1.37.tar.gz ... OK
  13  Configuring Catalyst-Devel-1.37 ... OK
  14  ==> 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
  15  --> Working on Test::Fatal
  16  Fetching http://www.cpan.org/authors/id/R/RJ/RJBS/Test-Fatal-0.010.tar.gz ... OK
  17  Configuring Test-Fatal-0.010 ... OK
  18  ==> Found dependencies: Try::Tiny
  19  ~~~ 以下略 ~~~

posted by Png akanuma on Sun 17 Jun 2012 at 22:48

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

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

   1  # yum install git
   2  Loaded plugins: fastestmirror
   3  Loading mirror speeds from cached hostfile
   4   * base: rsync.atworks.co.jp
   5   * epel: ftp.iij.ad.jp
   6   * extras: rsync.atworks.co.jp
   7   * remi: rpms.famillecollet.com
   8   * updates: rsync.atworks.co.jp
   9  Setting up Install Process
  10  Resolving Dependencies
  11  --> Running transaction check
  12  ---> Package git.x86_64 0:1.7.4.1-1.el5 set to be updated
  13  --> Processing Dependency: perl-Git = 1.7.4.1-1.el5 for package: git
  14  --> Processing Dependency: rsync for package: git
  15  --> Processing Dependency: perl(Error) for package: git
  16  --> Processing Dependency: perl(Git) for package: git
  17  --> Running transaction check
  18  ---> Package perl-Error.noarch 1:0.17010-1.el5 set to be updated
  19  ---> Package perl-Git.x86_64 0:1.7.4.1-1.el5 set to be updated
  20  ---> Package rsync.x86_64 0:3.0.6-4.el5_7.1 set to be updated
  21  --> Finished Dependency Resolution
  22  
  23  Dependencies Resolved
  24  
  25  ========================================================================================================================
  26   Package                      Arch                     Version                             Repository              Size
  27  ========================================================================================================================
  28  Installing:
  29   git                          x86_64                   1.7.4.1-1.el5                       epel                   4.5 M
  30  Installing for dependencies:
  31   perl-Error                   noarch                   1:0.17010-1.el5                     epel                    26 k
  32   perl-Git                     x86_64                   1.7.4.1-1.el5                       epel                    28 k
  33   rsync                        x86_64                   3.0.6-4.el5_7.1                     base                   347 k
  34  
  35  Transaction Summary
  36  ========================================================================================================================
  37  Install       4 Package(s)
  38  Upgrade       0 Package(s)
  39  
  40  Total download size: 4.9 M
  41  Is this ok [y/N]: y
  42  Downloading Packages:
  43  (1/4): perl-Error-0.17010-1.el5.noarch.rpm                                                       |  26 kB     00:00
  44  (2/4): perl-Git-1.7.4.1-1.el5.x86_64.rpm                                                         |  28 kB     00:00
  45  (3/4): rsync-3.0.6-4.el5_7.1.x86_64.rpm                                                          | 347 kB     00:00
  46  (4/4): git-1.7.4.1-1.el5.x86_64.rpm                                                              | 4.5 MB     00:00
  47  ------------------------------------------------------------------------------------------------------------------------
  48  Total                                                                                   4.1 MB/s | 4.9 MB     00:01
  49  Running rpm_check_debug
  50  Running Transaction Test
  51  Finished Transaction Test
  52  Transaction Test Succeeded
  53  Running Transaction
  54    Installing     : perl-Error                                                                                       1/4
  55    Installing     : rsync                                                                                            2/4
  56    Installing     : git                                                                                              3/4
  57    Installing     : perl-Git                                                                                         4/4
  58  
  59  Installed:
  60    git.x86_64 0:1.7.4.1-1.el5
  61  
  62  Dependency Installed:
  63    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
  64  
  65  Complete!

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

   1  $ git config --global user.name "h-akanuma"
   2  $ git config --global user.email "hiroaki.akanuma@gmail.com"

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

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

   1  $ git config --global credential.helper cache
   2  $ git config --global credential.helper 'cache --timeout=3600'

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

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

   1  $ mkdir PerlTools
   2  $ cd PerlTools/
   3  $ git init
   4  Initialized empty Git repository in /home/akanuma/scripts/PerlTools/.git/

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

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

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

   1  $ git remote add origin https://github.com/h-akanuma/PerlTools.git
   2  $ git push origin master
   3  Username:
   4  Password:
   5  Counting objects: 3, done.
   6  Compressing objects: 100% (2/2), done.
   7  Writing objects: 100% (3/3), 757 bytes, done.
   8  Total 3 (delta 0), reused 0 (delta 0)
   9  To https://github.com/h-akanuma/PerlTools.git
  10   * [new branch]      master -> master

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

posted by Png akanuma on Sun 10 Jun 2012 at 00:53

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

   1  $ ls result.log.*
   2  result.log.Fri
   3  result.log.Thu
   4  result.log.??
   5  result.log.??
   6  result.log.??

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

   1  $ wc -l 'result.log.??'
   2  wc: result.log.??: No such file or directory

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

   1  $ ls result.log.* | nkf -e
   2  result.log.Fri
   3  result.log.Thu
   4  result.log.金
   5  result.log.土
   6  result.log.木

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

   1  $ wc -l result.log.金
   2  409 result.log.金

posted by Png akanuma on Fri 8 Jun 2012 at 09:12 with 1 comment
Contents
[Haskell] GHCiのプロンプト設定
[Haskell] GHCインストール
[Perl] Catalystインストール
[Git] CentOS上からgithubを使う
[Linux] ファイル名が文字化けした場合の操作
Comments
yoku0825: nkfの方が使いやすいですが、glibcに含まれているiconvの方が 確実にどの環境にも入っ... '12-6
Hiroaki Akanuma: ご指摘ありがとうございます。「嗜好度は大きい値がより嗜好度が強いことを意味すればどのような値で... '11-11
akr: 初めての推薦エンジンのところ 「属性データはどんなものでも可能。」 は preference ... '11-11
Services from s21g
twpro(ツイプロ)
Twitterプロフィールを快適検索
地価2009
土地の値段を調べてみよう
MyRestaurant
自分だけのレストラン手帳
Formula
ブログに数式を埋め込める数式コミュニティ