<?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>red conservatory</title>
	<atom:link href="http://redconservatory.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://redconservatory.com/blog</link>
	<description>nicole chung</description>
	<lastBuildDate>Sun, 18 Dec 2011 23:20:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Concrete 5: custom theme</title>
		<link>http://redconservatory.com/blog/concrete-5-custom-theme/</link>
		<comments>http://redconservatory.com/blog/concrete-5-custom-theme/#comments</comments>
		<pubDate>Sun, 18 Dec 2011 23:16:07 +0000</pubDate>
		<dc:creator>nicole</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[concrete5]]></category>

		<guid isPermaLink="false">http://redconservatory.com/blog/?p=1411</guid>
		<description><![CDATA[If this line isn&#8217;t working for you: Use this: Why does this work? If you&#8217;re running versions of php earlier than say, 5.4, the shorthand]]></description>
			<content:encoded><![CDATA[<p>If this line isn&#8217;t working for you:</p>
<pre><?=$this->getThemePath()?></pre>
<p>Use this:</p>
<pre><?php echo $this->getThemePath()?></pre>
<p>Why does this work? If you&#8217;re running versions of php earlier than say, 5.4, the shorthand</p>
<pre><?=</pre>
<p>- won't work for you by default.</p>
]]></content:encoded>
			<wfw:commentRss>http://redconservatory.com/blog/concrete-5-custom-theme/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Making Eclipse + Android work well on a MAC</title>
		<link>http://redconservatory.com/blog/making-eclipse-android-work-well-on-a-mac/</link>
		<comments>http://redconservatory.com/blog/making-eclipse-android-work-well-on-a-mac/#comments</comments>
		<pubDate>Mon, 24 Oct 2011 14:32:42 +0000</pubDate>
		<dc:creator>nicole</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://redconservatory.com/blog/?p=1409</guid>
		<description><![CDATA[Lately I&#8217;ve started messing around with the Android SDK. The first thing I noticed is that Eclipse is WAY SLOW on my MAC. This post solved my problem: -Dosgi.requiredJavaVersion = 1.6 -Xms128m -Xmx1024m By changing the above lines in my eclipse.ini file (Applications > Eclipse > right-click and show package contents > Contents > MACOS [...]]]></description>
			<content:encoded><![CDATA[<p>Lately I&#8217;ve started messing around with the Android SDK. The first thing I noticed is that Eclipse is WAY SLOW on my MAC.</p>
<p><a href="http://stackoverflow.com/questions/2787055/using-the-android-sdk-on-a-mac-eclipse-is-really-slow-how-can-i-speed-it-up">This post</a> solved my problem:</p>
<pre>-Dosgi.requiredJavaVersion = 1.6
-Xms128m
-Xmx1024m</pre>
<p>By changing the above lines in my eclipse.ini file (Applications > Eclipse > right-click and show package contents > Contents > MACOS > eclipse.ini) eclipse started running faster and my crashes stopped&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://redconservatory.com/blog/making-eclipse-android-work-well-on-a-mac/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple design for mobile</title>
		<link>http://redconservatory.com/blog/simple-design-for-mobile/</link>
		<comments>http://redconservatory.com/blog/simple-design-for-mobile/#comments</comments>
		<pubDate>Mon, 24 Oct 2011 13:00:35 +0000</pubDate>
		<dc:creator>nicole</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://redconservatory.com/blog/?p=1398</guid>
		<description><![CDATA[After rebuilding a few sites for mobile this weekend I&#8217;ve learned a few things about CSS3 media queries and designing for mobile. 1. Include a meta viewport tag &#60;meta name="viewport" content="width=device-width"&#62; 2. Create one design for 768 pixels and up (netbooks, iPads and other screens) and 767 pixels and down (mobile). @media only screen and [...]]]></description>
			<content:encoded><![CDATA[<p>After rebuilding a few sites for mobile this weekend I&#8217;ve learned a few things about CSS3 media queries and designing for mobile.</p>
<p>1. Include a <a href="http://www.quirksmode.org/blog/archives/2010/09/combining_meta.html">meta viewport tag</a></p>
<pre>&lt;meta name="viewport" content="width=device-width"&gt;</pre>
<p>2. Create one design for 768 pixels and up (netbooks, iPads and other screens) and 767 pixels and down (mobile).</p>
<pre>@media only screen and (max-width: 767px) {
 // put mobile css here.
}</pre>
<p>3. Instead of setting the widths of mobile layouts in pixels, trying using percentages.</p>
<p>There&#8217;s a whole explanation of how the <a href="http://www.quirksmode.org/blog/archives/2010/09/combining_meta.html">viewport works with various mobile resolutions</a>.</p>
<h3>The iPhone 4 resolution</h3>
<p>The resolution of the iPhone is 960 x 640.</p>
<h3>The Google Nexus one resolution</h3>
<p>480 x 800</p>
<h3>The HTC Desire resolution</h3>
<p>800 x 480</p>
<h3>The LG Optimus One and older iPhones</h3>
<p>320 x 480</p>
<p>As you can see, all of these devices have different reolutions. Doing layouts in <strong>pixels</strong> will force you to make separate media queries for each device!</p>
<p>As an example &#8211; the iPhone 4 and 4s. With the Retina display (326 pixels per inch), displaying a layout in portrait mode means that a design that you created in <strong>pixels</strong> would require a whole separate layout be created in your stylesheet:</p>
<pre>only screen and (-webkit-min-device-pixel-ratio: 2) {
 // iPhone 4 uses double the pixels of older devices
}</pre>
<p>Don&#8217;t try to do this! You can avoid making a separate layout for each mobile device by setting the viewport meta tag and using percentages in your CSS whenever possible. Yes, you can probably set your #wrapper div to be 320 pixels (which would actually work for an iPhone 4 in portrait mode) but you can also set your form inputs and textareas to be 100%.</p>
<pre>&lt;meta name="viewport" content="width=device-width"&gt;</pre>
<p>The other nice thing about setting up the viewport this way, is, you can build your layout in a browser and then just resize your browser to get an idea of how your layout will look on a mobile device &#8211; while still having access to things like Firebug, the web inspector on Safari and Chrome, or the Web Developer&#8217;s toolbar.</p>
]]></content:encoded>
			<wfw:commentRss>http://redconservatory.com/blog/simple-design-for-mobile/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Viewing Flash trace statements in a browser</title>
		<link>http://redconservatory.com/blog/viewing-flash-trace-statements-in-a-browser/</link>
		<comments>http://redconservatory.com/blog/viewing-flash-trace-statements-in-a-browser/#comments</comments>
		<pubDate>Tue, 11 Oct 2011 18:35:19 +0000</pubDate>
		<dc:creator>nicole</dc:creator>
				<category><![CDATA[actionscript]]></category>

		<guid isPermaLink="false">http://redconservatory.com/blog/?p=1388</guid>
		<description><![CDATA[I used to use FlashTracer for Firefox but it stopped working in more recent versions of Firefox. However, I discovered that it&#8217;s even easier to just get Flash to output trace statements to a browers console. If you&#8217;re not familiar with the console, it looks like the following in Firefox with Firebug: And in Safari, [...]]]></description>
			<content:encoded><![CDATA[<p>I used to use <a href="https://addons.mozilla.org/en-US/firefox/addon/flashtracer/">FlashTracer</a> for Firefox but it stopped working in more recent versions of Firefox.</p>
<p>However, I discovered that it&#8217;s even easier to just get Flash to output trace statements to a browers console. If you&#8217;re not familiar with the console, it looks like the following in Firefox with Firebug:</p>
<p><a href="http://redconservatory.com/blog/wp-content/uploads/2011/10/console.png"><img class="alignnone size-large wp-image-1389" title="console" src="http://redconservatory.com/blog/wp-content/uploads/2011/10/console-520x180.png" alt="" width="520" height="180" /></a></p>
<p>And in Safari, you can get to the console by going to Develop > Show Error Console:</p>
<p><a href="http://redconservatory.com/blog/wp-content/uploads/2011/10/Safari-console.png"><img class="alignnone size-large wp-image-1390" title="Safari-console" src="http://redconservatory.com/blog/wp-content/uploads/2011/10/Safari-console-520x333.png" alt="" width="520" height="333" /></a></p>
<p>Telling Flash to output trace statements to a browser is as easy as importing the External Interface class:</p>
<pre>import flash.external.ExternalInterface;</pre>
<p>And then using the External Interface <strong>call</strong> method to output messages to the console</p>
<pre>trace("trace a message in Flash");
ExternalInterface.call("console.log", "Trace a message in the browser console");</pre>
<p>If you happen to be using <a href="https://github.com/arthur-debert/BulkLoader">bulkloader</a>, you can output your loading messages the following way</p>
<p>:</p>
<pre>bulkLoader = new BulkLoader("main-site");
bulkLoader.logFunction = logConsole;
private function logConsole(msg:String):void {
	trace(msg);
	ExternalInterface.call("console.log",msg);
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://redconservatory.com/blog/viewing-flash-trace-statements-in-a-browser/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TinyMCE modal window in WordPress</title>
		<link>http://redconservatory.com/blog/tinymce-modal-window-in-wordpress/</link>
		<comments>http://redconservatory.com/blog/tinymce-modal-window-in-wordpress/#comments</comments>
		<pubDate>Wed, 07 Sep 2011 12:04:57 +0000</pubDate>
		<dc:creator>nicole</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[tinyMCE]]></category>

		<guid isPermaLink="false">http://redconservatory.com/blog/?p=1379</guid>
		<description><![CDATA[(function() { tinymce.create('tinymce.plugins.my-plugin-name', { init : function(ed, url){ ed.addButton('my-plugin-name', { title : 'my-title', onclick : function() { tb_show("", "../wp-content/plugins/my-plugin-name/test.php?"); tinymce.DOM.setStyle(["TB_overlay", "TB_window", "TB_load"], "z-index", "999999") }, image: url + "/my-icon.png", }); } }); tinymce.PluginManager.add('my-plugin-name', tinymce.plugins.my-plugin-name); })(); I&#8217;m far from being a TinyMCE expert&#8230;so I opened the existing plugins from WordPress and borrowed some code from the [...]]]></description>
			<content:encoded><![CDATA[<pre>(function() {
    tinymce.create('tinymce.plugins.my-plugin-name', {
        init : function(ed, url){
            ed.addButton('my-plugin-name', {
            title : 'my-title',
                onclick : function() {
                    tb_show("", "../wp-content/plugins/my-plugin-name/test.php?");
                    tinymce.DOM.setStyle(["TB_overlay", "TB_window", "TB_load"], "z-index", "999999")
                },
                image: url + "/my-icon.png",
            });
        }
    });
    tinymce.PluginManager.add('my-plugin-name', tinymce.plugins.my-plugin-name);
})();</pre>
<p>I&#8217;m far from being a TinyMCE expert&#8230;so I opened the existing plugins from WordPress and borrowed some code from the WordPress plugin for TinyMCE. It works!</p>
<p>The important thing is to add a question mark (?) after your file name or else you will get a 404 error&#8230;</p>
<p>For a more detailed guide on how to add your own TinyMCE buttons to WordPress <a href="http://brettterpstra.com/adding-a-tinymce-button/">see Brett Terpstra&#8217;s guide</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://redconservatory.com/blog/tinymce-modal-window-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Vectors: Left and Right handed normals</title>
		<link>http://redconservatory.com/blog/vectors-left-and-right-handed-normals/</link>
		<comments>http://redconservatory.com/blog/vectors-left-and-right-handed-normals/#comments</comments>
		<pubDate>Tue, 30 Aug 2011 01:19:50 +0000</pubDate>
		<dc:creator>nicole</dc:creator>
				<category><![CDATA[AS3 snippets]]></category>
		<category><![CDATA[math]]></category>
		<category><![CDATA[normals]]></category>
		<category><![CDATA[vector]]></category>

		<guid isPermaLink="false">http://redconservatory.com/blog/?p=1359</guid>
		<description><![CDATA[Click and drag on the example above to see how normals follow the vector. There are different kinds of vectors in Flash. Vectors as Arrays One kind of vector is a strictly-typed array which is used to hold lists of stuff. var vector:Vector. = new [1,2,3,4,5]; trace(vector); Vectors as visual concept The other kind of [...]]]></description>
			<content:encoded><![CDATA[
    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="swfobj_0" width="550" height="400">
      <param name="movie" value="http://redconservatory.com/blog/wp-content/uploads/2011/08/Normals2.swf" />
      <param name="allowfullscreen" value="true" />
      <!--[if !IE]>-->
      <object type="application/x-shockwave-flash" data="http://redconservatory.com/blog/wp-content/uploads/2011/08/Normals2.swf" width="550" height="400" allowfullscreen="true">
      <!--<![endif]-->
        Interactive example of how left normals and right normals are calculated from a vector. A vector is a line with magnitude and direction.
      <!--[if !IE]>-->
      </object>
      <!--<![endif]-->
    </object>

<p><strong><em>Click and drag on the example above to see how normals follow the vector.</em></strong></p>
<p>There are different kinds of vectors in Flash. </p>
<h3>Vectors as Arrays</h3>
<p>One kind of vector is a <a href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/Vector.html">strictly-typed array</a> which is used to hold lists of stuff.</p>
<pre>var vector:Vector.<int> = new <int>[1,2,3,4,5];
trace(vector);</pre>
<h3>Vectors as visual concept</h3>
<p>The other kind of vector is a <strong>line</strong> with a magnitude and direction. It&#8217;s not actually a class in Actionscript (although, you can make your own Vector class&#8230;but don&#8217;t mix it up with the <strong>other</strong> Vector class mentioned above).</p>
<p>The simplest way to calculate a vector is to get the difference between point A and point B using the <strong>Point</strong> class:</p>
<pre>var pointA:Point;
pointA = new Point(0,0);
var pointB:Point;
pointB = new Point(1,1);
var myVector = new Point();
myVector.x = pointB.x - pointA.x;
myVector.y = pointB.y - pointA.y;
trace(myVector); // (x=1, y=1)</pre>
<p>So, a vector always contains an <strong>x</strong> value and a <strong>y</strong> value. Because of this, they are easy to store using the point class.</p>
<p>Keep in mind that, because they are lines, vectors are comprised of two points (point A and point B) but this can be expressed as a single point, which is the difference between them.</p>
<pre>myVector.x = pointB.x - pointA.x;
myVector.y = pointB.y - pointA.y;</pre>
<h3>Vector Normals</h3>
<p>Each vector has two normals:</p>
<p>A left normal (sometimes called a <em>left-handed</em> normal</p>
<p>A right normal (sometimes called a <em>right-handed</em> normal</p>
<h3>Left Normals</h3>
<p>A left normal is a vector that is perpendicular (90 degrees) of the vector on the left-hand side</p>
<pre>var left_normal_x:Number;
left_normal_x = vy;
var left_normal_y:Number;
left_normal_y = -vx;	</pre>
<h3>Right Normals</h3>
<p>A right normal is a vector that is perpendicular (90 degrees) of the vector on the right-hand side</p>
<pre>var right_normal_x:Number;
right_normal_x = vy;
var right_normal_y:Number;
right_normal_y = -vx;</pre>
]]></content:encoded>
			<wfw:commentRss>http://redconservatory.com/blog/vectors-left-and-right-handed-normals/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google Geocode API: Get the latitude and longitude of an address</title>
		<link>http://redconservatory.com/blog/google-geocode-api-get-the-latitude-and-longitude-of-an-address/</link>
		<comments>http://redconservatory.com/blog/google-geocode-api-get-the-latitude-and-longitude-of-an-address/#comments</comments>
		<pubDate>Fri, 26 Aug 2011 12:02:35 +0000</pubDate>
		<dc:creator>nicole</dc:creator>
				<category><![CDATA[Google Maps]]></category>
		<category><![CDATA[Geocode api]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[latitude]]></category>
		<category><![CDATA[longitude]]></category>

		<guid isPermaLink="false">http://redconservatory.com/blog/?p=1350</guid>
		<description><![CDATA[Using the google geocode api, you can get the latitude and longitude of an address. This is useful when building google maps. http://maps.googleapis.com/maps/api/geocode/json?address=street_number+street_name,city,country&#38;sensor=false If you type the above into your browser (with a real address) the result is a json file that contains, among other things, the latitude and longitude. $http_request .= "address="; $http_request .= [...]]]></description>
			<content:encoded><![CDATA[<p>Using the google geocode api, you can get the latitude and longitude of an address. This is useful when building google maps.</p>
<pre>http://maps.googleapis.com/maps/api/geocode/json?address=street_number+street_name,city,country&amp;sensor=false</pre>
<p>If you type the above into your browser (with a real address) the result is a json file that contains, among other things, the latitude and longitude.</p>
<pre>$http_request .= "address=";
$http_request .= $street_no . '+';
$http_request .= $street_name . ',';
$http_request .= $city . ',';
$http_request .= $province_or_state . ',';
$http_request .= $country;
$http_request .= '&amp;sensor=false';
</pre>
<p>Replace all the blank spaces that might be in any of the names with &#8216;%20&#8242; or else you will get an error that looks like this:</p>
<pre>failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request </pre>
<p>A simple way to replace the spaces with the correct encoding of &#8216;%20&#8242;:</p>
<pre>$http_request = str_replace(" ", "%20", $http_request);</pre>
<p>Then get the file contents:</p>
<pre>$fp = file_get_contents($http_request);</pre>
<p>Decode the result just json_decode:</p>
<pre>$arr = json_decode($fp, true);</pre>
<p>Then print the results:</p>
<pre>echo '&lt;pre&gt;';
 print_r($arr['results'][0]['geometry']['location']);
 echo '&lt;/pre&gt;';
</pre>
]]></content:encoded>
			<wfw:commentRss>http://redconservatory.com/blog/google-geocode-api-get-the-latitude-and-longitude-of-an-address/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Replace the end of every line with&#8230;</title>
		<link>http://redconservatory.com/blog/replace-the-end-of-every-line-with/</link>
		<comments>http://redconservatory.com/blog/replace-the-end-of-every-line-with/#comments</comments>
		<pubDate>Mon, 22 Aug 2011 19:45:50 +0000</pubDate>
		<dc:creator>nicole</dc:creator>
				<category><![CDATA[search and replace]]></category>
		<category><![CDATA[find-and-replace]]></category>
		<category><![CDATA[regex]]></category>

		<guid isPermaLink="false">http://redconservatory.com/blog/?p=1338</guid>
		<description><![CDATA[Here&#8217;s how to replace the end of every line with anything you want (in this case, a quote mark followed by a comma) using Textmate or any other program that accepts regular expressions for find-and-replace (this includes Dreamweaver and Word): Just remember to check the box marked, &#8220;regular expression&#8221;]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s how to replace the end of every line with anything you want (in this case, a quote mark followed by a comma) using Textmate or any other program that accepts regular expressions for find-and-replace (this includes Dreamweaver and Word):</p>
<p><a href="http://redconservatory.com/blog/wp-content/uploads/2011/08/replace-the-end.png"><img class="alignnone size-large wp-image-1339" title="replace-the-end" src="http://redconservatory.com/blog/wp-content/uploads/2011/08/replace-the-end-520x174.png" alt="" width="520" height="174" /></a></p>
<p>Just remember to check the box marked, &#8220;regular expression&#8221;</p>
]]></content:encoded>
			<wfw:commentRss>http://redconservatory.com/blog/replace-the-end-of-every-line-with/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Switched to Homebrew</title>
		<link>http://redconservatory.com/blog/switched-to-homebrew/</link>
		<comments>http://redconservatory.com/blog/switched-to-homebrew/#comments</comments>
		<pubDate>Tue, 16 Aug 2011 19:38:57 +0000</pubDate>
		<dc:creator>nicole</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://redconservatory.com/blog/?p=1333</guid>
		<description><![CDATA[So today I uninstalled Macports and installed Homebrew. After a half-hour of using Homebrew to install various packages (wget, memcached, postgres) without a hitch I am pretty pleased. I think I&#8217;m going to keep using it. There&#8217;s a terrific write up by Andre Arko that explains all the nice things about Homebrew. The only glitch [...]]]></description>
			<content:encoded><![CDATA[<p>So today I uninstalled <a href="http://www.macports.org/">Macports</a> and installed <a href="http://mxcl.github.com/homebrew/">Homebrew</a>. </p>
<p>After a half-hour of using Homebrew to install various packages (wget, memcached, postgres) without a hitch I am pretty pleased. I think I&#8217;m going to keep using it. There&#8217;s a terrific write up by <a href="http://www.engineyard.com/blog/2010/homebrew-os-xs-missing-package-manager/">Andre Arko</a> that explains all the nice things about Homebrew.</p>
<p>The only glitch I noticed after installing Homebrew was that my Preferrence Pane for MySQL stopped working, with the error message:</p>
<pre>Warning: The /usr/local/mysql/data directory is not owned by the 'mysql' or '_mysql' user</pre>
<p>This can be fixed by running the following:</p>
<pre>sudo chown -R _mysql:wheel /usr/local/mysql/data</pre>
]]></content:encoded>
			<wfw:commentRss>http://redconservatory.com/blog/switched-to-homebrew/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Django on Apache on Snow Leopard, Part 3: MySQL</title>
		<link>http://redconservatory.com/blog/django-on-apache-on-snow-leopard-part-3-mysqldb-or-mysql-for-python/</link>
		<comments>http://redconservatory.com/blog/django-on-apache-on-snow-leopard-part-3-mysqldb-or-mysql-for-python/#comments</comments>
		<pubDate>Fri, 12 Aug 2011 22:28:59 +0000</pubDate>
		<dc:creator>nicole</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[Terminal]]></category>

		<guid isPermaLink="false">http://redconservatory.com/blog/?p=1318</guid>
		<description><![CDATA[So, now that mod_wsgi is up and working and django is installed, another thing to get up and running is MySQLdb (now known as MySQL for Python). This is something that can be a bit of a special hell. First, as far as I can tell, it seems that MySQL for Python is 64 bit. [...]]]></description>
			<content:encoded><![CDATA[<p>So, now that <a href="http://redconservatory.com/blog/django-on-apache-on-snow-leopard-part-1-mod_wsgi/">mod_wsgi</a> is up and working and <a href="http://redconservatory.com/blog/django-on-apache-on-snow-leopard-part-2-install-django/">django is installed</a>, another thing to get up and running is MySQLdb (now known as MySQL for Python).</p>
<p>This is something that can be a bit of a special hell.</p>
<p>First, as far as I can tell, it seems that MySQL for Python is 64 bit.</p>
<p>So, the version of mysql that you use <strong>must be 64 bit</strong>, and also, the version of python that you are using <strong>must be 64 bit</strong>.</p>
<p>I could not get it running with 32 bit versions myself.</p>
<p>Open Terminal.  Type:</p>
<pre>mysql</pre>
<p>This <strong>should</strong> open mysql. Sometimes you have to type</p>
<pre>mysql -u root -p
Password:</pre>
<p>And enter your password. This is assuming that you have a username of <strong>root</strong>, but you might not.</p>
<p>Then, once you are in mysql, type:</p>
<pre>SHOW GLOBAL VARIABLES LIKE 'version_compile_machine';</pre>
<p>Which, hopefully, will give you something like:</p>
<pre>+-------------------------+--------+
| Variable_name | Value |
+-------------------------+--------+
| version_compile_machine | x86_64 |
+-------------------------+--------+
</pre>
<p>If it says:</p>
<pre>+-------------------------+-------+
| Variable_name | Value |
+-------------------------+-------+
| version_compile_machine | i686 |
+-------------------------+-------+
</pre>
<p>This is the <strong>wrong version</strong> for the instructions here.</p>
<p>If you don&#8217;t mind losing all of your databases, you can uninstall MySQL and reinstall a 64 bit version.</p>
<p>I only got my install working with a 64 bit version.</p>
<p>Now, if you are running the 64 bit version, exit MySQL by pressing CTRL-D:</p>
<pre>mysql&gt;bye</pre>
<p>Then, type:</p>
<pre>python</pre>
<p>This should open python for you. If not, there is something wrong with your path variable.</p>
<p>If python works, type:</p>
<pre>import platform</pre>
<p>And press Enter. Then type</p>
<pre>platform.architecture()</pre>
<p>You should see</p>
<pre>&gt;&gt;&gt; import platform
&gt;&gt;&gt; platform.architecture()
('64bit', '')</pre>
<p>If it says &#8217;32bit&#8217; instead, the instructions here won&#8217;t work for you. You need to get a 64 bit version of Python.</p>
<p>By default, Python on Snow Leopard <strong>should be</strong> a 64 bit version. But I think I might have messed around an installed a newer, 32 bit version instead. At any rate&#8230;I had to go an install Python 2.7 which I wouldn&#8217;t recommend because the current mod_wsgi <strong>only works with 2.6</strong>.</p>
<p>Hopefully you are just running the version of Python that came with your computer, so you don&#8217;t have this problem.</p>
<p>Next, now that you have verified that:<br />
 &#8211; your version of MySQL is 64 bit<br />
 &#8211; your version of Python is 64 bit</p>
<p>Download <a href="http://sourceforge.net/projects/mysql-python/files/mysql-python/1.2.3/MySQL-python-1.2.3.tar.gz/download">MySQLdb </a>(now called <a href="http://sourceforge.net/projects/mysql-python/files/mysql-python/1.2.3/MySQL-python-1.2.3.tar.gz/download">MySQL for Python)</a></p>
<p>Download it and copy it to your /Users/yourusername folder.</p>
<p>In Terminal, exit Python by pressing CTRL-D if you haven&#8217;t already. Then type:</p>
<pre>cd
tar xzvf MySQL-python-1.2.3.tar.gz
cd MySQL-python-1.2.3
ARCHFLAGS='-arch x86_64' python setup.py clean
ARCHFLAGS='-arch x86_64' python setup.py build
ARCHFLAGS='-arch x86_64' python setup.py install</pre>
<p>The first issue you might have is your version might not be MySQL-python-1.2.3.tar.gz.</p>
<p>So just enter your version or type</p>
<pre>tar xzvf MySQl-(press tab)</pre>
<p>And Terminal will figure out the rest for you (it autotypes the rest of the file name, assuming there aren&#8217;t files that begin with &#8220;MySQL-&#8221; in the same folder).</p>
<p>Now, another error you might get when you type:</p>
<pre>ARCHFLAGS='-arch x86_64' python setup.py clean</pre>
<p>Is:</p>
<pre>ImportError: No module named setuptools</pre>
<p>So you have to download <a href="http://pypi.python.org/pypi/setuptools#files">setuptools</a> and install it.</p>
<p>You <strong>must know</strong> what version of Python you are running and download the correct version of setuptools based on that.</p>
<p>Then copy the download to your Users/yourusername folder.</p>
<p>Then, in Terminal:</p>
<pre>sh setuptools-0.6c11-py2.7.egg </pre>
<p>Your version that you downloaded might be different. It might be 2.6 or 2.5 so don&#8217;t just copy and paste the line above.</p>
<p>Then run the commands again:</p>
<pre>ARCHFLAGS='-arch x86_64' python setup.py clean
ARCHFLAGS='-arch x86_64' python setup.py build
ARCHFLAGS='-arch x86_64' python setup.py install
</pre>
<p>The other issue is you might get a &#8220;<strong>you don&#8217;t have the right permissions</strong>&#8221; error.</p>
<p>If this is the case, use sudo:</p>
<pre>sudo ARCHFLAGS='-arch x86_64' python setup.py clean
sudo ARCHFLAGS='-arch x86_64' python setup.py build
sudo ARCHFLAGS='-arch x86_64' python setup.py install
</pre>
<p>The next step is to add some stuff to your .bash_profile file.</p>
<p>Change to your root directory:</p>
<pre>cd</pre>
<p>Then type:</p>
<pre>open .bash_profile</pre>
<p>Look around for a line that says something like:</p>
<pre># Setting PATH for Python</pre>
<p>Below this should be a line for your Python path. Below that stuff, add:</p>
<pre>export DYLD_LIBRARY_PATH=/usr/local/mysql/lib:$DYLD_LIBRARY_PATH
export VERSIONER_PYTHON_PREFER_64_BIT=yes
export VERSIONER_PYTHON_PREFER_32_BIT=no</pre>
<p>Save the file and close it.</p>
<p>Next, in Terminal, type:</p>
<pre>cd /usr/local/mysql/lib/</pre>
<p>Then type</p>
<pre>ls</pre>
<p>To view the files. You should have something that says</p>
<pre>libmysqlclient.18.dylib</pre>
<p>The number might be different, it might be libmysqlclient.16.dylib. Whatever it is, write this down.</p>
<p>Then type:</p>
<pre>cd
sudo install_name_tool -id /usr/local/mysql/lib/libmysqlclient.18.dylib</pre>
<p>Now, to test that everything is working, type:</p>
<pre>python</pre>
<p>You should get the standard python prompt with your version name. Type, after the arrows:</p>
<pre>import MySQLdb</pre>
<p>And hit enter. If you don&#8217;t get a string of error messages, MySQLdb is now installed and working properly.</p>
]]></content:encoded>
			<wfw:commentRss>http://redconservatory.com/blog/django-on-apache-on-snow-leopard-part-3-mysqldb-or-mysql-for-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

