<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>

<channel>
	<title>Kamibu</title>
	<atom:link href="http://blog.kamibu.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.kamibu.com</link>
	<description></description>
	<pubDate>Wed, 08 Oct 2008 20:50:06 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
	<language>en</language>
			<item>
		<title>The Vilundo Chat Protocol</title>
		<link>http://blog.kamibu.com/2008/10/08/the-vilundo-chat-protocol/</link>
		<comments>http://blog.kamibu.com/2008/10/08/the-vilundo-chat-protocol/#comments</comments>
		<pubDate>Wed, 08 Oct 2008 20:42:01 +0000</pubDate>
		<dc:creator>dionyziz</dc:creator>
		
		<category><![CDATA[Excalibur]]></category>

		<guid isPermaLink="false">http://blog.kamibu.com/?p=71</guid>
		<description><![CDATA[A while ago, we developed a simple chat protocol to-be-used for Zino. It&#8217;s still not in use, but we decided it would be a good idea to publish the specification so that other people could use it. It&#8217;s available under Creative Commons.
The Vilundo Chat Protocol Specification
]]></description>
			<content:encoded><![CDATA[<p>A while ago, we developed a simple chat protocol to-be-used for Zino. It&#8217;s still not in use, but we decided it would be a good idea to publish the specification so that other people could use it. It&#8217;s available under Creative Commons.</p>
<p><a href="http://www.dionyziz.com/Vilundo">The Vilundo Chat Protocol Specification</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kamibu.com/2008/10/08/the-vilundo-chat-protocol/feed/</wfw:commentRss>
		</item>
		<item>
		<title>RabbitEdit</title>
		<link>http://blog.kamibu.com/2008/10/04/rabbitedit/</link>
		<comments>http://blog.kamibu.com/2008/10/04/rabbitedit/#comments</comments>
		<pubDate>Sat, 04 Oct 2008 19:37:40 +0000</pubDate>
		<dc:creator>Indy</dc:creator>
		
		<category><![CDATA[Linux]]></category>

		<category><![CDATA[PHP]]></category>

		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://blog.kamibu.com/?p=65</guid>
		<description><![CDATA[RabbitEdit is a nifty tool that allows easier Rabbit development and saves you quite some time and effort.
Its purpose is to automatically do particular common things for you, like writing pieces of code, creating parent directories for your new source files, and add the newly created files (and directories) in the SVN repository.
It can be [...]]]></description>
			<content:encoded><![CDATA[<p>RabbitEdit is a nifty tool that allows easier Rabbit development and saves you quite some time and effort.<br />
Its purpose is to automatically do particular common things for you, like writing pieces of code, creating parent directories for your new source files, and add the newly created files (and directories) in the SVN repository.<br />
It can be found in rabbit/etc/rabbitedit/ and its installation is as simple as:</p>
<p><pre class="php"><span style="color: #808080; font-style: italic;"># make install </span></pre><br />
You can uninstall it similarly, running:</p>
<p><pre class="php"><span style="color: #808080; font-style: italic;"># make uninstall </span></pre><br />
Its configuration file can be found at /etc/rabbitedit/rabbitedit.conf and follows the common configuration rules used by the most programs.<br />
You can see how it works, by issuing:</p>
<p><pre class="php">$ rabbitedit --help</pre><br />
A simple example of its usage, could be the following:</p>
<p><pre class="php">$ rabbitedit --parents --svn libs/customer/settings.php</pre><br />
Let&#8217;s assume you are in the root directory of your rabbit project. By running the above, RabbitEdit creates libs/customer/ if it does not exist (this is indicated by the &#8220;&#8211;parents&#8221; option), adds that directory to the SVN repository (indicated by &#8220;&#8211;svn&#8221;) as well as libs/customer/settings.php, and if settings.php did not exist before, it creates it and writes a standard piece of code in it (having the information that the file is a lib, and is about the settings of customers). If the file existed before, it leaves it as it was. Then, it opens the file with the source code editor of your choice.</p>
<p>RabbitEdit is written in Python, and is designed with the hope it fastens up the development of Rabbit projects and gives developers the chance to avoid drudgery, and focus on really important things, like actually coding.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kamibu.com/2008/10/04/rabbitedit/feed/</wfw:commentRss>
		</item>
		<item>
		<title>&#8220;echo&#8221; and &#8220;md5sum&#8221;</title>
		<link>http://blog.kamibu.com/2008/10/04/echo-and-md5sum/</link>
		<comments>http://blog.kamibu.com/2008/10/04/echo-and-md5sum/#comments</comments>
		<pubDate>Sat, 04 Oct 2008 18:37:24 +0000</pubDate>
		<dc:creator>Indy</dc:creator>
		
		<category><![CDATA[Linux]]></category>

		<category><![CDATA[MySQL]]></category>

		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://blog.kamibu.com/?p=53</guid>
		<description><![CDATA[A problem I faced when I attempted to manually set a password for my user in Water, was that I could not login. I created the md5 sum of my password, running:
$ echo mypassword&#124;md5sum
and pasted it into the MySQL field of phpMyAdmin. After many login failures and enough searching about what is to blame, Kostis90gr [...]]]></description>
			<content:encoded><![CDATA[<p>A problem I faced when I attempted to manually set a password for my user in Water, was that I could not login. I created the md5 sum of my password, running:</p>
<p><pre class="php">$ <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> mypassword|md5sum</pre></p>
<p>and pasted it into the MySQL field of phpMyAdmin. After many login failures and enough searching about what is to blame, Kostis90gr found out that &#8220;echo&#8221;, is outputting a newline at the end of the string, so the md5 sum produced from the command above, was different than the one produced from PHP&#8217;s md5() function, simply because they were given different input. So, the right thing to do, is to pass &#8220;echo&#8221; the &#8220;-n&#8221; option, like:</p>
<p><pre class="php">$ <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> -n mypassword|md5sum</pre></p>
<p>which prevents &#8220;echo&#8221; from outputting a newline at the end of the string.<br />
I hope this post is helpful, because my unawareness of this &#8220;echo&#8221;&#8217;s little &#8220;particularity&#8221;, caused me quite enough frustration.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kamibu.com/2008/10/04/echo-and-md5sum/feed/</wfw:commentRss>
		</item>
		<item>
		<title>A Brief History of Comments</title>
		<link>http://blog.kamibu.com/2008/10/01/a-brief-history-of-comments/</link>
		<comments>http://blog.kamibu.com/2008/10/01/a-brief-history-of-comments/#comments</comments>
		<pubDate>Wed, 01 Oct 2008 16:16:41 +0000</pubDate>
		<dc:creator>kostis90gr</dc:creator>
		
		<category><![CDATA[Excalibur]]></category>

		<category><![CDATA[comment system v.0]]></category>

		<guid isPermaLink="false">http://blog.kamibu.com/?p=50</guid>
		<description><![CDATA[A quick first try to draw the commenting system of http://www.zino.gr
]]></description>
			<content:encoded><![CDATA[<p>A quick first try to draw the commenting system of <a title="Zino" href="http://www.zino.gr" target="_blank">http://www.zino.gr</a></p>
<div id="attachment_51" class="wp-caption alignnone" style="width: 310px"><a href="http://blog.kamibu.com/wp-content/uploads/2008/10/commenting.jpg"><img class="size-medium wp-image-51" title="commenting" src="http://blog.kamibu.com/wp-content/uploads/2008/10/commenting-300x225.jpg" alt="Commenting" width="300" height="225" /></a><p class="wp-caption-text">Commenting</p></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.kamibu.com/2008/10/01/a-brief-history-of-comments/feed/</wfw:commentRss>
		</item>
		<item>
		<title>vim regexp magic</title>
		<link>http://blog.kamibu.com/2008/09/23/vim-regexp-magic/</link>
		<comments>http://blog.kamibu.com/2008/09/23/vim-regexp-magic/#comments</comments>
		<pubDate>Tue, 23 Sep 2008 14:12:42 +0000</pubDate>
		<dc:creator>dionyziz</dc:creator>
		
		<category><![CDATA[Regular Expressions]]></category>

		<guid isPermaLink="false">http://blog.kamibu.com/?p=44</guid>
		<description><![CDATA[Input, this one big liner:
function UnitUserSettingsSave( tInteger $dobd, tInteger $dobm, tInteger $doby, tText $gender, tInteger $place, tInteger $education, tInteger $school, tInteger $mood, tText $sex, tText $religion, tText $politics, tText $slogan, tText $aboutme, tText $favquote, tText $haircolor, tText $eyecolor, tInteger $height, tInteger $weight, tText $smoker, tText $drinker, tText $email, tText $msn, tText $gtalk, tText $skype, tText [...]]]></description>
			<content:encoded><![CDATA[<p>Input, this one big liner:</p>
<p>function UnitUserSettingsSave( tInteger $dobd, tInteger $dobm, tInteger $doby, tText $gender, tInteger $place, tInteger $education, tInteger $school, tInteger $mood, tText $sex, tText $religion, tText $politics, tText $slogan, tText $aboutme, tText $favquote, tText $haircolor, tText $eyecolor, tInteger $height, tInteger $weight, tText $smoker, tText $drinker, tText $email, tText $msn, tText $gtalk, tText $skype, tText $yahoo, tText $web, tText $oldpassword, tText $newpassword, tText $emailprofilecomment, tText $notifyprofilecomment, tText $emailphotocomment, tText $notifyphotocomment, tText $emailpollcomment, tText $notifypollcomment, tText $emailjournalcomment, tText $notifyjournalcomment, tText $emailreply, tText $notifyreply, tText $emailfriendaddition, tText $notifyfriendaddition, tText $emailtagcreation, tText $notifytagcreation, tText $emailfavourite, tText $notifyfavourite ) {</p>
<p>Output, this beautifully spaced multiliner:</p>
<p><pre class="php"><span style="color: #000000; font-weight: bold;">function</span> UnitUserSettingsSave<span style="color: #66cc66;">&#40;</span> tInteger <span style="color: #0000ff;">$dobd</span>, tInteger <span style="color: #0000ff;">$dobm</span>,
          tInteger <span style="color: #0000ff;">$doby</span>, tText <span style="color: #0000ff;">$gender</span>,
          tInteger <span style="color: #0000ff;">$place</span>, tInteger <span style="color: #0000ff;">$education</span>,
          tInteger <span style="color: #0000ff;">$school</span>, tInteger <span style="color: #0000ff;">$mood</span>,
          tText <span style="color: #0000ff;">$sex</span>, tText <span style="color: #0000ff;">$religion</span>,
          tText <span style="color: #0000ff;">$politics</span>, tText <span style="color: #0000ff;">$slogan</span>,
          tText <span style="color: #0000ff;">$aboutme</span>, tText <span style="color: #0000ff;">$favquote</span>,
          tText <span style="color: #0000ff;">$haircolor</span>, tText <span style="color: #0000ff;">$eyecolor</span>,
          tInteger <span style="color: #0000ff;">$height</span>, tInteger <span style="color: #0000ff;">$weight</span>,
          tText <span style="color: #0000ff;">$smoker</span>, tText <span style="color: #0000ff;">$drinker</span>,
          tText <span style="color: #0000ff;">$email</span>, tText <span style="color: #0000ff;">$msn</span>,
          tText <span style="color: #0000ff;">$gtalk</span>, tText <span style="color: #0000ff;">$skype</span>,
          tText <span style="color: #0000ff;">$yahoo</span>, tText <span style="color: #0000ff;">$web</span>,
          tText <span style="color: #0000ff;">$oldpassword</span>, tText <span style="color: #0000ff;">$newpassword</span>,
          tText <span style="color: #0000ff;">$emailprofilecomment</span>, tText <span style="color: #0000ff;">$notifyprofilecomment</span>,
          tText <span style="color: #0000ff;">$emailphotocomment</span>, tText <span style="color: #0000ff;">$notifyphotocomment</span>,
          tText <span style="color: #0000ff;">$emailpollcomment</span>, tText <span style="color: #0000ff;">$notifypollcomment</span>,
          tText <span style="color: #0000ff;">$emailjournalcomment</span>, tText <span style="color: #0000ff;">$notifyjournalcomment</span>,
          tText <span style="color: #0000ff;">$emailreply</span>, tText <span style="color: #0000ff;">$notifyreply</span>,
          tText <span style="color: #0000ff;">$emailfriendaddition</span>, tText <span style="color: #0000ff;">$notifyfriendaddition</span>,
          tText <span style="color: #0000ff;">$emailtagcreation</span>, tText <span style="color: #0000ff;">$notifytagcreation</span>,
          tText <span style="color: #0000ff;">$emailfavourite</span>, tText <span style="color: #0000ff;">$notifyfavourite</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></pre></p>
<p>How? With one command, in vim:</p>
<p><pre class="php">:s/\<span style="color: #66cc66;">&#40;</span>.\<span style="color: #66cc66;">&#123;</span><span style="color: #cc66cc;">-1</span>,<span style="color: #66cc66;">&#125;</span>\<span style="color: #66cc66;">&#41;</span>,\<span style="color: #66cc66;">&#40;</span>.\<span style="color: #66cc66;">&#123;</span><span style="color: #cc66cc;">-1</span>,<span style="color: #66cc66;">&#125;</span>\<span style="color: #66cc66;">&#41;</span>,/\<span style="color: #cc66cc;">1</span>,\<span style="color: #cc66cc;">2</span>,\r        /ig</pre></p>
<p>What does it do? </p>
<p>First off, :s/<em>needle</em>/<em>replacement</em>/g searches the current line for regular expression <em>needle</em> and replaces it with expression <em>replacement</em>. The current line is being searched because we didn&#8217;t specify a range before the &#8220;s&#8221;. &#8220;s&#8221; is the extended command that we&#8217;re running, which stands for &#8220;search and replace&#8221;. The &#8220;g&#8221; modifier after the final slash stands for &#8220;global&#8221;, meaning it should feel free to replace several occurrences in the same line, not just the first.</p>
<p>Now, for the <em>needle</em> expression. It can be essentially split into two parts:<br />
1) \(.\{-1,}\),<br />
2) \(.\{-1,}\),</p>
<p>These two expressions match exactly the same thing. They match anything they want, denoted with a dot, followed by a comma (the one that you see at the end of each expression). The &#8220;anything they want part&#8221; denoted with a single dot is just one character, so we&#8217;re modifying it to be able to match more than just one character (as many as it needs to satisfy the comma at the end) by adding the lazy quantifier \{-1,} after the dot.</p>
<p>The expression .\{-1,} means: match as many of any characters as you need to match the whole expression. In reality, because this is a lazy quantifier, it matches as less characters as possible providing it can find a comma right afterwards (but not the comma itself).</p>
<p>So both expressions tied together match anything followed by a comma followed by anything followed by a comma. Translation? They match two of the arguments of those provided in the function argument list.</p>
<p>The parentheses around each of them denoted \( and \) capture what is within, to be used in the replacement string. Our replacement string is simply &#8220;\1,\2,\r        &#8220;. It will replace \1 with the first parenthesized match, then add a comma, then replace the \2 with the second parenthesized match, then add yet another comma. Finally it will add a new line (\r) and some whitespace.</p>
<p>Repeating this pattern with the &#8220;global&#8221; modifier applies the regular expression several times on the line, yielding to new lines being added after every second argument.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kamibu.com/2008/09/23/vim-regexp-magic/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Kamibu Workroom</title>
		<link>http://blog.kamibu.com/2008/09/17/kamibu-workroom/</link>
		<comments>http://blog.kamibu.com/2008/09/17/kamibu-workroom/#comments</comments>
		<pubDate>Wed, 17 Sep 2008 09:21:20 +0000</pubDate>
		<dc:creator>dionyziz</dc:creator>
		
		<category><![CDATA[Excalibur]]></category>

		<guid isPermaLink="false">http://blog.kamibu.com/?p=41</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p><img src="http://images.zino.gr/media/1/117270/117270_full.jpg" alt="Kamibu Workroom" /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kamibu.com/2008/09/17/kamibu-workroom/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Overloading in PHP must use public methods</title>
		<link>http://blog.kamibu.com/2008/07/25/overloading-in-php-must-use-public-methods/</link>
		<comments>http://blog.kamibu.com/2008/07/25/overloading-in-php-must-use-public-methods/#comments</comments>
		<pubDate>Fri, 25 Jul 2008 17:55:10 +0000</pubDate>
		<dc:creator>dionyziz</dc:creator>
		
		<category><![CDATA[Linux]]></category>

		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://blog.kamibu.com/?p=40</guid>
		<description><![CDATA[The magically overloading methods in PHP, such as __get, and __set must be public according to The PHP Manual.
Aleksis recently pointed that out to me by making his new methods public, which gave me the initiative to look it up at the manual.
I thought this script to convert them might end up being useful to [...]]]></description>
			<content:encoded><![CDATA[<p>The magically overloading methods in PHP, such as __get, and __set must be public according to <a href="http://gr.php.net/manual/en/language.oop5.overloading.php">The PHP Manual</a>.</p>
<p><a href="http://www.kamibu.com/about/abresas">Aleksis</a> recently pointed that out to me by making his new methods public, which gave me the initiative to look it up at the manual.</p>
<p>I thought this script to convert them might end up being useful to others, too:<br />
<pre class="bash"><span style="color: #b1b100;">for</span> i <span style="color: #b1b100;">in</span> `find -iname <span style="color: #ff0000;">&quot;*.php&quot;</span>
               |xargs egrep -i <span style="color: #ff0000;">&quot;(private|protected) function __(get|set)&quot;</span>
               |awk -F: <span style="color: #ff0000;">'{print $1}'</span>`
<span style="color: #b1b100;">do</span> 
sed <span style="color: #ff0000;">'s/<span style="color: #000099; font-weight: bold;">\(</span>private<span style="color: #000099; font-weight: bold;">\|</span>protected<span style="color: #000099; font-weight: bold;">\)</span> function __<span style="color: #000099; font-weight: bold;">\(</span>get<span style="color: #000099; font-weight: bold;">\|</span>set<span style="color: #000099; font-weight: bold;">\)</span>/public function __<span style="color: #000099; font-weight: bold;">\2</span>/'</span> <span style="color: #0000ff;">$i</span> &gt;<span style="color: #0000ff;">$i</span>.processed;
mv <span style="color: #0000ff;">$i</span>.processed <span style="color: #0000ff;">$i</span>
<span style="color: #b1b100;">done</span></pre></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kamibu.com/2008/07/25/overloading-in-php-must-use-public-methods/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Frontend optimizations</title>
		<link>http://blog.kamibu.com/2008/06/15/frontend-optimizations/</link>
		<comments>http://blog.kamibu.com/2008/06/15/frontend-optimizations/#comments</comments>
		<pubDate>Sun, 15 Jun 2008 20:35:22 +0000</pubDate>
		<dc:creator>Izual</dc:creator>
		
		<category><![CDATA[CSS]]></category>

		<category><![CDATA[Excalibur]]></category>

		<category><![CDATA[Javascript]]></category>

		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.kamibu.com/?p=39</guid>
		<description><![CDATA[In Excalibur Phoenix one aspect we are giving major attention to is frontend.
In contrast to Excalibur Reloaded (the previous version) we try not only to provide a user-friendly interface but we also want it to be as fast as possible for the client. The latter is mostly a need that came up as more and [...]]]></description>
			<content:encoded><![CDATA[<p>In Excalibur Phoenix one aspect we are giving major attention to is frontend.</p>
<p>In contrast to Excalibur Reloaded (the previous version) we try not only to provide a user-friendly interface but we also want it to be as fast as possible for the client. The latter is mostly a need that came up as more and more users started using Zino. Furthermore,  through the process of optimization we learn new techniques we weren&#8217;t keen with, that extend by far our knowledge especially on the way the browsers render a page and the lower level mechanisms that play a major part when there is a greater need for speed (the term is stolen from Google Blog <img src='http://blog.kamibu.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> ). So I want to write a few lines for some optimizations we started implementing in the new version.</p>
<p>1) Lessen HTTP requests</p>
<p>One of the most important aspects is to lessen the HTTP requests that are needed for a page to show properly. Till now, our pages had icons, images, many stylesheets and scripts. Each of those needed a separate HTTP request in order to download since all these files were separated. For example, we used to have the stylesheet for the user profile on a different file from the one for the frontpage.  What we do now, is combine all the scripts in one file, all the stylsheets in another and so we use just two separate files for all our styling and javascript. Another thing we did is known with the term &#8220;spriting&#8221;. We combined all of our background images into one bigger image file. Everytime we need to show an icon, we use this image we created as a source and through the background-position we specify exactly which icon we want to be visible. Those are the most common and effective ways we are currently using in Phoenix</p>
<p>2) Cache content</p>
<p>Another way of reducing HTTP requests and the weight of downloading for the client is to use caching. More specifically caching with far-future headers set. To make things a bit clearer if the browser has cached some of the needed components he has to check whether those are valid according to the Last-Modified header in the response. If the component hasn&#8217;t been modified there is no need to download it, so the size of the download decreases.  Though a request has been made, that could have been avoided if we used an Expires header. When we set an expires header, we are actually telling the browser to use the components in its cache till a specified date.  Until this expiry date the browser uses its cached content without the need to ask for modification of the content. This is more useful with static data such as javascript, stylesheets and icons.</p>
<p>3) Minification</p>
<p>In projects where great amount of javascript is in use, minifying the code makes a lot sense. With the term minification we mean the elimination of spaces, line breaks and comments from the original code. In other words all unnecessary stuff is removed in order to lessen the size of the data the client will download. This technique can also be used for stylesheets but is not so effective. Stylesheets optimization is a bit more complex, as you can get the most of it if you find duplicate rules for elements and remove them. Some developers go a step further with obfuscation but I believe it&#8217;s not worth. In obfuscation variable and function names are changed automatically to shorter ones, in order to reduce even more the size. Another reason for using obfuscation is to make the code unreadable to others. Implementing this technique is not as simple as minification and using it should be examined carefully as bugs are likely to appear because of core function name substitution.</p>
<p>4) Gzipping content</p>
<p>One last technique worth mentioning is to use gzip compression. The use of this technique is pretty obvious. Compression reduces download sizes leading to faster downstreaming times for the client. Gzipping is supported by almost all modern browsers so it doesn&#8217;t need further browser compatibility thoughts. This technique is more effective when combined with the others described. Minification combined with gzip compression decreases significantly the size of the content. To use it though the web server should be configured properly.</p>
<p>Last but not least few simple things to look after are: avoiding duplicate script inclusion, loading stylesheets at the beginning of the document, scripts at the bottom and sometimes clever content preloading that will be needed later on, while the user is interacting with other parts of the page.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kamibu.com/2008/06/15/frontend-optimizations/feed/</wfw:commentRss>
		</item>
		<item>
		<title>jQuery Style Rules</title>
		<link>http://blog.kamibu.com/2008/06/12/jquery-style-rules/</link>
		<comments>http://blog.kamibu.com/2008/06/12/jquery-style-rules/#comments</comments>
		<pubDate>Thu, 12 Jun 2008 21:57:13 +0000</pubDate>
		<dc:creator>kostis90gr</dc:creator>
		
		<category><![CDATA[Javascript]]></category>

		<category><![CDATA[jQuery]]></category>

		<category><![CDATA[rules]]></category>

		<category><![CDATA[style]]></category>

		<guid isPermaLink="false">http://blog.kamibu.com/?p=38</guid>
		<description><![CDATA[In Excalibur Phoenix a really powerful JavaScript library is used, jQuery. It allows developers to create JavaScript code fast, using only a few lines, and also offers a great variety of features that make coding life easier. jQuery code, though, doesn&#8217;t have many similarities with regular JavaScript DOM code. This post contains a few suggestions [...]]]></description>
			<content:encoded><![CDATA[<p>In Excalibur Phoenix a really powerful JavaScript library is used, <a href="http://jquery.com">jQuery</a>. It allows developers to create JavaScript code fast, using only a few lines, and also offers a great variety of features that make coding life easier. jQuery code, though, doesn&#8217;t have many similarities with regular JavaScript DOM code. This post contains a few suggestions about how Kamibu developers should write jQuery code. Before you start reading this post, please take a quick look on <a href="http://www.dionyziz.com/Style">this<br />
article</a>, since those style rules should be also applied whenever possible.</p>
<p>1) jQuery allows developers to execute more than one jQuery class methods using a technique called method chaining. Method Chaining should be used to the maximum by Kamibu developers.</p>
<p><em>Do not use this:</em><br />
<pre class="php">$<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;div.newcomment&quot;</span> <span style="color: #66cc66;">&#41;</span>.clone<span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">true</span> <span style="color: #66cc66;">&#41;</span>;
$<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;div.newcomment&quot;</span> <span style="color: #66cc66;">&#41;</span>.css<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;opacity&quot;</span>, <span style="color: #cc66cc;">0</span> <span style="color: #66cc66;">&#41;</span>.removeClass<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;newcomment&quot;</span> <span style="color: #66cc66;">&#41;</span>;</pre><br />
<em>Use this instead:</em><br />
<pre class="php">$<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;div.newcomment&quot;</span> <span style="color: #66cc66;">&#41;</span>.clone<span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">true</span> <span style="color: #66cc66;">&#41;</span>.css<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;opacity&quot;</span>, <span style="color: #cc66cc;">0</span> <span style="color: #66cc66;">&#41;</span>.removeClass<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;newcomment&quot;</span> <span style="color: #66cc66;">&#41;</span>;</pre></p>
<p>The first example is not as fast as the second, since two DOM searches are performed.</p>
<p>2) Sometimes, however, chaining makes the code complex and difficult to read, especially when find() is used a lot of times. Therefore, when end() is used, the developer should change a line exactly after it.</p>
<p><em>Do not use this:</em><br />
<pre class="php">$<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;div.comments&quot;</span> <span style="color: #66cc66;">&#41;</span>.find<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;span.time&quot;</span> <span style="color: #66cc66;">&#41;</span>.text<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;πριν λίγο&quot;</span> <span style="color: #66cc66;">&#41;</span>.<a href="http://www.php.net/end"><span style="color: #000066;">end</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.find<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;div.text&quot;</span> <span style="color: #66cc66;">&#41;</span>.<a href="http://www.php.net/empty"><span style="color: #000066;">empty</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.append<span style="color: #66cc66;">&#40;</span> document.createTextNode<span style="color: #66cc66;">&#40;</span> texter <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>.<a href="http://www.php.net/end"><span style="color: #000066;">end</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</pre><br />
<em>Use this instead:</em><br />
<pre class="php">$<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;div.comments&quot;</span> <span style="color: #66cc66;">&#41;</span>.find<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;span.time&quot;</span> <span style="color: #66cc66;">&#41;</span>.text<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;πριν λίγο&quot;</span> <span style="color: #66cc66;">&#41;</span>.<a href="http://www.php.net/end"><span style="color: #000066;">end</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
.find<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;div.text&quot;</span> <span style="color: #66cc66;">&#41;</span>.<a href="http://www.php.net/empty"><span style="color: #000066;">empty</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.append<span style="color: #66cc66;">&#40;</span> document.createTextNode<span style="color: #66cc66;">&#40;</span> texter <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>.<a href="http://www.php.net/end"><span style="color: #000066;">end</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</pre></p>
<p>3) This new JavaScript library provides a lot of ways to select a DOM node, apart from getElementById and getElementsByTagName. You should always use jQuery selectors, before trying to find another way to select the node you want.</p>
<p><em>Do not use this:</em><br />
<pre class="php"><span style="color: #000000; font-weight: bold;">var</span> node = $<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;div.comments&quot;</span> <span style="color: #66cc66;">&#41;</span>.get<span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">0</span> <span style="color: #66cc66;">&#41;</span>;
node = node.childNodes<span style="color: #66cc66;">&#91;</span> node.childNodes.length<span style="color: #cc66cc;">-1</span> <span style="color: #66cc66;">&#93;</span>;</pre><br />
<em>Use this instead:</em><br />
<pre class="php"><span style="color: #000000; font-weight: bold;">var</span> node = $<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;div.comments:last-child&quot;</span> <span style="color: #66cc66;">&#41;</span>.get<span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">0</span> <span style="color: #66cc66;">&#41;</span>;</pre></p>
<p><em>And do not use this:</em><br />
<pre class="php"><span style="color: #000000; font-weight: bold;">var</span> node = $<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;div.comments&quot;</span> <span style="color: #66cc66;">&#41;</span>.eq<span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">0</span> <span style="color: #66cc66;">&#41;</span>;</pre><br />
<em>Use this instead:</em><br />
<pre class="php"><span style="color: #000000; font-weight: bold;">var</span> node = $<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;div.comments:first&quot;</span> <span style="color: #66cc66;">&#41;</span>;</pre></p>
<p>4) Even though selectors could become really long, do not break them into parts, unless you have a good reason to do so.</p>
<p><em>Do not use this:</em><br />
<pre class="php">$<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;#dilution div.comments div.text&quot;</span> <span style="color: #66cc66;">&#41;</span>.find<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;div div:last-child&quot;</span> <span style="color: #66cc66;">&#41;</span>;</pre><br />
<em>Use this instead:</em><br />
<pre class="php">$<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;#dilution div.comments div.text div div:last-child&quot;</span> <span style="color: #66cc66;">&#41;</span>;</pre></p>
<p>5) When you want to create a node and append it to an element do not use jQuery&#8217;s append method using a string as an argument. Firstly, create the element you want using DOM JavaScript, and then append it to the node you want. This solution should be preffered since it is more object-oriented. Use jQuery&#8217;s append( &#8220;string&#8221; ) only when you would use innerHTML in normal DOM</p>
<p><em>Do not use this:</em><br />
<pre class="php">$<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;div.bottom&quot;</span> <span style="color: #66cc66;">&#41;</span>.append<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;&lt;a href='http://www.zino.gr'&gt;Click Me&lt;/a&gt;&quot;</span> <span style="color: #66cc66;">&#41;</span>;</pre><br />
<em>Use this instead:</em><br />
<pre class="php"><span style="color: #000000; font-weight: bold;">var</span> a = document.createElement<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">'a'</span> <span style="color: #66cc66;">&#41;</span>;
a.href = <span style="color: #ff0000;">&quot;http://www.zino.gr&quot;</span>;
a.appendChild<span style="color: #66cc66;">&#40;</span> document.createTextNode<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">'Click Me'</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>;
$<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;div.bottom&quot;</span> <span style="color: #66cc66;">&#41;</span>.append<span style="color: #66cc66;">&#40;</span> a <span style="color: #66cc66;">&#41;</span>;</pre></p>
<p>6) Always try to use jQuery&#8217;s characteristics as much as you can, before you try to find another &#8220;manual&#8221; way. A characteristic example is jQuery&#8217;s <a href="http://docs.jquery.com/Attributes/toggleClass">toggleClass</a> method.</p>
<p>7) Always prefer jQuery&#8217;s events except for the following situations.<br />
        7.1 When a DOM element that will be appended is going to be bound to an event.<br />
        7.2 When an argument from backend is going to be used.<br />
                   <em>You should use this:</em><br />
                   <pre class="php"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
				<span style="color: #0000ff;">$foo</span> = <span style="color: #cc66cc;">5</span>;
			?&gt;&lt;a onclick=<span style="color: #ff0000;">&quot;function() { alert( &lt;?php
			echo $foo;
			?&gt; );return false;&quot;</span> &gt;Test&lt;/a&gt;</pre><br />
         7.3 When an event that was not bounded by jQuery is going to be replaced.<br />
                   <em>Do not use this:</em><br />
                   <pre class="php"><span style="color: #000000; font-weight: bold;">var</span> a = document.createElement<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">'a'</span> <span style="color: #66cc66;">&#41;</span>;
		a.onclick = <span style="color: #000000; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> 
			alert<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">'lolek'</span> <span style="color: #66cc66;">&#41;</span>; 
		<span style="color: #66cc66;">&#125;</span>;
		$<span style="color: #66cc66;">&#40;</span>a<span style="color: #66cc66;">&#41;</span>.click<span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> alert<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">'bolek'</span> <span style="color: #66cc66;">&#41;</span>; <span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#41;</span>;</pre><br />
                   <em>Use this instead:</em><br />
                   <pre class="php"><span style="color: #000000; font-weight: bold;">var</span> a = document.createElement<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">'a'</span> <span style="color: #66cc66;">&#41;</span>;
		a.onclick = <span style="color: #000000; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> 
			alert<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">'lolek'</span> <span style="color: #66cc66;">&#41;</span>; 
		<span style="color: #66cc66;">&#125;</span>;
		a.onclick = <span style="color: #000000; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
			alert<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">'bolek'</span> <span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>;</pre></p>
<p>                  <strong>Notice:</strong> Keep in mind that jQuery supports multiple events. The first example, will just add another function to be executed when a is clicked. So two alerts will pop up (lolek,bolek). Moreover, the unbind method cannot be used since the first event was not bounded using jQuery.</p>
<p>8 ) Use fadeIn, fadeOut, fadeTo, show, hide methods, instead of the more general animate method, whenever possible.</p>
<p><em>Do not use this:</em><br />
<pre class="php">$<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">'chiki'</span> <span style="color: #66cc66;">&#41;</span>.animate<span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#123;</span> opacity : <span style="color: #cc66cc;">0</span> <span style="color: #66cc66;">&#125;</span>, <span style="color: #cc66cc;">400</span> <span style="color: #66cc66;">&#41;</span>;</pre><br />
<em>Use this instead:</em><br />
<pre class="php">$<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">'chiki'</span> <span style="color: #66cc66;">&#41;</span>.fadeOut<span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">400</span> <span style="color: #66cc66;">&#41;</span>;</pre></p>
<p>9) Prefer jQuery&#8217;s methods instead of the body&#8217;s onload event.</p>
<p><em>Do not use this:</em><br />
<pre class="php">&lt;body onload=<span style="color: #ff0000;">&quot;alert( 'done' );&quot;</span>&gt;&lt;/body&gt;</pre><br />
<em>Use this instead:</em><br />
<pre class="php">$<span style="color: #66cc66;">&#40;</span>document<span style="color: #66cc66;">&#41;</span>.ready<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
		alert<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">'done'</span> <span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#41;</span>;</pre></p>
<p>Moreover,<br />
<em>Do not use this:</em><br />
<pre class="php">$<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
		alert<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">'done'</span> <span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#41;</span>;</pre><br />
<em>Use this instead:</em><br />
<pre class="php">$<span style="color: #66cc66;">&#40;</span>document<span style="color: #66cc66;">&#41;</span>.ready<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
		alert<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">'done'</span> <span style="color: #66cc66;">&#41;</span>;
	<span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#41;</span>;</pre></p>
<p><strong>Notice:</strong> Use &#8220;jQuery(function($) {&#8221; format only when absolutely necessary</p>
<p>10) Always prefer $( &#8217;something&#8217; ) instead of jQuery( &#8217;something&#8217; ), unless a compatibility issue emerges.</p>
<p>11) Kamibu Specific:<br />
        11.1 Use jQuery&#8217;s effects instead of the objects of animation.js<br />
               <em>Do not use this:</em><br />
               <pre class="php">Animations.Create<span style="color: #66cc66;">&#40;</span> document.getElementById<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">'fire'</span> <span style="color: #66cc66;">&#41;</span> , <span style="color: #ff0000;">'opacity'</span> , <span style="color: #cc66cc;">2000</span> , <span style="color: #cc66cc;">1</span> , <span style="color: #cc66cc;">0.3</span> <span style="color: #66cc66;">&#41;</span>;</pre><br />
                <em>Use this instead:</em><br />
                <pre class="php">$<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">'#fire'</span> <span style="color: #66cc66;">&#41;</span>.css<span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">'opacity'</span>, <span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">&#41;</span>.fadeTo<span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">2000</span>, <span style="color: #cc66cc;">0.3</span> <span style="color: #66cc66;">&#41;</span>;</pre><br />
        11.2 Prefer Coala instead of jQuery.ajax</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kamibu.com/2008/06/12/jquery-style-rules/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Which &#8220;false&#8221; is it?</title>
		<link>http://blog.kamibu.com/2008/05/27/which-false-is-it/</link>
		<comments>http://blog.kamibu.com/2008/05/27/which-false-is-it/#comments</comments>
		<pubDate>Tue, 27 May 2008 18:38:02 +0000</pubDate>
		<dc:creator>dionyziz</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://blog.kamibu.com/?p=37</guid>
		<description><![CDATA[dionyziz@turing ~ $ cat test.php
&#60;?php
    class false &#123;
    &#125;
&#160;
    $c = New false&#40;&#41;;
    echo get_class&#40; $c &#41;;
?&#62;
&#160;
dionyziz@turing ~ $ php test.php
false
dionyziz@turing ~ $
]]></description>
			<content:encoded><![CDATA[<p><pre class="php">dionyziz@turing ~ $ cat test.php
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
    <span style="color: #000000; font-weight: bold;">class</span> <span style="color: #000000; font-weight: bold;">false</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #66cc66;">&#125;</span>
&nbsp;
    <span style="color: #0000ff;">$c</span> = <span style="color: #000000; font-weight: bold;">New</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
    <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <a href="http://www.php.net/get_class"><span style="color: #000066;">get_class</span></a><span style="color: #66cc66;">&#40;</span> <span style="color: #0000ff;">$c</span> <span style="color: #66cc66;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
dionyziz@turing ~ $ php test.php
<span style="color: #000000; font-weight: bold;">false</span>
dionyziz@turing ~ $</pre></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kamibu.com/2008/05/27/which-false-is-it/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
