<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.0" -->
<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/"
	>

<channel>
	<title>Matas Ideas and Thoughts</title>
	<link>http://blog.petrikas.de</link>
	<description>suddenly everything makes sense...</description>
	<pubDate>Sun, 03 Aug 2008 19:57:23 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0</generator>
	<language>en</language>
			<item>
		<title>Effective ActionScript: variable testing</title>
		<link>http://blog.petrikas.de/uncategorized/effective-actionscript-variable-testing/</link>
		<comments>http://blog.petrikas.de/uncategorized/effective-actionscript-variable-testing/#comments</comments>
		<pubDate>Wed, 28 Mar 2007 08:01:30 +0000</pubDate>
		<dc:creator>Matas Petrikas</dc:creator>
		
	<category>Uncategorized</category>
	<category>JavaScript</category>
	<category>ActionScript</category>
	<category>Front-End Programming</category>
		<guid isPermaLink="false">http://blog.petrikas.de/uncategorized/effective-actionscript-variable-testing/</guid>
		<description><![CDATA[It&#8217;s a pretty usual ActionScript code excerpt:

 if &#40;variable == true&#41;&#123; doSomething&#40;&#41;; &#125;
as you can see, the variable value is being tested here against its true value, which is a totally redundant action. A much more convenient style would be:

 if &#40;variable&#41;&#123; doSomething&#40;&#41;; &#125;
What so nice about this solution, that it can check any variable [...]]]></description>
			<content:encoded><![CDATA[It&#8217;s a pretty usual ActionScript code excerpt:

<code><pre> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">variable</span> == <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span> doSomething<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #66cc66;">&#125;</span></pre></code>
as you can see, the variable value is being tested here against its true value, which is a totally redundant action. A much more convenient style would be:

<code><pre> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">variable</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span> doSomething<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #66cc66;">&#125;</span></pre></code>
What so nice about this solution, that it can check any variable types for valid values. Both following tests work identically  : <code><pre>&nbsp;
<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">variable</span>:<span style="color: #0066CC;">Number</span> = <span style="color: #000000; font-weight: bold;">null</span>;
<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">variable</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span> doSomething<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">variable</span>:<span style="color: #0066CC;">String</span> = <span style="color: #0066CC;">undefined</span>;
<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">variable</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span> doSomething<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #66cc66;">&#125;</span></pre></code>]]></content:encoded>
			<wfw:commentRSS>http://blog.petrikas.de/uncategorized/effective-actionscript-variable-testing/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Effective ActionScript: Iteration</title>
		<link>http://blog.petrikas.de/flash/effective-actionscript-iterations/</link>
		<comments>http://blog.petrikas.de/flash/effective-actionscript-iterations/#comments</comments>
		<pubDate>Tue, 27 Mar 2007 09:12:47 +0000</pubDate>
		<dc:creator>Matas Petrikas</dc:creator>
		
	<category>Flash</category>
	<category>ActionScript</category>
	<category>Front-End Programming</category>
		<guid isPermaLink="false">http://blog.petrikas.de/front-end-programming/javascript/effective-actionscript-iterations/</guid>
		<description><![CDATA[This post was inspired by Volodja Kolesnikovs article about non-trivial syntax in JavaScript. ActionScript and JS are both ECMA languages, which is why these ideas could be aplied to AS programming too.

Take for example a &#8220;for&#8221; loop iteration. Here is a very usual example:

for&#40;var i = 0; i &#60; array.length; i++&#41;&#123;
// here comes iteration code
&#125;

The [...]]]></description>
			<content:encoded><![CDATA[This post was inspired by <a href="http://www.artlebedev.ru/tools/technogrette/js/likbez/">Volodja Kolesnikovs article</a> about non-trivial syntax in JavaScript. ActionScript and JS are both ECMA languages, which is why these ideas could be aplied to AS programming too.

Take for example a &#8220;for&#8221; loop iteration. Here is a very usual example:

<code><pre><span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i = <span style="color: #cc66cc;">0</span>; i &lt; <span style="color: #0066CC;">array</span>.<span style="color: #006600;">length</span>; i++<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
<span style="color: #808080; font-style: italic;">// here comes iteration code</span>
<span style="color: #66cc66;">&#125;</span></pre></code>

The problem is, it calls the array length every cycle, thus wasting CPU resources. A better soulution would be:

</code><code><pre><span style="color: #000000; font-weight: bold;">var</span> arrLength:<span style="color: #0066CC;">Number</span> = <span style="color: #0066CC;">array</span>.<span style="color: #006600;">length</span>;
<span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i = <span style="color: #cc66cc;">0</span>; i &lt; arrLength; i++<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
<span style="color: #808080; font-style: italic;">// here comes iteration code</span>
<span style="color: #66cc66;">&#125;</span></pre></code>

We&#8217;ve called array.length just once here, but also we&#8217;ve created a variable, which has probably no use outside of iteration loop. The prettier and more effective solution would be:

<code lang="actionscript" />

</code><code><pre>&nbsp;
<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i = <span style="color: #cc66cc;">0</span>, l = myArr.<span style="color: #006600;">length</span>; i &lt; l; i++<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
<span style="color: #808080; font-style: italic;">// here comes iteration code</span>
<span style="color: #66cc66;">&#125;</span></pre></code>

We&#8217;ve saved some CPU cycles, and packed all iteration code in one compact piece. I&#8217;ve rewritten Volodjas test script in AS so you could check it for yourself. It looks, that you can save up to 60-70% CPU cycles using the effective method.

<a id="p13" href="http://www.petrikas.de/WordPress/wp-content/uploads/2007/03/iteration_test.as">iteration_test.as</a>
</code><code><pre></pre></code>]]></content:encoded>
			<wfw:commentRSS>http://blog.petrikas.de/flash/effective-actionscript-iterations/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>How many times have I&#8230;</title>
		<link>http://blog.petrikas.de/front-end-programming/x-html/how-many-times-have-i/</link>
		<comments>http://blog.petrikas.de/front-end-programming/x-html/how-many-times-have-i/#comments</comments>
		<pubDate>Tue, 13 Mar 2007 11:05:40 +0000</pubDate>
		<dc:creator>Matas Petrikas</dc:creator>
		
	<category>(X)HTML</category>
	<category>Front-End Programming</category>
	<category>Accessibility</category>
		<guid isPermaLink="false">http://blog.petrikas.de/front-end-programming/x-html/how-many-times-have-i/</guid>
		<description><![CDATA[Just a short notice: next time you have to write 2&#215;2=4 or &#8220;2x faster!&#8221; in your code,  use a HTML entity times (Unicode No: 215) instead of small cap X.
More semantics — better Karma!]]></description>
			<content:encoded><![CDATA[<blockquote>Just a short notice: next time you have to write 2&#215;2=4 or &#8220;2x faster!&#8221; in your code,  use a HTML entity <code><pre>times</pre></code> (Unicode No: 215) instead of small cap X.</blockquote>
More semantics — better Karma!]]></content:encoded>
			<wfw:commentRSS>http://blog.petrikas.de/front-end-programming/x-html/how-many-times-have-i/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Soft-hyphen, &#038;Shy and word-wrapping problem solutions</title>
		<link>http://blog.petrikas.de/uncategorized/soft-hyphen-shy-and-word-wrapping-problem/</link>
		<comments>http://blog.petrikas.de/uncategorized/soft-hyphen-shy-and-word-wrapping-problem/#comments</comments>
		<pubDate>Fri, 16 Feb 2007 10:27:53 +0000</pubDate>
		<dc:creator>Matas Petrikas</dc:creator>
		
	<category>Uncategorized</category>
	<category>CSS</category>
	<category>(X)HTML</category>
	<category>Front-End Programming</category>
		<guid isPermaLink="false">http://blog.petrikas.de/uncategorized/soft-hyphen-shy-and-word-wrapping-problem/</guid>
		<description><![CDATA[If you&#8217;ve ever written CSS for a bigger website in some European language (other than English), you&#8217;ll know this problem:
your have built all the templates for a huge project, everything works perfect in all possible font-sizes and viewport-widths, even in the &#8220;bad&#8221; browsers, and then you get a call from your PM - he&#8217;s looking [...]]]></description>
			<content:encoded><![CDATA[If you&#8217;ve ever written CSS for a bigger website in some European language (other than English), you&#8217;ll know this problem:
your have built all the templates for a huge project, everything works perfect in all possible font-sizes and viewport-widths, even in the &#8220;bad&#8221; browsers, and then you get a call from your PM - he&#8217;s looking at the test version on development server and your layout seems to be &#8220;broken&#8221;&#8230; What do you mean by &#8220;broken&#8221;?

<a id="more-5"></a>
He tells you, he was testing the pages in a browser using a bigger text-size, and it&#8217;s all falling apart: navigation is too wide and the 3rd column is somewhere at the bottom of page&#8230; When you look at it yourself, you see that the problem is the list item labeled &#8220;Wirtschaftsgestaltung&#8221;. Where does it come from? I guess the navigation in your HTML template looked more like this:
<ul>
	<li>Lorem ipsum</li>
	<li>Lorem ipsum</li>
	<li>Lorem ipsum</li>
	<li>Lorem ipsum</li>
</ul>
<blockquote>Note for the next time: Always use real content! Repeate after me: Always use real content&#8230;</blockquote>
Once again, a simple proof how dumb HTML is - it has no soft hyphenation. Although, if you&#8217;ll google for it, you&#8217;ll learn about ­ entity ­­ ­ ­ — better leave your hopes now. It&#8217;s not going to work. No, not even in Firefox. <a href="http://www.cs.tut.fi/~jkorpela/personal.html">Jukka Korpela</a> wrote a very good <a href="http://www.cs.tut.fi/~jkorpela/shy.html">resource</a> about the shy fella.

I remember in 1992, when I was working at a local newspaper, every copytext that we would use in our PageMaker, had to be put through &#8220;Hyphenator&#8221;. So, when we build our layouts we wouldn&#8217;t care if some random word fits on a line or not. If it were too long, PageMaker would analyze it, find a possible hyphenation point(&#8221;Hyphenator&#8221; left it), break it in half and add a simple hyphen at the end of the line.
And why can&#8217;t your Firefox or your Safari do it for you? Well, the problem is, that there are simply too many languages and these languages have too many words. In some languages, like in my native lithuanian or in english, there are some simple rules for hyphenation - you separate the syllables. In german language though, the <a href="http://de.wikipedia.org/wiki/Neue_deutsche_Rechtschreibung#Worttrennung_am_Zeilenende">rules</a> are a little bit more complicated. I don&#8217;t think we are going to see some wide browser implementation soon. Unless, somebody decides to build a multilingual, extendable, open-source hyphenator.
<blockquote>Note: Microsoft has an <a href="http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/wordwrap.asp">hyphenating engine</a> built into IE. It doesn&#8217;t specify which languages are supported, i can just guess, that localized Windows fully supports at least English and the native(local) language.</blockquote>
Now we need some solution, and we need it fast.
<strong>Simple and </strong><strong>(almost) </strong><strong>perfect :</strong> put your navigation container in overflow:hidden; style mode. It&#8217;ll simply cut the remainder of the word if it gets too long for the container.
<strong>Pragmatic: </strong>if you got a separate stylesheet for IE, you can sweeten the pill for some users - give your &#8216;a&#8217; tag a non-standard (evil,evil) property  <span class="property"><a title="MSDN page for word-wrap atribute" href="http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/wordwrap.asp">word-wrap</a>:</span> break-word; and some specific width. Don&#8217;t forget to reset the overflow property in navigation container! overflow: auto;
<strong>Complicated: </strong>you write some custom JavaScript, that compares the text-size with word-length in navigation, and breaks the words in a right places (works only if the specific words are known).

I&#8217;m aware, that there could be some other solutions. If you have one, not listed here, please let me know!

Also, I&#8217;m totaly interested in non-European hyphenation problems. e.g. can you hyphenate a text written in <a href="http://en.wikipedia.org/wiki/Katakana">Katakana</a> or Arabic at all?]]></content:encoded>
			<wfw:commentRSS>http://blog.petrikas.de/uncategorized/soft-hyphen-shy-and-word-wrapping-problem/feed/</wfw:commentRSS>
		</item>
	</channel>
</rss>

