<?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>Flapping Head &#187; Uncategorized</title>
	<atom:link href="http://scottbarnham.com/blog/category/uncategorized/feed/" rel="self" type="application/rss+xml" />
	<link>http://scottbarnham.com/blog</link>
	<description>Code and comments on web development, Django, Python and things (un)related.</description>
	<lastBuildDate>Mon, 16 May 2011 19:22:44 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>What is mysql doing?  Why too many connections?</title>
		<link>http://scottbarnham.com/blog/2011/04/29/what-is-mysql-doing-why-too-many-connections/</link>
		<comments>http://scottbarnham.com/blog/2011/04/29/what-is-mysql-doing-why-too-many-connections/#comments</comments>
		<pubDate>Fri, 29 Apr 2011 22:43:27 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://scottbarnham.com/blog/?p=94</guid>
		<description><![CDATA[I recently had to troubleshoot a busy mysql database server for a client.  Here&#8217;s some basic tips.
SHOW PROCESSLIST is your friend
Inside mysql you can run show processlist to find out what the server is doing.  From the list you can see how many connections there are, which database, whether they are causing a [...]]]></description>
			<content:encoded><![CDATA[<p>I recently had to troubleshoot a busy mysql database server for a client.  Here&#8217;s some basic tips.</p>
<h2>SHOW PROCESSLIST is your friend</h2>
<p>Inside mysql you can run <code>show processlist</code> to find out what the server is doing.  From the list you can see how many connections there are, which database, whether they are causing a lock, waiting for a lock, and even the query being run.  Very helpful.</p>
<p>You can get the same info from the <code>mysqladmin</code> program.  A simple way to monitor what the server is doing is to have <code>cron</code> email you every hour (or whatever interval) with the process list:</p>
<p><code>crontab -e</code></p>
<pre>MAILTO="you@example.com"
31 * * * * mysqladmin -u root -psecret --verbose processlist</pre>
<h2>Sleeping connections need closing</h2>
<p>If you have a lot of connections in a <code>sleep</code> state, it means they&#8217;re not doing anything but are still held open.  The server can run out of connections if they&#8217;re all busy sleeping.</p>
<p>Assuming the database is being accessed by a website (e.g. php code), you could look for ways to close the database connection sooner.</p>
<p>If you&#8217;re using Smarty, instead of:</p>
<pre>// open mysql connection
// do stuff
$smarty->display('template.tpl');
// close mysql connection</pre>
<p>you might try:</p>
<pre>// open mysql connection
// do stuff
$output = $smarty->fetch('template.tpl');
// close mysql connection
print $output;</pre>
<p>The difference is, you&#8217;re closing the mysql connection before returning data to the client.  If you&#8217;ve got slow clients (and assuming no reverse-proxy or load balancer to spoon-feed) it could release the database connection much sooner.</p>
<h2>EXPLAIN those queries</h2>
<p>If you have slow queries, you can find out why using <a href="http://dev.mysql.com/doc/refman/5.0/en/explain.html">explain</a>.  See how many rows they need to read (perhaps there&#8217;s no index the query can use) and if they need to be optimised.</p>
]]></content:encoded>
			<wfw:commentRss>http://scottbarnham.com/blog/2011/04/29/what-is-mysql-doing-why-too-many-connections/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Repair all tables in MySQL</title>
		<link>http://scottbarnham.com/blog/2010/09/08/repair-all-tables-in-mysql/</link>
		<comments>http://scottbarnham.com/blog/2010/09/08/repair-all-tables-in-mysql/#comments</comments>
		<pubDate>Wed, 08 Sep 2010 12:08:04 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://scottbarnham.com/blog/?p=70</guid>
		<description><![CDATA[In mysql you can repair a table using:
repair table mytable;
How do you repair all the tables in a database?  There&#8217;s no command for that, so you&#8217;ll need to repair each one individually.
That&#8217;s quite tedious, so here&#8217;s a bit of help in MySQL 5.
select concat('repair table ', table_name, ';') from information_schema.tables where table_schema='mydatabase';
Change mydatabase to [...]]]></description>
			<content:encoded><![CDATA[<p>In mysql you can repair a table using:</p>
<pre>repair table mytable;</pre>
<p>How do you repair all the tables in a database?  There&#8217;s no command for that, so you&#8217;ll need to repair each one individually.</p>
<p>That&#8217;s quite tedious, so here&#8217;s a bit of help in MySQL 5.</p>
<pre>select concat('repair table ', table_name, ';') from information_schema.tables where table_schema='mydatabase';</pre>
<p>Change <code>mydatabase</code> to the name of your database.</p>
<p>This gives you a load of repair table statements.  They&#8217;re formatted in a table with vertical bars, so copy the whole lot, paste in to a text editor or word processor, do a find and replace: find &#8220;|&#8221; replace with nothing.  Don&#8217;t worry about the spaces.</p>
<p>Copy and paste that lot in to your mysql command prompt.  Job done.</p>
]]></content:encoded>
			<wfw:commentRss>http://scottbarnham.com/blog/2010/09/08/repair-all-tables-in-mysql/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>OpenX Upgrade Page Full of Errors</title>
		<link>http://scottbarnham.com/blog/2010/08/20/openx-upgrade-page-full-of-errors/</link>
		<comments>http://scottbarnham.com/blog/2010/08/20/openx-upgrade-page-full-of-errors/#comments</comments>
		<pubDate>Fri, 20 Aug 2010 10:29:04 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://scottbarnham.com/blog/?p=63</guid>
		<description><![CDATA[I was moving and upgrading OpenX for a client (v2.8.5).  I changed some things in the config file, then went in to the admin interface (install page).
I got a screen full of baffling error messages starting:

MESSAGE: Undefined variable: imgPath
TYPE: Notice
FILE: /home/nice/public_html/www/admin/install.php
LINE: 75
DEBUG INFO:

70 $oMenu->add(new OA_Admin_Menu_Section('install', '', ''));
71
72 if ($oController->hasLayout()) {
73 //layout
74 $oPageHeader = $oController->getModelProperty('pageHeader');
75 [...]]]></description>
			<content:encoded><![CDATA[<p>I was moving and upgrading OpenX for a client (v2.8.5).  I changed some things in the config file, then went in to the admin interface (install page).</p>
<p>I got a screen full of baffling error messages starting:</p>
<pre>
MESSAGE: Undefined variable: imgPath
TYPE: Notice
FILE: /home/nice/public_html/www/admin/install.php
LINE: 75
DEBUG INFO:

70 $oMenu->add(new OA_Admin_Menu_Section('install', '', ''));
71
72 if ($oController->hasLayout()) {
73 //layout
74 $oPageHeader = $oController->getModelProperty('pageHeader');
75 phpAds_PageHeader('install', $oPageHeader, $imgPath, false, true, false);

76 }
77 if ($view) {
78 $view->display();
79 }
80 echo $actionContent;

MESSAGE: Only variable references should be returned by reference
TYPE: Notice
FILE: /home/nice/public_html/lib/OA/Admin/Menu/Section.php
LINE: 354
DEBUG INFO:

349 {
350 if ($this->type == $type) {
351 return $this;
352 }
353 else {
354 return $this->parentSection != null ? $this->parentSection->getParentOrSelf($type) : null;

355 }
356 }
357
358
359 /**

MESSAGE: Only variable references should be returned by reference
TYPE: Notice
FILE: /home/nice/public_html/lib/OA/Admin/Menu/Section.php
LINE: 354
DEBUG INFO:

349 {
350 if ($this->type == $type) {
351 return $this;
352 }
353 else {
354 return $this->parentSection != null ? $this->parentSection->getParentOrSelf($type) : null;

355 }
356 }
357
358
359 /**

MESSAGE: Undefined index: PREF
TYPE: Notice
</pre>
<p>Undefined variables.  Something&#8217;s wrong with reading the config file.</p>
<p>I had to edit the code to find out what the problem was.  In the <code>init-parse.php</code> file, look for <code>$conf = @parse_ini_file</code>.  Remove that @ sign &#8211; it&#8217;s suppressing the error message.  Try again and you should see an error saying can&#8217;t parse ini file on line X.</p>
<p>In my case, it&#8217;s because I put a dollar sign in the database password.  Seems that&#8217;s not valid in the ini file.  I changed the password and it&#8217;s working.</p>
<p>Pretty obscure, no?</p>
]]></content:encoded>
			<wfw:commentRss>http://scottbarnham.com/blog/2010/08/20/openx-upgrade-page-full-of-errors/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Gvim menu bar missing</title>
		<link>http://scottbarnham.com/blog/2009/03/09/gvim-menu-bar-missing/</link>
		<comments>http://scottbarnham.com/blog/2009/03/09/gvim-menu-bar-missing/#comments</comments>
		<pubDate>Mon, 09 Mar 2009 03:04:08 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://scottbarnham.com/blog/2009/03/09/gvim-menu-bar-missing/</guid>
		<description><![CDATA[I just opened gvim on my Ubuntu (Hardy Heron) box and found there was no menu bar (File, Edit, etc).
After messing with some guioptions and getting nowhere I ran gvim as root (using sudo) and the menu bar was there.  The answer came from a forum post by &#8220;Marko&#8221;:
Delete the file ~/.gnome2/Vim
It will be [...]]]></description>
			<content:encoded><![CDATA[<p>I just opened <code>gvim</code> on my Ubuntu (Hardy Heron) box and found there was no menu bar (File, Edit, etc).</p>
<p>After messing with some <code>guioptions</code> and getting nowhere I ran <code>gvim</code> as root (using <code>sudo</code>) and the menu bar was there.  The answer came from a forum post by &#8220;Marko&#8221;:</p>
<p>Delete the file <code>~/.gnome2/Vim</code></p>
<p>It will be recreated when you run <code>gvim</code> again.  With luck, the menu will be displayed again.</p>
]]></content:encoded>
			<wfw:commentRss>http://scottbarnham.com/blog/2009/03/09/gvim-menu-bar-missing/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Layoff Talent &#8211; Django project just launched</title>
		<link>http://scottbarnham.com/blog/2008/12/11/layoff-talent-django-project-just-launched/</link>
		<comments>http://scottbarnham.com/blog/2008/12/11/layoff-talent-django-project-just-launched/#comments</comments>
		<pubDate>Thu, 11 Dec 2008 17:05:48 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://scottbarnham.com/blog/2008/12/11/layoff-talent-django-project-just-launched/</guid>
		<description><![CDATA[Andrew and I spent a few days this week putting together a new Django project.
It&#8217;s called Layoff Talent and it&#8217;s a place for people in the tech industry who have been laid off and are looking for a new job.  They can add a simple profile and then hopefully be picked up by employers [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://twitter.com/andrewgleave">Andrew</a> and <a href="http://twitter.com/scottbarnham">I</a> spent a few days this week putting together a new Django project.</p>
<p>It&#8217;s called <a href="http://layofftalent.com/">Layoff Talent</a> and it&#8217;s a place for people in the tech industry who have been laid off and are looking for a new job.  They can add a simple profile and then hopefully be picked up by employers looking for new talent.</p>
<p>It&#8217;s similar in some ways to <a href="http://djangopeople.net/">Django People</a> or the <a href="http://djangogigs.com/">Djangogigs</a> developer listings, but specifically for people who have been laid off and not restricted to Django developers.</p>
<p>There&#8217;s nothing ground breaking from a development point of view, but it&#8217;s another example of how Django makes it easy to put out a full-featured site in a short time.  Of course, we&#8217;ll be adding more features as the site gets popular.</p>
<p>If you know someone who has been laid off, please tell them about <a href="http://layofftalent.com/">layofftalent.com</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://scottbarnham.com/blog/2008/12/11/layoff-talent-django-project-just-launched/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>getSelection() returns empty in Google Mail</title>
		<link>http://scottbarnham.com/blog/2008/02/21/getselection-returns-empty-in-google-mail/</link>
		<comments>http://scottbarnham.com/blog/2008/02/21/getselection-returns-empty-in-google-mail/#comments</comments>
		<pubDate>Thu, 21 Feb 2008 11:23:17 +0000</pubDate>
		<dc:creator>Scott</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://scottbarnham.com/blog/2008/02/21/getselection-returns-empty-in-google-mail/</guid>
		<description><![CDATA[Getting selected text in a Firefox extension
I&#8217;m developing a Firefox extension for a client which does something with the currently selected text in the browser window.
The standard way to get the selection is with window.content.getSelection().  
Selection is empty in Gmail
Some users reported that selected text in Gmail messages wasn&#8217;t being found by the extension. [...]]]></description>
			<content:encoded><![CDATA[<h2>Getting selected text in a Firefox extension</h2>
<p>I&#8217;m developing a Firefox extension for a client which does something with the currently selected text in the browser window.</p>
<p>The standard way to get the selection is with <code>window.content.getSelection()</code>.  </p>
<h2>Selection is empty in Gmail</h2>
<p>Some users reported that selected text in Gmail messages wasn&#8217;t being found by the extension.  I suspect the issue is with content added using JavaScript, but I haven&#8217;t investigated.</p>
<h2>An alternative way to getSelection</h2>
<p>The standard <em>Search Google for &#8220;whatever&#8221;</em> contextual menu item does work in Gmail, so obviously it gets the selection another way.</p>
<p>I found a function <code>getBrowserSelection()</code> in the <code>browser.js</code> file in Firefox&#8217;s chrome.  It is used by Firefox for the contextual menu search.</p>
<p>This is how it gets the selection:</p>
<pre>var focusedWindow = document.commandDispatcher.focusedWindow;
var selection = focusedWindow.getSelection();</pre>
<p>I don&#8217;t know what the difference is, but I am now using this code in my Firefox extension and it is working well.</p>
]]></content:encoded>
			<wfw:commentRss>http://scottbarnham.com/blog/2008/02/21/getselection-returns-empty-in-google-mail/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.234 seconds -->

