<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Cowboy Coder</title>
	<atom:link href="http://txcowboycoder.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://txcowboycoder.wordpress.com</link>
	<description>roping in the chaos</description>
	<lastBuildDate>Sat, 19 Nov 2011 16:52:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='txcowboycoder.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Cowboy Coder</title>
		<link>http://txcowboycoder.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://txcowboycoder.wordpress.com/osd.xml" title="Cowboy Coder" />
	<atom:link rel='hub' href='http://txcowboycoder.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Keep code base clean &#8211; avoid unnecessary variable assignments</title>
		<link>http://txcowboycoder.wordpress.com/2011/07/14/keep-code-base-clean-avoid-unnecessary-variable-assignments/</link>
		<comments>http://txcowboycoder.wordpress.com/2011/07/14/keep-code-base-clean-avoid-unnecessary-variable-assignments/#comments</comments>
		<pubDate>Thu, 14 Jul 2011 17:04:17 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[Clean Code]]></category>
		<category><![CDATA[clean code]]></category>
		<category><![CDATA[temp variables]]></category>

		<guid isPermaLink="false">http://txcowboycoder.wordpress.com/?p=664</guid>
		<description><![CDATA[Can&#8217;t tell you how frustrating it is to find the context of a variable stripped away by a meaningless re-assgiment (login required). From Clean Code: A Handbook of Agile Software Craftsmanship: The name of a variable, function, or class, should answer all the big questions. It should tell you why it exists, what it does, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=txcowboycoder.wordpress.com&amp;blog=13018064&amp;post=664&amp;subd=txcowboycoder&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Can&#8217;t tell you how frustrating it is to find the context of a variable stripped away by a <a href="http://my.safaribooksonline.com/book/software-engineering-and-development/agile-development/9780136083238/meaningful-names/18" target="_blank">meaningless re-assgiment</a> (login required).</p>
<p>From Clean Code: A Handbook of Agile Software Craftsmanship:</p>
<blockquote><p>The name of a variable, function, or class, should answer all the big questions. It<br />
should tell you why it exists, what it does, and how it is used</p></blockquote>
<p><pre class="brush: php;">
// doing this totally strips away any meaningful context
$my_temp_variable = $employee_salaries[$an_employee_name];
$gross_salary = $bonus_factor * $my_temp_variable;

// hopefully the language constructs allow full variable interaction
$gross_salary = $bonus_factor * $employee_salaries[&quot;Fred&quot;]
</pre></p>
<br /> Tagged: <a href='http://txcowboycoder.wordpress.com/tag/clean-code/'>clean code</a>, <a href='http://txcowboycoder.wordpress.com/tag/temp-variables/'>temp variables</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/txcowboycoder.wordpress.com/664/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/txcowboycoder.wordpress.com/664/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/txcowboycoder.wordpress.com/664/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/txcowboycoder.wordpress.com/664/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/txcowboycoder.wordpress.com/664/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/txcowboycoder.wordpress.com/664/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/txcowboycoder.wordpress.com/664/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/txcowboycoder.wordpress.com/664/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/txcowboycoder.wordpress.com/664/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/txcowboycoder.wordpress.com/664/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/txcowboycoder.wordpress.com/664/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/txcowboycoder.wordpress.com/664/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/txcowboycoder.wordpress.com/664/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/txcowboycoder.wordpress.com/664/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=txcowboycoder.wordpress.com&amp;blog=13018064&amp;post=664&amp;subd=txcowboycoder&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://txcowboycoder.wordpress.com/2011/07/14/keep-code-base-clean-avoid-unnecessary-variable-assignments/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b304fa18931de25695a3c780f1e3155d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">txcowboycoder</media:title>
		</media:content>
	</item>
		<item>
		<title>Embedding CSS file in html e-mail</title>
		<link>http://txcowboycoder.wordpress.com/2011/07/13/embedding-css-file-in-html-e-mail/</link>
		<comments>http://txcowboycoder.wordpress.com/2011/07/13/embedding-css-file-in-html-e-mail/#comments</comments>
		<pubDate>Wed, 13 Jul 2011 16:51:09 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[clean code]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[embed]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://txcowboycoder.wordpress.com/?p=737</guid>
		<description><![CDATA[Sending html e-mails opens a whole can of worms on the many ways e-mail can be viewed. There is also no guarantee your e-mail will look as intended. Instead of linking to a remote css file that may be blocked, or prompt the user with a scary &#8216;prevented external content to load&#8217; error message, we [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=txcowboycoder.wordpress.com&amp;blog=13018064&amp;post=737&amp;subd=txcowboycoder&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Sending html e-mails opens a whole can of worms on the many <a href="http://www.alistapart.com/articles/cssemail/" target="_blank">ways e-mail can be viewed</a>. There is also no guarantee your e-mail will look as intended.</p>
<p>Instead of linking to a remote css file that may be blocked, or prompt the user with a scary &#8216;prevented external content to load&#8217; error message, we can use PHP to pull the file directly. This adheres to the DRY principle and keeps the code base clean.</p>
<p>Use the <a href="http://php.net/file_get_contents" target="_blank">file_get_contents</a> function in place of linking a style sheet via an html <code>style</code> element.</p>
<p>I would also recommend a try/catch block in case the <code>file_get_contents</code> command fails.</p>
<h2>Solution</h2>
<p>In head section:<br />
<pre class="brush: xml;">
&lt;style type=&quot;text/css&quot; media=&quot;screen&quot;&gt;
	&lt;!-- we do this to embed the file contents into the e-mail.
	&lt;?php echo file_get_contents(&quot;../common/css/blueprint/screen.css&quot;); ?&gt;
	--&gt;
&lt;/style&gt;
</pre></p>
<br /> Tagged: <a href='http://txcowboycoder.wordpress.com/tag/clean-code/'>clean code</a>, <a href='http://txcowboycoder.wordpress.com/tag/css/'>CSS</a>, <a href='http://txcowboycoder.wordpress.com/tag/email/'>email</a>, <a href='http://txcowboycoder.wordpress.com/tag/embed/'>embed</a>, <a href='http://txcowboycoder.wordpress.com/tag/php-2/'>php</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/txcowboycoder.wordpress.com/737/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/txcowboycoder.wordpress.com/737/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/txcowboycoder.wordpress.com/737/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/txcowboycoder.wordpress.com/737/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/txcowboycoder.wordpress.com/737/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/txcowboycoder.wordpress.com/737/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/txcowboycoder.wordpress.com/737/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/txcowboycoder.wordpress.com/737/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/txcowboycoder.wordpress.com/737/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/txcowboycoder.wordpress.com/737/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/txcowboycoder.wordpress.com/737/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/txcowboycoder.wordpress.com/737/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/txcowboycoder.wordpress.com/737/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/txcowboycoder.wordpress.com/737/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=txcowboycoder.wordpress.com&amp;blog=13018064&amp;post=737&amp;subd=txcowboycoder&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://txcowboycoder.wordpress.com/2011/07/13/embedding-css-file-in-html-e-mail/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b304fa18931de25695a3c780f1e3155d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">txcowboycoder</media:title>
		</media:content>
	</item>
		<item>
		<title>Blueprint CSS is total win</title>
		<link>http://txcowboycoder.wordpress.com/2011/07/12/blueprint-css-is-total-win/</link>
		<comments>http://txcowboycoder.wordpress.com/2011/07/12/blueprint-css-is-total-win/#comments</comments>
		<pubDate>Tue, 12 Jul 2011 16:47:38 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[blueprint]]></category>
		<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://txcowboycoder.wordpress.com/?p=729</guid>
		<description><![CDATA[Having not played around with CSS frameworks before I found this one very appealing. Really, it accomplishes something I used to spend an inordinate time doing: creating a simple set of CSS rules that bring all browsers to a common level playing field. My favorite aspect is the concept of 24 columns easily split into [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=txcowboycoder.wordpress.com&amp;blog=13018064&amp;post=729&amp;subd=txcowboycoder&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Having not played around with CSS frameworks before I found this one very appealing.</p>
<p>Really, it accomplishes something I used to spend an inordinate time doing: creating a simple set of CSS rules that bring all browsers to a common level playing field.</p>
<p>My favorite aspect is the concept of 24 columns easily split into classes <code>span-x</code> where x is a number of columns.</p>
<p>Check out <a href="http://www.blueprintcss.org/">blueprintcss.com</a> for more information.</p>
<br /> Tagged: <a href='http://txcowboycoder.wordpress.com/tag/blueprint/'>blueprint</a>, <a href='http://txcowboycoder.wordpress.com/tag/css/'>CSS</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/txcowboycoder.wordpress.com/729/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/txcowboycoder.wordpress.com/729/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/txcowboycoder.wordpress.com/729/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/txcowboycoder.wordpress.com/729/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/txcowboycoder.wordpress.com/729/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/txcowboycoder.wordpress.com/729/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/txcowboycoder.wordpress.com/729/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/txcowboycoder.wordpress.com/729/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/txcowboycoder.wordpress.com/729/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/txcowboycoder.wordpress.com/729/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/txcowboycoder.wordpress.com/729/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/txcowboycoder.wordpress.com/729/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/txcowboycoder.wordpress.com/729/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/txcowboycoder.wordpress.com/729/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=txcowboycoder.wordpress.com&amp;blog=13018064&amp;post=729&amp;subd=txcowboycoder&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://txcowboycoder.wordpress.com/2011/07/12/blueprint-css-is-total-win/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b304fa18931de25695a3c780f1e3155d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">txcowboycoder</media:title>
		</media:content>
	</item>
		<item>
		<title>Porting DATE_TO_CHAR function to PostgreSQL</title>
		<link>http://txcowboycoder.wordpress.com/2011/07/11/porting-date_to_char-function-to-postgresql/</link>
		<comments>http://txcowboycoder.wordpress.com/2011/07/11/porting-date_to_char-function-to-postgresql/#comments</comments>
		<pubDate>Mon, 11 Jul 2011 18:30:15 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[4D]]></category>
		<category><![CDATA[Postgres]]></category>
		<category><![CDATA[4D SQL]]></category>
		<category><![CDATA[SQL function]]></category>

		<guid isPermaLink="false">http://txcowboycoder.wordpress.com/?p=726</guid>
		<description><![CDATA[This allows multiple data stores but without rewriting all sql queries. Note you have to create two functions, one to accept dates, the other to accept times. Specifically the 4D SQL function DATE_TO_CHAR. Luckily PostgreSQL has the equivalent as a formatting function to_char. For business reasons it&#8217;s not practical to replace all instances of DATE_TO_CHAR [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=txcowboycoder.wordpress.com&amp;blog=13018064&amp;post=726&amp;subd=txcowboycoder&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This allows multiple data stores but without rewriting all sql queries. Note you have to create two functions, one to accept dates, the other to accept times.</p>
<p>Specifically the 4D SQL function <a href="http://doc.4d.com/4D-SQL-Reference-12.1/Functions/DATE-TO-CHAR.300-494541.en.html" target="_blank"><code>DATE_TO_CHAR</code></a>. Luckily PostgreSQL has the equivalent as a formatting function <a href="http://www.postgresql.org/docs/8.4/static/functions-formatting.html" target="_blank"><code>to_char</code></a>.</p>
<p>For business reasons it&#8217;s not practical to replace all instances of <code>DATE_TO_CHAR</code> to <code>to_char</code>.</p>
<h2>Solution</h2>
<p>Create a function in the postgresql data base that maps the <code>DATE_TO_CHAR</code> function to <code>to_char</code>. Luckily the formatting options I need are available.</p>
<p>Now <code>SELECT DATE_TO_CHAR(DateField1, "YYYY-MM-DD") FROM Table1</code> will return the correct value regardless of the database queried. It&#8217;s important to note this works great for getting integer values from dates and casting as date objects. If queries rely on returning non-iso formatting your mileage may vary.</p>
<p><pre class="brush: sql;">
-- Function: date_to_char(date, text)
CREATE OR REPLACE FUNCTION date_to_char(date, text)
  RETURNS text AS
$BODY$
  DECLARE
  BEGIN
       RETURN to_char($1,$2)::text;
  END;
  $BODY$
  LANGUAGE plpgsql VOLATILE
  COST 100;
ALTER FUNCTION date_to_char(date, text) OWNER TO postgres;
</pre></p>
<p><pre class="brush: sql;">
-- Function: date_to_char(time without time zone, text)
CREATE OR REPLACE FUNCTION date_to_char(time without time zone, text)
  RETURNS text AS
$BODY$
  DECLARE
  BEGIN
       RETURN to_char($1,$2)::text;
  END;
  $BODY$
  LANGUAGE plpgsql VOLATILE
  COST 100;
ALTER FUNCTION date_to_char(time without time zone, text) OWNER TO postgres;
</pre></p>
<br /> Tagged: <a href='http://txcowboycoder.wordpress.com/tag/4d-sql/'>4D SQL</a>, <a href='http://txcowboycoder.wordpress.com/tag/postgres/'>Postgres</a>, <a href='http://txcowboycoder.wordpress.com/tag/sql-function/'>SQL function</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/txcowboycoder.wordpress.com/726/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/txcowboycoder.wordpress.com/726/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/txcowboycoder.wordpress.com/726/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/txcowboycoder.wordpress.com/726/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/txcowboycoder.wordpress.com/726/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/txcowboycoder.wordpress.com/726/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/txcowboycoder.wordpress.com/726/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/txcowboycoder.wordpress.com/726/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/txcowboycoder.wordpress.com/726/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/txcowboycoder.wordpress.com/726/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/txcowboycoder.wordpress.com/726/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/txcowboycoder.wordpress.com/726/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/txcowboycoder.wordpress.com/726/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/txcowboycoder.wordpress.com/726/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=txcowboycoder.wordpress.com&amp;blog=13018064&amp;post=726&amp;subd=txcowboycoder&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://txcowboycoder.wordpress.com/2011/07/11/porting-date_to_char-function-to-postgresql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b304fa18931de25695a3c780f1e3155d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">txcowboycoder</media:title>
		</media:content>
	</item>
		<item>
		<title>Reverse PostgreSQL into model with undefined data types</title>
		<link>http://txcowboycoder.wordpress.com/2011/06/30/reverse-postgresql-into-model-with-undefined-data-types/</link>
		<comments>http://txcowboycoder.wordpress.com/2011/06/30/reverse-postgresql-into-model-with-undefined-data-types/#comments</comments>
		<pubDate>Thu, 30 Jun 2011 20:21:31 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[Oracle Data Integrator]]></category>
		<category><![CDATA[data types]]></category>
		<category><![CDATA[ODI]]></category>
		<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[reverse]]></category>

		<guid isPermaLink="false">http://txcowboycoder.wordpress.com/?p=724</guid>
		<description><![CDATA[Recently while importing a new physical schema from PostgreSQL 8.4 into Oracle Data Integrator(ODI) via JDBC driver all of the tables were reversing into the model without data types defined for text, double precision, smallint, integer and boolean. If one or two fields are missing it&#8217;s easy enough to set the data type manually for [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=txcowboycoder.wordpress.com&amp;blog=13018064&amp;post=724&amp;subd=txcowboycoder&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Recently while importing a new physical schema from PostgreSQL 8.4 into Oracle Data Integrator(ODI) via JDBC driver all of the tables were reversing into the model without data types defined for text, double precision, smallint, integer and boolean.</p>
<p>If one or two fields are missing it&#8217;s easy enough to set the data type manually for the column, but for a whole mess of tables and thousands of fields it&#8217;s unrealistic.</p>
<p>The solution is to define the proper data types using the physical architecture tab with PostgreSQL internal names for the data types. Even though by default there is one for integer, looking at the <a href="http://www.postgresql.org/docs/8.2/static/datatype.html#DATATYPE-TABLE" target="_blank">data type definitions</a> smallint maps to int2, integer maps to int4, double precision maps to float8, boolean maps to bool.</p>
<p>Using these aliases which are used internally by PostgreSQL for historical reasons in the ODI Physical Architecture will fix the missing data types during the reverse process.</p>
<br /> Tagged: <a href='http://txcowboycoder.wordpress.com/tag/data-types/'>data types</a>, <a href='http://txcowboycoder.wordpress.com/tag/odi/'>ODI</a>, <a href='http://txcowboycoder.wordpress.com/tag/postgresql/'>PostgreSQL</a>, <a href='http://txcowboycoder.wordpress.com/tag/reverse/'>reverse</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/txcowboycoder.wordpress.com/724/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/txcowboycoder.wordpress.com/724/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/txcowboycoder.wordpress.com/724/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/txcowboycoder.wordpress.com/724/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/txcowboycoder.wordpress.com/724/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/txcowboycoder.wordpress.com/724/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/txcowboycoder.wordpress.com/724/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/txcowboycoder.wordpress.com/724/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/txcowboycoder.wordpress.com/724/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/txcowboycoder.wordpress.com/724/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/txcowboycoder.wordpress.com/724/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/txcowboycoder.wordpress.com/724/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/txcowboycoder.wordpress.com/724/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/txcowboycoder.wordpress.com/724/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=txcowboycoder.wordpress.com&amp;blog=13018064&amp;post=724&amp;subd=txcowboycoder&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://txcowboycoder.wordpress.com/2011/06/30/reverse-postgresql-into-model-with-undefined-data-types/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b304fa18931de25695a3c780f1e3155d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">txcowboycoder</media:title>
		</media:content>
	</item>
		<item>
		<title>Pass object association by reference via &amp; to save resources</title>
		<link>http://txcowboycoder.wordpress.com/2011/06/15/pass-object-association-by-reference-via-to-save-resources/</link>
		<comments>http://txcowboycoder.wordpress.com/2011/06/15/pass-object-association-by-reference-via-to-save-resources/#comments</comments>
		<pubDate>Wed, 15 Jun 2011 19:43:05 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[association]]></category>
		<category><![CDATA[clean code]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[resource management]]></category>
		<category><![CDATA[traverse array]]></category>

		<guid isPermaLink="false">http://txcowboycoder.wordpress.com/?p=692</guid>
		<description><![CDATA[Not really a big deal, but could save resources on larger arrays. Is also a clean code practice to avoid awkward traversing array and assigning to &#8216;itself&#8217; from what is essentially a sub routine. Does it really matter? Likely not. Using the below script on my 2.66 Core i7 with 8gigs of ram passing by [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=txcowboycoder.wordpress.com&amp;blog=13018064&amp;post=692&amp;subd=txcowboycoder&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Not really a big deal, but could save resources on larger arrays. Is also a clean code practice to avoid awkward traversing array and assigning to &#8216;itself&#8217; from what is essentially a sub routine.</p>
<p>Does it really matter? Likely not. Using the below script on my 2.66 Core i7 with 8gigs of ram passing by reference is roughly 3-4 times faster. At 100000 array key value pairs the difference is still in microseconds (less than half a millisecond).</p>
<p>More information here: <a href="http://php.net/manual/en/language.references.pass.php">http://php.net/manual/en/language.references.pass.php</a></p>
<p><pre class="brush: php;">
&lt;?php

// want to loop over an array
$an_array = array();

// lets populate it with random values
for ($i=0; $i &lt; 100000; $i++) { 
	$an_array[$i] = md5(uniqid(uniqid(&quot;&quot;,true),true));
}

// start
var_dump(microtime(true));

// now lets maniuplate the 'old' way
foreach ($an_array as $key =&gt; $value) {
	// this modifies the value at the index using the array and key
	$an_array[$key] = &quot;ref original array and key&quot;;
}

var_dump(microtime(true));

// lets do it the 'new' way, notice we are passing &amp;
foreach ($an_array as $key =&gt; &amp;$value) {
	// $value is a reference to the $an_array[$key]
	$value = &quot;changes source array&quot;;
}
// finish
var_dump(microtime(true));

?&gt;
</pre></p>
<h3>Sample Executions</h3>
<table border="1">
<tr>
<th>Object</th>
<th>Pass reference</th>
</tr>
<tr>
<td>445</td>
<td>123</td>
</tr>
<tr>
<td>455</td>
<td>122</td>
</tr>
<tr>
<td>443</td>
<td>122</td>
</tr>
<tr>
<td>452</td>
<td>119</td>
</tr>
<tr>
<td>446</td>
<td>129</td>
</tr>
</table>
<p><strong>*Note* times in microseconds</strong></p>
<br /> Tagged: <a href='http://txcowboycoder.wordpress.com/tag/association/'>association</a>, <a href='http://txcowboycoder.wordpress.com/tag/clean-code/'>clean code</a>, <a href='http://txcowboycoder.wordpress.com/tag/php-2/'>php</a>, <a href='http://txcowboycoder.wordpress.com/tag/resource-management/'>resource management</a>, <a href='http://txcowboycoder.wordpress.com/tag/traverse-array/'>traverse array</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/txcowboycoder.wordpress.com/692/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/txcowboycoder.wordpress.com/692/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/txcowboycoder.wordpress.com/692/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/txcowboycoder.wordpress.com/692/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/txcowboycoder.wordpress.com/692/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/txcowboycoder.wordpress.com/692/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/txcowboycoder.wordpress.com/692/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/txcowboycoder.wordpress.com/692/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/txcowboycoder.wordpress.com/692/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/txcowboycoder.wordpress.com/692/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/txcowboycoder.wordpress.com/692/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/txcowboycoder.wordpress.com/692/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/txcowboycoder.wordpress.com/692/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/txcowboycoder.wordpress.com/692/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=txcowboycoder.wordpress.com&amp;blog=13018064&amp;post=692&amp;subd=txcowboycoder&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://txcowboycoder.wordpress.com/2011/06/15/pass-object-association-by-reference-via-to-save-resources/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b304fa18931de25695a3c780f1e3155d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">txcowboycoder</media:title>
		</media:content>
	</item>
		<item>
		<title>Creating fields via SQL vs creating fields via structure editor</title>
		<link>http://txcowboycoder.wordpress.com/2011/06/08/creating-fields-via-sql-vs-creating-fields-via-structure-editor/</link>
		<comments>http://txcowboycoder.wordpress.com/2011/06/08/creating-fields-via-sql-vs-creating-fields-via-structure-editor/#comments</comments>
		<pubDate>Wed, 08 Jun 2011 17:58:11 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[4D]]></category>
		<category><![CDATA[null]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[v11]]></category>
		<category><![CDATA[v12]]></category>

		<guid isPermaLink="false">http://txcowboycoder.wordpress.com/?p=691</guid>
		<description><![CDATA[Beware when creating fields via SQL engine with 4Dv12/v11. Creating fields via SQL does not allow setting field property &#8220;Map NULL values to blank values&#8221;. The suggested work around is to define the field with NOT NULL constraint. The different outcomes of the two ways to create fields is terrible behavior because of lack of [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=txcowboycoder.wordpress.com&amp;blog=13018064&amp;post=691&amp;subd=txcowboycoder&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Beware when creating fields via SQL engine with 4Dv12/v11. <a href="http://kb.4d.com/search/assetid=76119" target="_blank">Creating fields via SQL does not allow setting field property &#8220;Map NULL values to blank values&#8221;</a>. The suggested work around is to define the field with <code>NOT NULL</code> constraint.</p>
<p>The different outcomes of the two ways to create fields is terrible behavior because of <a href="http://txcowboycoder.wordpress.com/2011/06/07/allow-null-values-in-4db-engine/" title="Allow NULL values in 4DB engine" target="_blank">lack of support for null values in the 4DDB engine</a>. 4D seems to assume developers are either using 4D with all native code, or all SQL code, not hybrid solutions.</p>
<p>Ultimately the concern to the developer is having assumptions regarding the data respected. Coming from previous version of 4D all fields have the property checked for mapping null values to blank values. Legacy applications can have code reliant on the assumption of no null values.</p>
<p>From 4D Docs on <a href="http://doc.4d.com/4Dv11.4 /help/Title/en/page370.html" target="_blank">integrating 4D and the 4D SQL engine</a>:</p>
<blockquote><p>The NULL values are implemented in the 4D SQL language as well as in the 4D database engine. However, they are not supported in the 4D language</p></blockquote>
<p>More red flags from the knowledge base:</p>
<p><a href="http://kb.4d.com/search/assetid=75835" target="_blank">Sorting fields w/NULLS changes the current selection</a></p>
<blockquote><p>In version 11.4, if you have NULL values in any field and then do an ORDER BY on that field, any records that contain NULL values will be removed from the Current Selection.</p></blockquote>
<p>Also <a href="http://kb.4d.com/search/assetid=76069" target="_blank">displaying</a> and saving null values to the database is even more difficult.</p>
<h3>Create field via structure</h3>
<p>By default the &#8220;Map NULL values to blank values&#8221; field property is enabled.<br />
<a href="http://txcowboycoder.files.wordpress.com/2011/06/create_field_structure.png"><img src="http://txcowboycoder.files.wordpress.com/2011/06/create_field_structure.png?w=174&#038;h=300" alt="" title="create_field_structure" width="174" height="300" class="aligncenter size-medium wp-image-699" /></a></p>
<h3>Create field via SQL</h3>
<p>This field was created with <code>NOT NULL</code> constraint.<br />
<a href="http://txcowboycoder.files.wordpress.com/2011/06/create_field_sql.png"><img src="http://txcowboycoder.files.wordpress.com/2011/06/create_field_sql.png?w=174&#038;h=300" alt="" title="create_field_sql" width="174" height="300" class="aligncenter size-medium wp-image-700" /></a></p>
<br /> Tagged: <a href='http://txcowboycoder.wordpress.com/tag/4d/'>4D</a>, <a href='http://txcowboycoder.wordpress.com/tag/null/'>null</a>, <a href='http://txcowboycoder.wordpress.com/tag/sql/'>sql</a>, <a href='http://txcowboycoder.wordpress.com/tag/v11/'>v11</a>, <a href='http://txcowboycoder.wordpress.com/tag/v12/'>v12</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/txcowboycoder.wordpress.com/691/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/txcowboycoder.wordpress.com/691/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/txcowboycoder.wordpress.com/691/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/txcowboycoder.wordpress.com/691/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/txcowboycoder.wordpress.com/691/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/txcowboycoder.wordpress.com/691/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/txcowboycoder.wordpress.com/691/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/txcowboycoder.wordpress.com/691/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/txcowboycoder.wordpress.com/691/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/txcowboycoder.wordpress.com/691/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/txcowboycoder.wordpress.com/691/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/txcowboycoder.wordpress.com/691/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/txcowboycoder.wordpress.com/691/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/txcowboycoder.wordpress.com/691/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=txcowboycoder.wordpress.com&amp;blog=13018064&amp;post=691&amp;subd=txcowboycoder&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://txcowboycoder.wordpress.com/2011/06/08/creating-fields-via-sql-vs-creating-fields-via-structure-editor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b304fa18931de25695a3c780f1e3155d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">txcowboycoder</media:title>
		</media:content>

		<media:content url="http://txcowboycoder.files.wordpress.com/2011/06/create_field_structure.png?w=174" medium="image">
			<media:title type="html">create_field_structure</media:title>
		</media:content>

		<media:content url="http://txcowboycoder.files.wordpress.com/2011/06/create_field_sql.png?w=174" medium="image">
			<media:title type="html">create_field_sql</media:title>
		</media:content>
	</item>
		<item>
		<title>Allow NULL values in 4DB engine</title>
		<link>http://txcowboycoder.wordpress.com/2011/06/07/allow-null-values-in-4db-engine/</link>
		<comments>http://txcowboycoder.wordpress.com/2011/06/07/allow-null-values-in-4db-engine/#comments</comments>
		<pubDate>Tue, 07 Jun 2011 18:57:06 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[4D]]></category>
		<category><![CDATA[clean code]]></category>
		<category><![CDATA[null]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[v11]]></category>
		<category><![CDATA[v12]]></category>

		<guid isPermaLink="false">http://txcowboycoder.wordpress.com/?p=645</guid>
		<description><![CDATA[Developers need to be able to use nulls if using SQL engine and 4DB engine in 4D. As of this writing the concepts of NULL values are very loosely integrated with 4D. NULL Values in 4D The NULL values are implemented in the 4D SQL language as well as in the 4D database engine. However, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=txcowboycoder.wordpress.com&amp;blog=13018064&amp;post=645&amp;subd=txcowboycoder&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Developers need to be able to use nulls if using SQL engine and 4DB engine in 4D. As of this writing the concepts of <code>NULL</code> values are very <a href="http://doc.4d.com/4Dv11.4 /help/Title/en/page370.html" target="_blank">loosely integrated with 4D</a>.</p>
<blockquote><p>NULL Values in 4D  </p>
<p>The NULL values are implemented in the 4D SQL language as well as in the 4D database engine. However, they are not supported in the 4D language. It is nevertheless possible to read and write NULL values in a 4D field using the Is field value Null and SET FIELD VALUE NULL commands.
</p></blockquote>
<p>Never mind the very logic of a null value is to indicate not set. Mapping null values to &#8216;blank&#8217; values only mucks up the data. Does a widget inventory level of 0 indicate &#8216;not yet set&#8217; or &#8216;depleted to zero&#8217;? Yes business logic will clear these things up, but integration of null values with the 4D native engine would be better. </p>
<p><pre class="brush: plain;">
// http://doc.4d.com/4Dv11.6/help/command/en/page965.html
// This is a useless command, and is only used by the SQL kernal of 4D
SET FIELD VALUE NULL([Table_1]Field_1)

// having a null keyword would be useful
[Table_1]Field_1:=null
</pre></p>
<p>For example, you cannot search null values using the standard query window. Also, variables cannot accept null values. Null comparisons are limited to <a href="http://doc.4d.com/4Dv11.6/help/command/en/page964.html" target="_blank"><code>Is field value Null</code></a> which can only look at fields.</p>
<p>Seems as if 4D is not giving developers all the tools to make a hybrid deployable solution. Its been my experience to code solutions that either go 100% native 4D code or go 100% SQL engine, because integrating both together is a pain.</p>
<p>4D does annoying things like convert null values to blank values when trying to display them in an object, or puts into <a href="http://kb.4d.com/search/assetid=75825" target="_blank">object property definitions</a> display attributes to control how null values are rendered.</p>
<p>See my comments on <a href="http://txcowboycoder.wordpress.com/2010/11/11/new-4d-variable-data-type-float/" title="New 4D variable data type – float" target="_blank">float data types</a>.</p>
<br /> Tagged: <a href='http://txcowboycoder.wordpress.com/tag/4d/'>4D</a>, <a href='http://txcowboycoder.wordpress.com/tag/clean-code/'>clean code</a>, <a href='http://txcowboycoder.wordpress.com/tag/null/'>null</a>, <a href='http://txcowboycoder.wordpress.com/tag/sql/'>sql</a>, <a href='http://txcowboycoder.wordpress.com/tag/v11/'>v11</a>, <a href='http://txcowboycoder.wordpress.com/tag/v12/'>v12</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/txcowboycoder.wordpress.com/645/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/txcowboycoder.wordpress.com/645/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/txcowboycoder.wordpress.com/645/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/txcowboycoder.wordpress.com/645/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/txcowboycoder.wordpress.com/645/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/txcowboycoder.wordpress.com/645/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/txcowboycoder.wordpress.com/645/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/txcowboycoder.wordpress.com/645/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/txcowboycoder.wordpress.com/645/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/txcowboycoder.wordpress.com/645/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/txcowboycoder.wordpress.com/645/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/txcowboycoder.wordpress.com/645/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/txcowboycoder.wordpress.com/645/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/txcowboycoder.wordpress.com/645/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=txcowboycoder.wordpress.com&amp;blog=13018064&amp;post=645&amp;subd=txcowboycoder&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://txcowboycoder.wordpress.com/2011/06/07/allow-null-values-in-4db-engine/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b304fa18931de25695a3c780f1e3155d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">txcowboycoder</media:title>
		</media:content>
	</item>
		<item>
		<title>Automatic cron backup of PostgreSQL database</title>
		<link>http://txcowboycoder.wordpress.com/2011/06/03/automatic-cron-backup-of-postgresql-database/</link>
		<comments>http://txcowboycoder.wordpress.com/2011/06/03/automatic-cron-backup-of-postgresql-database/#comments</comments>
		<pubDate>Fri, 03 Jun 2011 13:31:31 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[Bash]]></category>
		<category><![CDATA[Postgres]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[cron]]></category>
		<category><![CDATA[pgsql]]></category>
		<category><![CDATA[pg_dump]]></category>
		<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[shell script]]></category>

		<guid isPermaLink="false">http://txcowboycoder.wordpress.com/?p=678</guid>
		<description><![CDATA[There are lots of great backup tools and utilities out there, but utilizing a simple script and cron task to target specific PostgreSQL database is often the fastest way to a locally based backup procedure. The below shell script is run as the postgres user on a Linux version 2.6.9-42.0.3.ELsmp (Red Hat 3.4.6-3) with PostgreSQL [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=txcowboycoder.wordpress.com&amp;blog=13018064&amp;post=678&amp;subd=txcowboycoder&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>There are lots of great backup tools and utilities out there, but utilizing a simple script and cron task to target specific PostgreSQL database is often the fastest way to a locally based backup procedure.</p>
<p>The below shell script is run as the <code>postgres</code> user on a <code>Linux version 2.6.9-42.0.3.ELsmp (Red Hat 3.4.6-3)</code> with <code>PostgreSQL 8.2.0</code> that has support for command-line execution. Not that there is anything fancy in the code that would require such specific versions.</p>
<p>Unique to the code is the ability to pass in a database name, or none at all to backup the entire cluster. This code only connects and writes files locally. Assumes appropriate permissions given to executing user. Maybe this works just fine for you, otherwise feel free to make your own modifications.</p>
<p>Personally I gzip the output, but improvements could be made to prevent hard disk saturation on larger databases and archiving utilities.</p>
<h2>crontab</h2>
<p><pre class="brush: bash;">
# CRON table for postgres user.

# run backup every night at 22:00 hours (10PM)
0 22 * * * /var/lib/pgsql/backups/backup.sh database_name

# run backup every week at midnight hour on sunday
0 0 * * 0 /var/lib/pgsql/backups/backup.sh
</pre></p>
<h2>backup.sh</h2>
<p><pre class="brush: bash; wrap-lines: false;">
#!/bin/bash
# This script will backup the postgresql database
# and store it in a specified directory

# PARAMETERS
# $1 database name (if none specified run pg_dumpall)

# CONSTANTS
# postgres home folder backups directory
# !! DO NOT specify trailing '/' as it is included below for readability !!
BACKUP_DIRECTORY=&quot;/var/lib/pgsql/backups&quot;

# Date stamp (formated YYYYMMDD)
# just used in file name
CURRENT_DATE=$(date &quot;+%Y%m%d&quot;)

# !!! Important pg_dump command does not export users/groups tables
# still need to maintain a pg_dumpall for full disaster recovery !!!

# this checks to see if the first command line argument is null
if [ -z &quot;$1&quot; ]
then
# No database specified, do a full backup using pg_dumpall
pg_dumpall | gzip - &gt; $BACKUP_DIRECTORY/pg_dumpall_$CURRENT_DATE.sql.gz

else
# Database named (command line argument) use pg_dump for targed backup
pg_dump $1 | gzip - &gt; $BACKUP_DIRECTORY/$1_$CURRENT_DATE.sql.gz

fi
</pre></p>
<br /> Tagged: <a href='http://txcowboycoder.wordpress.com/tag/backup/'>backup</a>, <a href='http://txcowboycoder.wordpress.com/tag/cron/'>cron</a>, <a href='http://txcowboycoder.wordpress.com/tag/pgsql/'>pgsql</a>, <a href='http://txcowboycoder.wordpress.com/tag/pg_dump/'>pg_dump</a>, <a href='http://txcowboycoder.wordpress.com/tag/postgresql/'>PostgreSQL</a>, <a href='http://txcowboycoder.wordpress.com/tag/shell-script/'>shell script</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/txcowboycoder.wordpress.com/678/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/txcowboycoder.wordpress.com/678/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/txcowboycoder.wordpress.com/678/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/txcowboycoder.wordpress.com/678/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/txcowboycoder.wordpress.com/678/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/txcowboycoder.wordpress.com/678/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/txcowboycoder.wordpress.com/678/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/txcowboycoder.wordpress.com/678/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/txcowboycoder.wordpress.com/678/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/txcowboycoder.wordpress.com/678/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/txcowboycoder.wordpress.com/678/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/txcowboycoder.wordpress.com/678/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/txcowboycoder.wordpress.com/678/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/txcowboycoder.wordpress.com/678/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=txcowboycoder.wordpress.com&amp;blog=13018064&amp;post=678&amp;subd=txcowboycoder&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://txcowboycoder.wordpress.com/2011/06/03/automatic-cron-backup-of-postgresql-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b304fa18931de25695a3c780f1e3155d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">txcowboycoder</media:title>
		</media:content>
	</item>
		<item>
		<title>Use 4D header macro to identify code blocks</title>
		<link>http://txcowboycoder.wordpress.com/2011/06/02/use-4d-header-macro-to-identify-code-blocks/</link>
		<comments>http://txcowboycoder.wordpress.com/2011/06/02/use-4d-header-macro-to-identify-code-blocks/#comments</comments>
		<pubDate>Thu, 02 Jun 2011 16:00:32 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[4D]]></category>
		<category><![CDATA[auto-comment]]></category>
		<category><![CDATA[automatically repaired method]]></category>
		<category><![CDATA[clean code]]></category>
		<category><![CDATA[corrupt]]></category>
		<category><![CDATA[macro]]></category>
		<category><![CDATA[method header]]></category>
		<category><![CDATA[orphan method]]></category>
		<category><![CDATA[structure]]></category>

		<guid isPermaLink="false">http://txcowboycoder.wordpress.com/?p=642</guid>
		<description><![CDATA[Standard installation of 4Dv11 comes with a set of macros to use in design mode. The one I find most useful is the Header macro. This macro takes my name, date time stamp, the method name and places it directly into whatever type of method I&#8217;m working in. Most analogous to function/class/package documentation blocks in [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=txcowboycoder.wordpress.com&amp;blog=13018064&amp;post=642&amp;subd=txcowboycoder&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Standard installation of 4Dv11 comes with a <a href="http://kb.4d.com/search/assetid=76246" target="_blank">set of macros</a> to use in design mode.</p>
<p>The one I find most useful is the <code>Header</code> macro. This macro takes my name, date time stamp, the method name and places it directly into whatever type of method I&#8217;m working in.</p>
<p>Most analogous to function/class/package documentation blocks in other languages, they are also an excellent starting point for other developers looking at your code. In 4D specifically, header blocks also serve as insurance against a corrupted structure file. </p>
<p>After repairing a corrupted structure file, <a href="http://kb.4d.com/search/assetid=76268" target="_blank"><code>orphan method(s)</code></a> can appear without context. The orphan methods are not linked to the original code, and the type of method (object/form/project) and original method name are lost.</p>
<p>Worse, the repair process could have replaced the original code in it&#8217;s entirety with a comment &#8220;<code>automatically repaired method</code>&#8220;.</p>
<p>The <code>method_name</code> tag of the macro generates the text as shown in the title portion of the method editor. So a project method will render <code>Method: Project_Method</code> while form and object methods will render <code>Method: Form Method [Table]Form</code> and <code>Method: Object Method [Table].Form.Object</code> respectively.</p>
<p>A header documents all the missing information to find the original code location and the confidence to delete or restore the orphan code. Having the headers in place has definitely saved me lots of time analyzing and recovering from a structure corruption.</p>
<h3>Example Macro</h3>
<p><pre class="brush: plain;">
&lt;macro name=&quot;Header&quot;&gt;
&lt;text&gt;` ----------------------------------------------------
` User name (OS): &lt;user_os/&gt;
` Date and time: &lt;date format=&quot;0&quot;/&gt;, &lt;time format=&quot;0&quot;/&gt;
` ----------------------------------------------------
` Method: &lt;method_name/&gt;
` Description
` &lt;caret/&gt;
`
` Parameters
` ----------------------------------------------------
&lt;/text&gt;
</pre><br />
<strong>Note</strong> The above macro is formatted for v11. 4D v12 has <code>//</code> for commenting out lines</p>
<p>A tech tip on creating header content automatically.<br />
<a href="http://kb.4d.com/search/assetid=49171">4D Tech Tip &#8211; Header Macro</a></p>
<br /> Tagged: <a href='http://txcowboycoder.wordpress.com/tag/4d/'>4D</a>, <a href='http://txcowboycoder.wordpress.com/tag/auto-comment/'>auto-comment</a>, <a href='http://txcowboycoder.wordpress.com/tag/automatically-repaired-method/'>automatically repaired method</a>, <a href='http://txcowboycoder.wordpress.com/tag/clean-code/'>clean code</a>, <a href='http://txcowboycoder.wordpress.com/tag/corrupt/'>corrupt</a>, <a href='http://txcowboycoder.wordpress.com/tag/macro/'>macro</a>, <a href='http://txcowboycoder.wordpress.com/tag/method-header/'>method header</a>, <a href='http://txcowboycoder.wordpress.com/tag/orphan-method/'>orphan method</a>, <a href='http://txcowboycoder.wordpress.com/tag/structure/'>structure</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/txcowboycoder.wordpress.com/642/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/txcowboycoder.wordpress.com/642/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/txcowboycoder.wordpress.com/642/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/txcowboycoder.wordpress.com/642/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/txcowboycoder.wordpress.com/642/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/txcowboycoder.wordpress.com/642/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/txcowboycoder.wordpress.com/642/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/txcowboycoder.wordpress.com/642/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/txcowboycoder.wordpress.com/642/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/txcowboycoder.wordpress.com/642/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/txcowboycoder.wordpress.com/642/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/txcowboycoder.wordpress.com/642/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/txcowboycoder.wordpress.com/642/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/txcowboycoder.wordpress.com/642/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=txcowboycoder.wordpress.com&amp;blog=13018064&amp;post=642&amp;subd=txcowboycoder&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://txcowboycoder.wordpress.com/2011/06/02/use-4d-header-macro-to-identify-code-blocks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/b304fa18931de25695a3c780f1e3155d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">txcowboycoder</media:title>
		</media:content>
	</item>
	</channel>
</rss>
