<?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>Şimşek Mert</title>
	<atom:link href="http://www.simsekmert.com/wp/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.simsekmert.com/wp</link>
	<description>Kişisel Web Sayfası</description>
	<lastBuildDate>Thu, 13 Jan 2011 09:10:00 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Ext JS Javascript Framework</title>
		<link>http://www.simsekmert.com/wp/2011/01/ext-js-javascript-framework/</link>
		<comments>http://www.simsekmert.com/wp/2011/01/ext-js-javascript-framework/#comments</comments>
		<pubDate>Sun, 02 Jan 2011 21:22:38 +0000</pubDate>
		<dc:creator>Şimşek Mert</dc:creator>
				<category><![CDATA[Ext JS]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Web Programlama]]></category>
		<category><![CDATA[ext]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[sencha]]></category>

		<guid isPermaLink="false">http://www.simsekmert.com/wp/?p=139</guid>
		<description><![CDATA[Bu bölümde, bir çok önemli özelliği ile ön plana çıkan ve benzer kütüphanelere göre çok daha kabiliyetli olan ve kullanıcı arayüzü açısından oldukça başarılı bir javascript çatısı olan Ext JS den ve özelliklerinden bahsedeceğim.

1.Bölüm
Gerekli dosyalar

Ext JS Kütüphanesi : Öncelikle http://www.sencha.com/products/js/download.php adresinden Ext JS kütüphanesinin en son sürümünü indirim. Ben bu yazıyı yazarken Ext JS nin [...]]]></description>
			<content:encoded><![CDATA[<p>Bu bölümde, bir çok önemli özelliği ile ön plana çıkan ve benzer kütüphanelere göre çok daha kabiliyetli olan ve kullanıcı arayüzü açısından oldukça başarılı bir javascript çatısı olan Ext JS den ve özelliklerinden bahsedeceğim.</p>
<p><span id="more-139"></span></p>
<h1>1.Bölüm</h1>
<h3>Gerekli dosyalar</h3>
<ul>
<li style="text-align: justify;"><strong>Ext JS Kütüphanesi :</strong> Öncelikle <a href="http://www.sencha.com/products/js/download.php">http://www.sencha.com/products/js/download.php</a> adresinden Ext JS kütüphanesinin en son sürümünü indirim. Ben bu yazıyı yazarken Ext JS nin indirilebilir en son sürümü 3.3.1 idi. Bu nedenle yazımızın devamında 3.3.1 diye bahsettiğimiz bölüm siz yeni bir sürüm ile çalışıyorsanız değişecektir.</li>
<li style="text-align: justify;"><strong>Web Sunucusu :</strong> Ext JS kütüphanesi, istemci tarafında çalışan javascript dosyalarından oluştuğu için html dosyalar ile herhangi bir web sunucusu olmadan da tarayıcılar tarafından çalıştırılabilir. Fakat biz çalışmamıza bir web sunucusu ile devam edeceğiz. Windows üzerinde çalışıyorsanız windows işletim sistemlerine Apache Web Sunucusu, MySQL veritabanı sunucusu ve PHP web programlama dili desteğini otomatik olarak kuran bir kaç paket bulunmaktadır. Bunlardan ikisini aşağıda belirttim. Bunlardan birini kullanarak web sunucunuzu yapılandırabilirsiniz.
<ul>
<li style="text-align: justify;">AppServNetwork -&gt; <a href="http://www.appservnetwork.com">http://www.appservnetwork.com</a></li>
<li>WampServer -&gt; <a href="http://www.wampserver.com">http://www.wampserver.com</a></li>
</ul>
</li>
</ul>
<h3>Kurulum</h3>
<p>Web sunucunuzu kurduysanız web sunucusu kurulum sırasında belirttiğiniz adresin içine www klasörü oluşturmuştur. Bu klasörün içine örnek uygulamamız için myApp isimli bir klasör oluşturalım. Bu klasör içine indirdiğimiz Ext JS kütüphanesini kopyalayalım.</p>
<p>myApp klasörünün içine geliştireceğimiz uygulamalara ait dosyaları tutmak için application adında bir klasör daha oluşturalım.</p>
<p><img class="alignnone size-full wp-image-156" title="1" src="http://www.simsekmert.com/wp/wp-content/uploads/2011/01/1.PNG" alt="1" width="544" height="175" /></p>
<p>Şimdi ext-3.3.1 klasörünün içindeki dosya ve klasörleri inceleyelim.</p>
<p><img class="alignnone size-full wp-image-157" title="2" src="http://www.simsekmert.com/wp/wp-content/uploads/2011/01/2.png" alt="2" width="540" height="188" /></p>
<ul>
<li style="text-align: justify;"><strong>adapter</strong> klasörü, prototype, jQuery, YUI and Ext JS gibi klasörlerin bulunduğu bir klasördür. Bu klasör ve içindekiler ileride daha detaylı incelenecektir.</li>
<li style="text-align: justify;"><strong>resources</strong> klasörü, içerisinde görseller, css dosyaları vs bulunur.</li>
<li style="text-align: justify;"><strong>ext-all.js</strong> dosyası, Ext JS nin bileşenlerinin bulunduğu javascript dosyasıdır.</li>
</ul>
<h3>Testing Ext JS Framework</h3>
<p><img src="file:///C:/Users/simsek/AppData/Local/Temp/moz-screenshot.png" alt="" /></p>
<p>Şimdi ilk html dosyamızı oluşturup ext kütüphanesini yükleyelim. Bunun için üç tane dosyanın &lt;head&gt;&lt;/head&gt; bloğunda çağrılması gerekir.</p>
<ul>
<li>ext-3.3.1/resources/css/ext-all.css</li>
<li>ext-3.3.1/adapter/ext/ext-base.js</li>
<li style="text-align: justify;">ext-3.3.1/ext-all.js</li>
</ul>
<p>Bun göre aşağıdaki html kodlarını sayfamızın &lt;head&gt;&lt;/head&gt; bloğuna  yerleştirelim.</p>
<pre class="js">&lt;link rel="stylesheet" type="text/css" href="../ext-3.3.1/resources/css/ext-all.css" /&gt;

&lt;script type="text/javascript" src="../ext-3.3.1/adapter/ext/ext-base.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="../ext-3.3.1/ext-all.js"&gt;&lt;/script&gt;</pre>
<p style="text-align: justify;">Ext JS kütüphanesini test etmek için kütüphanemizin kullandığı onReady olayına bir dinleyici eklemek yeterlidir. onReady olayı tüm sistem yüklendikten sonra aktif olur. Örneğin, DOM kullanıma hazır hale geldiğinde kullanıcıya &#8220;Hoşgeldiniz.&#8221; diye bir mesaj verelim.</p>
<blockquote>
<p style="text-align: justify;">&lt;script type=&#8221;text/javascript&#8221;&gt;</p>
<p style="text-align: justify; padding-left: 30px;">Ext.onReady(function(){<br />
alert(&#8217;Hoşgeldiniz.&#8217;);<br />
});</p>
<p style="text-align: justify;">&lt;/script&gt;</p>
</blockquote>
<p>Buna göre, first.html olarak application klasörü içine oluşturduğumuz dosyanın içeriği aşağıdaki gibi olmalıdır.</p>
<blockquote>
<p style="text-align: justify;">&lt;!DOCTYPE html PUBLIC &#8220;-//W3C//DTD XHTML 1.0 Strict//EN&#8221; &#8220;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&#8221;&gt;</p>
<p>&lt;html xmlns=&#8221;http://www.w3.org/1999/xhtml&#8221; xml:lang=&#8221;en&#8221;&gt;<br />
&lt;head&gt;<br />
&lt;meta http-equiv=&#8221;Content-Type&#8221; content=&#8221;text/html; charset=UTF-8&#8243; /&gt;<br />
&lt;title&gt;Ext JS Library&lt;/title&gt;</p>
<p>&lt;link rel=&#8221;stylesheet&#8221; type=&#8221;text/css&#8221; href=&#8221;../ext-3.3.1/resources/css/ext-all.css&#8221; /&gt;</p>
<p>&lt;script type=&#8221;text/javascript&#8221; src=&#8221;../ext-3.3.1/adapter/ext/ext-base.js&#8221;&gt;&lt;/script&gt;<br />
&lt;script type=&#8221;text/javascript&#8221; src=&#8221;../ext-3.3.1/ext-all.js&#8221;&gt;&lt;/script&gt;</p>
<p>&lt;script type=&#8221;text/javascript&#8221;&gt;<br />
Ext.onReady(function() {<br />
alert(&#8217;Hosgeldiniz.&#8217;);<br />
});<br />
&lt;/script&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;</p>
<p>&lt;/body&gt;<br />
&lt;/html&gt;</p></blockquote>
<p>Bu dosyayı web tarayıcınız ile çalıştırdığınızda aşağıdaki gibi &#8220;Hoşgeldiniz.&#8221; mesajı verilecektir.</p>
<p><img class="alignnone size-full wp-image-155" title="3" src="http://www.simsekmert.com/wp/wp-content/uploads/2011/01/3.png" alt="3" width="395" height="155" /></p>
<ul>
<li><a href="http://www.simsekmert.com/wp/files/extjs/myApp/application/first.rar">Uygulamayı buradan indirebilirsiniz.</a></li>
<li><a href="http://www.simsekmert.com/wp/files/extjs/myApp/application/first.html" target="_blank">Uygulamanın demosunu buradan görebilirsiniz.</a></li>
</ul>
<h1>2.Bölüm</h1>
<p>Bu bölümde yeni bir uygulama ile bir pencere oluşturalım. Pencere oluşturmak için</p>
<blockquote>
<p style="padding-left: 30px;">win = new Ext.Window({<br />
title: &#8216;İlk Pencerem&#8217;, //pencerenin bağlığını belirtir.<br />
width:500, //pencerenin genişliğini belirtir.<br />
height:300,  //pencerenin yüksekliğini belirtir.<br />
minimizable: true,<br />
maximizable: true,<br />
closeAction:&#8217;hide&#8217;,<br />
});</p></blockquote>
<p>kodlarını kullanmamız gerekir. Burada önemli olan new Ext.Window komutu ile yeni bir pencere oluşturmaktır. Diğer seçenekler pencerenin özelliklerini düzenlemeye yarar.</p>
<p>Pencereyi oluşturmak pencereyi göstermek için yeterli değildir. Pencereyi göstermek için ayrıca win.show() fonksiyonunu çağırmamız gerekir.</p>
<p>Bu durumda yeni html sayfamız aşağıdaki gibi olacaktır.</p>
<blockquote><p>&lt;!DOCTYPE html PUBLIC &#8220;-//W3C//DTD XHTML 1.0 Strict//EN&#8221; &#8220;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&#8221;&gt;</p>
<p>&lt;html xmlns=&#8221;http://www.w3.org/1999/xhtml&#8221; xml:lang=&#8221;en&#8221;&gt;<br />
&lt;head&gt;<br />
&lt;meta http-equiv=&#8221;Content-Type&#8221; content=&#8221;text/html; charset=UTF-8&#8243; /&gt;<br />
&lt;title&gt;Ext JS Library &#8211; İkinci Örnek&lt;/title&gt;</p>
<p>&lt;link rel=&#8221;stylesheet&#8221; type=&#8221;text/css&#8221; href=&#8221;../ext-3.3.1/resources/css/ext-all.css&#8221; /&gt;</p>
<p>&lt;script type=&#8221;text/javascript&#8221; src=&#8221;../ext-3.3.1/adapter/ext/ext-base.js&#8221;&gt;&lt;/script&gt;<br />
&lt;script type=&#8221;text/javascript&#8221; src=&#8221;../ext-3.3.1/ext-all.js&#8221;&gt;&lt;/script&gt;</p>
<p>&lt;script type=&#8221;text/javascript&#8221;&gt;<br />
Ext.onReady(function() {<br />
win = new Ext.Window({<br />
title: &#8216;İlk Pencerem&#8217;, //pencerenin bağlığını gösterir<br />
width:500,<br />
height:300,<br />
minimizable: true,<br />
maximizable: true,<br />
closeAction:&#8217;hide&#8217;,<br />
});<br />
win.show();<br />
});<br />
&lt;/script&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;</p>
<p>&lt;/body&gt;<br />
&lt;/html&gt;</p></blockquote>
<p>Bu sayfayı ben second.html olarak kaydedip çalıştıdığımda aşağıdaki gibi bir görüntü oluştu.</p>
<p><img class="alignnone size-full wp-image-162" title="4" src="http://www.simsekmert.com/wp/wp-content/uploads/2011/01/4.PNG" alt="4" width="568" height="365" /></p>
<ul>
<li><a href="http://www.simsekmert.com/wp/files/extjs/myApp/application/second.rar">Uygulamayı buradan indirebilirsiniz.</a></li>
<li><a href="http://www.simsekmert.com/wp/files/extjs/myApp/application/second.html" target="_blank">Uygulamanın demosunu buradan görebilirsiniz.</a></li>
</ul>
<h3>Örnekler</h3>
<ul>
<li>Penceremize <strong>menü veya buton çubuğu</strong> eklemek istersek aşağıdaki kodu kullanabiliriz.</li>
</ul>
<blockquote><p>tbar: [{<br />
text:'Yeni',<br />
handler: function(){<br />
Ext.Msg.alert('Bilgi', '"' + this.text + '"' + ' butonuna bastınız.');<br />
}<br />
},{<br />
text: 'Sil',<br />
disabled:true<br />
}],</p></blockquote>
<p style="padding-left: 30px;"><img class="alignnone size-full wp-image-165" title="5" src="http://www.simsekmert.com/wp/wp-content/uploads/2011/01/5.png" alt="5" width="519" height="319" /><a href="http://www.simsekmert.com/wp/files/extjs/myApp/application/second-bars.rar"></a></p>
<p style="padding-left: 30px;"><a href="http://www.simsekmert.com/wp/files/extjs/myApp/application/second-bars.rar">İndir</a> |   <a href="http://www.simsekmert.com/wp/files/extjs/myApp/application/second-bars.html" target="_blank">Gör</a></p>
<p style="padding-left: 30px;">
<ul>
<li>Penceremize <strong>buton</strong> eklemek istersek aşağıdaki kodu kullanabiliriz.</li>
</ul>
<blockquote><p>buttons: [{<br />
text:'Kaydet',<br />
disabled:true<br />
},{<br />
text: 'Kapat',<br />
handler: function(){<br />
win.hide();<br />
}<br />
}],</p></blockquote>
<p><img class="alignnone size-full wp-image-168" title="6" src="http://www.simsekmert.com/wp/wp-content/uploads/2011/01/6.png" alt="6" width="517" height="319" /><a href="http://www.simsekmert.com/wp/files/extjs/myApp/application/second-buttons.rar"></a></p>
<p><a href="http://www.simsekmert.com/wp/files/extjs/myApp/application/second-buttons.rar">İndir</a> |   <a href="http://www.simsekmert.com/wp/files/extjs/myApp/application/second-buttons.html" target="_blank">Gör</a></p>
<ul>
<li>Penceremize <strong>sekme</strong> eklemek istersek aşağıdaki kodu kullanabiliriz.</li>
</ul>
<blockquote><p>items: new Ext.TabPanel({<br />
renderTo: Ext.getBody(),<br />
activeTab:0,<br />
border:false,<br />
items: [{<br />
title: 'Birinci Sekme',<br />
html: 'Birinci sekmenin içeriği burada görüntülenir.'<br />
},{<br />
title: 'İkinci Sekme',<br />
html: 'İkinci sekmenin içeriği burada görüntülenecek. Bu bölüme istediğiniz bilgiyi ekleyebilirsiniz.'<br />
}]<br />
}),</p></blockquote>
<p><img class="alignnone size-full wp-image-169" title="7" src="http://www.simsekmert.com/wp/wp-content/uploads/2011/01/7.png" alt="7" width="523" height="319" /><a href="http://www.simsekmert.com/wp/files/extjs/myApp/application/second-tabs.rar"></a></p>
<p><a href="http://www.simsekmert.com/wp/files/extjs/myApp/application/second-tabs.rar">İndir</a> |   <a href="http://www.simsekmert.com/wp/files/extjs/myApp/application/second-tabs.html" target="_blank">Gör</a></p>
<ul>
<li>Bu eklemeleri birlikte de yapabiliriz.</li>
</ul>
<p><img class="alignnone size-full wp-image-170" title="8" src="http://www.simsekmert.com/wp/wp-content/uploads/2011/01/8.png" alt="8" width="521" height="323" /><a href="http://www.simsekmert.com/wp/files/extjs/myApp/application/second-bars-tabs.rar"></a></p>
<p><a href="http://www.simsekmert.com/wp/files/extjs/myApp/application/second-bars-tabs.rar">İndir</a> |   <a href="http://www.simsekmert.com/wp/files/extjs/myApp/application/second-bars-tabs.html" target="_blank">Gör</a></p>
<p style="padding-left: 30px;"><img class="alignnone size-full wp-image-171" title="9" src="http://www.simsekmert.com/wp/wp-content/uploads/2011/01/9.PNG" alt="9" width="519" height="324" /><a href="http://www.simsekmert.com/wp/files/extjs/myApp/application/second-bars-buttons.rar"></a></p>
<p style="padding-left: 30px;"><a href="http://www.simsekmert.com/wp/files/extjs/myApp/application/second-bars-buttons.rar">İndir</a> |   <a href="http://www.simsekmert.com/wp/files/extjs/myApp/application/second-bars-buttons.html" target="_blank">Gör</a></p>
<p style="padding-left: 30px;">
<p style="padding-left: 30px;"><img class="alignnone size-full wp-image-172" title="10" src="http://www.simsekmert.com/wp/wp-content/uploads/2011/01/10.png" alt="10" width="524" height="324" /><a href="http://www.simsekmert.com/wp/files/extjs/myApp/application/second-bars-tabs-buttons.rar"></a></p>
<p style="padding-left: 30px;"><a href="http://www.simsekmert.com/wp/files/extjs/myApp/application/second-bars-tabs-buttons.rar">İndir</a> |   <a href="http://www.simsekmert.com/wp/files/extjs/myApp/application/second-bars-tabs-buttons.html" target="_blank">Gör</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.simsekmert.com/wp/2011/01/ext-js-javascript-framework/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>FPDF Türkçe Fontlar</title>
		<link>http://www.simsekmert.com/wp/2010/11/fpdf-turkce-fontlar/</link>
		<comments>http://www.simsekmert.com/wp/2010/11/fpdf-turkce-fontlar/#comments</comments>
		<pubDate>Sun, 28 Nov 2010 22:07:41 +0000</pubDate>
		<dc:creator>Şimşek Mert</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Programlama]]></category>
		<category><![CDATA[font]]></category>
		<category><![CDATA[fpdf]]></category>
		<category><![CDATA[pdf]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[türkçe]]></category>

		<guid isPermaLink="false">http://www.simsekmert.com/wp/?p=136</guid>
		<description><![CDATA[FPDF, php ile  pdf e dönüştürme aracı olarak kullanılan bir sınıftır. Fakat bu sınıf kullanılırken karşılaşılan en büyük sorunlardan birisi Türkçe karakter sorunudur.
Aşağıdaki linkte FPDF için kendi yaptığım Türkçe fontları bulabilirsiniz. arial_tr ve arial_tr_bold&#8230; Kolay gelsin
Fontları indirmek için tıklayın&#8230;
]]></description>
			<content:encoded><![CDATA[<p>FPDF, php ile  pdf e dönüştürme aracı olarak kullanılan bir sınıftır. Fakat bu sınıf kullanılırken karşılaşılan en büyük sorunlardan birisi Türkçe karakter sorunudur.</p>
<p><span id="more-136"></span>Aşağıdaki linkte FPDF için kendi yaptığım Türkçe fontları bulabilirsiniz. arial_tr ve arial_tr_bold&#8230; Kolay gelsin</p>
<p><a class="alignleft" title="Türkçe Fontlar" href="http://www.simsekmert.com/wp/files/turkce_fontlar.rar" target="_self">Fontları indirmek için tıklayın&#8230;</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.simsekmert.com/wp/2010/11/fpdf-turkce-fontlar/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To Optimize Your Site With GZIP Compression</title>
		<link>http://www.simsekmert.com/wp/2010/07/how-to-optimize-your-site-with-gzip-compression/</link>
		<comments>http://www.simsekmert.com/wp/2010/07/how-to-optimize-your-site-with-gzip-compression/#comments</comments>
		<pubDate>Sat, 24 Jul 2010 14:32:54 +0000</pubDate>
		<dc:creator>Şimşek Mert</dc:creator>
				<category><![CDATA[Web Programlama]]></category>

		<guid isPermaLink="false">http://www.simsekmert.com/wp/?p=134</guid>
		<description><![CDATA[Compression is a simple, effective way to save bandwidth and speed up  your site. I hesitated when recommending gzip compression when speeding up your javascript because of problems in older browsers.
But it’s the 21st century. Most of my traffic comes from modern browsers, and quite frankly, most of my users are fairly tech-savvy. I [...]]]></description>
			<content:encoded><![CDATA[<p>Compression is a simple, effective way to save bandwidth and speed up  your site. I hesitated when recommending gzip compression when <a href="http://betterexplained.com/articles/speed-up-your-javascript-load-time/">speeding up your javascript</a> because of <a href="http://support.microsoft.com/kb/837251">problems</a> <a href="http://support.microsoft.com/kb/823386">in</a> <a href="http://schroepl.net/projekte/mod_gzip/browser.htm">older browsers</a>.</p>
<p>But it’s the 21st century. Most of my traffic comes from modern browsers, and quite frankly, most of <a href="http://instacalc.com/">my users</a> are fairly tech-savvy. I don’t want to slow everyone else down because  somebody is chugging along on IE 4.0 on Windows 95. Google and Yahoo use  gzip compression. A modern browser is needed to enjoy modern web  content and modern web speed — so gzip encoding it is. Here’s how to set  it up.</p>
<p><span id="more-134"></span></p>
<h2>Wait, wait, wait: Why are we doing this?</h2>
<p>Before we start I should explain what content encoding is. When you request a file like <code>http://www.yahoo.com/index.html</code>, your browser talks to a web server. The conversation goes a little like this:</p>
<p><img title="HTTP_request.png" src="http://betterexplained.com/wp-content/uploads/compression/HTTP_request.png" border="0" alt="HTTP_request.png" width="437" height="221" /></p>
<p>1. Browser: Hey, <strong><span>GET</span></strong> me /index.html<br />
2. Server: Ok, let me see if index.html is lying around…<br />
3. Server: Found it! Here’s your response code (200 OK) and I’m sending the file.<br />
4. Browser: 100KB? Ouch… waiting, waiting… ok, it’s loaded.</p>
<p>Of course, the actual headers and protocols are much more formal (monitor them with <a href="http://betterexplained.com/articles/how-to-debug-web-applications-with-firefox/">Live <span>HTTP</span> Headers</a> if you’re so inclined).</p>
<p>But it worked, and you got your file.</p>
<h2>So what’s the problem?</h2>
<p>Well, the system works, but it’s not that efficient. 100KB is a <strong>lot of text</strong>, and frankly, <span>HTML </span>is redundant. Every <code>&lt;html&gt;, &lt;table&gt; and &lt;div&gt;</code> tag has a closing tag that’s almost the same. Words are repeated throughout the document. Any way you slice it, <span>HTML </span>(and its beefy cousin, <span>XML</span>) is not lean.</p>
<p>And what’s the plan when a file’s too big? Zip it!</p>
<p>If we could send a .zip file to the browser (index.html.zip) instead  of plain old index.html, we’d save on bandwidth and download time. The  browser could download the zipped file, extract it, and then show it to  user, who’s in a good mood because the page loaded quickly. The  browser-server conversation might look like this:</p>
<p><img title="HTTP_request_compressed.png" src="http://betterexplained.com/wp-content/uploads/compression/HTTP_request_compressed.png" border="0" alt="HTTP_request_compressed.png" width="436" height="213" /></p>
<p>1. Browser: Hey, can I <strong><span>GET</span></strong> index.html? I’ll take a compressed version if you’ve got it.<br />
2. Server: Let me find the file… yep, it’s here. And you’ll take a compressed version? Awesome.<br />
3. Server: Ok, I’ve found index.html (200 OK), am zipping it and sending it over.<br />
4. Browser: Great! It’s only 10KB. I’ll unzip it and show the user.</p>
<p>The formula is simple: Smaller file = faster download = <strong>happy user</strong>.</p>
<p>Don’t believe me? The <span>HTML </span>portion of the yahoo home page goes from 101kb to 15kb after compression:</p>
<p><img title="yahoo_compression.PNG" src="http://betterexplained.com/wp-content/uploads/compression/yahoo_compression.PNG" border="0" alt="yahoo_compression.PNG" width="391" height="50" /></p>
<h2>The (not so) hairy details</h2>
<p>The tricky part of this exchange is the browser and server knowing  it’s ok to send a zipped file over. The agreement has two parts</p>
<ul>
<li>The <strong>browser sends a header</strong> telling the server it accepts compressed content (gzip and deflate are two compression schemes): <code>Accept-Encoding: gzip, deflate</code></li>
</ul>
<ul>
<li>The <strong>server sends a response</strong> if the content is actually compressed: <code>Content-Encoding: gzip</code></li>
</ul>
<p>If the server doesn’t send the content-encoding response header, it  means the file is not compressed (the default on many servers). The  “Accept-encoding” header is just a request by the browser, not a demand.  If the server doesn’t want to send back compressed content, the browser  has to make do with the heavy regular version.</p>
<h2>Setting up the server</h2>
<p>The “good news” is that we can’t control the browser. It either sends the <code>Accept-encoding: gzip, deflate</code> header or it doesn’t.</p>
<p>Our job is to configure the server so it returns zipped content if  the browser can handle it, saving bandwidth for everyone (and giving us a  happy user).</p>
<p>For <span>IIS, </span><a href="http://technet.microsoft.com/en-us/library/cc771003%28WS.10%29.aspx">enable compression</a> in the settings.</p>
<p>In Apache, <a href="http://httpd.apache.org/docs/2.0/mod/mod_deflate.html">enabling output compression</a> is fairly straightforward. Add the following to your .htaccess file:</p>
<pre><code>
# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

# Or, compress certain file types by extension:
&lt;Files *.html&gt;
SetOutputFilter DEFLATE
&lt;/Files&gt;
</code></pre>
<p>Apache actually has two compression options:</p>
<ul>
<li><strong>mod_deflate</strong> is easier to set up and is standard.</li>
<li><strong>mod_gzip</strong> seems more powerful: you can pre-compress content.</li>
</ul>
<p>Deflate is quick and works, so I use it; use mod_gzip if that floats  your boat. In either case, Apache checks if the browser sent the  “Accept-encoding” header and returns the compressed or regular version  of the file. However, some older browsers may have trouble (more below)  and there are special directives you can add to correct this.</p>
<p>If you can’t change your .htaccess file, you can <a href="http://perishablepress.com/press/2007/03/26/fast-effective-php-compression/">use <span>PHP</span></a> to return compressed content. Give your <span>HTML </span>file a .php extension and add this code to the top:</p>
<pre><code>
In PHP:
&lt;?php if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) ob_start("ob_gzhandler"); else ob_start(); ?&gt;
</code></pre>
<p>We check the “Accept-encoding” header and return a gzipped version of  the file (otherwise the regular version). This is almost like building  your own webserver (what fun!). But really, try to use Apache to  compress your output if you can help it. You don’t want to monkey with  your files.</p>
<h2>Verify Your Compression</h2>
<p>Once you’ve configured your server, check to make sure you’re actually serving up compressed content.</p>
<ul>
<li><strong>Online:</strong> Use the <a href="http://www.gidnetwork.com/tools/gzip-test.php">online gzip test</a> to check whether your page is compressed.</li>
<li><strong>In your browser:</strong> Use <a href="https://addons.mozilla.org/en-US/firefox/addon/60">Web Developer Toolbar</a> &gt; Information &gt; View Document Size (like I did for Yahoo, above) to see whether the page is compressed.</li>
<li><strong>View the headers:</strong> Use <a href="https://addons.mozilla.org/en-US/firefox/addon/3829">Live <span>HTTP</span> Headers</a> to examine the response. Look for a line that says “Content-encoding: gzip”.</li>
</ul>
<p>Be prepared to marvel at the results. The <a href="http://instacalc.com/">instacalc homepage</a> shrunk from 36k to 10k, a 75% reduction in size.</p>
<h2>Try Some Examples</h2>
<p>I’ve set up some pages and a <a href="http://betterexplained.com/examples/compressed/compression-example.zip">downloadable example</a>:</p>
<ul>
<li><a href="http://betterexplained.com/examples/compressed/index.html">index.html</a> – No explicit compression (on this server, I am using compression by default <img src="http://betterexplained.com/wp-includes/images/smilies/icon_smile.gif" alt=":)" /> ).</li>
<li><a href="http://betterexplained.com/examples/compressed/index.htm">index.htm</a> – Explicitly compressed with Apache .htaccess using *.htm as a rule</li>
<li><a href="http://betterexplained.com/examples/compressed/index.php">index.php</a> – Explicitly compressed using the <span>PHP </span>header</li>
</ul>
<p>Feel free to download the files, put them on your server and tweak the settings.</p>
<h2>Caveats</h2>
<p>As exciting as it may appear, <span>HTTP</span> Compression isn’t all fun and games. Here’s what to watch out for:</p>
<ul>
<li><strong>Older browsers</strong>: Yes, some browsers still may have  trouble with compressed content (they say they can accept it, but really  they can’t). If your site absolutely must work with Netscape 1.0 on  Windows 95, you may not want to use <span>HTTP</span> Compression. Apache mod_deflate <a href="http://httpd.apache.org/docs/2.0/mod/mod_deflate.html#recommended">has some rules</a> to avoid compression for older browsers.</li>
<li><strong>Already-compressed content</strong>: Most images, music and  videos are already compressed. Don’t waste time compressing them again.  In fact, you probably only need to compress the “big 3″ (HTML, <span>CSS </span>and Javascript).</li>
<li><strong><span>CPU</span>-load</strong>: Compressing content on-the-fly uses <span>CPU </span>time  and saves bandwidth. Usually this is a great tradeoff given the speed  of compression. There are ways to pre-compress static content and send  over the compressed versions. This requires more configuration; even if  it’s not possible, compressing output may still be a net win. Using <span>CPU </span>cycles for a faster user experience is well worth it, given the short attention spans on the web.</li>
</ul>
<p>Enabling compression is one of the fastest ways to improve your  site’s performance. Go forth, set it up, and let your users enjoy the  benefits.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.simsekmert.com/wp/2010/07/how-to-optimize-your-site-with-gzip-compression/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fast, Effective PHP Compression</title>
		<link>http://www.simsekmert.com/wp/2010/07/fast-effective-php-compression/</link>
		<comments>http://www.simsekmert.com/wp/2010/07/fast-effective-php-compression/#comments</comments>
		<pubDate>Sat, 24 Jul 2010 14:15:35 +0000</pubDate>
		<dc:creator>Şimşek Mert</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Programlama]]></category>
		<category><![CDATA[compression]]></category>
		<category><![CDATA[gzip]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.simsekmert.com/wp/?p=132</guid>
		<description><![CDATA[PHP compression is an excellent method of conserving bandwidth and  reducing client download times. We have already discussed an excellent  method for CSS compression, and in this article we share a super-easy technique for compressing all PHP content without editing a single file.
Using two PHP files and two corresponding lines of .htaccess, it [...]]]></description>
			<content:encoded><![CDATA[<p>PHP compression is an excellent method of conserving bandwidth and  reducing client download times. We have already discussed an excellent  method for <a href="http://perishablepress.com/press/2006/10/23/compressed-css-compression/">CSS compression</a>, and in this article we share a super-easy technique for compressing all PHP content without editing a single file.</p>
<p>Using two PHP files and two corresponding lines of .<code>htaccess</code>, it is possible to compress your PHP files via <a title="The gzip Home Page" href="http://www.gzip.org/">gzip-encoding</a>.  Browsers and other user-agents capable of interpreting gz-encoded data  will employ the compressed content, while other user-agents will utilize  the content uncompressed.</p>
<p><span id="more-132"></span></p>
<p><span id="more-341"> </span></p>
<p>Before we begin, it is important to determine if your  server employs output buffering. If so, it may not be necessary to  compress content via this method. Also, this PHP compression technique  requires PHP version 4.0.5 or better.</p>
<p>Now, create two PHP files, &#8220;gzip_start.php&#8221; and &#8220;gzip_stop&#8221;. Open gzip_start.php and add this:</p>
<pre style="overflow: hidden; width: 525px; display: block;"><code>&lt;?php
   ob_start("ob_gzhandler");
?&gt;</code></pre>
<p>Then, open gzip_stop.php and add this:</p>
<pre style="overflow: hidden; width: 525px; display: block;"><code>&lt;?php
   ob_flush();
?&gt;</code></pre>
<p>Save and upload both files to a convenient location on your  server. The first file instructs the server to begin output buffering  via gz-encoding. The second file instructs the server to transmit the  buffered content to the user-agent, assuming it sends a header  indicating its ability to process gzipped data.</p>
<p>Finally, we need a way to include first file at the  beginning of each PHP document and the second file at the end of each  PHP document. Rather than manually adding <code>include()</code> or <code>require()</code> functions to every PHP document, we will summon the mysterious powers of .<code>htaccess</code> to do it all automatically. Simply add the following lines to your .<code>htaccess</code> file:</p>
<pre style="overflow: hidden; width: 525px; display: block;"><code># dual file includes for PHP compression
php_value  auto_prepend_file  /specify/full/path/to/gzip_start.php
php_value  auto_append_file   /specify/full/path/to/gzip_stop.php</code></pre>
<p>Edit the path in each line, save and upload the .<code>htaccess</code> file to your server. These two lines will ensure proper inclusion of  both files to every PHP document subject to their influence (i.e., the  containing directory and all subdirectories). The <code>auto_prepend_file</code> function literally prepends data, while the <code>auto_append_file</code> function, well, you get the idea..</p>
<h3>Alternate Method</h3>
<p>For an even easier PHP-compression method, simply place the following code before the (X)HTML content in any PHP script:</p>
<pre style="overflow: hidden; z-index: 99; position: relative; width: 525px; display: block;"><code>&lt;?php if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) ob_start("ob_gzhandler"); else ob_start(); ?&gt;</code></pre>
<p>In this case, the <code>ob_flush()</code> command is  unnecessary as PHP inherently flushes the buffer. The script delivers  gzipped content to capable browsers and uncompressed content to  incapable browsers. It’s a win-win!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.simsekmert.com/wp/2010/07/fast-effective-php-compression/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL Server, PHP and Truncating Text</title>
		<link>http://www.simsekmert.com/wp/2010/06/sql-server-php-and-truncating-text/</link>
		<comments>http://www.simsekmert.com/wp/2010/06/sql-server-php-and-truncating-text/#comments</comments>
		<pubDate>Sun, 20 Jun 2010 19:45:42 +0000</pubDate>
		<dc:creator>Şimşek Mert</dc:creator>
				<category><![CDATA[MSSQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[truncate]]></category>

		<guid isPermaLink="false">http://www.simsekmert.com/wp/?p=130</guid>
		<description><![CDATA[PHP and SQL Server are a powerful combination, however sometimes data stored in a text type column is truncated for no apparent reason after 4096 characters. Here&#8217;s how to fix the problem.

PHP can work with a large number of database systems, most common of  which is MySQL. However, SQL Server is a very poweful [...]]]></description>
			<content:encoded><![CDATA[<p>PHP and SQL Server are a powerful combination, however sometimes data stored in a text type column is truncated for no apparent reason after 4096 characters. Here&#8217;s how to fix the problem.</p>
<p><span id="more-130"></span></p>
<p>PHP can work with a large number of database systems, most common of  which is MySQL. However, SQL Server is a very poweful alternative to  MySQL, and well worth considering for larger projects.</p>
<p>However, settings for the mssql extension in PHP can easily be  overlooked, resulting in strange behaviour. One of the most unusual  problems I encountered on a recent project was that every time text was  pulled from a column of type &#8220;text&#8221;, it was truncated at around 4000  characters.</p>
<p>If you are experiencing a similar problem, there are a few ways to  work around it.</p>
<p>You need to increase the maximum size of a text column to be returned  from SQL Server by PHP. You can do this with a simple SQL query:</p>
<p><code>SET TEXTSIZE 2147483647</code></p>
<p>Which you can run with the following PHP (best run just after you  make a connection).</p>
<p><code>mssql_query("SET TEXTSIZE 2147483647");</code></p>
<p>A better way to work around the issue is to change the &#8220;textlimit&#8221;  and &#8220;textsize&#8221; settings within php.ini, like so:</p>
<p><code>mssql.textlimit = 2147483647 mssql.textsize = 2147483647</code></p>
<p>In the above examples, I have used &#8220;2147483647&#8243; (number of bytes) for  the value. You don&#8217;t need to set it this high necessarily, however  there is no real harm in doing so.</p>
<p>And why does this not happen with ASP? When you use Microsoft&#8217;s SQL  Server ODBC driver and OLE DB Provider, textsize is automatically set to  2147483647 when a connection is made.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.simsekmert.com/wp/2010/06/sql-server-php-and-truncating-text/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>the Tar Command &#8211; Archiving, Compression, Encoding And Encryption</title>
		<link>http://www.simsekmert.com/wp/2010/06/the-tar-command-archiving-compression-encoding-and-encryption/</link>
		<comments>http://www.simsekmert.com/wp/2010/06/the-tar-command-archiving-compression-encoding-and-encryption/#comments</comments>
		<pubDate>Mon, 07 Jun 2010 07:01:38 +0000</pubDate>
		<dc:creator>Şimşek Mert</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[tar]]></category>

		<guid isPermaLink="false">http://www.simsekmert.com/wp/?p=126</guid>
		<description><![CDATA[How Can I Do Archiving With Tar?]]></description>
			<content:encoded><![CDATA[<p>The tar (tape archive) command bundles a bunch of files together and creates an archive (commonly called a tar file or tarball) on a tape, disk drive, or floppy disk. The original files are not deleted after being copied to the tar file. </p>
<p>To create an archive using tar, use a command like this, which bundles all the files in the current directory that end with  .doc into the alldocs.tar file:</p>
<p>tar cvf alldocs.tar *.doc</p>
<p><span id="more-126"></span></p>
<p>Here&#8217;s a second example, which creates a tar file named panda.tar containing all the files from the panda directory (and any of its subdirectories):</p>
<p>tar cvf panda.tar panda/</p>
<p>In these examples, the c, v, and f flags mean create a new archive, be verbose (list files being archived), and write the archive to a file. You can also create tar files on tape drives or floppy disks, like this:</p>
<p>tar cvfM /dev/fd0 panda Archive the files in the panda directory to floppy disk(s).<br />
tar cvf /dev/rmt0 panda Archive the files in the panda directory to the tape drive.</p>
<p>The /dev/fd0 entry is Linux-ese for &#8220;floppy drive zero&#8221; (your A drive under DOS), and /dev/rmt0 means &#8220;removable media tape zero,&#8221; or your primary tape drive. The M flag means use multiple floppy disks&#8211;when one disk is full, tar prompts you to insert another.</p>
<p>To automatically compress the tar file as it is being created, add the z flag, like this:</p>
<p>tar cvzf alldocs.tar.gz *.doc</p>
<p>In this example, I added the .gz suffix to the archive file name, because the z flag tells tar to use the same compression as the gzip command.</p>
<p>To list the contents of a tar file, use the t (type) flag in a command, like this:</p>
<p>tar tvf alldocs.tar List all files in alldocs.tar.</p>
<p>To extract the contents of a tar file, use the x (extract) flag in a command, like this:</p>
<p>tar xvf panda.tar Extract files from panda.tar.</p>
<p>This will copy all the files from the panda.tar file into the current directory. When a tar file is created, it can bundle up all the files in a directory, as well as any subdirectories and the files in them. So when you&#8217;re extracting a tar file, keep in mind that you might end up with some new subdirectories in the current directory.</p>
<p>We&#8217;ve used several different flags in the sample tar commands so far. Here&#8217;s a list of the most common flags:</p>
<p>c Create a new archive.<br />
t List the contents of an archive.<br />
x Extract the contents of an archive.<br />
f The archive file name is given on the command line (required whenever the tar output is going to a file)<br />
M The archive can span multiple floppies.<br />
v Print verbose output (list file names as they are processed).<br />
u Add files to the archive if they are newer than the copy in the tar file.<br />
z Compress or decompress files automatically.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.simsekmert.com/wp/2010/06/the-tar-command-archiving-compression-encoding-and-encryption/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Download Entire Folder using Wget Command in Linux</title>
		<link>http://www.simsekmert.com/wp/2010/06/download-entire-folder-using-wget-command-in-linux/</link>
		<comments>http://www.simsekmert.com/wp/2010/06/download-entire-folder-using-wget-command-in-linux/#comments</comments>
		<pubDate>Tue, 01 Jun 2010 18:57:00 +0000</pubDate>
		<dc:creator>Şimşek Mert</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[wget]]></category>

		<guid isPermaLink="false">http://www.simsekmert.com/wp/?p=117</guid>
		<description><![CDATA[wget -m http://www.simsekmert.com/FOLDER_TO_DOWNLOAD/

-m,  –mirror
shortcut for -N -r -l inf –no-remove-listing. 

wget -H -r --level=1 -k -p  http://www.simsekmert.com/FOLDER_TO_DOWNLOAD/
-r,  –recursive

Specify recursive download.
-l,  –level=NUMBER
Maximum recursion depth (inf or 0 for infinite).
-k,  –convert-links
Make links in downloaded HTML point to local files.
-p,  –page-requisites
Get all images, etc. needed to display HTML page.

]]></description>
			<content:encoded><![CDATA[<p><code>wget -m http://www.simsekmert.com/FOLDER_TO_DOWNLOAD/</code></p>
<dl>
<dt>-m,  –mirror</dt>
<dd>shortcut for -N -r -l inf –no-remove-listing. </dd>
</dl>
<p><code>wget -H -r --level=1 -k -p  http://www.simsekmert.com/FOLDER_TO_DOWNLOAD/</code></p>
<p>-r,  –recursive</p>
<dl>
<dd>Specify recursive download.</dd>
<dt>-l,  –level=NUMBER</dt>
<dd>Maximum recursion depth (inf or 0 for infinite).</dd>
<dt>-k,  –convert-links</dt>
<dd>Make links in downloaded HTML point to local files.</dd>
<dt>-p,  –page-requisites</dt>
<dd>Get all images, etc. needed to display HTML page.</dd>
</dl>
]]></content:encoded>
			<wfw:commentRss>http://www.simsekmert.com/wp/2010/06/download-entire-folder-using-wget-command-in-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MS-SQL limit command</title>
		<link>http://www.simsekmert.com/wp/2010/04/ms-sql-limit-command/</link>
		<comments>http://www.simsekmert.com/wp/2010/04/ms-sql-limit-command/#comments</comments>
		<pubDate>Mon, 12 Apr 2010 19:44:14 +0000</pubDate>
		<dc:creator>Şimşek Mert</dc:creator>
				<category><![CDATA[MSSQL]]></category>
		<category><![CDATA[Limit]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Top]]></category>

		<guid isPermaLink="false">http://www.simsekmert.com/wp/?p=114</guid>
		<description><![CDATA[This example shows the MS-SQL (Microsoft SQL-Server) counterpiece for  the limit command of MySQL.


-- MS-SQL / SQL-Server 2005
SELECT TOP 15 * FROM ExampleTable WHERE Active = 1 ORDER BY Id DESC

-- MySQL
SELECT * FROM ExampleTable WHERE Active = 1 LIMIT 0,15 ORDER BY Id DESC

]]></description>
			<content:encoded><![CDATA[<p>This example shows the MS-SQL (Microsoft SQL-Server) counterpiece for  the limit command of MySQL.</p>
<p><span id="more-114"></span></p>
<div id="source_code">
<pre><span style="color: #808080; font-style: italic;">-- MS-SQL / SQL-Server 2005</span>
<span style="color: #993333; font-weight: bold;">SELECT</span> TOP <span style="color: #cc66cc;">15</span> * <span style="color: #993333; font-weight: bold;">FROM</span> ExampleTable <span style="color: #993333; font-weight: bold;">WHERE</span> Active = <span style="color: #cc66cc;">1</span> <span style="color: #993333; font-weight: bold;">ORDER</span> <span style="color: #993333; font-weight: bold;">BY</span> Id <span style="color: #993333; font-weight: bold;">DESC</span>

<span style="color: #808080; font-style: italic;">-- MySQL</span>
<span style="color: #993333; font-weight: bold;">SELECT</span> * <span style="color: #993333; font-weight: bold;">FROM</span> ExampleTable <span style="color: #993333; font-weight: bold;">WHERE</span> Active = <span style="color: #cc66cc;">1</span> <span style="color: #993333; font-weight: bold;">LIMIT</span> <span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">15</span> <span style="color: #993333; font-weight: bold;">ORDER</span> <span style="color: #993333; font-weight: bold;">BY</span> Id <span style="color: #993333; font-weight: bold;">DESC</span></pre>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.simsekmert.com/wp/2010/04/ms-sql-limit-command/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL to Select a random row from a database table</title>
		<link>http://www.simsekmert.com/wp/2010/03/sql-to-select-a-random-row-from-a-database-table/</link>
		<comments>http://www.simsekmert.com/wp/2010/03/sql-to-select-a-random-row-from-a-database-table/#comments</comments>
		<pubDate>Wed, 17 Mar 2010 09:49:27 +0000</pubDate>
		<dc:creator>Şimşek Mert</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[random]]></category>
		<category><![CDATA[row]]></category>
		<category><![CDATA[select]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://www.simsekmert.com/wp/?p=109</guid>
		<description><![CDATA[There are lots of ways to select a random record or row from a  database table. Here are some example SQL statements that don&#8217;t require  additional application logic, but each database server requires  different SQL syntax.
Select a random row with MySQL:
SELECT column FROM table
ORDER BY RAND()
LIMIT 1


Select a random row with PostgreSQL:
SELECT [...]]]></description>
			<content:encoded><![CDATA[<p>There are lots of ways to select a random record or row from a  database table. Here are some example SQL statements that don&#8217;t require  additional application logic, but each database server requires  different SQL syntax.</p>
<h3>Select a random row with MySQL:</h3>
<pre>SELECT column FROM table
ORDER BY <strong>RAND()</strong>
LIMIT 1

<span id="more-109"></span></pre>
<h3>Select a random row with PostgreSQL:</h3>
<pre>SELECT column FROM table
ORDER BY <strong>RANDOM()</strong>
LIMIT 1</pre>
<h3>Select a random row with Microsoft SQL Server:</h3>
<pre>SELECT TOP 1 column FROM table
ORDER BY <strong>NEWID()</strong></pre>
<h3>Select a random row with IBM DB2</h3>
<pre>SELECT column, RAND() as IDX
FROM table
ORDER BY IDX FETCH FIRST 1 ROWS ONLY</pre>
<p><a title="DB2 Random Row Selection" href="http://www.timfanelli.com/cgi-bin/pyblosxom.cgi/database/random_row_selection"></a></p>
<h3>Select a random record with Oracle:</h3>
<pre>SELECT column FROM
( SELECT column FROM table
ORDER BY dbms_random.value )
WHERE rownum = 1</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.simsekmert.com/wp/2010/03/sql-to-select-a-random-row-from-a-database-table/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What is the maximum length of a URL?</title>
		<link>http://www.simsekmert.com/wp/2010/03/what-is-the-maximum-length-of-a-url/</link>
		<comments>http://www.simsekmert.com/wp/2010/03/what-is-the-maximum-length-of-a-url/#comments</comments>
		<pubDate>Tue, 16 Mar 2010 07:29:47 +0000</pubDate>
		<dc:creator>Şimşek Mert</dc:creator>
				<category><![CDATA[Web Programlama]]></category>
		<category><![CDATA[length]]></category>
		<category><![CDATA[url]]></category>

		<guid isPermaLink="false">http://www.simsekmert.com/wp/?p=106</guid>
		<description><![CDATA[Although the specification of the  HTTP  protocol does not specify any maximum length, practical limits are imposed by web browser and server software.
Microsoft Internet Explorer (Browser)
Microsoft states that  the maximum length of a URL in Internet Explorer is 2,083 characters,  with no  more than 2,048 characters in the path portion [...]]]></description>
			<content:encoded><![CDATA[<p><span id="KonaBody">Although the <a href="http://www.w3.org/Protocols/rfc2616/rfc2616.html">specification</a> of the  <a href="http://www.boutell.com/newfaq/definitions/http.html">HTTP  protocol</a> does not specify any maximum length, practical limits are imposed by web browser and server software.</span></p>
<h4>Microsoft Internet Explorer (Browser)</h4>
<p><a href="http://support.microsoft.com/kb/q208427/">Microsoft states</a> that  the maximum length of a URL in Internet Explorer is 2,083 characters,  with no  more than 2,048 characters in the path portion of the  <a href="http://www.boutell.com/newfaq/definitions/url.html">URL</a>. In  my tests, attempts to use URLs longer than this produced a clear error message in Internet  Explorer.</p>
<h4>Firefox (Browser)</h4>
<p>After 65,536 characters, the location bar no longer displays the URL in Windows Firefox 1.5.x. However, longer URLs will work. I stopped testing   after 100,000 characters.</p>
<p><span id="more-106"></span></p>
<h4>Safari (Browser)</h4>
<p>At least 80,000 characters will work. I stopped testing after  80,000 characters.</p>
<h4>Opera (Browser)</h4>
<p>At least 190,000 characters will work. I stopped testing after 190,000 characters. Opera 9 for Windows continued to display a fully  editable, copyable and pasteable URL in the location bar even at 190,000  characters.</p>
<h4>Apache (Server)</h4>
<p>My early attempts to measure the maximum URL length in web browsers  bumped into a server URL length limit of approximately 4,000 characters, after which  Apache produces a &#8220;413 Entity Too Large&#8221; error. I used the current up to date Apache build found in Red Hat Enterprise Linux 4. The official Apache documentation only mentions an 8,192-byte limit on an individual field in a request.</p>
<h4>Microsoft Internet Information Server</h4>
<p>The default limit is 16,384 characters (yes, Microsoft&#8217;s web server accepts longer URLs than Microsoft&#8217;s web browser). This is configurable.</p>
<h4>Perl HTTP::Daemon (Server)</h4>
<p>Up to 8,000 bytes will work. Those constructing web application servers  with  Perl&#8217;s HTTP::Daemon module will encounter a 16,384 byte limit on the  combined  size of all HTTP request headers. This does <em>not</em> include  POST-method  form data, file uploads, etc., but it does include the URL. In practice  this resulted in a 413 error when a URL was significantly longer than 8,000 characters. This limitation can be easily removed. Look for all occurrences of <tt>16x1024</tt> in <tt>Daemon.pm</tt> and replace  them with a larger value. Of course, this does increase your exposure to  denial of service attacks.</p>
<h4>Recommendations</h4>
<p>Extremely long URLs are usually a mistake. URLs over 2,000 characters will not work in the most popular web browser. Don&#8217;t use them if you intend your site to work for the majority of Internet users.When you wish to submit a form  containing many fields, which would otherwise produce a very long URL, the standard solution is to use the POST method rather than the GET  method:</p>
<pre>&lt;form action="myscript.php" method="POST"&gt;
...
&lt;/form&gt;</pre>
<p>The form fields are then transmitted as part of the HTTP transaction body, not as part of the URL, and are not subject to the URL length limit. Short-lived information should not be stored in URLs.As a rule of thumb, if a piece of information isn&#8217;t needed to regenerate  the  same page as a result of returning to a favorite or bookmark, then it  doesn&#8217;t belong in the URL.</p>
<h4>The Bookmark Problem</h4>
<p>In very rare cases, it may be useful to keep a large amount of &#8220;state&#8221;  information in a URL. For instance, users of a map-navigating website might wish to add the currently displayed map to their &#8220;bookmarks&#8221; or &#8220;favorites&#8221; list and return later. If you must do this and your  URLs are approaching 2,000 characters in length, keep your representation of the information as compact as you can, squeezing out as much &#8220;air&#8221; as possible. If your field names take up too much  space, use a fixed field order instead. Squeeze out any field that doesn&#8217;t really need to be bookmarked. And avoid large decimal numbers &#8211; use only as much accuracy as you must, and consider a base-64 representation using letters and digits (I didn&#8217;t say this was easy).In extreme cases, consider using the <a href="http://www.gzip.org/">gzip</a> algorithm to  compress your pretty but excessively long URL. Then reencode that binary data in base64 using only characters that are legal in URLs. This can yield a 3-4x space gain, at the cost of some CPU time when you unzip the URL again on the next visit. Again, I never said  it was easy!</p>
<p>An alternative is to store the state information in a file or a database. Then you can store only the identifier needed to look up that information again in the URL. The disadvantage here is that you will have many state files or database records. Some of which might be linked to on websites run by others. One solution to this problem is to delete the state files or database records for the URLs that have not been revisited after a certain amount of time.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.simsekmert.com/wp/2010/03/what-is-the-maximum-length-of-a-url/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

