Saturday, September 29, 2007

Call me if you can.

I was born in a small town.
And that area is called "郡" which means country side of country sides.
But, one letter from my family tells me that I no longr am "郡民".
The return address on the letter shows "由布" which used to be "大分".

What? what is this address? City?

Oh yes, the letter which I just saw means "City".
Yes, yes, yes, I'm a City boy!!

" C I T Y " Boy.

Guys! Call me "City boy !" as big voice as you can !!
(weight 86.6kg BMI 29%)

Labels:

Tuesday, September 25, 2007

Zend Framework 1.0.2 is released!!

Yahoooooooooooooooooooooooooooooooooooooo!!

Zend Framework 1.0.2 is released today! :p

And so happy to forget how fatty I am!!
(weight I don't kg BMI care%)

Labels:

Try Zend Framework vol.4 "Validate Date"

As you know, Zend Framework has a lot of fancy validators like Zend_Validte_Ccnum.
But, it comes to "Zend_Validate_Date", I have to be quiet, because it only allows "YYYY-mm-dd" format.
Date sometimes look like "YYYY/mm/dd" but the validator returns "false". :<

It's Okay. But it should be more flexible, isn't it?

Zend Framework has Date class which is pretty powerful to create date object, but it's also powerful as Date validator.
So I wrote a Date validator.

library/Hoge/Validate/Date.php
<php
require_once 'Zend/Validate/Abstract.php';
require_once 'Zend/Date.php';

class Hoge_Validate_Date extends Zend_Validate_Abstract
{

/**
* Invalid date error message.
*/
const INVALID = 'dateInvalid';

/**
* Validation failure message template.
*
* @var array
*/
protected $_messageTemplates = array(
self::INVALID => "'%value%' does not appear to be a valid date"
);

/**
* Defined by Zend_Validate_Interface
*
* Return if the date is correct.
*
* @param string $value
* @return boolean
*/
public function isValid($value)
{

$valueString = (string) $value;

$this->_setValue($valueString);

if (!Zend_Date::isDate($value)) {
$this->_error(self::INVALID);
return false;
}

return true;
}

}


To use it
application/controller/HogeController.php
<php
function dateValidateAction()
{
$date = '2004/02/29';

require 'Hoge/Validate/Date.php';
$validator = new Hoge_Validate_Date();
echo $validator->isValid($date);
exit;
}

Return "true".
It distinguish "/" and validate the Date correctly!! :p

(weight 86.4kg BMI 29%)

Labels:

Monday, September 24, 2007

Faster than it was !

Chaged Mac book's memory 512 to 1G.
It's much faster than it was! So confotable!!!

(weight 86.5kg BMI 30%)

Labels:

Saturday, September 22, 2007

Try Zend Framework vol.3 "Extends Zend_View_Helper_Select"

Zend Framwrok has some useful helpers.
One of them is "Zend_View_Helper_Select".
Using it, you may set arguments like this.

controller/views/scripts/hoge/index.phtml
<?= $this->formSelect('hoge', null, null, array(''=>'', 'foo'=>'foo', 'bar'=>'bar')) ?>

You may not want to set blank as the default of options.

So, I extends Zend_View_Helper_FormSelect and add an argument to set default options.
library/Hoge/View/Helper/FormSelect.php
<php
require_once 'Zend/View/Helper/FormSelect.php';

class Hoge_View_Helper_FormSelect extends Zend_View_Helper_FormSelect
{
public function formSelect($name, $value = null, $attribs = null,
$options = null, $default_options = null, $listsep = "<br />\n")
{
$options = (is_array($default_options)) ? array_merge($default_options, $options) : $options;
return parent::formSelect($name, $value, $attribs, $options, $listsep);
}
}

It's just added argument for setting default options.
But, be careful it changes the number of arguments and changed order. :>

To use it.
<?= $this->formSelect('hoge', null, null, array('foo'=>'foo', 'bar'=>'bar'), array('' => '')) ?>

Simple right? :p
(weight 86.5kg BMI 30%)

Labels:

Thursday, September 20, 2007

Tagging PukiWiki

PukiWiki is a pretty useful tools.
But, if only it has tagging functionality, it would be much more useful.

My friend made a sophisticated plugin and introduce how to use it on his wiki.
Now my wiki is tagged elegant!!

It must help you a lot! :>
(weight 85.7kg BMI 29%)

Labels:

Tuesday, September 18, 2007

Try Zend Framework vol.2 "Debug Utils"

It's sometimes annoying to type "print_r" "get_class_methods".
"print_r" has 7 characters.
"get_class_methods" has 17 characters.
It just unbelievable!!
You might get hurt on your fingers.
And they just show the results as messy. It's not easy to read.

Zend Framework gives us a great class "Zend_Debug" for debugging.
It formats the result for you to read easily!

But, when you use the class you still need to type "Zend_Debug::dump()".
muu...18 characters. :<>
<php
require_once 'Zend/Debug.php';

function d($val)
{
Zend_Debug::dump($val);
}

function m($val)
{
Zend_Debug::dump(get_class_methods($val));
}


It's just simple functions but gives you time to make coffee instead of typing a lot of long letter functions. Isn't it? :p

(weight 85.4kg BMI 30%)

Labels:

Saturday, September 15, 2007

Been to Shibuya.js on 2007/09/15

I had been to shibuya.js.
Some entries were so fun.

I felt "Javascript can do everything!!"

I need to study Javascript.
Already late? :p

(weight 85.6kg BMI 30%)

Labels: