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

<channel>
	<title>Thoughts from a developer</title>
	<atom:link href="http://www.erikhallander.com/blog/feed" rel="self" type="application/rss+xml" />
	<link>http://www.erikhallander.com/blog</link>
	<description>Technical rants from a performance possessed Swede</description>
	<pubDate>Fri, 22 Aug 2008 09:49:28 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
	<language>en</language>
			<item>
		<title>Pixelator - Yet another transition effect for AS3</title>
		<link>http://www.erikhallander.com/blog/2008/pixelator-yet-another-transition-effect-for-as3.html</link>
		<comments>http://www.erikhallander.com/blog/2008/pixelator-yet-another-transition-effect-for-as3.html#comments</comments>
		<pubDate>Fri, 22 Aug 2008 09:47:55 +0000</pubDate>
		<dc:creator>E.Hallander</dc:creator>
		
		<category><![CDATA[Actionscript 3.0]]></category>

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

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

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

		<category><![CDATA[pixel effect]]></category>

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

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

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

		<guid isPermaLink="false">http://www.erikhallander.com/blog/?p=15</guid>
		<description><![CDATA[
I am not naive enough to believe I originally created this effect. As with anything, there always seems to be someone somewhere that did it sometime before :). Either way, I made a version of it for my previous site in AS2 and it came with me when I updated the site. 
Ever since that [...]]]></description>
			<content:encoded><![CDATA[<div class="summarypic"><img alt="pixelation" src="http://www.erikhallander.com/blog/images/pixelpreview.jpg" /></div>
<p>I am not naive enough to believe I originally created this effect. As with anything, there always seems to be someone somewhere that did it sometime before :). Either way, I made a version of it for my previous site in AS2 and it came with me when I updated the site. </p>
<p>Ever since that first site there&#8217;s been a somewhat steady flow of questions regarding it. I vaguely remember writing a AS2 tutorial for it on <a rel="external" href="http://www.gotoandlearnforum.com/">gotoandlearn</a> and I get a lot of mails regarding it.</p>
<p>So, I figured I&#8217;d take advantage of AS3&#8217;s massive improvements and create a transition class with the same effect. It&#8217;s hard to give it a specific name, but I&#8217;ve always called it the &#8220;<em>pixelating transition</em>&#8220;. You&#8217;ll understand when you check it out. Go ahead tough guy. Click the header!</p>
<span id="more-15"></span>
<p>So, in short, this class will take two displayobjects and create a transition between the both. The DisplayObjects don&#8217;t necessarily need to be on the Display List, in fact it&#8217;s probably wiser to use the Pixelator as an intermediary. You set it up with two clips and add it to the display list. The class itself will do nothing but setup and display the first picture. You can later call a trigger that makes it transition between the first and second image/object. Simple as that.</p>
<p>If you later need to keep transitioning, there&#8217;s also a reconfigure command that allows you to re-setup the class while maintaining the visible appearance. In other words, It&#8217;s just really simple! :)</p><blockquote><p>public function Pixelator(_source:DisplayObject, _dest:DisplayObject, _ct:int = 125)<br />//ct is the cutoff, or how big you want the pixels to become. Larger = bigger.</p></blockquote>
<div id="flashcontent">&nbsp;</div>
<script type="text/javascript">
   var so = new SWFObject("http://www.erikhallander.com/blog/flash/pixelator.swf", "ff", "400", "300", "9", "#22180E");
   so.addParam("scale", "noscale");
   so.addParam("salign", "tl"); 
   so.write("flashcontent");
</script>
<p><a href="http://www.erikhallander.com/blog/?download=pixelator">Download here</a> (350Kb) (<em>3537 downloads</em>)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.erikhallander.com/blog/2008/pixelator-yet-another-transition-effect-for-as3.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>Greensock releases TransformManager, a spectacular AS3 class</title>
		<link>http://www.erikhallander.com/blog/2008/greensock-releases-transformmanager-a-spectacular-as3-class.html</link>
		<comments>http://www.erikhallander.com/blog/2008/greensock-releases-transformmanager-a-spectacular-as3-class.html#comments</comments>
		<pubDate>Sun, 27 Jul 2008 13:54:38 +0000</pubDate>
		<dc:creator>E.Hallander</dc:creator>
		
		<category><![CDATA[Actionscript 3.0]]></category>

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

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

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

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

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

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

		<guid isPermaLink="false">http://www.erikhallander.com/blog/?p=14</guid>
		<description><![CDATA[Just got word from Jack / Greensock (Creator of TweenMax/TweenLite) that his most recent creation, TransformManager, is out on the market. Unlike the tween packages, it&#8217;s not open source, but has a small price tag on it. Personally, I would encourage everyone to either buy this, or support Jack via his Club Greensock. TweenMax/Lite is [...]]]></description>
			<content:encoded><![CDATA[<p>Just got word from Jack / Greensock (Creator of TweenMax/TweenLite) that his most recent creation, <a rel="external" href="http://blog.greensock.com/transformmanageras3/">TransformManager</a>, is out on the market. Unlike the tween packages, it&#8217;s not open source, but has a small price tag on it. Personally, I would encourage everyone to either buy this, or support Jack via his Club Greensock. TweenMax/Lite is an amazing accomplishment from just one person and accomplishments should always be rewarded</p>
<p>Here&#8217;s a snip from the release statement;</p>
<blockquote><p>TransformManager makes it easy to add interactive scaling/rotating/moving of DisplayObjects to your Flash application. It uses an intuitive interface that&#8217;s similar to most modern drawing applications. When the user clicks on a managed DisplayObject, a selection box will be drawn around it along with 8 handles for scaling/rotating. When the mouse is placed just outside of any of the scaling handles, the cursor will change to indicate that they&#8217;re in rotation mode. Just like most other applications, the user can hold down the SHIFT key to select multiple items, to constrain scaling proportions, or to limit the rotation to 45 degree increments.</p></blockquote>
<p>As mentioned; this class, unlike the other ones Jack released, does come at a small price. I know people go to great great <strong>GREAT</strong> lengths to not have to pay for their music, software, classes et cetera but at some point you should step back and consider the implications it has on the evolution of web products. I&#8217;ve personally always been a &#8216;pay for your shit&#8217; vigilante and I strongly encourage everyone to pay for anything you&#8217;re using on a regular basis.</p>
<p>That preach being done, if you use TweenMax/Lite, do check out the transform manager and it&#8217;s cool features! <a rel="external" href="http://blog.greensock.com/transformmanageras3/">TransformManager</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.erikhallander.com/blog/2008/greensock-releases-transformmanager-a-spectacular-as3-class.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>Update alert: Circle loader</title>
		<link>http://www.erikhallander.com/blog/2008/update-alert-circle-loader.html</link>
		<comments>http://www.erikhallander.com/blog/2008/update-alert-circle-loader.html#comments</comments>
		<pubDate>Thu, 17 Jul 2008 21:40:19 +0000</pubDate>
		<dc:creator>E.Hallander</dc:creator>
		
		<category><![CDATA[Actionscript 3.0]]></category>

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

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

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

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

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

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

		<guid isPermaLink="false">http://www.erikhallander.com/blog/?p=13</guid>
		<description><![CDATA[Quick and short post. Due to a suggestion from Ryan Ragona I checked out how much resources the circle loader took up and it was pretty unacceptable. I re-wrote the class so that it snapshots the vectors to a bitmap object and rotates that instead of the vectors (vectors are now never even added to [...]]]></description>
			<content:encoded><![CDATA[<p>Quick and short post. Due to a suggestion from <a rel="external" href="http://www.ragonadesign.com/">Ryan Ragona</a> I checked out how much resources the circle loader took up and it was pretty unacceptable. I re-wrote the class so that it snapshots the vectors to a bitmap object and rotates that instead of the vectors (vectors are now never even added to the display list)</p>
<p>CPU usage on my dual 3.2 went from 11% to 1%. Quite a difference. I would strongly encourage you to re-download it if you plan to use it. (I also updated the original link)</p>
<p><a href="http://www.erikhallander.com/blog/?download=circle">Download V2</a> (300Kb) (<em>3903 downloads</em>)</p>]]></content:encoded>
			<wfw:commentRss>http://www.erikhallander.com/blog/2008/update-alert-circle-loader.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>A customizable gradient circle loader / animation for AS3</title>
		<link>http://www.erikhallander.com/blog/2008/a-customizable-gradient-circle-loader-animation-for-as3.html</link>
		<comments>http://www.erikhallander.com/blog/2008/a-customizable-gradient-circle-loader-animation-for-as3.html#comments</comments>
		<pubDate>Sun, 13 Jul 2008 15:02:38 +0000</pubDate>
		<dc:creator>E.Hallander</dc:creator>
		
		<category><![CDATA[Actionscript 3.0]]></category>

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

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

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

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

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

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

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

		<guid isPermaLink="false">http://www.erikhallander.com/blog/?p=12</guid>
		<description><![CDATA[
That&#8217;s quite a topic. &#8220;A customizable gradient circle loader / animation for AS3&#8220;. I wrote it then looked at it and couldn&#8217;t help giggling. Aaaanyway. You know the one, we&#8217;ve all seen it. From the worst sites to the best sites, every now and then you see that circle that spins with an internal gradient. [...]]]></description>
			<content:encoded><![CDATA[<div class="summarypic"><img alt="snake" src="http://www.erikhallander.com/blog/images/SnakeScreen.jpg" /></div>
<p>That&#8217;s quite a topic. &#8220;<em>A customizable gradient circle loader / animation for AS3</em>&#8220;. I wrote it then looked at it and couldn&#8217;t help giggling. Aaaanyway. You know the one, we&#8217;ve all seen it. From the worst sites to the best sites, every now and then you see that circle that spins with an internal gradient. Like a snake trying to eat its own tail.</p>
<p>Most commonly these are bitmaps. Pngs exported from PS that are rotated. The problem with that is that it becomes pretty <em>rigid</em>. If you need to change the width or height or whatnot, you&#8217;re quickly faced with re-exporting a new one. Actually more or less the same thing goes for those that took the time to make it with Illustrator. Once you are faced with increasing the inner radius and not the outer, or vice versa - you gotta redo it.</p>
<p>Soooooo, without further adieu, here&#8217;s a scripted version that uses the drawing API to construct a circle that is fairly customizable. You can use it as a loading animation or just .. just a spinning circle because how cool aren&#8217;t spinning circles? Much much cooler than <a href="http://www.erikhallander.com/blog/2008/bitmapvector-into-firefly-particles-as30.html">fireflies</a>, for sure!</p>
<span id="more-12"></span>
<p>Alright so, it&#8217;s a class. The class has three public functions. The constructor creates the initial circle with your arguments (inner and outer radius, rotation speed, color) and after that you can call a <em>start()</em> method to make it visible and start spinning. Alternatively, <em>stop() </em>shuts it down and makes it non visible, but it does NOT remove it from memory, you can restart it again. It just clears the listeners. If you want to kill it, you need to remove the instance from the displaylist.</p>
<blockquote><p>public function SnakeCircle(_radius:int,  _circleSize:int, fillColor:uint, speed:Number, direction:String = &#8220;CLOCKWISE&#8221;):void</p></blockquote>
<p>The sliders are (top to bottom): Speed, Inner Radius, Outer Radius. Also a little cute colorpicker. <em>Click the circle to change direction</em></p>
<div style="height:400;width:400;" id="snakeflash">&nbsp;</div>
<p>All that remains now is the <a href="http://www.erikhallander.com/blog/?download=circle">Download Link</a> (300Kb) (<em>3903 downloads</em>)</p>
<p><em>(I know, 300k wtf right!?! Friggin components&#8230; not to worry though, the swf is 17 kb :P)</em></p>
<script type="text/javascript">
   var so = new SWFObject("http://www.erikhallander.com/blog/flash/circle.swf", "snakeflash", "400", "400", "9", "#22180E");
   so.addParam("scale", "noscale");
   so.addParam("salign", "tl"); 
   so.write("snakeflash");
</script>
]]></content:encoded>
			<wfw:commentRss>http://www.erikhallander.com/blog/2008/a-customizable-gradient-circle-loader-animation-for-as3.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>Transition effect for AS3 with Perlin noise and DisplacementMap</title>
		<link>http://www.erikhallander.com/blog/2008/transition-effect-for-as3-with-perlin-noise-and-displacementmap.html</link>
		<comments>http://www.erikhallander.com/blog/2008/transition-effect-for-as3-with-perlin-noise-and-displacementmap.html#comments</comments>
		<pubDate>Wed, 25 Jun 2008 22:51:00 +0000</pubDate>
		<dc:creator>E.Hallander</dc:creator>
		
		<category><![CDATA[Actionscript 3.0]]></category>

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

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

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

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

		<category><![CDATA[perlin noise]]></category>

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

		<guid isPermaLink="false">http://www.erikhallander.com/blog/?p=11</guid>
		<description><![CDATA[&#160;

   var so = new SWFObject("http://www.erikhallander.com/blog/flash/perlin_transition.swf", "perlinflash", "400", "400", "9", "#22180E");
   so.addParam("scale", "noscale");
   so.addParam("salign", "tl"); 
   so.write("perlinflash");

Well.. everyone loves transitions right? I do anyway. Even if they are utterly useless like the firefly one I posted a few days ago I still enjoy it just for the [...]]]></description>
			<content:encoded><![CDATA[<div style="float:right;clear:both;height:400;width:400;" id="perlinflash">&nbsp;</div>
<script type="text/javascript">
   var so = new SWFObject("http://www.erikhallander.com/blog/flash/perlin_transition.swf", "perlinflash", "400", "400", "9", "#22180E");
   so.addParam("scale", "noscale");
   so.addParam("salign", "tl"); 
   so.write("perlinflash");
</script>
<p>Well.. everyone loves transitions right? I do anyway. Even if they are utterly useless like the firefly one I posted a few days ago I still enjoy it just for the sake of the &#8216;<em>ooooo</em>&#8216; effect it can produce. I&#8217;ve always been a bit of a sucker for the pure visual parts of flash, which is probably why I went in the direction of ActionScript instead of C# or something else.</p>
<p>This class will take any content you give to it <em>(A displayobject is required though)</em> and distort it with the help of Perlin Noise, DisplacementMapFilter and a Blurfilter. The end result is something that looks like its &#8216;<em>rippling out</em>&#8216;. (lack of better words! haha)</p>
<p>It dispatches an event when the content is completely gone, and you can choose what to do before starting the &#8216;road back&#8217; so to speak. The last event it dispatches triggers a reset of the parameters so you can do it all over again! Click the ducky to try it! Download the class inside&#8230;</p>
<span id="more-11"></span>
<p>As always, if you like it, it&#8217;d be cool if you left a digg or a comment! I&#8217;ll answer any questions you might have in the means of time or whatnot ;)</p>
<p><a href="http://www.erikhallander.com/blog/?download=perlin">Download here</a> (20Kb) (<em>4297 downloads</em>)</p>
<script type="text/javascript">
   var so = new SWFObject("http://www.erikhallander.com/blog/flash/perlin_transition.swf", "ff", "400", "400", "9", "#22180E");
   so.addParam("scale", "noscale");
   so.addParam("salign", "tl"); 
   so.write("perlinflash");
</script>]]></content:encoded>
			<wfw:commentRss>http://www.erikhallander.com/blog/2008/transition-effect-for-as3-with-perlin-noise-and-displacementmap.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>Get a unique random value or position from an array in AS3</title>
		<link>http://www.erikhallander.com/blog/2008/get-a-unique-random-value-or-position-from-an-array-in-as3.html</link>
		<comments>http://www.erikhallander.com/blog/2008/get-a-unique-random-value-or-position-from-an-array-in-as3.html#comments</comments>
		<pubDate>Sun, 22 Jun 2008 03:05:28 +0000</pubDate>
		<dc:creator>E.Hallander</dc:creator>
		
		<category><![CDATA[Actionscript 3.0]]></category>

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

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

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

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

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

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

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

		<guid isPermaLink="false">http://www.erikhallander.com/blog/?p=10</guid>
		<description><![CDATA[Admittedly, this is nothing fancy like crazy fireflies! Just a small auxiliary class I wrote just now because I needed it in a project. I call it Shuffler. :)
What it basically does is to generate either a random position in the array, or return the value at that position, but keeps it unique (ie: no [...]]]></description>
			<content:encoded><![CDATA[<p>Admittedly, this is nothing fancy like crazy fireflies! Just a small auxiliary class I wrote just now because I needed it in a project. I call it Shuffler. :)</p>
<p>What it basically does is to generate either a random position in the array, or return the value at that position, but keeps it unique (ie: no value will appear twice). It&#8217;s super lightweight and has close to no commenting whatsoever! haha!</p>
<span id="more-10"></span>
<p>Quick syntax:</p>
<blockquote><p>import com.utils.shuffler;<br />shuffler.addSource(array_with_values);<br />trace(shuffler.getUniqueValue());</p></blockquote>
<p>Or, if you just want the position in the array returned (better performance wise)</p>
<blockquote><p>import com.utils.shuffler;<br />shuffler.addSource(array_with_values);<br />trace(shuffler.getUniquePosition());</p></blockquote>
<p>You can download the class files and example FLA by <a href="http://www.erikhallander.com/blog/?download=shuffler">clicking here</a> (8Kb) (<em>771 downloads</em>)</p>]]></content:encoded>
			<wfw:commentRss>http://www.erikhallander.com/blog/2008/get-a-unique-random-value-or-position-from-an-array-in-as3.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>Bitmap/Vector into firefly particles AS3.0</title>
		<link>http://www.erikhallander.com/blog/2008/bitmapvector-into-firefly-particles-as30.html</link>
		<comments>http://www.erikhallander.com/blog/2008/bitmapvector-into-firefly-particles-as30.html#comments</comments>
		<pubDate>Thu, 19 Jun 2008 17:21:43 +0000</pubDate>
		<dc:creator>E.Hallander</dc:creator>
		
		<category><![CDATA[Actionscript 3.0]]></category>

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

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

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

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

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

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

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

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

		<guid isPermaLink="false">http://www.erikhallander.com/blog/?p=9</guid>
		<description><![CDATA[
Inside you can find a quick experiment + source to a AS3 class that breaks up vectors/bitmaps into particles and then moves them around in a semi-random firefly pattern. It&#8217;s a little bit CPU intense so I added a fps meter (fpsbox, courtesy of Schell Scivally). On lesser computers I&#8217;m sure it can choke a [...]]]></description>
			<content:encoded><![CDATA[<div class="summarypic"><img src="http://www.erikhallander.com/blog/images/as3_ff.jpg" alt="particles" id="particles" /></div>
<p>Inside you can find a quick experiment + source to a AS3 class that breaks up vectors/bitmaps into particles and then moves them around in a semi-random firefly pattern. It&#8217;s a little bit CPU intense so I added a fps meter (fpsbox, courtesy of Schell Scivally). On lesser computers I&#8217;m sure it can choke a little bit due to the 2000-ish bitmap particles swarming around with filters but all it all it should be fairly okay.</p>
<p>I guess it&#8217;s fairly useless, usability wise, but it looks friggin cool and it can handle any shape or size. The larger, the slower however&#8230;.</p> 
<span id="more-9"></span>
<p>You can revert back (animates back) and that jazz as well. Please note that the in/out motion is done with <a rel="external" href="http://blog.greensock.com/tweenmaxas3/">TweenMax</a>, so if you don&#8217;t have it you might want to download it first. Thanks Greensock ;) His collection of tween libraries are lightning speed fast! :P</p>
<div id="flashcontent">&nbsp;</div>
<script type="text/javascript">
   var so = new SWFObject("http://www.erikhallander.com/blog/flash/fireflies.swf", "ff", "400", "400", "9", "#22180E");
   so.addParam("scale", "noscale");
   so.addParam("salign", "tl"); 
   so.write("flashcontent");
</script>
<p><a href="http://www.erikhallander.com/blog/?download=fireflies">Download here</a> (20Kb) (<em>5012 downloads</em>)</p>]]></content:encoded>
			<wfw:commentRss>http://www.erikhallander.com/blog/2008/bitmapvector-into-firefly-particles-as30.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>Free stuff: Automatic MySQL table optimizer</title>
		<link>http://www.erikhallander.com/blog/2008/free-stuff-automatic-mysql-table-optimizer.html</link>
		<comments>http://www.erikhallander.com/blog/2008/free-stuff-automatic-mysql-table-optimizer.html#comments</comments>
		<pubDate>Fri, 13 Jun 2008 01:37:47 +0000</pubDate>
		<dc:creator>E.Hallander</dc:creator>
		
		<category><![CDATA[MySQL]]></category>

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

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

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

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

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

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

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

		<guid isPermaLink="false">http://www.erikhallander.com/blog/?p=7</guid>
		<description><![CDATA[
One of the most irritating aspects of the web is that you so often find (almost) exactly what you&#8217;re looking for, but seldom just exactly. There&#8217;s bits and pieces out there and it can be terribly frustrating to combine information from multiple sources since they don&#8217;t always merge well or are compatible. Enough talk. Here&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<div class="summarypic"><img src="http://www.erikhallander.com/blog/images/icon.jpg" alt="mysql" id="mysql" /></div>
<p>One of the most irritating aspects of the web is that you so often find (almost) exactly what you&#8217;re looking for, but seldom <em>just exactly</em>. There&#8217;s bits and pieces out there and it can be terribly frustrating to combine information from multiple sources since they don&#8217;t always merge well or are compatible. Enough talk. Here&#8217;s the free stuff! : <b>mysqlTuner</b>!</p>
<p>I&#8217;ve written and compiled a script that will automatically keep your MySQL database in tip-top condition, and tried my best to keep the installation process to a bare minimum&#8230;</p>
<span id="more-7"></span>
<p><span class="entryheadlinesmall">How it works, and why you should care</span></p>
<p>To cut to the chase, databases delete, add and update data so often that eventually a lot of redundant data is created. This data does not only take up space, it also makes your queries run slower. For a more in-depth view on MySQL, please do read <a href="http://www.erikhallander.com/blog/2008/web-server-performance-guide-part-23-mysql.html">my entry</a> on it. You can get rid of this by doing something called &#8220;table optimization&#8221;. This can be done in a few different ways, phpMyAdmin among other things.</p>
<p><b>mysqlTuner</b> relies on one of two things. It can either be called through a PHP script which you can bookmark for easy access, or set up through a server scheduler. (Cron is the most common one). There&#8217;s also no need to worry about your database information to be compromised since it is accessed with arguments instead of storing data somewhere. If you have access to cron, there&#8217;s actually not even any need to put the file that is accessible from the web whatsoever.</p>
<p><span class="entryheadlinesmall">How do I use it?!</span></p>
<p>mysqlOptimizer is a shell script that runs on your linux server with command line arguments. To optimize the table my_blog, you need the username and password of a user that has access to that database. After you fetch that, you can run the shell script from the command line as;</p>
<blockquote><p>sh mysqlOptimizer.sh username password databasename</p></blockquote>
<p>Logging in to run it every time can get old fast however, so I advice you&#8217;d do one of these two:</p>
<p><span class="entryheadlinesmall">Option 1: You have access to Cron either through a control panel or SSH</span></p>
<p>Easy peasy. Put the file in a directory of your choice and password protect it or block web access through .htaccess. Schedule the file to run through cron at an interval you see fit (<a href="http://www.adminschoice.com/docs/crontab.htm" rel="external">here</a> is a tutorial on how to use cron):</p>
<blockquote><p>30 2 * * * sh /path/mysqlOptimizer.sh user password database</p></blockquote>
<p>The example above will run at 2.30 AM (02.30 for Euros :D) every day, optimizing your stuff for you! ;)</p>
<p><span class="entryheadlinesmall">Option 2: No Cron Access! :(</span></p>
<p>Don&#8217;t despair! You can create a php file to run the shell file through <a href="http://us3.php.net/function.exec" rel="external">exec()</a>. I have included some information regarding this in the README.TXT, but you need to at least have some basic PHP knowledge. Also, if your server has <em>safe_mode</em> on, you need to make sure you are running the file in a dir defined by <em>safe_mode_exec_dir</em>.</p>
<p><span class="entryheadlinesmall">Can it mess up my data??</span></p>
<p>Short answer is no. The OPTIMIZE command is non destructive and can&#8217;t mess anything up by itself. As long as you read the docs, you are fine. /hug</p>
<p><span class="entryheadlinesmall">I don&#8217;t know how to do this :(</span></p>
<p>Feel free to ask, but most importantly, google is your friend! Usually your host support techs will be happy to help you set up a cron job too. After all, you are paying them for it! :D There&#8217;s a few additional pointers in the README.TXT.</p>
<p>Share, steal, copy, improve, break. I really don&#8217;t care! If you like it, let me know!</p>
<p><a href="http://www.erikhallander.com/blog/?download=mysqloptimizer">Download here</a> (4Kb) (<em>601 downloads</em>)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.erikhallander.com/blog/2008/free-stuff-automatic-mysql-table-optimizer.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>Lightweight SHA1 encryption class for Actionscript 3</title>
		<link>http://www.erikhallander.com/blog/2008/lightweight-sha1-encryption-class-for-actionscript-3.html</link>
		<comments>http://www.erikhallander.com/blog/2008/lightweight-sha1-encryption-class-for-actionscript-3.html#comments</comments>
		<pubDate>Tue, 10 Jun 2008 15:53:53 +0000</pubDate>
		<dc:creator>E.Hallander</dc:creator>
		
		<category><![CDATA[Actionscript 3.0]]></category>

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

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

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

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

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

		<guid isPermaLink="false">http://www.erikhallander.com/blog/?p=8</guid>
		<description><![CDATA[Don&#8217;t send unencrypted data from Flash to PHP. I&#8217;ve prepared a class that will take a string and convert it to HEX SHA1. It&#8217;s fully compatible to compare with PHP sha1(), puts less than 1Kb filesize penalty to your project and is able to iterate through at least 50 calculations a second&#8230;

You can download the [...]]]></description>
			<content:encoded><![CDATA[<p>Don&#8217;t send unencrypted data from Flash to PHP. I&#8217;ve prepared a class that will take a string and convert it to HEX SHA1. It&#8217;s fully compatible to compare with PHP sha1(), puts less than 1Kb filesize penalty to your project and is able to iterate through at least 50 calculations a second&#8230;</p>
<span id="more-8"></span>
<p>You can download the class file and an example <a href="http://www.erikhallander.com/blog/?download=shaencrypt">FLA+Document class here</a> (8Kb) (<em>1613 downloads</em>)</p>
<p>Modify, break, sell, copy, steal or improve. If you like it, tell me!</p>]]></content:encoded>
			<wfw:commentRss>http://www.erikhallander.com/blog/2008/lightweight-sha1-encryption-class-for-actionscript-3.html/feed</wfw:commentRss>
		</item>
		<item>
		<title>Web server performance guide, part 2/3 - MySQL</title>
		<link>http://www.erikhallander.com/blog/2008/web-server-performance-guide-part-23-mysql.html</link>
		<comments>http://www.erikhallander.com/blog/2008/web-server-performance-guide-part-23-mysql.html#comments</comments>
		<pubDate>Mon, 09 Jun 2008 14:04:19 +0000</pubDate>
		<dc:creator>E.Hallander</dc:creator>
		
		<category><![CDATA[Linux]]></category>

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

		<category><![CDATA[Web stuff]]></category>

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

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

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

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

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

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

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

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

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

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

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

		<guid isPermaLink="false">http://www.erikhallander.com/blog/?p=6</guid>
		<description><![CDATA[Following up my previous post regarding server performance, I wanted to try and communicate my experiences with tuning specific applications that might run alongside (and under) Apache. MySQL has become amazingly popular during the last couple of years and its popularity is not undeserved. It performs well already out of the box and the fifth [...]]]></description>
			<content:encoded><![CDATA[<p>Following up my <a href="http://www.erikhallander.com/blog/2008/web-server-performance-guide-part-13.html">previous post</a> regarding server performance, I wanted to try and communicate my experiences with tuning specific applications that might run alongside (<em>and under</em>) Apache. MySQL has become amazingly popular during the last couple of years and its popularity is not undeserved. It performs well already out of the box and the fifth version is incredibly stable.</p>
<p>There are (<em>of course! :D</em>) a number of things you can do to improve your mySQL performance however, and here they are, in all their glory! :p</p>
<p><span class="entryheadline">MySQL tuning:</span></p>
<span id="more-6"></span>
<p>One of the most surprising aspects of MySQLd is that it so often comes served with little to no cache in the main config. No query cache is especially devastating for servers that run applications with constant small database accesses (<em>much like WordPress</em>). To elaborate; Query-Cache is a buffer where MySQLd stores Query Results. When an incoming query comes from Apache, MySQLd checks its cache for matches before parsing. The query cache (obviously) has a timeout and never lives long enough to cause problems for rapidly updating content. For for example, if these two queries come in, subsequently:</p>
<blockquote><p>SELECT tbl.posts FROM db.posts LIMIT 20<br />SELECT tbl.posts FROM db.posts LIMIT 20</p></blockquote>
<p>Only the first one will actually be parsed and run through the database. The second one matches byte by byte and will hence get fetched from the cache (<em>which is significantly faster</em>). So, cache is good. There&#8217;s a couple of other types of cache, apart from Query cache which all can benefit your blog.. or&#8230; eCommerce site or whatever you want to improve :)</p>
<p>Start by grabbing a backup of your current configuration. Again, if you need a brush up with the text editor Vi, there&#8217;s a good one <a href="http://amath.colorado.edu/computing/unix/vi/" rel="external">here</a>:</p>
<blockquote><p>cp /etc/my.cnf /etc/my.bak<br />vi /etc/my.cnf</p></blockquote>
<p>Navigate your way to this section (<em>normally is at the top</em>)</p>
<blockquote><p>[mysqld]</p></blockquote>
<p>Without going in too deep on the subject, below follows a list of key settings for a well performing database server (<em>note that some of these might be omitted from your configuration by default.</em>):</p>
<ul>
<li><span class="entryspan">query-cache-type: (<em>controls whether Qcache is on/off. Default is off</em>)</span></li>
<li><span class="entryspan">query-cache-size: (<em>Specifies the size of your Qcache</em>)</span></li>
<li><span class="entryspan">key_buffer_size: (<em>A cache mechanism to keep the most frequently accessed table blocks in memory</em>)</span></li>
<li><span class="entryspan">read_buffer_size: (<em>Each request that performs a sequential scan of a table allocates a read buffer.</em>)</span></li>
<li><span class="entryspan">table_cache: (<em>A combination of read buffer and key buffer, but only keeps critical data</em>)</span></li>
<li><span class="entryspan">wait_timeout: (<em>The number of seconds the server waits for activity on a non-interactive connection before closing it</em>)</span></li>
<li><span class="entryspan">interactive_timeout: (<em>I&#8217;ll let you take a stab at what this means ;)</em>)</span></li>
<li><span class="entryspan">connect_timeout: (<em>The number of seconds that the MySQLd server waits for a connect packet before sending a kill signal</em>)</span></li>
<li><span class="entryspan">skip-innodb: (<em>Sets whether innodb is allowed or not. More on this below</em>)</span></li>
</ul>
<p>You could discuss the optimal setting for these indefinitely, so I&#8217;m just going to leave it with this: MySQLd is programmed to run in very low memory environments. If it is allowed more memory, it will run better. Memory also means cache, cache generally means improved speed. Most servers have well beyond the default memory cap that MySQLd takes up out of the box, and unless you are on a server with 128MB or less available memory, these following settings should results in a <em>major performance boost for your database applications</em>. Do note that if the setting doesn&#8217;t exist at all in your config file, you can just add it:</p>
<blockquote><p>max_connections = 400<br />
key_buffer = 16M<br />
sort_buffer_size = 2M<br />
read_buffer_size = 1M<br />
table_cache = 1024<br />
interactive_timeout = 15<br />
connect_timeout = 10<br />
query_cache_limit = 1M<br />
query_cache_size = 16M<br />
query_cache_type = 1<br />
skip-innodb<br /></p></blockquote>
<p>It&#8217;s <em>VERY IMPORTANT</em> to notice that if you run innodb applications you need to take out that last line (for Plesk users: Plesk uses innodb for user management!) otherwise they will cease to function! Save and restart MySQLd;</p>
<blockquote><p>/etc/init.d/mysqld stop<br />/etc/init.d/mysqld start</p></blockquote>
<p><span class="entryheadlinesmall">Table optimization:</span></p>
<p>Apart from configuration, another key issue to smooth SQL sailing is keeping your tables repaired and optimized. You can do this regularly through <em>phpmyadmin</em>, or you can set up a script to do it for you. Optimizing a table is most beneficial if you have deleted a large part of a table or if you have made many changes to a table with variable-length rows (tables that have <em>VARCHAR</em>, <em>VARBINARY</em>, <em>BLOB</em>, or <em>TEXT</em> columns, which is most of them). Deleted rows are maintained in a linked list and new INSERT queries reuse old row positions. This causes a slowdown in response time as the list grows larger. You can Optimize the table to kill the dead positions and to defragment the data file. This process will also free up storage space. On eCommerce sites or community sites or active blogs, Optimizing the tables will have a <em>significant</em> impact in the response time of your MySQLd.</p>
<p><span class="entryheadlinesmall">Misc performance tips</span></p>
<p>Lastly, let me just touch briefly on table design. There&#8217;s an excellent article on database partitioning, something every MySQL developer should read. You can find it <a href="http://dev.mysql.com/tech-resources/articles/performance-partitioning.html" rel="external">here</a>. Here are a couple of quick hints on how to design and query your database for maximum performance;</p>
<ul>
<li><span class="entryspan">Don&#8217;t use <em>DISTINCT</em> when you could use <em>GROUP BY</em></span></li>
<li><span class="entryspan">Make similar queries identical/very similar so <em>Qcache</em> is used</span></li>
<li><span class="entryspan">Avoid wildcards at the start of <em>LIKE</em> queries</span></li>
<li><span class="entryspan">Don&#8217;t avoid table joins, they are faster than denormalization</span></li>
<li><span class="entryspan">Use <em>LOAD DATA</em> instead of <em>INSERT</em> </span></li>
</ul>
<p>In closing, don&#8217;t forget to optimize!</p>]]></content:encoded>
			<wfw:commentRss>http://www.erikhallander.com/blog/2008/web-server-performance-guide-part-23-mysql.html/feed</wfw:commentRss>
		</item>
	</channel>
</rss>
