<?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>GraysUnderground.com</title>
	<atom:link href="http://www.graysunderground.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.graysunderground.com</link>
	<description>Gray's Tech Blog</description>
	<lastBuildDate>Thu, 12 Jan 2012 23:41:25 +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>Mysql General Query Log</title>
		<link>http://www.graysunderground.com/2012/01/12/mysql-general-query-log/</link>
		<comments>http://www.graysunderground.com/2012/01/12/mysql-general-query-log/#comments</comments>
		<pubDate>Thu, 12 Jan 2012 23:41:25 +0000</pubDate>
		<dc:creator>Gray</dc:creator>
				<category><![CDATA[MySQL]]></category>

	<!-- AutoMeta Start -->
	<category></category>
	<category></category>
	<!-- AutoMeta End -->
	
		<guid isPermaLink="false">http://www.graysunderground.com/?p=44</guid>
		<description><![CDATA[In Mysql 5.1.6 and greater you can turn the General Query Log on and log to a table. Works nice when you just need to find out query issues. SET GLOBAL general_log = &#8216;ON&#8217;; SET GLOBAL log_output=&#8217;table&#8217;;]]></description>
			<content:encoded><![CDATA[<p>In Mysql 5.1.6 and greater you can turn the General Query Log on and log to a table. Works nice when you just need to find out query issues.</p>
<p>SET GLOBAL general_log = &#8216;ON&#8217;;<br />
SET GLOBAL log_output=&#8217;table&#8217;;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.graysunderground.com/2012/01/12/mysql-general-query-log/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Optimize MySQL tables after deleteing alot of data</title>
		<link>http://www.graysunderground.com/2011/04/12/optimize-mysql-tables-after-deleteing-alot-of-data/</link>
		<comments>http://www.graysunderground.com/2011/04/12/optimize-mysql-tables-after-deleteing-alot-of-data/#comments</comments>
		<pubDate>Tue, 12 Apr 2011 18:11:23 +0000</pubDate>
		<dc:creator>Gray</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

	<!-- AutoMeta Start -->
	<category></category>
	<category></category>
	<!-- AutoMeta End -->
	
		<guid isPermaLink="false">http://www.graysunderground.com/?p=40</guid>
		<description><![CDATA[OPTIMIZE TABLE foo; will squeeze out the dead space. ALTER TABLE foo ORDER BY something; does what OPTIMIZE does (but in a totally different way), plus clusters data based on the ORDER BY. In a few cases, this can be quite beneficial. Here&#8217;s an example: * Table is bigger than will fit in cache. * [...]]]></description>
			<content:encoded><![CDATA[<p>OPTIMIZE TABLE foo;<br />
will squeeze out the dead space.</p>
<p>ALTER TABLE foo ORDER BY something;<br />
does what OPTIMIZE does (but in a totally different way), plus clusters data based on the ORDER BY. In a few cases, this can be quite beneficial. Here&#8217;s an example:<br />
* Table is bigger than will fit in cache.<br />
* Table has two ways to look at it, one is date oriented, the other is by some &#8220;key&#8221;.<br />
* There are hundreds of rows for each key (one per day)<br />
* There are thousands of keys for each day.<br />
* Data is coming in daily &#8212; That is, new rows are appended to the table and/or filling in holes left by deleted rows.<br />
* Your main query is SELECT &#8230; WHERE key = &#8216;&#8230;&#8217; &#8212; that is, one row per day.</p>
<p>Normally the rows for that SELECT will be quite scattered, and because of the size of the table, it will take a lot of disk hits.</p>
<p>The ALTER table will rearrange the rows so that the SELECT will find all the rows for the &#8216;key&#8217; clustered in a few blocks, hence much less disk I/O.</p>
<p>IF this use of ALTER feels right for you, I recommend doing it monthly. Watch out: It could take hours (remember, it is bigger than will fit in cache).</p>
<p>For small tables (say, <100K rows), the ALTER is reasonably fast, but gives only limited improvement.</p>
<p>I have felt the need for the ALTER in less than 1% of the tables I have studied.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.graysunderground.com/2011/04/12/optimize-mysql-tables-after-deleteing-alot-of-data/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Force Postgres to stop</title>
		<link>http://www.graysunderground.com/2011/02/23/force-postgres-to-stop/</link>
		<comments>http://www.graysunderground.com/2011/02/23/force-postgres-to-stop/#comments</comments>
		<pubDate>Wed, 23 Feb 2011 20:29:08 +0000</pubDate>
		<dc:creator>Gray</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

	<!-- AutoMeta Start -->
	<category></category>
	<!-- AutoMeta End -->
	
		<guid isPermaLink="false">http://www.graysunderground.com/2011/02/23/force-postgres-to-stop/</guid>
		<description><![CDATA[You might see the following when issuing the normal stop command to postgres via pg_ctl. -bash-3.1$ pg_ctl stop waiting for server to shut down……………………………………………………… failed pg_ctl: server does not shut down Sometimes postgres does not want to shutdown by just issuing a pg_ctl stop as the postgres user. User might feel the need to “kill [...]]]></description>
			<content:encoded><![CDATA[<p>You might see the following when issuing the normal stop command to postgres via pg_ctl.</p>
<p>-bash-3.1$ pg_ctl stop<br />
waiting for server to shut down……………………………………………………… failed<br />
pg_ctl: server does not shut down</p>
<p>Sometimes postgres does not want to shutdown by just issuing a pg_ctl stop as the postgres user. User might feel the need to “kill -9″ the postgres processes however this could be dangerous for PostgreSQL. Instead of trying to kill the PID follow the directions below in an attempt to stop postgres in an organized fashion.</p>
<p>   1. Attempt Normal Stop: bash-3.1$pg_ctl stop<br />
   2. Attempt Smart Stop: bash-3.1$pg_ctl stop -m s<br />
   3. Attempt Fast Stop: bash-3.1$pg_ctl stop -m f<br />
   4. Attempt Immediate Stop: bash-3.1$pg_ctl stop -m i<br />
The immediate stop almost always ends up stopping postgres if you are having trouble in stopping the processes. If the immediate stop does not work the issue should be investigated before attempting to kill -9 the PID.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.graysunderground.com/2011/02/23/force-postgres-to-stop/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Argument list too long</title>
		<link>http://www.graysunderground.com/2011/02/17/argument-list-too-long/</link>
		<comments>http://www.graysunderground.com/2011/02/17/argument-list-too-long/#comments</comments>
		<pubDate>Fri, 18 Feb 2011 01:32:36 +0000</pubDate>
		<dc:creator>Gray</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Linux]]></category>

	<!-- AutoMeta Start -->
	<category></category>
	<!-- AutoMeta End -->
	
		<guid isPermaLink="false">http://www.graysunderground.com/2011/02/17/argument-list-too-long/</guid>
		<description><![CDATA[Hate when you can&#8217;t delete everything in a directory at once because rm runs out of args. This will DELETE everything in your current folder. Try this: find . -name &#8216;*&#8217; -exec rm {} \; What to force it so it does not ask you y/n for each file? find . -name &#8216;*&#8217; -exec rm [...]]]></description>
			<content:encoded><![CDATA[<p>Hate when you can&#8217;t delete everything in a directory at once because rm runs out of args. This will DELETE everything in your current folder.</p>
<p>Try this:</p>
<p>find . -name &#8216;*&#8217; -exec rm {} \; </p>
<p>What to force it so it does not ask you y/n for each file?</p>
<p>find . -name &#8216;*&#8217; -exec rm -f {} \; </p>
<p>To remove/delete only directories just add a &#8216;type&#8217; flag to find&#8230;</p>
<p>find . -name &#8216;*&#8217; -type d -exec rm {} \; </p>
]]></content:encoded>
			<wfw:commentRss>http://www.graysunderground.com/2011/02/17/argument-list-too-long/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Upgrade The Ubuntu Linux Kernel</title>
		<link>http://www.graysunderground.com/2011/01/31/how-to-upgrade-the-ubuntu-linux-kernel/</link>
		<comments>http://www.graysunderground.com/2011/01/31/how-to-upgrade-the-ubuntu-linux-kernel/#comments</comments>
		<pubDate>Tue, 01 Feb 2011 00:12:49 +0000</pubDate>
		<dc:creator>Gray</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[kernel]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[ubuntu]]></category>

	<!-- AutoMeta Start -->
	<category></category>
	<!-- AutoMeta End -->
	
		<guid isPermaLink="false">http://www.graysunderground.com/2011/01/31/how-to-upgrade-the-ubuntu-linux-kernel/</guid>
		<description><![CDATA[This is how I do it. Mileage may very, use at own risk. First: sudo apt-get install linux-image- This will give you all current options for a new linux kernel image. Next do the same with the headers! sudo apt-get install linux-headers- Make sure you do your headers too!!!]]></description>
			<content:encoded><![CDATA[<p>This is how I do it. Mileage may very, use at own risk.</p>
<p>First:<br />
sudo apt-get install linux-image-<tab></p>
<p>This will give you all current options for a new linux kernel image. </p>
<p>Next do the same with the headers!<br />
sudo apt-get install linux-headers-<tab></p>
<p>Make sure you do your headers too!!!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.graysunderground.com/2011/01/31/how-to-upgrade-the-ubuntu-linux-kernel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux Unrar batch of files with password</title>
		<link>http://www.graysunderground.com/2011/01/18/linux-unrar-batch-of-files-with-password/</link>
		<comments>http://www.graysunderground.com/2011/01/18/linux-unrar-batch-of-files-with-password/#comments</comments>
		<pubDate>Tue, 18 Jan 2011 22:57:17 +0000</pubDate>
		<dc:creator>Gray</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Linux]]></category>

	<!-- AutoMeta Start -->
	<category></category>
	<!-- AutoMeta End -->
	
		<guid isPermaLink="false">http://www.graysunderground.com/2011/01/18/linux-unrar-batch-of-files-with-password/</guid>
		<description><![CDATA[So I need to unrar password protected files that are in a batch. Apprx 10-20 each time. This little command line script worked wonders for me, just replace PASSWORD with your password. find -type f -name &#8216;*.rar&#8217; -exec unrar -pPASSWORD x {} \;]]></description>
			<content:encoded><![CDATA[<p>So I need to unrar password protected files that are in a batch. Apprx 10-20 each time. This little command line script worked wonders for me, just replace PASSWORD with your password.</p>
<p>find -type f -name &#8216;*.rar&#8217; -exec unrar -pPASSWORD x {} \;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.graysunderground.com/2011/01/18/linux-unrar-batch-of-files-with-password/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Delete all files older than a certain amount of days</title>
		<link>http://www.graysunderground.com/2010/09/20/delete-all-files-older-than-a-certain-amount-of-days/</link>
		<comments>http://www.graysunderground.com/2010/09/20/delete-all-files-older-than-a-certain-amount-of-days/#comments</comments>
		<pubDate>Mon, 20 Sep 2010 19:19:43 +0000</pubDate>
		<dc:creator>Gray</dc:creator>
				<category><![CDATA[Linux]]></category>

	<!-- AutoMeta Start -->
	<category></category>
	<!-- AutoMeta End -->
	
		<guid isPermaLink="false">http://www.graysunderground.com/2010/09/20/delete-all-files-older-than-a-certain-amount-of-days/</guid>
		<description><![CDATA[Found a nice little clean up command to clean up folders and files older than a specfic amount of days: find /path/to/files/* -mtime +90 -exec rm {} \; Just replace the 90 with the number of days old you want to delete. You can also pipe it into a log file: bash -c ‘date;find /path/to/files* [...]]]></description>
			<content:encoded><![CDATA[<p>Found a nice little clean up command to clean up folders and files older than a specfic amount of days:</p>
<p>find /path/to/files/* -mtime +90 -exec rm {} \;</p>
<p>Just replace the 90 with the number of days old you want to delete.</p>
<p>You can also pipe it into a log file:</p>
<p>bash -c ‘date;find /path/to/files* -mtime +5 -exec rm -v {} \;;date’ &gt; ~/mylog</p>
]]></content:encoded>
			<wfw:commentRss>http://www.graysunderground.com/2010/09/20/delete-all-files-older-than-a-certain-amount-of-days/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Postgres: FATAL:  sorry, too many clients already</title>
		<link>http://www.graysunderground.com/2010/05/20/postgres-fatal-sorry-too-many-clients-already/</link>
		<comments>http://www.graysunderground.com/2010/05/20/postgres-fatal-sorry-too-many-clients-already/#comments</comments>
		<pubDate>Thu, 20 May 2010 17:31:11 +0000</pubDate>
		<dc:creator>Gray</dc:creator>
				<category><![CDATA[postgres]]></category>

	<!-- AutoMeta Start -->
	<category></category>
	<!-- AutoMeta End -->
	
		<guid isPermaLink="false">http://www.graysunderground.com/?p=28</guid>
		<description><![CDATA[Ok so I have a postgres database at work that we use to store application information and this database is shared across some large web applications. We recently started getting the above error in the postgres logs, and occasional failures in the web apps. Let me state for the record I am not a postgres [...]]]></description>
			<content:encoded><![CDATA[<p>Ok so I have a postgres database at work that we use to store application information and this database is shared across some large web applications. We recently started getting the above error in the postgres logs, and occasional failures in the web apps. Let me state for the record I am not a postgres expert, I can install it, get it running and use it, beyond that is the extent of my postgres knowledge. Anyway back to my story. So we started having this wierd failures and not knowing how to diagnose it I started googling.</p>
<p>The first thing I find is how to see how many processes I have running:</p>
<p>ps auxww | grep ^postgres | wc -l</p>
<p>ps auxww | grep ^postgres</p>
<p>The first shows you how many process are running, and the second gives you more detail. So I now I had a little bit better understanding of what was going on. I could see how many postgres process I had at any one time. But that did not help me figure out which queries and what app was causing the problems.</p>
<p>I googled some more and figured out how to query the active queries.</p>
<p>So I run this query against the stats database:</p>
<p>SELECT count(*) as cnt, usename, current_query FROM pg_stat_activity GROUP BY usename,current_query ORDER BY cnt DESC;</p>
<p>But I get &#8220;&lt;command string not enabled&gt;&#8221;; so more googling and I found I need to change a setting in the postgresql.conf and set the stats_command_string = true.</p>
<p>Ok with this done I was able to run the query above and find 1 single query that was getting repeated over and over again hundreds of times and was taking 8-10 minutes to finish, and even longer as the queries stacked up.</p>
<p>On further inspection, this one query is supposed to be memcached, its hit on every page of a site and should cache once and never hit the database again, but its not. Some times it does and things run great, other times it continues to not find it in cache and hit the database.</p>
<p>We could not figure out why this particular query out of the hundreds we store in memcache is not being cached properly. So we cache it the old fashion way in file, till we can work out why it won&#8217;t cache in memcache. Once its cached again properly, ir improperly in this case, Postgres starts working properly again. No more high connections and no more app failures.</p>
<p>The end, or is it? Now we have to figure out why it won&#8217;t cache in Memcache properly.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.graysunderground.com/2010/05/20/postgres-fatal-sorry-too-many-clients-already/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Run command as apache in centos</title>
		<link>http://www.graysunderground.com/2010/05/06/run-command-as-apache-in-centos/</link>
		<comments>http://www.graysunderground.com/2010/05/06/run-command-as-apache-in-centos/#comments</comments>
		<pubDate>Fri, 07 May 2010 00:41:25 +0000</pubDate>
		<dc:creator>Gray</dc:creator>
				<category><![CDATA[Linux]]></category>

	<!-- AutoMeta Start -->
	<category></category>
	<!-- AutoMeta End -->
	
		<guid isPermaLink="false">http://www.graysunderground.com/2010/05/06/run-command-as-apache-in-centos/</guid>
		<description><![CDATA[Here is how you run a command as apache in centos without giving apache a valid shell. su -s /bin/sh apache -c &#8220;whoami&#8221;]]></description>
			<content:encoded><![CDATA[<p>Here is how you run a command as apache in centos without giving apache a valid shell.</p>
<p>su -s /bin/sh apache -c &#8220;whoami&#8221;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.graysunderground.com/2010/05/06/run-command-as-apache-in-centos/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Validate an email address using regular expressions</title>
		<link>http://www.graysunderground.com/2009/04/15/validate-an-email-address-using-regular-expressions/</link>
		<comments>http://www.graysunderground.com/2009/04/15/validate-an-email-address-using-regular-expressions/#comments</comments>
		<pubDate>Wed, 15 Apr 2009 21:55:41 +0000</pubDate>
		<dc:creator>Gray</dc:creator>
				<category><![CDATA[PHP]]></category>

	<!-- AutoMeta Start -->
	<category></category>
	<!-- AutoMeta End -->
	
		<guid isPermaLink="false">http://www.graysunderground.com/2009/04/15/validate-an-email-address-using-regular-expressions/</guid>
		<description><![CDATA[If you want a PHP script to validate an email address here is a quick and simple PHP regular expression to do it. This script is also case-insensitive, so it will treat all characters as lower case. This script is a simple and  easy way to check the syntax and format of an email address. [...]]]></description>
			<content:encoded><![CDATA[<p>If you want a PHP script to validate an email address here is a quick and simple PHP regular expression to do it. This script is also case-insensitive, so it will treat all characters as lower case. This script is a simple and  easy way to check the syntax and format of an email address.</p>
<h2>The code</h2>
<pre><code><span style="color: #000000">
<span style="color: #0000bb">&lt;?php

$email </span><span style="color: #007700">= </span><span style="color: #dd0000">"someone@example.com"</span><span style="color: #007700">;

if(</span><span style="color: #0000bb">eregi</span><span style="color: #007700">(</span><span style="color: #dd0000">"^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$"</span><span style="color: #007700">, </span><span style="color: #0000bb">$email</span><span style="color: #007700">)) {

  echo </span><span style="color: #dd0000">"Valid email address."</span><span style="color: #007700">;

}

else {

  echo </span><span style="color: #dd0000">"Invalid email address."</span><span style="color: #007700">;

}

</span><span style="color: #0000bb">?&gt;</span>
</span>
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.graysunderground.com/2009/04/15/validate-an-email-address-using-regular-expressions/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

