9/30/2008

Pack Method in Ruby

"pack" method is to show us binary format of object in Ruby Program.

Recently I want to create binary data from text file with Ruby.
Ruby has powerful regexp and convenient methods to be equip.

Therefore I try to create file and to store binary data.
But, I wonder how to store binary data!

Ruby provides the way to store for file is only text format.
I am in trouble.

I study a reference of Ruby.
It describes following.

  • Firstly You must use "pack" of Array Class method in order to know text of binary format of object
  • Secondly You store text of binary format in file.


    Example code is next.

    file << [10].pack("i")
  • 9/29/2008

    Playing Game in iMac

    Since I buy a iMac recently, I enjoy iMac life.
    iMac is very beautiful and small.
    My house is narrow, Therefore I like that iMac have only display, keybord and mouse without box.


    But There is one problem, It is that game for iMac is just a little.
    If I live in USA, no problem.
    In actuality I live in Japan, I can not buy games for iMac.

    I want to buy Spore and AOE3 for iMac.

    9/26/2008

    Disk Checker Ruby Program

    I wrote ruby program to work checking disk and reporting result.

    It is following code


    #!/usr/bin/ruby
    require 'net/smtp'

    if ARGV[0] == nil then
    print "usage : " + $0 + " directory\n"
    exit(1)
    end

    print "check directory " + ARGV[0] + "\n"

    cmd = "du -h -c " + ARGV[0]

    array = []

    IO.popen(cmd, 'r+') do |pipe|
    t = pipe.read
    t.gsub(/(?:[0-9]+(\.[0-9]*)?|(\.[0-9]+))([eE][-+]?[0-9]+)?\w/){|s|
    array.push(s)
    }
    end

    mailstring = "total = " + array.last() + "\n"

    Net::SMTP.start( 'severname', portnumber ) {|smtp|
    smtp.send_mail(mailstring, "from@localhost", "to@localhost")
    }

    9/25/2008

    Grouping Polygon

    I think new 3d format using my campany.

    This new 3d format is more than just to display 3d cg data.
    In other words, this format does not have only coordinate, connectivity and color value, but grouping polygon.

    Grouping polygon allow user to sign polygons.

    9/19/2008

    dotX format

    Now, I think new format of 3d shape data.

    And I study other application's data formats.
    First, I study dotX, is format of softimage|XSI.

    dotX is perfect for 3dcg data, has not only shape data but also animation , bone and so on.

    Shape data in dotX is named SI_Mesh, It involves volume and face group.
    In addition, It has triangle strips.

    9/18/2008

    Moving House

    I and My wife moved house last week.
    Next house has two room and living.

    There are many my books, therefore my wife is angry.
    My books belong to science and technologic field.

    My CDs are almost L'Arc en ciel. Shine, Kiss, Awake, and so on...

    9/09/2008

    Tecmo rejected Square Enix

    Recentry, Tecmo did not accept takeover bid from Square Enix.
    Tecmo select the way to join Koei.

    9/04/2008

    I married a great girl

    Yesterday, I married a great girl.
    She is smart, Her cooking is good taste and She make more maney than me.
    I am very happy man.

    I have gone with her since 02/27/2006.
    I proposed her at 08/09/2008.

    Two days are My memorial day.