<?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>Zach Dwiel &#187; code</title>
	<atom:link href="http://dwiel.net/blog/category/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://dwiel.net</link>
	<description>Repository of code snippits and ideas</description>
	<lastBuildDate>Fri, 06 Jan 2012 03:36:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>python onexit</title>
		<link>http://dwiel.net/blog/python-onexit/</link>
		<comments>http://dwiel.net/blog/python-onexit/#comments</comments>
		<pubDate>Fri, 15 Jul 2011 22:39:28 +0000</pubDate>
		<dc:creator>dwiel</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[howto]]></category>

		<guid isPermaLink="false">http://dwiel.net/?p=313</guid>
		<description><![CDATA[Was looking for python's equivalent to onexit and found this: import atexit atexit.register&#40;function_that_will_be_called_before_this_program_exits&#41;]]></description>
			<content:encoded><![CDATA[<p>Was looking for python's equivalent to onexit and found this:</p>
<pre class="python"><span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">atexit</span>
<span style="color: #dc143c;">atexit</span>.<span style="color: black;">register</span><span style="color: black;">&#40;</span>function_that_will_be_called_before_this_program_exits<span style="color: black;">&#41;</span></pre>
]]></content:encoded>
			<wfw:commentRss>http://dwiel.net/blog/python-onexit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>web.py: error: No socket could be created</title>
		<link>http://dwiel.net/blog/web-py-error-no-socket-could-be-created/</link>
		<comments>http://dwiel.net/blog/web-py-error-no-socket-could-be-created/#comments</comments>
		<pubDate>Thu, 14 Jul 2011 16:40:06 +0000</pubDate>
		<dc:creator>dwiel</dc:creator>
				<category><![CDATA[bug fix]]></category>
		<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://dwiel.net/?p=307</guid>
		<description><![CDATA[This error message most often occurrs when trying to run web.py on an invalid address and port. An example of an invalid address would be example.net, instead of a proper ip address like 98.228.37.242. Other Causes: Was just trying to get a simple web.py test running: import web &#160; urls = &#40; '/x', 'X', &#41; [...]]]></description>
			<content:encoded><![CDATA[<p>This error message most often occurrs when trying to run web.py on an invalid address and port.  An example of an invalid address would be  example.net, instead of a proper ip address like 98.228.37.242.</p>
<h2>Other Causes:</h2>
<p></p>
<p>Was just trying to get a simple web.py test running:</p>
<pre class="python"><span style="color: #ff7700;font-weight:bold;">import</span> web
&nbsp;
urls = <span style="color: black;">&#40;</span>
  <span style="color: #483d8b;">'/x'</span>, <span style="color: #483d8b;">'X'</span>,
<span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">class</span> X :
  <span style="color: #ff7700;font-weight:bold;">def</span> GET<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span> :
    <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #483d8b;">'x'</span>
&nbsp;
app = web.<span style="color: black;">application</span><span style="color: black;">&#40;</span>urls, <span style="color: #008000;">globals</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
app.<span style="color: black;">run</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre>
<p>but I kept getting the error:</p>
<p><code> error: No socket could be created </code></p>
<p>The problem was that due to the way web.py loading works, you need to have the creation and running of the app only occur if this is the main entry point of the program.  Otherwise, the class loader in web.py will reload this file again later, and wind up spawning a new server when its intent was simply to load a class:</p>
<pre class="python"><span style="color: #ff7700;font-weight:bold;">if</span> __name__ == <span style="color: #483d8b;">'__main__'</span> :
  app = web.<span style="color: black;">application</span><span style="color: black;">&#40;</span>urls, <span style="color: #008000;">globals</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
  app.<span style="color: black;">run</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre>
]]></content:encoded>
			<wfw:commentRss>http://dwiel.net/blog/web-py-error-no-socket-could-be-created/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>python random timezone</title>
		<link>http://dwiel.net/blog/python-random-timezone/</link>
		<comments>http://dwiel.net/blog/python-random-timezone/#comments</comments>
		<pubDate>Tue, 12 Jul 2011 01:44:46 +0000</pubDate>
		<dc:creator>dwiel</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[fyi]]></category>

		<guid isPermaLink="false">http://dwiel.net/?p=302</guid>
		<description><![CDATA[&#160; import random import pytz &#160; pytz.timezone&#40;random.choice&#40;pytz.all_timezones&#41;&#41; &#160;]]></description>
			<content:encoded><![CDATA[<pre class="python">&nbsp;
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">random</span>
<span style="color: #ff7700;font-weight:bold;">import</span> pytz
&nbsp;
pytz.<span style="color: black;">timezone</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">random</span>.<span style="color: black;">choice</span><span style="color: black;">&#40;</span>pytz.<span style="color: black;">all_timezones</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
&nbsp;</pre>
]]></content:encoded>
			<wfw:commentRss>http://dwiel.net/blog/python-random-timezone/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>python: parsing the output of datetime.isoformat()</title>
		<link>http://dwiel.net/blog/python-parsing-the-output-of-datetime-isoformat/</link>
		<comments>http://dwiel.net/blog/python-parsing-the-output-of-datetime-isoformat/#comments</comments>
		<pubDate>Tue, 21 Jun 2011 19:12:02 +0000</pubDate>
		<dc:creator>dwiel</dc:creator>
				<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://dwiel.net/?p=280</guid>
		<description><![CDATA[I couldn't find this explicitly anywhere, so here it is. A function to parse a string which was generated by datetime.isoformat() import datetime &#160; def parse_iso_datetime&#40;str&#41; : # parse a datetime generated by datetime.isoformat() try : return datetime.datetime.strptime&#40;str, &#34;%Y-%m-%dT%H:%M:%S&#34;&#41; except ValueError : return datetime.datetime.strptime&#40;str, &#34;%Y-%m-%dT%H:%M:%S.%f&#34;&#41; &#160; # and a simple test case def test&#40;&#41; : [...]]]></description>
			<content:encoded><![CDATA[<p>I couldn't find this explicitly anywhere, so here it is.  A function to parse a string which was generated by datetime.isoformat()</p>
<pre class="python"><span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">datetime</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> parse_iso_datetime<span style="color: black;">&#40;</span><span style="color: #008000;">str</span><span style="color: black;">&#41;</span> :
  <span style="color: #808080; font-style: italic;"># parse a datetime generated by datetime.isoformat()</span>
  <span style="color: #ff7700;font-weight:bold;">try</span> :
    <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #dc143c;">datetime</span>.<span style="color: #dc143c;">datetime</span>.<span style="color: black;">strptime</span><span style="color: black;">&#40;</span><span style="color: #008000;">str</span>, <span style="color: #483d8b;">&quot;%Y-%m-%dT%H:%M:%S&quot;</span><span style="color: black;">&#41;</span>
  <span style="color: #ff7700;font-weight:bold;">except</span> <span style="color: #008000;">ValueError</span> :
    <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #dc143c;">datetime</span>.<span style="color: #dc143c;">datetime</span>.<span style="color: black;">strptime</span><span style="color: black;">&#40;</span><span style="color: #008000;">str</span>, <span style="color: #483d8b;">&quot;%Y-%m-%dT%H:%M:%S.%f&quot;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># and a simple test case</span>
<span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #dc143c;">test</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span> :
  d = <span style="color: #dc143c;">datetime</span>.<span style="color: #dc143c;">datetime</span>.<span style="color: black;">now</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
  <span style="color: #ff7700;font-weight:bold;">assert</span> parse_iso_datetime<span style="color: black;">&#40;</span>d.<span style="color: black;">isoformat</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span> == d
  d = <span style="color: #dc143c;">datetime</span>.<span style="color: #dc143c;">datetime</span>.<span style="color: black;">now</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>.<span style="color: black;">replace</span><span style="color: black;">&#40;</span>microsecond = <span style="color: #ff4500;">0</span><span style="color: black;">&#41;</span>
  <span style="color: #ff7700;font-weight:bold;">assert</span> parse_iso_datetime<span style="color: black;">&#40;</span>d.<span style="color: black;">isoformat</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span> == d
&nbsp;</pre>
]]></content:encoded>
			<wfw:commentRss>http://dwiel.net/blog/python-parsing-the-output-of-datetime-isoformat/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQLdb: TypeError: %d format: a number is required, not str</title>
		<link>http://dwiel.net/blog/mysqldb-typeerror-d-format-a-number-is-required-not-str/</link>
		<comments>http://dwiel.net/blog/mysqldb-typeerror-d-format-a-number-is-required-not-str/#comments</comments>
		<pubDate>Tue, 01 Feb 2011 01:29:48 +0000</pubDate>
		<dc:creator>dwiel</dc:creator>
				<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://dwiel.net/?p=257</guid>
		<description><![CDATA[I was getting this error message from MySQLdb: TypeError: %d format: a number is required, not str The error message was the result of this code: assert type&#40;gateway_id&#41; == int sql = &#34;&#34;&#34; SELECT meter_id FROM mtus WHERE gateway_id = %d AND name = '%s' &#34;&#34;&#34; conn = mysql_connect&#40;&#41; cursor = conn.cursor&#40;&#41; cursor.execute&#40;sql, &#40;gateway_id, name&#41;&#41; [...]]]></description>
			<content:encoded><![CDATA[<p>I was getting this error message from MySQLdb:</p>
<p><code>TypeError: %d format: a number is required, not str</code></p>
<p>The error message was the result of this code:</p>
<pre class="python">  <span style="color: #ff7700;font-weight:bold;">assert</span> <span style="color: #008000;">type</span><span style="color: black;">&#40;</span>gateway_id<span style="color: black;">&#41;</span> == <span style="color: #008000;">int</span>
  sql = <span style="color: #483d8b;">&quot;&quot;</span><span style="color: #483d8b;">&quot;
    SELECT meter_id
    FROM mtus
    WHERE gateway_id = %d
      AND name = '%s' &quot;</span><span style="color: #483d8b;">&quot;&quot;</span>
  conn = mysql_connect<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
  cursor = conn.<span style="color: black;">cursor</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
  cursor.<span style="color: black;">execute</span><span style="color: black;">&#40;</span>sql, <span style="color: black;">&#40;</span>gateway_id, name<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
  ret = cursor.<span style="color: black;">fetchone</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
  cursor.<span style="color: black;">close</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre>
<p>It turns out, execute converts all the arguments to SQL literal values. <a href="http://mysql-python.sourceforge.net/MySQLdb.html#some-examples">reference</a> All %Xs should be %s and there shouldn't be any quotes around them. MySQLdb takes care of the string escaping too.</p>
<h2>Other Causes:</h2>
<p><br></p>
<p>For those of you arriving here from a search and are not having problems with MySQL, the reason for this error is that a string was passed into a format where a number was expected:</p>
<pre class="python"><span style="color: #808080; font-style: italic;"># throws the TypeError:</span>
message = <span style="color: #483d8b;">&quot;%d seconds until done&quot;</span> % <span style="color: #483d8b;">&quot;three&quot;</span>
<span style="color: #808080; font-style: italic;"># works:</span>
message = <span style="color: #483d8b;">&quot;%d seconds until done&quot;</span> % <span style="color: #ff4500;">3</span></pre>
]]></content:encoded>
			<wfw:commentRss>http://dwiel.net/blog/mysqldb-typeerror-d-format-a-number-is-required-not-str/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails Headers</title>
		<link>http://dwiel.net/blog/rails-headers/</link>
		<comments>http://dwiel.net/blog/rails-headers/#comments</comments>
		<pubDate>Mon, 04 Oct 2010 19:49:14 +0000</pubDate>
		<dc:creator>dwiel</dc:creator>
				<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://dwiel.net/?p=241</guid>
		<description><![CDATA[You can access header values from rails from the request.env hash. request.env contains a lot of other non HTTP header values. The header name is a bit transformed too: prepended with HTTP_ converted to uppercase dashes converted to undersocres ... more? Example: &#160; curl -H 'x-custom-value: foo' http://example.com/ &#160; can be accessed in rails with: [...]]]></description>
			<content:encoded><![CDATA[<p>You can access header values from rails from the request.env hash.  request.env contains a lot of other non HTTP header values.  The header name is a bit transformed too:</p>
<ul>
<li>prepended with HTTP_
<li>converted to uppercase
<li>dashes converted to undersocres
<li>... more?
</ul>
<p>Example:</p>
<pre class="bash">&nbsp;
curl -H <span style="color: #ff0000;">'x-custom-value: foo'</span> http://example.com/
&nbsp;</pre>
<p>can be accessed in rails with:</p>
<pre class="ruby">&nbsp;
request.<span style="color:#9900CC;">env</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'HTTP_X_CUSTOM_VALUE'</span><span style="color:#006600; font-weight:bold;">&#93;</span>
&nbsp;</pre>
]]></content:encoded>
			<wfw:commentRss>http://dwiel.net/blog/rails-headers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ruby rescue error message example</title>
		<link>http://dwiel.net/blog/ruby-rescue-error-message/</link>
		<comments>http://dwiel.net/blog/ruby-rescue-error-message/#comments</comments>
		<pubDate>Mon, 20 Sep 2010 21:41:25 +0000</pubDate>
		<dc:creator>dwiel</dc:creator>
				<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://dwiel.net/?p=235</guid>
		<description><![CDATA[begin raise &#34;this is an error message&#34; rescue Exception =&#62; e # prints &#34;this is an error message&#34; puts e.message # or if you want the entire error message with stack trace and all: puts &#34;failed sending weekly power usage to house: #{$!}&#34; end]]></description>
			<content:encoded><![CDATA[<pre class="ruby"><span style="color:#9966CC; font-weight:bold;">begin</span>
  <span style="color:#CC0066; font-weight:bold;">raise</span> <span style="color:#996600;">&quot;this is an error message&quot;</span>
<span style="color:#9966CC; font-weight:bold;">rescue</span> <span style="color:#CC00FF; font-weight:bold;">Exception</span> =&gt; e
  <span style="color:#008000; font-style:italic;"># prints &quot;this is an error message&quot;</span>
  <span style="color:#CC0066; font-weight:bold;">puts</span> e.<span style="color:#9900CC;">message</span>
  <span style="color:#008000; font-style:italic;"># or if you want the entire error message with stack trace and all:</span>
  <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;failed sending weekly power usage to house: #{$!}&quot;</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre>
]]></content:encoded>
			<wfw:commentRss>http://dwiel.net/blog/ruby-rescue-error-message/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>mongorestore: ERROR: root directory must be a dump of a single collection when specifying a collection name with &#8211;collection</title>
		<link>http://dwiel.net/blog/mongorestore-error-root-directory-must-be-a-dump-of-a-single-collection-when-specifying-a-collection-name-with-collection/</link>
		<comments>http://dwiel.net/blog/mongorestore-error-root-directory-must-be-a-dump-of-a-single-collection-when-specifying-a-collection-name-with-collection/#comments</comments>
		<pubDate>Thu, 22 Apr 2010 02:20:38 +0000</pubDate>
		<dc:creator>dwiel</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[fyi]]></category>

		<guid isPermaLink="false">http://dwiel.net/?p=195</guid>
		<description><![CDATA[mongorestore wants the specific collection's filename rather than the entire database's dump folder: dwiel@dwiel$ mongodump -d db -c variables -o ../backups/1 connected to: 127.0.0.1 DATABASE: db to ../backups/1/db &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;db.variables to ../backups/1/db/variables.bson &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;3 objects dwiel@dwiel$ mongorestore -d db -c variables --drop ../backups/1 ERROR: root directory must be a dump of a single collection &#160;&#160;&#160;&#160;&#160;&#160;&#160;when specifying a [...]]]></description>
			<content:encoded><![CDATA[<p>mongorestore wants the specific collection's filename rather than the entire database's dump folder:</p>
<style>span, strong { font-family: courier, monospace; }</style>
<p><code></p>
<div style="font-family: courier, monospace;"><strong>dwiel@dwiel$</strong><span style="color: #000000;"> </span>mongodump -d db -c variables -o ../backups/1<br />
<span style="color: #333333;">connected to: 127.0.0.1<br />
DATABASE: db	 to 	../backups/1/db<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;db.variables to ../backups/1/db/variables.bson<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3 objects</span><br />
<strong>dwiel@dwiel$</strong> mongorestore -d db -c variables --drop ../backups/1<br />
<span style="color: #800000;">ERROR: root directory must be a dump of a single collection<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;when specifying a collection name with --collection<br />
usage: ........</span><br />
<strong>dwiel@dwiel$</strong> mongorestore -d db -c variables --drop ../backups/1/db/variables.bson<br />
<span style="color: #333333;">connected to: 127.0.0.1<br />
../backups/1/db/variables.bson<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;going into namespace [db.variables]<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dropping<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3 objects</span></div>
<p></code></p>
<p>quite obvious in retrospect given the error message, but the internet didn't know the answer yet and there isn't much documentation about mongorestore.</p>
]]></content:encoded>
			<wfw:commentRss>http://dwiel.net/blog/mongorestore-error-root-directory-must-be-a-dump-of-a-single-collection-when-specifying-a-collection-name-with-collection/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>MySQL Permission Errors After Moving Datadir</title>
		<link>http://dwiel.net/blog/mysql-permission-errors-after-moving-datadir/</link>
		<comments>http://dwiel.net/blog/mysql-permission-errors-after-moving-datadir/#comments</comments>
		<pubDate>Thu, 12 Nov 2009 03:52:11 +0000</pubDate>
		<dc:creator>dwiel</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[fyi]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://dwiel.net/?p=161</guid>
		<description><![CDATA[I wanted to make space on my root partition and so moved my mysql data dir to /home/mysql in /etc/mysql/my.conf and received the following errors: dwiel@dwiel:~$ sudo mysqld 091111 20:39:16 [Warning] Can't create test file /home/mysql/dwiel.lower-test 091111 20:39:16 [Warning] Can't create test file /home/mysql/dwiel.lower-test 091111 20:39:16 [Note] Plugin 'FEDERATED' is disabled. mysqld: Can't find file: [...]]]></description>
			<content:encoded><![CDATA[<p>I wanted to make space on my root partition and so moved my mysql data dir to /home/mysql in /etc/mysql/my.conf and received the following errors:</p>
<p><code>dwiel@dwiel:~$ sudo mysqld<br />
091111 20:39:16 [Warning] Can't create test file /home/mysql/dwiel.lower-test<br />
091111 20:39:16 [Warning] Can't create test file /home/mysql/dwiel.lower-test<br />
091111 20:39:16 [Note] Plugin 'FEDERATED' is disabled.<br />
mysqld: Can't find file: './mysql/plugin.frm' (errno: 13)<br />
091111 20:39:16 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.<br />
091111 20:39:16  InnoDB: Operating system error number 13 in a file operation.<br />
InnoDB: The error means mysqld does not have the access rights to<br />
InnoDB: the directory.<br />
InnoDB: File name ./ibdata1<br />
InnoDB: File operation call: 'open'.<br />
InnoDB: Cannot continue operation.<br />
</code></p>
<p>The problem was with apparmor.  It was restricting mysql from reading and writing to /home/mysql.  To correct this I edited the file /etc/apparmor.d/usr.sbin.mysqld and added:</p>
<p><code><br />
/home/mysql r,<br />
/home/mysql** rwk,<br />
</code></p>
<p>to the end of the file.  Then restarted apparmor:</p>
<p><code><br />
sudo /etc/init.d/apparmor restart<br />
</code></p>
<p>and then restarted apache with no problem</p>
]]></content:encoded>
			<wfw:commentRss>http://dwiel.net/blog/mysql-permission-errors-after-moving-datadir/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Build tolua++ files with makefile</title>
		<link>http://dwiel.net/blog/build-tolua-files-with-makefile/</link>
		<comments>http://dwiel.net/blog/build-tolua-files-with-makefile/#comments</comments>
		<pubDate>Fri, 31 Jul 2009 15:04:46 +0000</pubDate>
		<dc:creator>dwiel</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://dwiel.net/?p=151</guid>
		<description><![CDATA[Here is how you can have your makefile build your tolua++ .cpp and .h files for you. It should work for plain tolua also. TOLUA = tolua++5.1 &#160; tolua_%.cpp tolua_%.h : %.pkg $(TOLUA) -o $(@:%.h=%.cpp) -H $(@:%.cpp=%.h) $&#60; this will generate tolua_file.cpp and tolua_file.h files from corresponding file.pkg files anytime they the .cpp or .h [...]]]></description>
			<content:encoded><![CDATA[<p>Here is how you can have your makefile build your tolua++ .cpp and .h files for you.  It should work for plain tolua also.</p>
<pre>TOLUA = tolua++5.1
&nbsp;
tolua_%.cpp tolua_%.h : %.pkg
	$(TOLUA) -o $(@:%.h=%.cpp) -H $(@:%.cpp=%.h) $&lt;</pre>
<p>this will generate tolua_file.cpp and tolua_file.h files from corresponding file.pkg files anytime they the .cpp or .h file is depended on somewhere else in the file.  In my case I just added tolua_file.o to my list of objects.  Here is the full makefile for the project which required this - for reference:</p>
<pre>&nbsp;
&nbsp;
# LINUX
LIBLUA=lua5.1
# MAC OSX
#LIBLUA=lua
&nbsp;
# LDFLAGS=-arch x86_64
OBJS = swarm.o group.o scene.o vmath.o tolua_group.o tolua_swarm.o tolua_vmath.o
CXX = g++
CXXFLAGS = -Wall -c -O2 `sdl-config --cflags`
LDFLAGS = -Wall `sdl-config --libs`
INCLUDES = -I./include -I/usr/include/lua5.1 -I/opt/local/include
LIBS = -L./lib -lANN -lGL -lGLU -llo -ltolua++5.1 -l$(LIBLUA)
TOLUA = tolua++5.1
&nbsp;
tolua_%.cpp tolua_%.h : %.pkg
	$(TOLUA) -o $(@:%.h=%.cpp) -H $(@:%.cpp=%.h) $&lt;
&nbsp;
%.o: %.cpp
	$(CXX) $(INCLUDES) $(CXXFLAGS) -c $&lt; -o $@
&nbsp;
# the executable
swarm: $(OBJS)
	$(CXX) $(LDFLAGS) -o $@ $^ $(LIBS)
&nbsp;</pre>
<p><a href="http://github.com/dwiel/swarm/raw/8716451c8b9844bbf9ec8e7f9649aca0b622c752/makefile">download</a></p>
]]></content:encoded>
			<wfw:commentRss>http://dwiel.net/blog/build-tolua-files-with-makefile/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

