<?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>MindBy</title>
	<atom:link href="http://mindby.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://mindby.com</link>
	<description>A Community Guy</description>
	<lastBuildDate>Thu, 23 Feb 2012 16:17:23 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>IntelliJ/PyCharm Performance on Linux</title>
		<link>http://mindby.com/2012/02/intellijpycharm-performance-on-linux/</link>
		<comments>http://mindby.com/2012/02/intellijpycharm-performance-on-linux/#comments</comments>
		<pubDate>Thu, 23 Feb 2012 16:17:23 +0000</pubDate>
		<dc:creator>mindby</dc:creator>
				<category><![CDATA[Tips and Tricks]]></category>

		<guid isPermaLink="false">http://mindby.com/?p=619</guid>
		<description><![CDATA[For the longest time I couldn&#8217;t get into the IntelliJ IDE for software development, however last year I tried out PyCharm and loved it.  One of the key things for me when dealing with an IDE is their VIM support and JetBrains has one of the better implementations of VIM I&#8217;ve used in an IDE. [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft size-full wp-image-626" src="http://mindby.com/files/2012/02/thumb.jpg" alt="thumb" width="400" height="300" />For the longest time I couldn&#8217;t get into the IntelliJ IDE for software development, however last year I tried out PyCharm and loved it.  One of the key things for me when dealing with an IDE is their VIM support and JetBrains has one of the better implementations of VIM I&#8217;ve used in an IDE.  Recently I noticed the performance of PyCharm had fallen off to the point where it was becoming unusable.  Little things like moving up and down in the editor window sometimes had 0.5 &#8211; 1 second lag times which is totally unacceptable.  My laptop is an old Dell D830 with a Core2Duo 2.0 GHz with 4GB of memory so it is getting a bit dated but still&#8230;  I was almost ready to head back to the Ecilpse platform in order to save my sanity when I thought I&#8217;d try one more time to find an answer to my performance woes.</p>
<p>There are lots of tricks out and about that provide advice on performance improvements, most are common sense&#8230; don&#8217;t use network drives for files, have enough RAM, blah, blah, blah.  I knew none of these were my issue.   Finally, however, I saw something that caught my eye, something about the JVM having performance issues with Intel&#8217;s graphic card EXA acceleration method which my laptop uses.  The fix was the simple addition of the following to the pycharm.vmoptions file.</p>
<blockquote><p>
<code>-Dsun.java2d.pmoffscreen=false</code>
</p></blockquote>
<p>I&#8217;ll be the first to admit that this trick didn&#8217;t make PyCharm a screamer however it is certainly usable again and hopefully I can squeeze a few more months out of my old Dell <img src='http://mindby.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://mindby.com/2012/02/intellijpycharm-performance-on-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Building the nginx module &#8211; ngx_postgres</title>
		<link>http://mindby.com/2011/03/building-the-nginx-module-ndx_postgres/</link>
		<comments>http://mindby.com/2011/03/building-the-nginx-module-ndx_postgres/#comments</comments>
		<pubDate>Sat, 05 Mar 2011 04:41:09 +0000</pubDate>
		<dc:creator>mindby</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://mindby.com/?p=604</guid>
		<description><![CDATA[I stumbled across a nifty little module for nginx called ngx_postgres.  It allows you to access a Postgres database directly through nginx and HTTP with little more than a configuration file that creates a REST mapping to your tables.  Interesting idea so I thought I&#8217;d give it a spin and see if it could be [...]]]></description>
			<content:encoded><![CDATA[<p><img class="size-full wp-image-611 alignleft" src="http://mindby.com/files/2011/03/731px-Nginx-battleship-alt.svg_.png" alt="731px-Nginx-battleship-alt.svg_" width="439" height="224" />I stumbled across a nifty little module for nginx called <a href="https://github.com/FRiCKLE/ngx_postgres/">ngx_postgres</a>.  It allows you to access a Postgres database directly through nginx and HTTP with little more than a configuration file that creates a REST mapping to your tables.  Interesting idea so I thought I&#8217;d give it a spin and see if it could be useful, however there were a couple of &#8220;gotchas&#8221; in setting it up that I thought I&#8217;d document.</p>
<p>First adding modules to nginx requires recompiling nginx so you&#8217;ve got to get your hands a little dirty to get it going.  I&#8217;m currently running Debian 6 in a hosted environment so I&#8217;ll give you the blow by blow based on my config.</p>
<h2><span id="more-604"></span>Build Process</h2>
<p>The first thing we&#8217;ll do is cd to /usr/src and grab the source for nginx by issuing the command&#8230;</p>
<pre style="background-color:#efefef;border:1px solid #999;margin-bottom:10px;padding:5px;font-size:12px">cd /usr/src/
apt-get source nginx</pre>
<p>Also make sure you have the following packages installed&#8230;</p>
<ul>
<li>fakeroot</li>
<li>debhelper</li>
<li>dpkg-dev</li>
<li>autotools-dev</li>
<li>libssl-dev</li>
<li>libpq5</li>
<li>libpq-dev</li>
</ul>
<p>You&#8217;ll also need git installed so that you can grab the sources for the nginx modules you&#8217;ll need.  Along with ngx_postgres, you&#8217;ll also need rds-json-nginx-module to help with the json production.</p>
<pre style="background-color:#efefef;border:1px solid #999;margin-bottom:10px;padding:5px;font-size:12px">cd nginx-x.x.xx/modules
git clone https://github.com/agentzh/rds-json-nginx-module.git
git clone https://github.com/FRiCKLE/ngx_postgres.git</pre>
<p>Next you&#8217;ll need to see if there are any other dependencies you&#8217;ll need for the build which is quite easy on Debian using&#8230;</p>
<pre style="background-color:#efefef;border:1px solid #999;margin-bottom:10px;padding:5px;font-size:12px">apt-get build-dep nginx</pre>
<p>After you know you&#8217;ve got everything you&#8217;ll need for the build you can modify the ./configure parameters of the build to include the two new modules.  Use your editor of choice to modify the rules file.  Something like vim ../debian/rules</p>
<p>You&#8217;ll need to add the &#8211;add-module lines to ./configure for the new modules.</p>
<pre style="background-color:#efefef;border:1px solid #999;margin-bottom:10px;padding:5px;font-size:12px">--add-module=$(CURDIR)/modules/ngx_postgres \
--add-module=$(CURDIR)/modules/rds-json-nginx-module</pre>
<p>That&#8217;s it.  Now run</p>
<pre style="background-color:#efefef;border:1px solid #999;margin-bottom:10px;padding:5px;font-size:12px">dpkg-buildpackage</pre>
<p>After a couple of minutes you should have a few .deb files in /usr/src for your enjoyment.  Install the appropriate .deb using dpkg and you&#8217;re ready to get ndx_postgres working.</p>
<h2>nginx/ndx_postgres Setup</h2>
<p>So the build part was pretty straightforward and didn&#8217;t take very long but getting it setup and working without any instructions was a bit more challenging.  There are a few configuration <a href="https://github.com/FRiCKLE/ngx_postgres/blob/master/README.md">examples</a> that come with ngx_postgres that you&#8217;ll need to read through to get a feel how a configuration is created and mapped to your tables.</p>
<p>Once you&#8217;ve established a basic configuration file for your database tables save the file in the /etc/nginx/sites-enabled/ directory.  The important thing to note is that by default you already have a file in this directory called <em>default. </em>This file does the obvious and creates the default site for a basic nginx installation.  What I didn&#8217;t realize was that ngx_postgres wouldn&#8217;t work with the default site enabled.  I spent at least an hour going through everything until I finally tried disabling the default file from sites-enabled.  After disabling the default site for nginx.  Everything should start working fine&#8230; assuming you&#8217;ve formatted your ndx_postgres configuration correctly <img src='http://mindby.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>Good Luck.</p>
]]></content:encoded>
			<wfw:commentRss>http://mindby.com/2011/03/building-the-nginx-module-ndx_postgres/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Celery and Twisted</title>
		<link>http://mindby.com/2011/02/celery-and-twisted/</link>
		<comments>http://mindby.com/2011/02/celery-and-twisted/#comments</comments>
		<pubDate>Mon, 14 Feb 2011 12:25:37 +0000</pubDate>
		<dc:creator>mindby</dc:creator>
				<category><![CDATA[Tips and Tricks]]></category>

		<guid isPermaLink="false">http://mindby.com/?p=573</guid>
		<description><![CDATA[I&#8217;ve been working with Celery, Twisted and Cyclone recently on a side project I have going on, however the integration between Celery and Twisted is not ideal for asynchronous programming which prompted me to jot down some notes for what I&#8217;ve worked out.  Hopefully this will be useful to someone, also if anyone wants to [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been working with <a href="http://celeryproject.org/">Celery</a>, <a href="http://twistedmatrix.com/trac/">Twisted</a> and <a href="https://github.com/fiorix/cyclone">Cyclone</a> recently on a side project I have going on, however the integration between Celery and Twisted is not ideal for asynchronous programming which prompted me to jot down some notes for what I&#8217;ve worked out.  Hopefully this will be useful to someone, also if anyone wants to offer a better way I&#8217;m all ears <img src='http://mindby.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>Celery has some built in methods to allow you to check the completeness of a remote job by calling the successful() method on a returned AsyncResult object.  For example you can do something like this&#8230;</p>
<p><span id="more-573"></span>From Python interpreter&#8230;  (BTW, the add task as a sleep in it for testing purposes)</p>
<pre style="background-color:#efefef;border:1px solid #999;margin-bottom:10px;padding:5px;font-size:12px">&gt;&gt;&gt; from celery.execute import send_task
&gt;&gt;&gt; result=send_task('tasks.add', [4,5])
&gt;&gt;&gt; result.successful()
False
&gt;&gt;&gt; result.successful()
False
&gt;&gt; result.successful()
True
&gt;&gt;&gt; result.get()
9</pre>
<p>So the question was how to wrap this Celery mechanism in something I could use from Twisted and Cyclone.  Here is what I came up&#8230;</p>
<pre style="background-color:#efefef;border:1px solid #999;margin-bottom:10px;padding:5px;font-size:12px">from twisted.internet import task
def monitor_task(self, celery_jobResult, reactor):
  if celery_jobResult.successful():
     self.result = celery_jobResult.get()
     print self.result
       return self.result
   else:
       self.result = None
  return task.deferLater(reactor, 0.5, self.monitor_task, celery_jobResult, reactor)</pre>
<p>This allowed me to call Celery jobs and poll periodically to see if the task had finished before returning the result.</p>
<pre style="background-color:#efefef;border:1px solid #999;margin-bottom:10px;padding:5px;font-size:12px">def printResult(result):
   print result

from twisted.internet.threads import deferToThread
from celery.execute import send_task as send_celery_task
deferred = deferToThread(send_celery_task, 'tasks.add', [4,5]).\
addCallback(monitor_task, reactor).\
addCallback(printResult)</pre>
<p>This is a bit simplified and doesn&#8217;t take into account any error handling but this is the jist of it.  If you&#8217;ve found a better more elegant way please leave a comment.</p>
]]></content:encoded>
			<wfw:commentRss>http://mindby.com/2011/02/celery-and-twisted/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dell Bios Update from Linux</title>
		<link>http://mindby.com/2011/01/dell-bios-update-from-linux/</link>
		<comments>http://mindby.com/2011/01/dell-bios-update-from-linux/#comments</comments>
		<pubDate>Thu, 13 Jan 2011 14:28:48 +0000</pubDate>
		<dc:creator>mindby</dc:creator>
				<category><![CDATA[Tips and Tricks]]></category>

		<guid isPermaLink="false">http://mindby.com/?p=567</guid>
		<description><![CDATA[As many of you know that follow my blog I&#8217;m an avid user of Linux and Mac.  I haven&#8217;t had a full-time Windows PC since around 2001, so when I need a BIOS update it can sometimes be painful since most of the tools for updating a PC&#8217;s BIOS are written for Windows.  [...]]]></description>
			<content:encoded><![CDATA[<p>As many of you know that follow my blog I&#8217;m an avid user of Linux and Mac.  I haven&#8217;t had a full-time Windows PC since around 2001, so when I need a BIOS update it can sometimes be painful since most of the tools for updating a PC&#8217;s BIOS are written for Windows.  Recently I needed to update my Dell D830&#8217;s BIOS to A15 from A08 and had to do some serious Googling to figure it out so I thought I would jot it down for others.</p>
<p>Before we begin you&#8217;ll need two things installed on your Linux machine&#8230;</p>
<ol>
<li>The first thing you&#8217;ll need is the dellBiosUpdate program.  Depending on your distro you&#8217;ll need to Google around and find the appropriate package for your distro that contains this program and it&#8217;s associated libraries.</li>
<li>Second you&#8217;ll need either Wine installed or an old Windows PC lying around.  My wife has an old Dell Windows machine so I chose to use it rather than bloat my Linux distro with Wine.</li>
</ol>
<p>That&#8217;s it for prerequisites, the rest is easy.<span id="more-567"></span></p>
<ol>
<li>Download the appropriate BIOS update program from the Dell website.  It will be a Windows program but that&#8217;s not a problem for us now.  In my case the file was called D830_A15.exe.</li>
<li>Use Wine or the second Windows machine to create a .hdr file which you&#8217;ll use later to update the BIOS.  You do this by running the BIOS update .exe from the command line and using the -writehdrfile switch like so&#8230;  <span style="font-family: Consolas, Monaco, 'Courier New', Courier, monospace;line-height: 18px;font-size: 12px">D830_A15.exe -writehdrfile. </span></li>
<li>This should have created a second file for you in the same directory that you ran the program from.  This will be the file you use to update the BIOS with so copy it (the .hdr file)  to the Linux machine if you ran this from a Windows machine.</li>
<li>Run the dellBiosUpdate program with -u  and -f switches and ensure that the laptop is running on AC before you begin or the update will fail.  <span style="font-family: Consolas, Monaco, 'Courier New', Courier, monospace;line-height: 18px;font-size: 12px">dellBiosUpdate -u -f D830_A15.hdr</span></li>
<li>Reboot and you should see your Dell getting updated.</li>
</ol>
<p><strong>Word of caution:</strong> U<em>pdating the BIOS can be a dangerous undertaking.  I do not under any circumstances guarantee the procedure above to work.  It worked for me but may not work for you.  You&#8217;ve been warned.  I take no responsibility for what may happen during your attempt.<br />
</em></p>
]]></content:encoded>
			<wfw:commentRss>http://mindby.com/2011/01/dell-bios-update-from-linux/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>psycopg2 on Snow Leopard</title>
		<link>http://mindby.com/2010/12/psycopg2-on-snow-leopard/</link>
		<comments>http://mindby.com/2010/12/psycopg2-on-snow-leopard/#comments</comments>
		<pubDate>Fri, 31 Dec 2010 16:50:53 +0000</pubDate>
		<dc:creator>mindby</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://mindby.com/?p=547</guid>
		<description><![CDATA[Just a quick tip to share since this was not as straightforward on Snow Leopard as I would have liked.  I originally went to install psycopg2 on Snow Leopard and got the following error&#8230;
In file included from psycopg/psycopgmodule.c:32:
./psycopg/psycopg.h:31:22: error: libpq-fe.h: No such file or directory
No problem since I hadn&#8217;t installed Postgresql anyway.  But after installing [...]]]></description>
			<content:encoded><![CDATA[<p>Just a quick tip to share since this was not as straightforward on Snow Leopard as I would have liked.  I originally went to install psycopg2 on Snow Leopard and got the following error&#8230;</p>
<pre>In file included from psycopg/psycopgmodule.c:32:
./psycopg/psycopg.h:31:22: error: libpq-fe.h: No such file or directory</pre>
<div style="padding-top:20px">No problem since I hadn&#8217;t installed Postgresql anyway.  But after installing postgreqsql91 via MacPorts I was still getting the same error.  I used the command <strong>port contents postgresql</strong> to determine the files that were installed via MacPorts and noted that Postgresql&#8217;s include files where in /opt/local/include and the libraries were in /opt/local/lib/.</div>
<div style="padding-top:20px">I then downloaded the psycopg2 Python package from http://initd.org/psycopg/tarballs/psycopg2-2.3.2.tar.gz and unpacked it.  You then need to modify the setup.cfg file adding the following lines:</div>
<div style="padding-top:20px">
<pre>include_dirs=/opt/local/include/postgresql91</pre>
</div>
<div>
<pre>library_dirs=/opt/local/lib/postgresql91</pre>
</div>
<div style="padding-top:20px">You can then install as normal using python setup.py install</div>
<div>Hope it helps somebody.</div>
]]></content:encoded>
			<wfw:commentRss>http://mindby.com/2010/12/psycopg2-on-snow-leopard/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

