<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.0.2" -->
<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/"
	>

<channel>
	<title>novicecoder.com</title>
	<link>http://novicecoder.com</link>
	<description>Coding tips I wish I had known earlier...</description>
	<pubDate>Sun, 20 Aug 2006 06:24:36 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.2</generator>
	<language>en</language>
			<item>
		<title>Find and replace in SQL tables</title>
		<link>http://novicecoder.com/site-info/find-and-replace-in-sql-tables</link>
		<comments>http://novicecoder.com/site-info/find-and-replace-in-sql-tables#comments</comments>
		<pubDate>Sun, 20 Aug 2006 06:17:05 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
		
	<category>Site Info</category>
		<guid isPermaLink="false">http://novicecoder.com/site-info/find-and-replace-in-sql-tables</guid>
		<description><![CDATA[Pretty obvious, but I had to look it up so I figured I should save it here.  Say I misspelled &#8220;people&#8221; as &#8220;peeple&#8221; and I wanted to fix them all in my database.  Just do:
UPDATE table SET field=REPLACE(field, &#8216;peeple&#8216;, &#8216;people&#8216; );
]]></description>
			<content:encoded><![CDATA[<p>Pretty obvious, but I had to look it up so I figured I should save it here.  Say I misspelled &#8220;people&#8221; as &#8220;peeple&#8221; and I wanted to fix them all in my database.  Just do:</p>
<pre class="codeblock">UPDATE <i>table</i> SET <i>field</i>=REPLACE(<i>field</i>, &#8216;<i>peeple</i>&#8216;, &#8216;<i>people</i>&#8216; );</pre>
]]></content:encoded>
			<wfw:commentRSS>http://novicecoder.com/site-info/find-and-replace-in-sql-tables/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Implode checkbox group arrays into query strings</title>
		<link>http://novicecoder.com/php/implode-checkbox-group-arrays-into-query-strings</link>
		<comments>http://novicecoder.com/php/implode-checkbox-group-arrays-into-query-strings#comments</comments>
		<pubDate>Thu, 20 Jul 2006 05:42:47 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
		
	<category>PHP</category>
	<category>Site Info</category>
	<category>Strings</category>
	<category>Arrays</category>
		<guid isPermaLink="false">http://novicecoder.com/php/implode-checkbox-group-arrays-into-query-strings</guid>
		<description><![CDATA[In going from an html form to php code and finally to a sql query there are a lot of steps that could get messy, but fortunately php has a simple way to do this all.  Let&#8217;s say I have some checkbox options on my html form for a user to select the sports [...]]]></description>
			<content:encoded><![CDATA[<p>In going from an html form to php code and finally to a sql query there are a lot of steps that could get messy, but fortunately php has a simple way to do this all.  Let&#8217;s say I have some checkbox options on my html form for a user to select the sports they like.</p>
<pre class="codeblock">
&lt;input type="checkbox" name="sports[]" value="baseball"&gt;
&lt;input type="checkbox" name="sports[]" value="basketball"&gt;
&lt;input type="checkbox" name="sports[]" value="football"&gt;
&lt;input type="checkbox" name="sports[]" value="hockey"&gt;
</pre>
<p>Note how the checkboxes are grouped by giving them the same name with the index ([]) suffix.  This makes it so that an array containing the checked values is returned.  The next step is to use the php function <i>implode</i>.  This function takes an array and creates a delimited list of the array items connected by whatever glue string you want.  The simple example is to generate a comma delimited list like &#8220;basketball, baseball, football, hockey&#8221;.</p>
<pre class="codeblock">
$csv = implode(",", $_POST['sports']);
</pre>
<p>In this example we want to build a query string.</p>
<pre class="codeblock">
$query = "SELECT * FROM sportstable WHERE
         sport='" . implode("' OR sport='",$_POST['sports']) . "'";
</pre>
<p>This would create the string, &#8220;SELECT * FROM sportstable WHERE sport=&#8217;basketball&#8217; OR sport=&#8217;baseball&#8217; OR sport=&#8217;football&#8217;&#8221;, with the items that were checked by the user.  Of course you&#8217;ll want to validate the input first (check that the array count is greater than zero, sql injection, etc.) but user input validation is a whole post of its own.
</p>
]]></content:encoded>
			<wfw:commentRSS>http://novicecoder.com/php/implode-checkbox-group-arrays-into-query-strings/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Visual Studio margin guide lines</title>
		<link>http://novicecoder.com/ides/visual-studio-margin-guide-lines</link>
		<comments>http://novicecoder.com/ides/visual-studio-margin-guide-lines#comments</comments>
		<pubDate>Wed, 28 Jun 2006 03:32:21 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
		
	<category>IDEs</category>
	<category>Visual Studio</category>
		<guid isPermaLink="false">http://novicecoder.com/ides/visual-studio-margin-guide-lines</guid>
		<description><![CDATA[Some of us like to keep our lines under 80 characters wide (and some are forced to by coding standards).  Either way, it&#8217;s a little bit easier to keep track of it with a guide line denoting the margins.  Just modify the registry and create a string value at &#8220;HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\7.1\Text Editor&#8221; (or change [...]]]></description>
			<content:encoded><![CDATA[<p>Some of us like to keep our lines under 80 characters wide (and some are forced to by coding standards).  Either way, it&#8217;s a little bit easier to keep track of it with a guide line denoting the margins.  Just modify the registry and create a string value at &#8220;HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\7.1\Text Editor&#8221; (or change the 7.1 to 8.0 if you&#8217;re using Visual Studio 2005).  Name the value &#8220;Guides&#8221; and set it to &#8220;RGB(204,204,204) 79&#8243; where the (204,204,204) is the color you want and the 79 is the zero based column you want the guide on.  You can also add multiple guides by adding a comma delimited list like, &#8220;RGB(204,204,204) 79,99&#8243; to get guides at the 80 and 100 character mark.</p>
<p>For ease, here are some .reg files that will produce a grey line at the 80 column mark:<br />
<a href="/files/VS2003-80columnguide.reg">Visual Studio 2003</a><br />
<a href="/files/VS2005-80columnguide.reg">Visual Studio 2005</a></p>
]]></content:encoded>
			<wfw:commentRSS>http://novicecoder.com/ides/visual-studio-margin-guide-lines/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Regular expressions</title>
		<link>http://novicecoder.com/general/regular-expressions</link>
		<comments>http://novicecoder.com/general/regular-expressions#comments</comments>
		<pubDate>Sun, 11 Jun 2006 22:49:04 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
		
	<category>General</category>
	<category>Algorithms</category>
		<guid isPermaLink="false">http://novicecoder.com/general/regular-expressions</guid>
		<description><![CDATA[Regular expressions (regex) are used in many situations.  Web server administration and search algorithms are just a couple of the tasks where I&#8217;ve found myself looking up references on them.  Rather than always searching for the latest search engine optimized page on the internet, I figure I should just keep it here&#8230;


Syntax
Definition
Usage


.
Any character
/l.mb/ [...]]]></description>
			<content:encoded><![CDATA[<p>Regular expressions (regex) are used in many situations.  Web server administration and search algorithms are just a couple of the tasks where I&#8217;ve found myself looking up references on them.  Rather than always searching for the latest search engine optimized page on the internet, I figure I should just keep it here&#8230;</p>
<table border="1" style="font-size:small">
<tr style="font-weight:bold">
<td>Syntax</td>
<td>Definition</td>
<td>Usage</td>
</tr>
<tr>
<td>.</td>
<td>Any character</td>
<td>/l.mb/ - Will match &#8220;lamb&#8221; or &#8220;limb&#8221; (or any other l_mb)</td>
</tr>
<tr>
<td>?</td>
<td>Matches preceding character (or group) zero or one time</td>
<td>/Brand?/ - Matches both &#8220;Bran&#8221; and &#8220;Brand&#8221;</td>
</tr>
<tr>
<td>+</td>
<td>Matches preceding character (or group) one or more times</td>
<td>/Class A+/ - Matches &#8220;Class A&#8221;, &#8220;Class AA&#8221;, &#8220;Class AAA&#8221;, and so on</td>
</tr>
<tr>
<td>*</td>
<td>Matches preceding character (or group) any number of times</td>
<td>/abcd*/ - Matches &#8220;abc&#8221;, &#8220;abcd&#8221;, &#8220;abcdd&#8221;, &#8220;abcddd&#8221;, and so on</td>
</tr>
<tr>
<td>{<em>n</em>}</td>
<td>Matches preceding character (or group)  <em>n</em> number of times</td>
<td>/Mag{2}et{2}e/ - Matches &#8220;Maggette&#8221;</td>
</tr>
<tr>
<td>{<em>n</em>,<em>m</em>}</td>
<td>Matches preceding character (or group)  between <em>n</em> and <em>m</em> number of times inclusive</td>
<td>/Clip{1,3}ers/ - Matches &#8220;Clipers&#8221;, &#8220;Clippers&#8221;, and &#8220;Clipppers&#8221;</td>
</tr>
<tr>
<td>{<em>n</em>,<em></em>}</td>
<td>Matches preceding character (or group)  <em>n</em> or more times</td>
<td>/Clip{2,}ers/ - Matches &#8220;Clippers&#8221;, &#8220;Clipppers&#8221;, &#8220;Clippppers&#8221;, and so on</td>
</tr>
<tr>
<td>^</td>
<td>Beginning of the string/line</td>
<td>/^begin/ - Find strings/lines where the first characters are &#8220;begin&#8221;</td>
</tr>
<tr>
<td>$</td>
<td>End of the string/line</td>
<td>/end$/ - Find strings/lines where the last characters are &#8220;end&#8221;</td>
</tr>
<tr>
<td>[<em>abcd</em>]</td>
<td>Any of the characters</td>
<td>/sa[dmw]/ - Matches &#8220;sad&#8221;, &#8220;sam&#8221;, and &#8220;saw&#8221;</td>
</tr>
<tr>
<td>[^<em>abcd</em>]</td>
<td>Not one of the characters</td>
<td>/sa[^dm]/ - Matches anything that contains &#8220;sa&#8221; followed by another character except for &#8220;sad&#8221; and &#8220;sam&#8221;</td>
</tr>
<tr>
<td>[<em>a-d</em>]</td>
<td>Any character in the range</td>
<td>/[a-d]/ - Matches a, b, c, or d.  Can use numbers too like /[1-5]/ to match 1, 2, 3, 4, or 5</td>
</tr>
<tr>
<td>(<em>abcd</em>)</td>
<td>Grouping</td>
<td>/(Elton)+/ - Matches one or more occurances of &#8220;Elton&#8221;</td>
</tr>
<tr>
<td>(<em>a</em>|<em>b</em>)</td>
<td><em>a</em> or <em>b</em></td>
<td>/(Chris|Shaun)/ - Matches either &#8220;Chris&#8221; or &#8220;Shaun&#8221;</td>
</tr>
<tr>
<td>!(<em>a</em>)</td>
<td>Not in this group</td>
<td>/!(Donald)/ - Doesn&#8217;t contain &#8220;Donald&#8221;</td>
</tr>
<tr>
<td>*?, +?, ??, {<em>n</em>}?</td>
<td>Least number of possible matches</td>
<td>/bo+?/ - Given the string, &#8220;boo&#8221;, would return &#8220;bo&#8221;<br /> /bo+/ - Would return &#8220;boo&#8221; in this case</td>
</tr>
</table>
]]></content:encoded>
			<wfw:commentRSS>http://novicecoder.com/general/regular-expressions/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Better array pushing</title>
		<link>http://novicecoder.com/php/better-array-pushing</link>
		<comments>http://novicecoder.com/php/better-array-pushing#comments</comments>
		<pubDate>Wed, 07 Jun 2006 02:32:46 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
		
	<category>PHP</category>
	<category>Arrays</category>
		<guid isPermaLink="false">http://novicecoder.com/php/better-array-pushing</guid>
		<description><![CDATA[In any language, you&#8217;ll often find yourself working with arrays.  PHP offers a couple methods for adding items to them.  Say you have an array:
$arrayvals = array("elton", "sam");
and you want to add the value, &#8220;shaun&#8221; to it.  You can either do:
$arrayvals[] = "shaun";
or you can do:
array_push($arrayvals, "shaun");
So which is better, or does [...]]]></description>
			<content:encoded><![CDATA[<p>In any language, you&#8217;ll often find yourself working with arrays.  PHP offers a couple methods for adding items to them.  Say you have an array:</p>
<pre class="codeblock">$arrayvals = array("elton", "sam");</pre>
<p>and you want to add the value, &#8220;shaun&#8221; to it.  You can either do:</p>
<pre class="codeblock">$arrayvals[] = "shaun";</pre>
<p>or you can do:</p>
<pre class="codeblock">array_push($arrayvals, "shaun");</pre>
<p>So which is better, or does it even matter?  The answer is the first one, <em>$arrayvals[]=&#8221;shaun&#8221;;</em>, because <a href="http://php.net/array_push">according to the php manual</a>, there is no overhead of calling a function with this method.  A minor difference, but when writing web apps, every line you write is potentially called millions of times per second so you don&#8217;t want to be wasting cycles for no reason.  Is there a point to <em>array_push</em> then?  Remember that <em>array_push</em> allows adding multiple values at once so it&#8217;s easier to do:</p>
<pre class="codeblock">array_push($arrayvals, "shaun", "corey", "chris");</pre>
]]></content:encoded>
			<wfw:commentRSS>http://novicecoder.com/php/better-array-pushing/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>String testing made easy</title>
		<link>http://novicecoder.com/c/faster-string-testing</link>
		<comments>http://novicecoder.com/c/faster-string-testing#comments</comments>
		<pubDate>Tue, 06 Jun 2006 01:42:26 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
		
	<category>C#</category>
	<category>Strings</category>
		<guid isPermaLink="false">http://novicecoder.com/c/faster-string-testing</guid>
		<description><![CDATA[Do you have lots of places in your code where you do:
if (stringval == null &#124;&#124; stringval.Length == 0)
{
  handle string...
}
Well, .NET 2.0 adds a static method to the string class for IsNullOrEmpty.  So now you can just test against string.IsNullOrEmpty(stringval) and save yourself a few keystrokes.

]]></description>
			<content:encoded><![CDATA[<p>Do you have lots of places in your code where you do:</p>
<pre class="codeblock">if (stringval == null || stringval.Length == 0)
{
  handle string...
}</pre>
<p>Well, .NET 2.0 adds a static method to the string class for IsNullOrEmpty.  So now you can just test against string.IsNullOrEmpty(stringval) and save yourself a few keystrokes.
</p>
]]></content:encoded>
			<wfw:commentRSS>http://novicecoder.com/c/faster-string-testing/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Purpose</title>
		<link>http://novicecoder.com/site-info/purpose</link>
		<comments>http://novicecoder.com/site-info/purpose#comments</comments>
		<pubDate>Fri, 02 Jun 2006 19:00:00 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
		
	<category>Site Info</category>
		<guid isPermaLink="false"></guid>
		<description><![CDATA[This is my log for random coding things that make life easier.  Most things won&#8217;t be too technically advanced, but rather buried features that might not be obvious.  They&#8217;re typically things I&#8217;ve learned by writing some long method and having someone else come along and ask why I didn&#8217;t just do it this [...]]]></description>
			<content:encoded><![CDATA[<p>This is my log for random coding things that make life easier.  Most things won&#8217;t be too technically advanced, but rather buried features that might not be obvious.  They&#8217;re typically things I&#8217;ve learned by writing some long method and having someone else come along and ask why I didn&#8217;t just do it this other simpler way.
</p>
]]></content:encoded>
			<wfw:commentRSS>http://novicecoder.com/site-info/purpose/feed/</wfw:commentRSS>
		</item>
	</channel>
</rss>
