<?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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>
<channel>
	<title>all your code are belong to us</title>
	<atom:link href="http://allurcode.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://allurcode.com</link>
	<description>and all my code are belong to you</description>
	<lastBuildDate>Mon, 30 Aug 2010 18:41:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>JavaScript, return index of an element in array</title>
		<link>http://allurcode.com/2010/08/30/javascript-return-index-of-an-element-in-array/</link>
		<comments>http://allurcode.com/2010/08/30/javascript-return-index-of-an-element-in-array/#comments</comments>
		<pubDate>Mon, 30 Aug 2010 18:41:20 +0000</pubDate>
		<dc:creator>Wojtek Kosinski</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[fix]]></category>
		<category><![CDATA[ie]]></category>
		<category><![CDATA[index]]></category>
		<category><![CDATA[indexOf]]></category>
		<guid isPermaLink="false">http://allurcode.com/?p=374</guid>
		<description><![CDATA[Recently I&#8217;ve been working on a project with HTML5 &#60;video&#62; tag event handling and I needed to check if an element exists in the array. Quick googling resulted in neat native JavaScript method Array.indexOf. It returns the first index at which a given element can be found in the array, or -1 if it is [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I&#8217;ve been working on a <a href="http://allurcode.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2xvb2tib29rLm1vbnNvb24tYWNjZXNzb3JpemUuY28udWsv">project</a> with HTML5 &lt;video&gt; tag event handling and I needed to check if an element exists in the array. Quick googling resulted in neat native JavaScript method <em>Array.indexOf</em>. It returns the first index at which a given element can be found in the array, or -1 if it is not present. It all worked just fine in Firefox, Chrome and such.<br />
Why wasn&#8217;t I surprised when my script behaved a bit weird in Internet Explorer. After many hours of &#8220;fun&#8221; with IE JavaScript debugger, I found that none of IE&#8217;s support the Array.indexOf method.</p>
<p>Thanks to <a href="http://allurcode.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3NvbGVkYWRwZW5hZGVzLmNvbS8yMDA3LzA1LzE3L2FycmF5aW5kZXhvZi1pbi1pbnRlcm5ldC1leHBsb3Jlci8=">this post</a> I was able to quickly fix it by adding below code to my script.</p>
<pre class="brush: jscript;">
if(!Array.indexOf){
	Array.prototype.indexOf = function(obj){
		for(var i=0; i&lt;this.length; i++){
			if(this[i]===obj){
				return i;
			}
		}
		return -1;
	}
}
</pre>
<p>and the world was beautiful again.</p>
<p>&nbsp;</p>
 <img src="http://allurcode.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=374" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://allurcode.com/2010/08/30/javascript-return-index-of-an-element-in-array/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Multiple borders with CSS2</title>
		<link>http://allurcode.com/2010/07/06/multiple-borders-with-css2/</link>
		<comments>http://allurcode.com/2010/07/06/multiple-borders-with-css2/#comments</comments>
		<pubDate>Tue, 06 Jul 2010 10:18:45 +0000</pubDate>
		<dc:creator>Wojtek Kosinski</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[border]]></category>
		<category><![CDATA[multiple]]></category>
		<guid isPermaLink="false">http://allurcode.com/?p=353</guid>
		<description><![CDATA[How to make a div with multiple borders? Usual approach is to create a div with border then create another div inside that one with different border. We end up with lots of divs inside of another divs. If there only was an easier way to do it in CSS without the need of more [...]]]></description>
			<content:encoded><![CDATA[<h2>How to make a div with multiple borders?</h2>
<p>Usual approach is to create a div with border then create another div inside that one with different border. We end up with lots of divs inside of another divs. If there only was an easier way to do it in CSS without the need of more divs&#8230; There is!</p>
<h3>:before and :after pseudo classes</h3>
<p>Internet Explorer 6 and 7 does not support :before and :after pseudo classes and to be honest I couldn&#8217;t find a working fix for it. The good thing is that those dinosaurs are fading out from our lives.<br />
:before and :after pseudo classes allow to place text or an image before and after each HTML element using <em>content: &#8221;;</em> attribute. In below example <em>content</em> is empty as we need just a border.</p>
<pre class="brush: xml;">
&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;en&quot;&gt;
&lt;head&gt;
&lt;title&gt;Multiple borders with CSS2&lt;/title&gt;
&lt;meta charset=&quot;utf-8&quot; /&gt;
&lt;style&gt;
body { background: #fff; }
#box {
	float: left;
	position: relative;
	width: 100px;
	height: 100px;
	margin: 20px;
	border: #f00 solid 5px;
}
	#box:before {
		position: absolute;
		width: 90px;
		height: 90px;
		content: '';
		border: #0f0 solid 5px;
	}
	#box:after {
		position: absolute;
		left: 5px;
		top: 5px;
		width: 80px;
		height: 80px;
		content: '';
		border: #00f solid 5px;
	}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
	&lt;div id=&quot;box&quot;&gt;&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>Above code should result in:<br />
<img src="http://allurcode.com/wp-content/uploads/2010/07/multiple_borders.png" alt="Multiple borders with CSS" /></p>
<p>More information about :before and :after pseudo classes can be found <a href="http://allurcode.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy53My5vcmcvVFIvQ1NTMjEvZ2VuZXJhdGUuaHRtbCNiZWZvcmUtYWZ0ZXItY29udGVudA==">here</a></p>
<p>&nbsp;</p>
 <img src="http://allurcode.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=353" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://allurcode.com/2010/07/06/multiple-borders-with-css2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTML5 Where to start?</title>
		<link>http://allurcode.com/2010/06/15/html5-where-to-start/</link>
		<comments>http://allurcode.com/2010/06/15/html5-where-to-start/#comments</comments>
		<pubDate>Tue, 15 Jun 2010 13:16:55 +0000</pubDate>
		<dc:creator>Wojtek Kosinski</dc:creator>
				<category><![CDATA[HTML]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[markup]]></category>
		<category><![CDATA[semantic]]></category>
		<category><![CDATA[start]]></category>
		<category><![CDATA[tag]]></category>
		<guid isPermaLink="false">http://allurcode.com/?p=258</guid>
		<description><![CDATA[Everyone is excited about the new kid on the block &#8211; HTML5, but where to start and how to use it? There are couple of things you can start using right now with a few hacks for our lovely IE6 and other browsers not yet supporting HTML5. Before we get into it, it&#8217;s good to [...]]]></description>
			<content:encoded><![CDATA[<p>Everyone is excited about the new kid on the block &#8211; HTML5, but where to start and how to use it? There are couple of things you can start using right now with a few hacks for our lovely IE6 and other browsers not yet supporting HTML5. Before we get into it, it&#8217;s good to know the level of support of HTML5 in different browsers. These few links can help you find it out.</p>
<ul>
<li><a href="http://allurcode.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2h0bWw1dGVzdC5jb20v">Test your browser for support</a></li>
<li><a href="http://allurcode.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3d3dy5maW5kbWVieWlwLmNvbS9saXRtdXMjdGFyZ2V0LXNlbGVjdG9y">Web Designer&#8217;s Checklist</a></li>
<li><a href="http://allurcode.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2Nhbml1c2UuY29tLw==">When can I use</a></li>
</ul>
<h1>Not supported elements</h1>
<p>Following elements are no longer supported in HTML5:</p>
<ul>
<li>&lt;acronym&gt;</li>
<li>&lt;applet&gt;</li>
<li>&lt;basefont&gt;</li>
<li>&lt;big&gt;</li>
<li>&lt;center&gt;</li>
<li>&lt;dir&gt;</li>
<li>&lt;font&gt;</li>
<li>&lt;frame&gt;</li>
<li>&lt;frameset&gt;</li>
<li>&lt;noframes&gt;</li>
<li>&lt;s&gt;</li>
<li>&lt;strike&gt;</li>
<li>&lt;tt&gt;</li>
<li>&lt;u&gt;</li>
<li>&lt;xmp&gt;</li>
</ul>
<p>Now, lets start with a few simple tags.</p>
<h1>Doctype</h1>
<p>Oh the doctype, who could remember the whole thing?</p>
<pre class="brush: xml;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;</pre>
<p>Instead of old doctype like the one above we can finally start using something that is really easy to remember.</p>
<pre class="brush: xml;">&lt;!DOCTYPE html&gt;</pre>
<p>YES! That&#8217;s it, we&#8217;re done <img src='http://allurcode.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Even Google is using it already.</p>
<h1>Character Set</h1>
<p>Again, a lot simpler than it used to be.</p>
<pre class="brush: xml;">&lt;meta charset=&quot;utf-8&quot; /&gt;</pre>
<h1>&lt;script&gt;, &lt;style&gt; and &lt;link&gt; elements</h1>
<p>We&#8217;re all used to this</p>
<pre class="brush: xml;">
&lt;script type=&quot;text/javascript&quot; src=&quot;/path/to/my/file.js&quot;&gt;&lt;/script&gt;
&lt;style type=&quot;text/css&quot;&gt;
#myId { margin:0px; }
&lt;/style&gt;
&lt;link type=&quot;text/css&quot; rel=&quot;stylesheet&quot; href=&quot;/path/to/my/file.css&quot; /&gt;
</pre>
<p>but with HTML5 the we can omit the <em>type</em> attributes as the values above are set as default. Our bit of code becomes a little more clean.</p>
<pre class="brush: xml;">
&lt;script src=&quot;/path/to/my/file.js&quot;&gt;&lt;/script&gt;
&lt;style&gt;
#myId { margin:0px; }
&lt;/style&gt;
&lt;link rel=&quot;stylesheet&quot; href=&quot;/path/to/my/file.css&quot; /&gt;
</pre>
<h1>Semantic structure</h1>
<p>A few new elements were added to only add a more semantic meaning to well known &lt;div&gt; tag. Some of those elements are:</p>
<ul>
<li>&lt;article&gt;</li>
<li>&lt;section&gt;</li>
<li>&lt;aside&gt;</li>
<li>&lt;hgroup&gt;</li>
<li>&lt;header&gt;</li>
<li>&lt;footer&gt;</li>
<li>&lt;nav&gt;</li>
<li>&lt;time&gt;</li>
<li>&lt;mark&gt;</li>
<li>&lt;figure&gt;</li>
<li>&lt;figcaption&gt;</li>
</ul>
<h1>Support in IE</h1>
<p>IE9 is supposed to support HTML5 when it&#8217;s out but for now we have to tell IE what type are those elements. To not complicate things too much all we need to do is make a use of <a href="http://allurcode.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL3JlbXlzaGFycC5jb20vMjAwOS8wMS8wNy9odG1sNS1lbmFibGluZy1zY3JpcHQv">this awesome script</a>. Just paste it within your <em>head</em> tag.</p>
<pre class="brush: xml;">
&lt;!--[if IE]&gt;
&lt;script src=&quot;http://html5shim.googlecode.com/svn/trunk/html5.js&quot;&gt;&lt;/script&gt;
&lt;![endif]--&gt;
</pre>
<h1>Sample page layout</h1>
<pre class="brush: xml;">
&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;en&quot;&gt;
&lt;head&gt;
&lt;title&gt;Title&lt;/title&gt;
&lt;meta charset=&quot;utf-8&quot; /&gt;
&lt;meta http-equiv=&quot;imagetoolbar&quot; content=&quot;no&quot; /&gt;
&lt;meta name=&quot;robots&quot; content=&quot;index, follow&quot; /&gt;
&lt;meta name=&quot;keywords&quot; content=&quot;Keywords&quot; /&gt;
&lt;meta name=&quot;description&quot; content=&quot;Description&quot; /&gt;
&lt;!--[if IE]&gt;
&lt;script src=&quot;http://html5shim.googlecode.com/svn/trunk/html5.js&quot;&gt;&lt;/script&gt;
&lt;![endif]--&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id=&quot;wrapAll&quot;&gt;
	&lt;header&gt;
		&lt;nav&gt;
			&lt;ul&gt;
				&lt;li&gt;&lt;a href=&quot;#&quot;&gt;Item 1&lt;/a&gt;&lt;/li&gt;
				&lt;li&gt;&lt;a href=&quot;#&quot;&gt;Item 2&lt;/a&gt;&lt;/li&gt;
				&lt;li&gt;&lt;a href=&quot;#&quot;&gt;Item 3&lt;/a&gt;&lt;/li&gt;
			&lt;/ul&gt;
		&lt;/nav&gt;
	&lt;/header&gt;
	&lt;section&gt;
		&lt;article&gt;
			&lt;header&gt;
				&lt;h1&gt;Article Header&lt;/h1&gt;
				&lt;time datetime=&quot;2010-06-15&quot; pubdate&gt;June 15th, 2010&lt;/time&gt;
			&lt;/header&gt;
			&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit.&lt;/p&gt;
		&lt;/article&gt;
	&lt;/section&gt;
	&lt;footer&gt;
		Footer content
	&lt;/footer&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>&nbsp;</p>
 <img src="http://allurcode.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=258" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://allurcode.com/2010/06/15/html5-where-to-start/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Every IT manager should watch this</title>
		<link>http://allurcode.com/2010/06/08/every-it-manager-should-watch-this/</link>
		<comments>http://allurcode.com/2010/06/08/every-it-manager-should-watch-this/#comments</comments>
		<pubDate>Tue, 08 Jun 2010 20:35:00 +0000</pubDate>
		<dc:creator>Wojtek Kosinski</dc:creator>
				<category><![CDATA[Self development]]></category>
		<category><![CDATA[it]]></category>
		<category><![CDATA[motivation]]></category>
		<category><![CDATA[video]]></category>
		<guid isPermaLink="false">http://allurcode.com/?p=316</guid>
		<description><![CDATA[What motivates us At the beginning of the video I didn&#8217;t agree to what he was saying but then he explained &#8220;Why&#8221; and &#8220;How&#8221; and it all made sense. &#160;]]></description>
			<content:encoded><![CDATA[<h1>What motivates us</h1>
<p>At the beginning of the video I didn&#8217;t agree to what he was saying but then he explained &#8220;Why&#8221; and &#8220;How&#8221; and it all made sense.</p>
<p><object width="640" height="385"><param name="movie" value="http://www.youtube.com/v/u6XAPnuFjJc&#038;hl=en_GB&#038;fs=1&#038;color1=0x3a3a3a&#038;color2=0x999999"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/u6XAPnuFjJc&#038;hl=en_GB&#038;fs=1&#038;color1=0x3a3a3a&#038;color2=0x999999" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed></object></p>
<p>&nbsp;</p>
 <img src="http://allurcode.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=316" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://allurcode.com/2010/06/08/every-it-manager-should-watch-this/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Gmail&#8217;s recent email rendering change</title>
		<link>http://allurcode.com/2010/06/01/gmails-recent-email-rendering-change/</link>
		<comments>http://allurcode.com/2010/06/01/gmails-recent-email-rendering-change/#comments</comments>
		<pubDate>Tue, 01 Jun 2010 09:14:28 +0000</pubDate>
		<dc:creator>Wojtek Kosinski</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[gmail]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[spacing]]></category>
		<guid isPermaLink="false">http://allurcode.com/?p=305</guid>
		<description><![CDATA[Problem Gmail recently made a few changes in their email rendering engine. Unfortunately for us our image based HTML newsletters that used to look fine in gmail are now broken. Each image seems to have a weird spacing after it. If you&#8217;ve been sending HTML newsletters for your clients for some time now, you probably [...]]]></description>
			<content:encoded><![CDATA[<h1>Problem</h1>
<p>Gmail recently made a few changes in their email rendering engine. Unfortunately for us our image based HTML newsletters that used to look fine in gmail are now broken. Each  image seems to have a weird spacing after it.<br />
If you&#8217;ve been sending HTML newsletters for your clients for some time now, you probably have your own email templates that work well in all email clients. Well not all thanks to Google. </p>
<h1>Solution</h1>
<p>To make things back to what they were just add <em>style=&#8221;display:block;&#8221;</em> to every img tag in your HTML email and we&#8217;re back in business.</p>
<p>&nbsp;</p>
 <img src="http://allurcode.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=305" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://allurcode.com/2010/06/01/gmails-recent-email-rendering-change/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Technorati and their blog claim code</title>
		<link>http://allurcode.com/2010/05/25/technorati-and-their-blog-claim-code/</link>
		<comments>http://allurcode.com/2010/05/25/technorati-and-their-blog-claim-code/#comments</comments>
		<pubDate>Tue, 25 May 2010 10:02:36 +0000</pubDate>
		<dc:creator>Wojtek Kosinski</dc:creator>
				<category><![CDATA[non-tech]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[claim]]></category>
		<category><![CDATA[claim code]]></category>
		<category><![CDATA[technorati]]></category>
		<guid isPermaLink="false">http://allurcode.com/?p=291</guid>
		<description><![CDATA[Technorati code: G8GA9E4SYN2J Recently I wrote about Google making our life much easier. Unfortunately there are still companies that make our life a never ending stream of frustration. Yes Technorati I&#8217;m talking about your awesome blog claim process. I was under an impression of mutual benefits from me adding my blog to your directory. You [...]]]></description>
			<content:encoded><![CDATA[<p>Technorati code: G8GA9E4SYN2J</p>
<p>Recently I wrote about Google making our life much easier. Unfortunately there are still companies that make our life a never ending stream of frustration. Yes Technorati I&#8217;m talking about your awesome blog claim process. I was under an impression of mutual benefits from me adding my blog to your directory. You have more blogs in your database providing better search results and I get a bit more exposure thanks to you. In theory that is.</p>
<p>I registered, filled in my profile details and made it to claiming my blog part. After reading a bit vague instructions I guessed you want me to write a new post adding my unique <strong>claim code</strong> to the body of that post. I did that and surprise, surprise, it&#8217;s not working. Googling for problems with you blog claim process returns close to <strong>600 000</strong> results with increase of about 5k a day. I think that&#8217;s quite a lot of people who have no clue why it&#8217;s not working. Here&#8217;s another post by a frustrated blogger. I found at least 4 separate threads in your <a href="http://allurcode.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2dldHNhdGlzZmFjdGlvbi5jb20vdGVjaG5vcmF0aS90b3BpY3MvdGVjaG5vcmF0aV9pc19ub3RfY2xhaW1pbmdfYmxvZ3NfZ29pbmdfb25fNV9tb250aHM=">GetSatisfaction</a> board.</p>
<p>If you haven&#8217;t noticed <strong>a lot of people have problems</strong> with this tedious process.</p>
<p>Guys, admit it already, scanning RSS feeds <strong>does not work</strong> for most of us. A word of advice, why won&#8217;t you do what other services are doing like claiming a blog by adding a meta tag to my homepage, uploading a blank HTML file with my claim code in the filename or maybe requiring an email address in the same domain. Even if someone has access <strong>only</strong> to admin panel and can&#8217;t upload files nor modify meta tags maybe something easy like adding your damn code in my blog&#8217;s sidebar could work? No? Sorry for trying.</p>
<p>Your instructions are so unclear as no one seems to know for sure how to make it work.</p>
<p>I&#8217;m trying to put your claim code in the beginning of my post so that maybe it will be visible in my RSS&#8217;s preview that you&#8217;re scanning.</p>
<p>Crossing fingers and hoping for the best.</p>
<p>&nbsp;</p>
 <img src="http://allurcode.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=291" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://allurcode.com/2010/05/25/technorati-and-their-blog-claim-code/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Google font api and font directory</title>
		<link>http://allurcode.com/2010/05/23/google-font-api-and-font-directory/</link>
		<comments>http://allurcode.com/2010/05/23/google-font-api-and-font-directory/#comments</comments>
		<pubDate>Sun, 23 May 2010 11:08:36 +0000</pubDate>
		<dc:creator>Wojtek Kosinski</dc:creator>
				<category><![CDATA[HTML]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[font]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Tangerine]]></category>
		<guid isPermaLink="false">http://allurcode.com/?p=263</guid>
		<description><![CDATA[Technorati code: G8GA9E4SYN2J Google just made our life much easier by announcing Google font api and Google font directory. Using custom fonts on your website is as easy as adding two lines of code. Lets consider this simple example. &#60;!DOCTYPE html&#62; &#60;html lang=&#34;en&#34;&#62; &#60;head&#62; &#60;title&#62;Custom fonts&#60;/title&#62; &#60;meta charset=&#34;utf-8&#34; /&#62; &#60;style&#62; body { font-size: 48px; } [...]]]></description>
			<content:encoded><![CDATA[<p>Technorati code: G8GA9E4SYN2J</p>
<p>Google just made our life much easier by announcing <a href="http://allurcode.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2NvZGUuZ29vZ2xlLmNvbS9hcGlzL3dlYmZvbnRzLw==">Google font api</a> and <a href="http://allurcode.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2NvZGUuZ29vZ2xlLmNvbS93ZWJmb250cw==">Google font directory</a>.<br />
Using custom fonts on your website is as easy as adding two lines of code. Lets consider this simple example.</p>
<pre class="brush: xml;">
&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;en&quot;&gt;
&lt;head&gt;
&lt;title&gt;Custom fonts&lt;/title&gt;
&lt;meta charset=&quot;utf-8&quot; /&gt;
&lt;style&gt;
      body { font-size: 48px; }
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;header&gt;
	&lt;p&gt;Hello world!&lt;/p&gt;
&lt;/header&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>Nothing fancy here, result as expected.</p>
<p>&nbsp;</p>
<p style="font-size: 48px;">Hello world!</p>
<p>&nbsp;</p>
<p>Now lets add those two aforementioned lines. Line 6 and line 9 in below listing.</p>
<pre class="brush: xml;">
&lt;!DOCTYPE html&gt;
&lt;html lang=&quot;en&quot;&gt;
&lt;head&gt;
&lt;title&gt;Custom fonts&lt;/title&gt;
&lt;meta charset=&quot;utf-8&quot; /&gt;
&lt;link href='http://fonts.googleapis.com/css?family=Tangerine' rel='stylesheet' type='text/css'&gt;
&lt;style&gt;
      body { font-size: 48px; }
      p { font-family: 'Tangerine', serif; }
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;header&gt;
	&lt;p&gt;Hello world!&lt;/p&gt;
&lt;/header&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>and the effect</p>
<link href='http://fonts.googleapis.com/css?family=Tangerine' rel='stylesheet' type='text/css' />
<p>&nbsp;</p>
<p style="font-size: 48px; font-family: 'Tangerine', serif;">Hello world!</p>
<p>&nbsp;</p>
<p>The font directory is a bit limited at the moment but I think we can safely assume that Google will be adding more fonts over time.</p>
<p>&nbsp;</p>
 <img src="http://allurcode.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=263" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://allurcode.com/2010/05/23/google-font-api-and-font-directory/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Handling responses from PHP&#8217;s cURL</title>
		<link>http://allurcode.com/2010/04/14/handling-responses-from-phps-curl/</link>
		<comments>http://allurcode.com/2010/04/14/handling-responses-from-phps-curl/#comments</comments>
		<pubDate>Wed, 14 Apr 2010 21:38:56 +0000</pubDate>
		<dc:creator>Wojtek Kosinski</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[cURL]]></category>
		<category><![CDATA[response]]></category>
		<guid isPermaLink="false">http://allurcode.com/?p=241</guid>
		<description><![CDATA[Recently I had a small problem with cURL. The request was supposed to return only JSON data to use in my app. I wrote the following: $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, 'http://somedomain.com/api/123'); curl_setopt($curl, CURLOPT_HEADER, false); curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); curl_exec($curl); $status = curl_getinfo($curl); curl_close($curl); The variable $status contained the API&#8217;s response in plain text and concatenated, [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I had a small problem with cURL. The request was supposed to return only JSON data to use in my app. I wrote the following:</p>
<pre class="brush: php;">
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'http://somedomain.com/api/123');
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_exec($curl);
$status = curl_getinfo($curl);
curl_close($curl);
</pre>
<p>The variable <em>$status</em> contained the API&#8217;s response in plain text and concatenated, inaccessible in this format, array with cURL&#8217;s status response. This made impossible for example checking if the request was successful. I had to get rid of the JSON response and leave only cURL status array. In order to do that I added <em>curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);</em> option which cleared all this garbage and left only cURL&#8217;s status array.</p>
<pre class="brush: php;">
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'http://somedomain.com/api/123');
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_exec($curl);
$status = curl_getinfo($curl);
curl_close($curl);
</pre>
<p>Last thing I had to do was retrieve API&#8217;s JSON response and assign it to another variable. I have to say the solution wasn&#8217;t my first logical choice. After some time it turned out that <em>curl_exec()</em> returns exactly what I need.<br />
In the end, my bit of code became something like this:</p>
<pre class="brush: php;">
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'http://somedomain.com/api/123');
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
$response = curl_exec($curl);
$status = curl_getinfo($curl);
curl_close($curl);
</pre>
<p>Now, variable <em>$response</em> contained only JSON and <em>$status</em> contained only cURL&#8217;s response status. I was happy again.<br />
&nbsp;</p>
 <img src="http://allurcode.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=241" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://allurcode.com/2010/04/14/handling-responses-from-phps-curl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL very slow without a reason</title>
		<link>http://allurcode.com/2010/04/07/mysql-very-slow-without-a-reason/</link>
		<comments>http://allurcode.com/2010/04/07/mysql-very-slow-without-a-reason/#comments</comments>
		<pubDate>Wed, 07 Apr 2010 15:39:49 +0000</pubDate>
		<dc:creator>Wojtek Kosinski</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[DNS]]></category>
		<category><![CDATA[slow]]></category>
		<guid isPermaLink="false">http://allurcode.com/?p=197</guid>
		<description><![CDATA[Is your MySQL really slow without actually being too busy? Does your scripts take very long time to connect to the database? Do you have lots of RAM, strong CPU, just a little traffic and despite that a very long database response time? Are you seeing connections with &#8220;unauthenticated user&#8221; while running show processlist in [...]]]></description>
			<content:encoded><![CDATA[<p>Is your MySQL really slow without actually being too busy?<br />
Does your scripts take very long time to connect to the database?<br />
Do you have lots of RAM, strong CPU, just a little traffic and despite that a very long database response time?<br />
Are you seeing connections with &#8220;<em>unauthenticated user</em>&#8221; while running <em>show processlist</em> in MySQL console?</p>
<pre class="brush: bash;">
mysql&gt; show processlist;
+------+----------------------+-----------+----------+----------+------+-------+--------------+
| Id   | User                 | Host      | db      | Command   | Time | State | Info         |
+------+----------------------+-----------+----------+----------+------+-------+--------------+
| 2047 | unauthenticated user | localhost | myDB    | Connect   |   81 |       | NULL         |
| 2049 | unauthenticated user | localhost | myDB    | Connect   |   81 |       | NULL         |
| 2050 | unauthenticated user | localhost | myDB    | Connect   |   76 |       | NULL         |
...
+------+----------------------+-----------+----------+----------+------+-------+--------------+
131 rows in set (0.00 sec)
</pre>
<p>If you answered <strong>yes</strong> to any of the above questions your MySQL might have a problem with resolving connection&#8217;s host name.<br />
When attempt is made for a new connection, MySQL tries to resolve the host name for that request. It takes the IP address and resolves it to a host name (using gethostbyaddr()). It then takes that host name and resolves it back to the IP address (using gethostbyname()) and compares to ensure it is the original IP address.<br />
This might considerably increase connection time and slow down your whole application or produce <em>show processlist</em> result as above. You can easily solve this problem by disabling DNS host name lookups. In order to do this you need to run your mysqld with <em>&#8211;skip-name-resolve</em> option or add it to your my.cnf file like that:</p>
<pre class="brush: bash;">
[mysqld]
skip-name-resolve
</pre>
<p>After that running <em>show processlist</em> will result in &#8220;Host&#8221; column displaying only IP addresses instead of host names and the connection speed should be much faster.</p>
<p>Just keep in mind that also you have to change allowed hosts for your database users to proper IP addresses.<br />
&nbsp;</p>
 <img src="http://allurcode.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=197" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://allurcode.com/2010/04/07/mysql-very-slow-without-a-reason/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PDO rowCount() not working in PHP 5.1.6</title>
		<link>http://allurcode.com/2010/03/30/pdo-rowcount-not-working-in-php-5-1-6/</link>
		<comments>http://allurcode.com/2010/03/30/pdo-rowcount-not-working-in-php-5-1-6/#comments</comments>
		<pubDate>Tue, 30 Mar 2010 22:41:50 +0000</pubDate>
		<dc:creator>Wojtek Kosinski</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[PDO]]></category>
		<category><![CDATA[rowcount]]></category>
		<guid isPermaLink="false">http://allurcode.com/?p=195</guid>
		<description><![CDATA[The bug If you&#8217;re running PHP 5.1.6 and just started using PDO for your database connection, it&#8217;s likely you&#8217;ll run into quite an annoying bug. Lets test a simple query partly taken from PHP documentation. $calories = 150; $colour = 'red'; $sth = $myPDO-&#62;prepare('SELECT name, colour, calories FROM fruit WHERE calories &#60; :calories AND colour [...]]]></description>
			<content:encoded><![CDATA[<h1>The bug</h1>
<p>If you&#8217;re running PHP 5.1.6 and just started using PDO for your database connection, it&#8217;s likely you&#8217;ll run into quite an annoying bug.<br />
Lets test a simple query partly taken from PHP documentation.</p>
<pre class="brush: php;">
$calories = 150;
$colour = 'red';
$sth = $myPDO-&gt;prepare('SELECT name, colour, calories
    FROM fruit
    WHERE calories &lt; :calories AND colour = :colour');
$sth-&gt;bindParam(':calories', $calories, PDO::PARAM_INT);
$sth-&gt;bindParam(':colour', $colour, PDO::PARAM_STR, 12);
$sth-&gt;execute();
if ($sth-&gt;rowCount() &gt;= 1) {
    // iterate through results
}
</pre>
<p>Everything seems great.  The problem is that <em>$sth-&gt;rowCount()</em> will <strong>always</strong> return 0. No matter how many results your query returns, the value of <em>rowCount()</em> will always be 0.</p>
<p>Full bug report can be found here: <a href="http://allurcode.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?url=aHR0cDovL2J1Z3MucGhwLm5ldC80MDgyMg==">http://bugs.php.net/40822</a>.</p>
<h1>Solution</h1>
<p>Upgrade PHP <img src='http://allurcode.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>If that&#8217;s not an option read on.</p>
<p>Lets create our own simple PDO and PDOStatement classes.</p>
<pre class="brush: php;">
class myPDO extends PDO {
	function __construct($name_host, $username='', $password='', $driverOptions=array()) {
		parent::__construct($name_host, $username, $password, $driverOptions);
		$this-&gt;setAttribute(PDO::ATTR_STATEMENT_CLASS, array('myPDOStatement', array($this)));
	}
}
class myPDOStatement extends PDOStatement {
	public $db;
	protected function __construct($db) {
		$this-&gt;db = $db;
	}
}
</pre>
<p>Above will not fix anything. This is just a start so we can overload some PDO methods to apply the fix.</p>
<p>To fix the bug we need to tell MySQL to use the buffered versions of the MySQL API by setting attribute <em>MYSQL_ATTR_USE_BUFFERED_QUERY</em> to <em>true</em>.<br />
For some reason, still unknown to me setting this option like that</p>
<pre class="brush: php;">
class myPDO extends PDO {
	function __construct($name_host, $username='', $password='', $driverOptions=array()) {
		parent::__construct($name_host, $username, $password, $driverOptions);
		$this-&gt;setAttribute(PDO::ATTR_STATEMENT_CLASS, array('myPDOStatement', array($this)));
		$this-&gt;setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
	}
}
</pre>
<p>will <strong>not</strong> work.</p>
<p>After many hours of tearing my hair out I found out that all you need to do is this:</p>
<pre class="brush: php;">
class myPDO extends PDO {
	function __construct($name_host, $username='', $password='', $driverOptions=array()) {
		$driverOptions[PDO::MYSQL_ATTR_USE_BUFFERED_QUERY] = true;
		parent::__construct($name_host, $username, $password, $driverOptions);
		$this-&gt;setAttribute(PDO::ATTR_STATEMENT_CLASS, array('myPDOStatement', array($this)));
	}
}
</pre>
<p>You have to set <em>MYSQL_ATTR_USE_BUFFERED_QUERY</em> before instantiating a connection.  Setting it after the connection was made will not work.</p>
<p>When this is done we need to modify our <em>myPDOStatement</em> class.</p>
<pre class="brush: php;">
class myPDOStatement extends PDOStatement {
	public $db;
	// other attributes
	private $foundRows; // will hold number of affected rows
	protected function __construct($db) {
		$this-&gt;db = $db;
	}
	public function execute($array = null) {
		if ($array === null) {
			$result = parent :: execute();
		} else {
			$result = parent :: execute($array);
		}
		// fix for PHP 5.1.6 rowCount error
		$this-&gt;foundRows = $this-&gt;db-&gt;query(&quot;SELECT FOUND_ROWS()&quot;)-&gt;fetchColumn();
		return $result;
	}
	public function rowCount() {
		return $this-&gt;foundRows;
	}
}
</pre>
<p>After above changes our <em>rowCount()</em> method will return proper values.<br />
&nbsp;</p>
 <img src="http://allurcode.com/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=195" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://allurcode.com/2010/03/30/pdo-rowcount-not-working-in-php-5-1-6/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
