gem install devise
script/generate devise User

app/models/user.rb

class User < ActiveRecord::Base
  # Include default devise modules. Others available are:
  # :http_authenticatable, :token_authenticatable, :confirmable, :lockable, :timeoutable and :activatable
  devise :registerable, :database_authenticatable, :recoverable,
         :recoverable, :rememberable, :trackable, :validatable

  # Setup accessible (or protected) attributes for your model
  attr_accessible :email, :password, :password_confirmation
end

db/migrate/20100712034250_devise_create_users.rb

class DeviseCreateUsers < ActiveRecord::Migration
  def self.up
    create_table(:users) do |t|
      t.database_authenticatable :null => false
      #t.confirmable
      t.recoverable
      t.rememberable
      t.trackable
      # t.lockable

      t.timestamps
    end

    add_index :users, :email,                :unique => true
    #add_index :users, :confirmation_token,   :unique => true
    add_index :users, :reset_password_token, :unique => true
    # add_index :users, :unlock_token,         :unique => true
  end

  def self.down
    drop_table :users
  end
end

RubyGemsに繋がらない問題(Windows XPでの対処法)

昨日から、RubyGemsDNSが死んでいるようで、gemコマンドを使っても繋がらないみたいです。
http://gist.github.com/429688
こちらに書かれているhostsファイルはLinuxでのパスですが、Windows XPの場合は
C:\WINDOWS\system32\drivers\etc\
にあるhostsファイルに
72.4.120.124 rubygems.org
207.171.181.231 production.s3.rubygems.org
216.137.45.24 production.cf.rubygems.org
を追記すると、繋がりました。

↑こんな感じ

それにしても、まだ復活しないんでしょうか。

6/10 追記
現在は復旧しているようです。

クワガタイズ出来たよ|イエイリカズマ Official Blog 〜生け贄スタイルの理論と実践〜

今さらですが、Flashで作ってみました。
KUWAGATize on Flash

OpenCVをAS3に移植したMarilenaを使っています。

以下コード

package 
{
	import adobe.utils.CustomActions;
	import flash.display.*;
	import flash.events.ActivityEvent;
	import flash.events.Event;
	import flash.events.TimerEvent;
	import flash.geom.Matrix;
	import flash.geom.Rectangle;
	import flash.media.Camera;
	import flash.media.Video;
	import flash.utils.Timer;
	import jp.maaash.ObjectDetection.*;
	
	/**
	 * ...
	 * @author kazutoyo
	 */
	public class Main extends Sprite 
	{
		[Embed(source = 'kuwa0.png')]
		private const Kuwa0:Class;
		private const CAMERA_WIDTH:Number = 640;
		private const CAMERA_HEIGHT:Number = 480;
		private const VIDEO_SCALE:Number = 0.5;
		private const DEFAULT_FACE_RECT:Number = 40;
		private const DEFAULT_FACE_WIDTH:Number = 40;
		private const DEFAULT_FACE_HEIGHT:Number = 40;
		private const DEFAULT_IMG_WIDTH:Number = 165;
		private const DEFAULT_IMG_HEIGHT:Number = 164;
		private var img:Bitmap;
		private var camera:Camera;
		private var video:Video;
		private var detector:ObjectDetector;
		private var options:ObjectDetectorOptions;
		private var timer:Timer = new Timer(500, 0);
		private var v_bmd:BitmapData;
		private var matrix:Matrix = new Matrix();
		private var v_bmp:Bitmap = new Bitmap(v_bmd);
		
		public function Main():void 
		{
			if (stage) init();
			else addEventListener(Event.ADDED_TO_STAGE, init);
		}
		
		private function init(e:Event = null):void 
		{
			removeEventListener(Event.ADDED_TO_STAGE, init);
			// entry point
			//Stage
			stage.scaleMode = StageScaleMode.NO_SCALE;
			stage.align = StageAlign.TOP_LEFT;
			
			//クワガタさんを呼び出す
			img = new Kuwa0();
			addChild(img);
			
			//カメラの初期化
			this.setupCamera();
			//Detector
			this.initDetector();
			
			//matrix
			matrix.scale(VIDEO_SCALE, VIDEO_SCALE);
			v_bmd = new BitmapData(CAMERA_WIDTH * VIDEO_SCALE, CAMERA_HEIGHT * VIDEO_SCALE);
		}
		
		private function setupCamera():void {
			camera = Camera.getCamera();
            if(camera == null){
                trace("カメラがありません");
                return;
            }else{
				camera.setMode(CAMERA_WIDTH, CAMERA_HEIGHT, 15);
				video = new Video(camera.width, camera.height);
				video.attachCamera(camera);
				timer.addEventListener(TimerEvent.TIMER, onTimer);
				timer.start();
				addChildAt(video,0);
			}
        }
		
		private function initDetector():void {
			detector = new ObjectDetector();
			detector.options = this.getDetectorOptions();
			detector.addEventListener(ObjectDetectorEvent.DETECTION_COMPLETE, onDetectorComplete);
			detector.loadHaarCascades('face.zip');
		}
		
		private function getDetectorOptions():ObjectDetectorOptions {
			options = new ObjectDetectorOptions();
			options.min_size = 50;
			options.startx = ObjectDetectorOptions.INVALID_POS;
			options.starty = ObjectDetectorOptions.INVALID_POS;
			options.endx = ObjectDetectorOptions.INVALID_POS;
			options.endy = ObjectDetectorOptions.INVALID_POS;
			return options;
		}
		
		private function onDetectorComplete(e:ObjectDetectorEvent):void {
			if (e.rects) {
				e.rects.forEach( function( r :Rectangle, idx :int, arr :Array ) :void {
					img.width = ((r.width / DEFAULT_FACE_WIDTH) * DEFAULT_IMG_WIDTH)/VIDEO_SCALE;
					img.height = ((r.height / DEFAULT_FACE_HEIGHT) * DEFAULT_IMG_HEIGHT)/VIDEO_SCALE;
					img.x = (r.x/VIDEO_SCALE) - (img.width*(70/165));
					img.y = (r.y/VIDEO_SCALE) - (img.height * (90 / 164));
				});
			}
		}
		
		private function onTimer(e:TimerEvent):void {
			timer.stop();
			v_bmd.draw(video, matrix);
			v_bmp.bitmapData = v_bmd;
			detector.detect(v_bmp);
			timer.start();
		}
		
	}
	
}

ClamAV0.9.4を利用していてPostfixでメールが送れない問題

久々にはてなでブログ書いてみるkazutoyoです。

つい先日、
Mailmanで運用されているメーリングリストが送れない!ちょっと調べてみて!」
とお手伝いしている会社の方からお願いされたので、しらべていました。

でも、Mailmanの設定は合っている・・・
ってことはSMTPサーバがおかしいんじゃね?

ってことでmaillogをあさっていると、ClamAV0.9.4にバグがあるため0.9.5以上にアップグレードしてください!と警告がされて、メールが送れない状態でした。

ってことで、ClamAVを最新の0.9.6をインストールすると、無事警告が出ることもなくメールを送信できました。

なので、最近どうもメールが送れていないぞ?という方はmaillogをみて、ClamAVの問題か調べてみるといいと思います。

CentOS4.5にFMS3入れた

LivedoorさんのサーバにFMS3を入れました。
ディストリはCentOS4.5だったみたいです。
まず、必要なパッケージを入れます。LDのサーバには最初から入ってたみたいです。

yum install compat-libstdc++-33.i386
yum install seamonkey-nspr.i386
yum install libstdc++.so.5

あらかじめFMS3をダウンロードしておいて、解凍、そのディレクトリに移動します。

sudo ./installFMS
だとディストリが違うって怒られるので
sudo ./installFMS -platformWarnOnly
とオプションを付け加えてあげます。

あとはインストール設定が始まるので、てけとーに設定するだけです。

早くNODERA (.tv)がFMS3で動くと良いな♪

参考:林檎生活100 Flash Media Server 2をインストールしてみた.
http://applelife100.blogspot.com/2007/10/flash-media-server-2.html