<?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>Collectively Speaking</title>
	<atom:link href="http://collectivecolony.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://collectivecolony.com/blog</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Fri, 19 Mar 2010 00:24:23 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Helpful MySQL Tips and General Understandings</title>
		<link>http://collectivecolony.com/blog/2010/03/18/helpful-mysql-tips-and-general-understandings/</link>
		<comments>http://collectivecolony.com/blog/2010/03/18/helpful-mysql-tips-and-general-understandings/#comments</comments>
		<pubDate>Thu, 18 Mar 2010 23:35:02 +0000</pubDate>
		<dc:creator>Collin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Data Types]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://collectivecolony.com/blog/?p=21</guid>
		<description><![CDATA[I&#8217;ve only worked in the Web industry for a handful of years at this point but in that time, I&#8217;ve realized there is plenty to learn and adjust to, specifically from a project-to-project basis. One thing, though, that seems to be pretty consistent across the board and that drives me up the wall is inefficiencies [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve only worked in the Web industry for a handful of years at this point but in that time, I&#8217;ve realized there is plenty to learn and adjust to, specifically from a project-to-project basis. One thing, though, that seems to be pretty consistent across the board and that drives me up the wall is inefficiencies due to laziness. Having worked in a team environment for the last few years, I&#8217;ve had the opportunity to dive into other projects to meet deadlines, troubleshoot issues, etc., and boy have I encountered some wonderful code that has caused some sever headaches for a few days.  So, to help alleviate the headaches, I&#8217;ve compiled a short list of commonly encountered inefficiencies that I tend to find on the database side of projects.</p>
<p>Most of the following is scattered around the Web, but I simply wanted to centralize the most useful of the bunch.  If you have any of your own useful gems, want to share your frustration drop us a line; we&#8217;ll gladly add to the list.</p>
<h4>Data Types</h4>
<p>A year or so ago I came across <a title="Choosing Optimal Mysql Data Types" href="http://www.making-the-web.com/2008/04/27/choosing-optimal-mysql-data-types/">this outstanding post</a> that, unfortunately, no longer seems to exist.  Thankfully, I&#8217;ve compiled my own chart for the more commonly used datatypes.  I find this very handy when working on my database schemas.</p>
<table>
<tbody>
<tr>
<th width="200px">Type</th>
<th width="130px">Minimum</th>
<th width="130px">Maximum</th>
</tr>
<tr>
<td>SIGNED TINYINT</td>
<td align="right">-128</td>
<td align="right">127</td>
</tr>
<tr>
<td>UNSIGNED TINYINT</td>
<td align="right">0</td>
<td align="right">255</td>
</tr>
<tr>
<td>SIGNED SMALLINT</td>
<td align="right">-32768</td>
<td align="right">32767</td>
</tr>
<tr>
<td>UNSIGNED SMALLINT</td>
<td align="right">0</td>
<td align="right">65535</td>
</tr>
<tr>
<td>SIGNED MEDIUMINT</td>
<td align="right">-8388608</td>
<td align="right">8388607</td>
</tr>
<tr>
<td>UNSIGNED MEDIUMINT</td>
<td align="right">0</td>
<td align="right">16777215</td>
</tr>
<tr>
<td>SIGNED INT</td>
<td align="right">-2147483648</td>
<td align="right">2147483647</td>
</tr>
<tr>
<td>UNSIGNED INT</td>
<td align="right">0</td>
<td align="right">4294967295</td>
</tr>
<tr>
<td>SIGNED BIGINT</td>
<td align="right">-9.22E+018</td>
<td align="right">9.22E+018</td>
</tr>
<tr>
<td>UNSIGNED BIGINT</td>
<td align="right">0</td>
<td align="right">1.84E+019</td>
</tr>
</tbody>
</table>
<h4>Password Storage</h4>
<p>I&#8217;m notorious for forgetting required storage sizes for hash values.  Listed below is a simple outline for your reference (and ours).</p>
<table>
<tbody>
<tr>
<th width="130">Algo</th>
<th width="100">Size</th>
<th width="100">Data Type</th>
</tr>
<tr>
<td>md5</td>
<td align="right">16 bytes</td>
<td align="right">char(32)</td>
</tr>
<tr>
<td>sha1</td>
<td align="right">20 bytes</td>
<td align="right">char(40)</td>
</tr>
<tr>
<td>sha256</td>
<td align="right">32 bytes</td>
<td align="right">char(64)</td>
</tr>
<tr>
<td>sha384</td>
<td align="right">48 bytes</td>
<td align="right">char(96)</td>
</tr>
<tr>
<td>sha512</td>
<td align="right">64 bytes</td>
<td align="right">char(128)</td>
</tr>
</tbody>
</table>
<h4>IP Storage</h4>
<p>Typically I see all IP information stored in a VARCHAR(15). This works just fine, however, let&#8217;s say your client asks you to gather some reports on an specific IP &#8211; maybe they are asking for a subnet count or even an IP range lookup. This could get messy depending on the database size.  I will leave out the specifics here and direct you to <a title="Mysql IP Storage Optimization" href="http://bafford.com/2009/03/09/mysql-performance-benefits-of-storing-integer-ip-addresses/">bafford.com</a> for a quality read on the details and breakdown of storing an IP as an UNSIGNED INT as opposed to a VARCHAR(15).  All I can recommend is: utilize INET functions; integers are much easier to work with and there is a significant performance boost.  The following snippet is the basic usage (from <a title="MySQL Miscellaneous Functions" href="http://dev.mysql.com/doc/refman/5.1/en/miscellaneous-functions.html">dev.mysql.com&#8217;s</a> resources):</p>
<pre class="brush: sql;">INSERT INTO users (ip) VALUES (INET_ATON('209.207.224.40'));

SELECT * AS ip
FROM users
WHERE ip = INET_ATON('209.207.224.40')</pre>
<h4>32 Tips</h4>
<p>Below is a great link that contains some easy and very ideal tips on ways to improve your Queries.  I would like to point out specifically the following:  Char vs Varchar (tip #9), Table ordering (tip #12), Session data management  (tip #16), Caching (tips #21 &amp; #22, Mass inserts (tip #23)</p>
<p><a href="http://www.ajaxline.com/32-tips-to-speed-up-your-mysql-queries">http://www.ajaxline.com/32-tips-to-speed-up-your-mysql-queries</a></p>
<p>I hope the former proves to be helpful for anyone who is looking for little ways to improve their database performance.<br />
<script src="/file-bin/js/syntaxhighlighter/scripts/shBrushSql.js" type="text/javascript"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://collectivecolony.com/blog/2010/03/18/helpful-mysql-tips-and-general-understandings/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>That which is typically unnoticed: Easter eggs with jQuery and 960.gs</title>
		<link>http://collectivecolony.com/blog/2010/02/17/that-which-is-typically-unnoticed/</link>
		<comments>http://collectivecolony.com/blog/2010/02/17/that-which-is-typically-unnoticed/#comments</comments>
		<pubDate>Wed, 17 Feb 2010 20:07:59 +0000</pubDate>
		<dc:creator>Collin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://collectivecolony.com/blog/?p=13</guid>
		<description><![CDATA[I love digging around sites&#8217; code and Google Chrome has made it even more of a habit. I&#8217;ve learned quite a bit just by doing said digging. That being said, we tried to incorporate some similar type &#8220;Easter Eggs&#8221; on the re-launch and re-focus of Collective Colony.
One of the first things we did was setup [...]]]></description>
			<content:encoded><![CDATA[<p>I love digging around sites&#8217; code and Google Chrome has made it even more of a habit. I&#8217;ve learned quite a bit just by doing said digging. That being said, we tried to incorporate some similar type &#8220;Easter Eggs&#8221; on the re-launch and re-focus of Collective Colony.</p>
<p>One of the first things we did was setup a simple layout grid that followed the <a title="960 gs" href="http://960.gs">960 gs</a>. Used for development purposes, as well as eye candy, it was a very straightforward and simple setup. Below is a simple snippet of the bulk of the work:</p>
<pre class="brush: js;">// create div, make sure it's hidden, prepend it to body
var gridElem = $('&lt;div id="' + elemId + '"&gt;&lt;div&gt;`Esc`&lt;/div&gt;&lt;/div&gt;');
var pageHeight = parseFloat($(document).height());
gridElem.height(pageHeight);
gridElem.css('display', 'none');
</pre>
<p>Once this has been &#8220;prepended&#8221; to the body, you can simply attach an event handler for the click event and use a slideIn/Out() transition.</p>
<p>Another &#8220;egg&#8221; that sort of came after the fact was a simple random projects sort / swap. The one tricky part to this &#8220;sort&#8221; was carrying the position as the elements shifted. This was easily resolved with two simple arrays. The first simple maps element locations, while the other maps the original states. Seen below is, again, the bulk of the work:</p>
<pre class="brush: js;">// Array - holds all original positions
var projectListPositionState = [];
var listKeys = [0, 1, 2, 3, 4];

// Sort positions
listKeys.sort(function() { return 0.5 - Math.random(); })

// Calculate movement and animate
projectList.each(function(key, item) {
    var movement = projectListPositionState[listKeys[key]] - projectListPositionState[key];
    $(this).stop().animate({"left": movement}, 2000);
});
</pre>
<p>I&#8217;m sure there may be a jQuery plugin that will do something very similar but I wasn&#8217;t too keen on adding another plugin thus having the server dish out another file of xyz size. Simple and efficient is what we were going for. Plus there&#8217;s nothing like the satisfaction of doing it yourself.</p>
<p>If you want to see either of these in action, simply click the gray box or green box in the header of <a href="http://collectivecolony.com/">our home page</a>. The gray will display the grid, while clicking the green box will re-arrange the images in our projects section farther down the page.<br />
<script src='/file-bin/js/syntaxhighlighter/scripts/shBrushJScript.js' type='text/javascript' language='javascript'></script></p>
]]></content:encoded>
			<wfw:commentRss>http://collectivecolony.com/blog/2010/02/17/that-which-is-typically-unnoticed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hello. Welcome. Salut.</title>
		<link>http://collectivecolony.com/blog/2010/02/16/hello-welcome-salut/</link>
		<comments>http://collectivecolony.com/blog/2010/02/16/hello-welcome-salut/#comments</comments>
		<pubDate>Wed, 17 Feb 2010 04:41:32 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Housekeeping]]></category>

		<guid isPermaLink="false">http://collectivecolony.com/blog/?p=14</guid>
		<description><![CDATA[If you&#8217;ve found your way to this tiny nook of the Internet, Collective Colony welcomes you to our blog.
We&#8217;ll write about the Internet, Web design, social media and coding tips and tricks.
Come often. Stay late. But don&#8217;t forget to turn the lights off when you leave. We need to save on electricity.
]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve found your way to this tiny nook of the Internet, Collective Colony welcomes you to our blog.</p>
<p>We&#8217;ll write about the Internet, Web design, social media and coding tips and tricks.</p>
<p>Come often. Stay late. But don&#8217;t forget to turn the lights off when you leave. We need to save on electricity.</p>
]]></content:encoded>
			<wfw:commentRss>http://collectivecolony.com/blog/2010/02/16/hello-welcome-salut/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

