<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <id>tag:www.refactormycode.com,2007:users71</id>
  <link type="application/atom+xml" href="http://www.refactormycode.com/users/71" rel="self"/>
  <title>travis</title>
  <updated>Tue Oct 09 14:57:36 -0700 2007</updated>
  <entry>
    <id>tag:www.refactormycode.com,2007:Refactor350</id>
    <published>2007-10-09T14:57:36-07:00</published>
    <title>[PHP] On Copyright Year</title>
    <content type="html">&lt;p&gt;d'oh, i forgot a ';' :-(&lt;/p&gt;

&lt;pre&gt;&lt;/pre&gt;</content>
    <author>
      <name>travis</name>
      <email>travis.hardiman@gmail.com</email>
    </author>
    <link type="text/html" href="http://www.refactormycode.com/codes/68-copyright-year/refactors/350" rel="alternate"/>
  </entry>
  <entry>
    <id>tag:www.refactormycode.com,2007:Refactor349</id>
    <published>2007-10-09T14:56:50-07:00</published>
    <title>[PHP] On Copyright Year</title>
    <content type="html">&lt;p&gt;Why even bother with concatenation server side?&lt;/p&gt;

&lt;pre&gt;Copyright &amp;amp;copy; 2007&amp;lt;?php
echo (intval(date('Y')) != 2007) ? date(' - Y') : '')
?&amp;gt; - All Rights Reserved - Design by scott2010_h&lt;/pre&gt;</content>
    <author>
      <name>travis</name>
      <email>travis.hardiman@gmail.com</email>
    </author>
    <link type="text/html" href="http://www.refactormycode.com/codes/68-copyright-year/refactors/349" rel="alternate"/>
  </entry>
  <entry>
    <id>tag:www.refactormycode.com,2007:Refactor348</id>
    <published>2007-10-09T14:51:59-07:00</published>
    <title>[JavaScript] On ucfirst</title>
    <content type="html">&lt;p&gt;There is a way to do this with CSS, in case you don't specifically need to do it with JS: &lt;a href="http://www.w3.org/TR/REC-CSS2/text.html#caps-prop" target="_blank"&gt;http://www.w3.org/TR/REC-CSS2/text.html#caps-prop&lt;/a&gt;&lt;/p&gt;

&lt;pre&gt;## CSS [css]

#someSelector
{
	text-transform: capitalize;
}&lt;/pre&gt;</content>
    <author>
      <name>travis</name>
      <email>travis.hardiman@gmail.com</email>
    </author>
    <link type="text/html" href="http://www.refactormycode.com/codes/69-ucfirst/refactors/348" rel="alternate"/>
  </entry>
  <entry>
    <id>tag:www.refactormycode.com,2007:Refactor270</id>
    <published>2007-10-04T07:09:15-07:00</published>
    <title>[JavaScript] On Simple Form Validation</title>
    <content type="html">&lt;p&gt;oops, the button should be type=&amp;quot;submit&amp;quot;&lt;/p&gt;

&lt;pre&gt;&lt;/pre&gt;</content>
    <author>
      <name>travis</name>
      <email>travis.hardiman@gmail.com</email>
    </author>
    <link type="text/html" href="http://www.refactormycode.com/codes/48-simple-form-validation/refactors/270" rel="alternate"/>
  </entry>
  <entry>
    <id>tag:www.refactormycode.com,2007:Refactor269</id>
    <published>2007-10-04T07:06:41-07:00</published>
    <title>[JavaScript] On Simple Form Validation</title>
    <content type="html">&lt;p&gt;You could really reduce your code with jQuery. (&lt;a href="http://jquery.com/" target="_blank"&gt;http://jquery.com/&lt;/a&gt;)&lt;/p&gt;

&lt;pre&gt;## Javascript [javascript]
$(function() {
	$(&amp;quot;#formID&amp;quot;).bind(&amp;quot;submit&amp;quot;, function() {
		var err = [];
		$(&amp;quot;label.required&amp;quot;).each(function(i) {
			err[err.length] = this.htmlFor;
		});
		if (err.length &amp;gt; 0) {
			alert(&amp;quot;Please fill in the following fields:\n-&amp;quot; + err.join(&amp;quot;\n-&amp;quot;));
		}
		return (err.length &amp;lt;= 0);
	});
});

## XHTML [xhtml_1.0]

&amp;lt;!DOCTYPE html PUBLIC &amp;quot;-//W3C//DTD XHTML 1.0 Strict//EN&amp;quot;
	&amp;quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&amp;quot;&amp;gt;

&amp;lt;html xmlns=&amp;quot;http://www.w3.org/1999/xhtml&amp;quot; xml:lang=&amp;quot;en&amp;quot; lang=&amp;quot;en&amp;quot;&amp;gt;
&amp;lt;head&amp;gt;
	&amp;lt;meta http-equiv=&amp;quot;Content-Type&amp;quot; content=&amp;quot;text/html; charset=utf-8&amp;quot;/&amp;gt;
	&amp;lt;title&amp;gt;Sample Form&amp;lt;/title&amp;gt;
	&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;jquery.js&amp;quot; /&amp;gt;
&amp;lt;/head&amp;gt;

&amp;lt;body&amp;gt;
	&amp;lt;form method=&amp;quot;post&amp;quot; id=&amp;quot;formID&amp;quot; action=&amp;quot;#&amp;quot;&amp;gt;
		&amp;lt;fieldset&amp;gt;
			&amp;lt;legend&amp;gt;Sample Form&amp;lt;/legend&amp;gt;
			&amp;lt;label for=&amp;quot;Username&amp;quot; class=&amp;quot;required&amp;quot;&amp;gt;Username:&amp;lt;/label&amp;gt;
			&amp;lt;input type=&amp;quot;text&amp;quot; id=&amp;quot;Username&amp;quot; name=&amp;quot;Username&amp;quot; /&amp;gt;

			&amp;lt;label for=&amp;quot;Comments&amp;quot;&amp;gt;Comments&amp;lt;/label&amp;gt;
			&amp;lt;textarea name=&amp;quot;Comments&amp;quot; id=&amp;quot;Comments&amp;quot; rows=&amp;quot;10&amp;quot; cols=&amp;quot;40&amp;quot;&amp;gt;&amp;lt;/textarea&amp;gt;

			&amp;lt;input type=&amp;quot;button&amp;quot; value=&amp;quot;Submit&amp;quot; /&amp;gt;
			&amp;lt;input type=&amp;quot;reset&amp;quot; value=&amp;quot;Reset&amp;quot; /&amp;gt;
		&amp;lt;/fieldset&amp;gt;
	&amp;lt;/form&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/pre&gt;</content>
    <author>
      <name>travis</name>
      <email>travis.hardiman@gmail.com</email>
    </author>
    <link type="text/html" href="http://www.refactormycode.com/codes/48-simple-form-validation/refactors/269" rel="alternate"/>
  </entry>
  <entry>
    <id>tag:www.refactormycode.com,2007:Refactor164</id>
    <published>2007-10-01T11:55:44-07:00</published>
    <title>[JavaScript] On Go Back To Yesterday</title>
    <content type="html">&lt;p&gt;I would even extend it a bit further, although it may be overkill for your application.&lt;/p&gt;

&lt;pre&gt;Date.prototype.addDays = function(daysToAdd){
  return this.setDate(this.getDate() + daysToAdd);
}
Date.prototype.getYesterday = function(){
  return this.addDays(-1);
}
var d = new Date();
document.write(d.getYesterday())&lt;/pre&gt;</content>
    <author>
      <name>travis</name>
      <email>travis.hardiman@gmail.com</email>
    </author>
    <link type="text/html" href="http://www.refactormycode.com/codes/38-go-back-to-yesterday/refactors/164" rel="alternate"/>
  </entry>
  <entry>
    <id>tag:www.refactormycode.com,2007:Code36</id>
    <published>2007-10-01T08:16:00-07:00</published>
    <updated>2007-11-29T16:30:25-08:00</updated>
    <title>[VB.NET] Load XmlNodeList into an XmlDocument</title>
    <content type="html">&lt;p&gt;Basically I'm just try to load an XmlNodeList into an XmlDocument and I was wondering if there's a more efficient method than looping.&lt;/p&gt;

&lt;pre&gt;## VB.Net 2.0 [asp_vb.net]

  Private Function GetPreviousMonthsXml(ByVal months As Integer, ByVal startDate As Date, ByVal xDoc As XmlDocument, ByVal path As String, ByVal nodeName As String) As XmlDocument
    ' build xpath string with list of months to return
    Dim xp As New StringBuilder(&amp;quot;//&amp;quot;)
    xp.Append(nodeName)
    xp.Append(&amp;quot;[&amp;quot;)
    For i As Integer = 0 To (months - 1)
      ' get year and month portion of date for datestring
      xp.Append(&amp;quot;starts-with(@Id, '&amp;quot;)
      xp.Append(startDate.AddMonths(-i).ToString(&amp;quot;yyyy-MM&amp;quot;))
      If i &amp;lt; (months - 1) Then
        xp.Append(&amp;quot;') or &amp;quot;)
      Else
        xp.Append(&amp;quot;')]&amp;quot;)
      End If
    Next

' *** This is the block that needs to be refactored ***
    ' import nodelist into an xmldocument
    Dim xnl As XmlNodeList = xDoc.SelectNodes(xp.ToString())
    Dim returnXDoc As New XmlDocument(xDoc.NameTable)
    returnXDoc = xDoc.Clone()
    Dim nodeParents As XmlNodeList = returnXDoc.SelectNodes(path)
    For Each nodeParent As XmlNode In nodeParents
      For Each nodeToDelete As XmlNode In nodeParent.SelectNodes(nodeName)
        nodeParent.RemoveChild(nodeToDelete)
      Next
    Next

    For Each node As XmlNode In xnl
      Dim newNode As XmlNode = returnXDoc.ImportNode(node, True)
      returnXDoc.DocumentElement.SelectSingleNode(&amp;quot;//&amp;quot; &amp;amp; node.ParentNode.Name &amp;amp; &amp;quot;[@Id='&amp;quot; &amp;amp; newNode.Attributes(&amp;quot;Id&amp;quot;).Value.Split(&amp;quot;-&amp;quot;)(0) &amp;amp; &amp;quot;']&amp;quot;).AppendChild(newNode)
    Next

' *** end ***
    Return returnXDoc
  End Function
&lt;/pre&gt;</content>
    <author>
      <name>travis</name>
      <email>travis.hardiman@gmail.com</email>
    </author>
    <link type="text/html" href="http://www.refactormycode.com/codes/36-load-xmlnodelist-into-an-xmldocument" rel="alternate"/>
  </entry>
</feed>

