memo

複数ファイルに一括で処理する

バッファに複数ファイルを開く複数ファイルを開く 現在のバッファすべてに対して処理を実行する。 以下は、app/以下の.rbファイルを、すべてutf-8に変換して保存する例。 vim app/**/*.rb :bufdo set fileencoding=utf-8 | :w (追記)argdoを使う解法 ka-nach…

text_field_tagのサイズを指定する

railsで使用する、text_fieldの入力領域変更など、HTMLの指定をするには、3つ目の引数に渡す。 例、その1 <%= text_field_tag :url, '' ,:size => '80' %>このerbの記述は、こうHTMLに展開される。 <input id="url" name="url" size="80" value="" type="text"> 例、その2 <%= text_field_tag :url, 'default' ,{ :siz…

saslpasswd2があるのにrc.dにsaslauthdが無くて困ってたけど

portsでのインストール時に /usr/ports/security/cyrus-sasl2 こっちも必要ということに気づくまで無駄に時間を使って(ノ∀`)アチ- /usr/ports/security/cyrus-sasl2-saslauthd

actionmailerで使える認証方法のメモ書き

利用できるのは:plain, :login, :cram_md5の3つ。 この3つは、Net::SMTPで利用できる3つでもある。 (actionmailer内部では、Net::SMTP.startを利用している)

なんか設定ミスったっぽいぞ

topの実行結果。 last pid: 637; load averages: 1.00, 0.95, 0.65 up 0+00:15:35 14:11:45 26 processes: 2 running, 24 sleeping CPU states: 33.8% user, 0.0% nice, 66.2% system, 0.0% interrupt, 0.0% idle Mem: 35M Active, 11M Inact, 26M Wired, 28…

最近

あんまりプログラミングできてないなぁ。精進せねば。

11-1

テストがムズかしくなってきた。 /* * 入力中の行、単語、文字のカウント **/ main(){ int c, nl, nw, nc, state; state = OUT; nl = nw = nc = 0; while((c = getchar()) != EOF ){ ++nc; if( c == '\n') { ++nl; } if( c == ' ' || c == '\n' || c == '\t'…

1-10

これ、バックスペースの入力ってどうやってテストするんだろと思ったけど、 echoで出力した文字列をパイプでつないでやって解決。 #include <stdio.h> /* * タブを\tに、バックスペースを\bに、バックスラッシュを\\に置き換え、 * 入力を出力に複写する **/ main(){ </stdio.h>…

1-9

OKOK #include <stdio.h> /* * 2つ以上の空白を1つの空白に置き換えながら * 入力を出力に複写する **/ main(){ int c,beforec; while((c = getchar() ) != EOF){ if (c != ' ' ){ if(beforec == ' '){ putchar(beforec); } putchar(c); } beforec = c; } exit(0); </stdio.h>…

1-8

まだなんとか。 #include <stdio.h> /* * 空白、タブ、改行を数えるプログラム **/ main(){ int c,spaceCounts,tabCounts,returnCounts; spaceCounts = 0; tabCounts = 0; returnCounts = 0; while((c = getchar() ) != EOF){ if (c == ' '){ spaceCounts++; } if (c </stdio.h>…

1-7

コレは簡単。 #include <stdio.h> /* * EOF の値を印字するプログラム **/ main(){ printf("%d",EOF); } [ERROR:1]% ./1-7 -1%</stdio.h>

1-6

難しい。。。。 #include <stdio.h> /* * getchar() != EOF が0か1しかないことを確認 **/ main(){ int c; c = 1; while(c){ c = (getchar() != EOF); printf("%d",c); } } [ERROR:1]% echo '1234' | ./1-6 111110% 5回1がでてるのは末尾に\nがついているから?全</stdio.h>…

1-6

難しいなぁ。。。。

1-5

for文を使ってみる [5638]% gcc 1-5.c -o 1-5 -Wall 1-5.c:6: warning: return type defaults to `int' 1-5.c: In function `main': 1-5.c:17: warning: control reaches end of non-void function [5639]% cat 1-5.c | c2utf #include <stdio.h> /* * fahr=300,280・</stdio.h>…

1-4

ちょっとした復習。 [ERROR:15]% cat 1-4.c |c2utf && ./1-4 #include <stdio.h> /* * celsius=0,20,・・・300に対して、摂氏-華氏温度対応表を作成 **/ main(){ float fahr, celsius; int lower, upper, step; lower = 0; upper = 300; step = 20; celsius = lower; </stdio.h>…

1-3

printfの使い方。man printf。 [5623]% cat 1-3.c |c2utf #include <stdio.h> /* * fahr=0,20,・・・300に対して、華氏-摂氏温度対応表を作成 **/ main(){ float fahr, celsius; int lower, upper, step; lower = 0; upper = 300; step = 20; fahr = lower; printf("%</stdio.h>…

1-2

printfのなかで\xを使ってみなさいという演習。 [ERROR:13]% cat 1-2.c [/home/utadaq/work/kandr] #include <stdio.h> main(){ printf("hello, world\x",0x0c); } [5418]% gcc 1-2.c -o 1-2 [/home/utadaq/work/kandr] 1-2.c:4:9: \x used with no following hex dig</stdio.h>…

1-1

hello worldの演習。 [5414]% cat 1-1.c [/home/utadaq/work/kandr] #include <stdio.h> main(){ printf("hello, world\n"); } [ERROR:127]% ./1.1 [/home/utadaq/work/kandr] hello, world</stdio.h>

自重とは

褒めコトバ

Nice boatとは

最近やたらと見かけるとおもったら、こういう意味でしたか。 http://d.hatena.ne.jp/keyword/Nice%20boat

gmail経由でメールを送信する

http://b.hatena.ne.jp/entry/4196739 上記のサイトを参考に(見れないときはGoogleキャッシュで)設定したのですが、 最後の Cyrus sasl plinのインストール$ apt-cache search cyrus $ apt-get install cyrus-sasl-plain が自分はcyrus-sasl-plainが…

redmine使ってみる

[3058]% svn checkout http://redmine.rubyforge.org/svn/ >| /dev/null [/home/utadaq/work] [3063]% mv svn redmine [/home/utadaq/work] [ERROR:1]% mysql -u root -p [/home/utadaq/work] Enter password: Welcome to the MySQL monitor. Commands end w…

ActiveRecordで使用するDBの列名にtypeと指定してはまる。

んー、Object.typeっていうメソッドがあると言うのを知らないで定義してしまって、思い通りに動かなかったんだけど、 よく考えたらオーバーライドされるから動くはず?とりあえず列名変更で回避しようと思うけど、とりあえずメモ。

requireとloadの違い

test.rb require 'test2.rb' require 'test2.rb' p '----------------------' load 'test2.rb' load 'test2.rb' test2.rb p 'test2 here' 実行結果 [2774]% ruby test.rb "test2 here" "----------------------" "test2 here" "test2 here" ちなみに、load '…

ar_fixturesのインストールとテストデータの作成

インストール [ERROR:1]% script/plugin source http://topfunky.net/svn/plugins/ Added 1 repositories. [2367]% script/plugin install ar_fixtures + ./ar_fixtures/CHANGELOG + ./ar_fixtures/History.txt + ./ar_fixtures/MIT-LICENSE + ./ar_fixtures…

朝起きてTwitterで天気予報が見れたらいいなぁ

なんかあるのかな。

ActsAsTaggablePluginHowto

http://wiki.rubyonrails.org/rails/pages/ActsAsTaggablePluginHowto ruby script/plugin install http://svn.viney.net.nz/things/rails/plugins/acts_as_taggable_on_steroids/

opencobolのインストール

http://pub.cozmixng.org/~kenke/diary/?date=200410うまくできなくて(´・ω・`)

railsをapache2で動かそうと思った

エラーがでて500の画面が出る。 なので、apacheのログをみると [Sun May 13 12:33:10 2007] [alert] .htaccess: Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration Rewriteができな…

apache2でモジュールを有効にするコマンド

よく忘れるのでメモ。 $ sudo a2enmod rewrite $ sudo a2dismod rewrite 参考: http://memo.officebrook.net/20060320.html