RubyのCursesを使って!!

あとで読む

RubyのCursesを使ってコンソールを制御する

Posted at 12pm on 01/11/08 | Posted in | no responses | read on

ruby-gd captcha インストールメモ

ruby-gdインストールしようとしたらエラーが出たのでメモ

まずは、何も考えずインストール

%sudo gem install ruby-gd -- --build-flag --with-freetype                                                                                            

Building native extensions.  This could take a while...
ERROR:  Error installing ruby-gd:
        ERROR: Failed to build gem native extension.

/usr/local/bin/ruby extconf.rb install ruby-gd -- --build-flag --with-freetype
checking for main() in -lfreetype... yes
checking for main() in -lz... yes
checking for main() in -lpng... yes
checking for gdImagePng() in -lgd... no

*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=/usr/local/bin/ruby
        --with-gd-dir
        --without-gd-dir
        --with-gd-include
        --without-gd-include=${gd-dir}/include
        --with-gd-lib
        --without-gd-lib=${gd-dir}/lib
        --with-xpm
        --without-xpm
        --with-jpeg
        --without-jpeg
        --with-ttf
        --without-ttf
        --with-xpm
        --without-xpm
        --with-freetype
        --with-freetypelib
        --without-freetypelib
        --with-zlib
        --without-zlib
        --with-pnglib
        --without-pnglib
        --with-gdlib
        --without-gdlib

Gem files will remain installed in /usr/local/lib/ruby/gems/1.8/gems/ruby-gd-0.7.4 for inspection.
Results logged to /usr/local/lib/ruby/gems/1.8/gems/ruby-gd-0.7.4/gem_make.out

パッケージ freetype,libpng3,libpng-dev,libgd-devあたりを入れる

%sudo apt-get   build-dep freetype 
%sudo apt-get   install freetype
%sudo aptitude instlal libpng-dev
%sudo aptitude instlal libpng3 libpng3-dev
%sudo aptitude install libgd-dev

再度インストール

%sudo gem install ruby-gd -- --build-flag --with-freetype                                                                                            

Building native extensions.  This could take a while...
Successfully installed ruby-gd-0.7.4
1 gem installed
Installing ri documentation for ruby-gd-0.7.4...
Installing RDoc documentation for ruby-gd-0.7.4...

最後にcaptcha

%sudo gem install captcha
Posted at 11am on 12/24/07 | Posted in , , | no responses | read on

sparkelines

前から気になっていたのだが、sparklinesとは何ぞやと。 railsから使えるグラフライブラリらしい。

$sudo gem install sparklines
$sudo gem install sparklines_generator

とりあえず、入れてみたがこれからどうしようか。
こんなもんらしいが、どうだろう。。

Posted at 5pm on 12/21/07 | Posted in , | no responses | read on

rails2.0.1は scaffold :model が動かない

ついさっき、rails本第2版が出たばっかりなのに、もうそのRails本のコード動かないもんね。

P63

class AdminController < ApplicationController
 scaffold :product
end

63ページ目でもう動かないからね。

Posted at 9pm on 12/16/07 | Posted in , | no responses | read on

rubygemsのエラーのメモ

メモ

rubygemsのバージョンアップにともない、 require_gemがobsoleleになり、gemを使うことが推奨されます。

rails1.1.6以下では、require_gemを使用しており、うっかりrubygemsのバージョンを上げてしまうと、不具合が発生します。

手元で確認したところ

    * rubygems (=0.9.0) → gem, require_gem共に使える
    * rubygems (>0.9.0) → require_gemがwarningを吐く

という違いがあるようです。

rubygemsとrailsのversion整合性より
Posted at 9pm on 12/16/07 | Posted in , | no responses | read on

古いバージョンのRailsを動かす

rails2.0.1が出たのだけれども、やっぱり、typoなどrailsアプリがうまくうごいてくれないので、どうしたもんかなーと思っていたのだけれども、ここに古いバージョンでrailsをという記事が載ってた。

とりあえず、最低限覚えておくコマンドはこの2つ

$sudo gem install rails --version 1.2.6
→ これでバージョン指定してインストールできる
$sudo rails _1.2.6_ rails126
→ これでrailsのバージョンを指定してインストールできる

ちなみにmysqlを動かすのも面倒なので、sqliteにしたい場合は

$sudo rails _1.2.6_ -d sqlite3  rails126withsqlite

でOK

Posted at 5pm on 12/14/07 | Posted in , , , | no responses | read on

rails 第2版が出たばっかりなのに

もう、rails2.0が出てるもんなー。早いなー。

rails 2.0のスライド

Posted at 10am on 12/11/07 | Posted in , , | no responses | read on

rails2.0.1は RubyGems >=0.9.4

ということで、update gemをupdateする場合は、「gem update --system」というように「--system」オプションを付けるんだね。

Rails requires RubyGems >= 0.9.4 (you have 0.9.2). Please `gem update --system` and try again.

% sudo gem update --system                                                                                 
Updating RubyGems...
Bulk updating Gem source index for: http://gems.rubyforge.org
Need to update 10 gems from http://gems.rubyforge.org
..........
complete
Attempting remote update of rubygems-update
Successfully installed rubygems-update-0.9.5
Updating version of RubyGems to 0.9.5
Installing RubyGems 0.9.5
・・・・
・・・・
・・・・
As of RubyGems 0.8.0, library stubs are no longer needed.
Searching $LOAD_PATH for stubs to optionally delete (may take a while)...
...done.
No library stubs found.
RubyGems system software updated

ruby界隈はupdateが早くて追従するの大変ですね。こりゃ。

Posted at 11am on 12/10/07 | Posted in , | no responses | read on

ruby-talkのメーリングリスト

メチャクチャ流量が多い。 一日100通以上あるよね。。。 読み切れないなぁ。

Posted at 12am on 11/19/07 | Posted in , | no responses | read on

gruffでのグラフの作り方メモ


#グラフサイズの指定 文字列で横x縦でのsize指定になる 500x375くらいがBest
graph_size = "500x375"

graph_data = {:test1 => 10, :test2 => 20, :test3 => 30, :test4 => 40}

theme = {
 :colors = ["#000", "#111" , "#222", "#333", "#444", "#555"]
 :maker_color = "#999"
 :font_color = "#000"
 :background_colors = "#FFF"
}

g = Gruff::Pie.new graph_size

g.theme = theme
g.title  = "日本語のタイトル"

graph_data.each { |key,value|
 g.data( key, value)
}

g.write "your_filename.png"

:font_color #=> フォントカラー(タイトル、%などのフォントの色を指定)
※ フォントの指定は :font_color = "#000" or "#000000" どちらでもOK

:background_colors #=> 背景の色指定
※ :background_colors = "#000" or "#000000" でOK
※ :background_colors = ["#000" , "#FFF"]とすると、黒から白へのグラデーションになる。

:maker_color 棒グラフ表示、線グラフ表示の際の補助線(目盛り線)の色

:colors Pieグラフ、棒グラフ、線グラフの際に使われる色、Arrayに入れたものから順に表示される gruff_colors = ['#FFCCE5','#EFBFD7','#FFB2D8','#FF99CC','#FF7FBF',"#FF007\ F","#E00070","#C10060","#A30051","#666666","#AAAAAA"]

グラフに日本語を表示したい場合は gruff.font = "/usr/share/fonts/truetype/sazanami/sazanami-gothic.ttf"
といった形でフォントを指定する

g.data に項目名、値をそれぞれ入れる

Posted at 11pm on 05/05/07 | Posted in | no responses | read on

Older posts: 1 2