<rss version="2.0">
			<channel>
			<title>Burnette</title>
			<link>http://www.burnette.us/blog/index.cfm</link>
			<description></description>
			<language>en-us</language>
			<pubDate>Sun, 20 May 2012 16:33:06 -0400</pubDate>
			<lastBuildDate>Thu, 26 Oct 2006 21:46:00 -0400</lastBuildDate>
			<generator>BlogCFC</generator>
			<docs>http://blogs.law.harvard.edu/tech/rss</docs>
			<managingEditor>trevor@burnette.us</managingEditor>
			<webMaster>trevor@burnette.us</webMaster>
			
			
			
			
			
			<item>
				<title>San Jose Semaphore Observations</title>
				<link>http://www.burnette.us/blog/index.cfm/2006/10/26/San-Jose-Semaphore-Observations</link>
				<description>
				
				I just started to look at the &lt;a href=&quot;http://www.sanjosesemaphore.org&quot; target=&quot;_blank&quot;&gt;Semaphore Signals&lt;/a&gt; on the Adobe building last night and here are a few observations I have made.

It looks like a base 4 type system. &lt;br&gt;
- 0&lt;br&gt;
\ 1&lt;br&gt;
| 2&lt;br&gt;
/ 3&lt;br&gt;

Also it is broken into 2 parts the first 2 signals are the spoken alpha character and the second 2 signals are the spoken numeric.

Example&lt;br&gt;
---- A01&lt;br&gt;

When the first 2 make one tick it becomes&lt;br&gt;
-\-- B01&lt;br&gt;

If the second 2 make one tick it becomes&lt;br&gt;
---\ A02&lt;br&gt;

So based on this you can go from&lt;br&gt;
---- A01 to //// P16&lt;br&gt;

That is all I have for now.  I am not sure how it is encoded, some guesses would be that it is a combination of the 2 signals due to lack of repeating codes.

Here is a key of the 2 signals
&lt;code&gt;
Signal Alpha Numeric Base4 Decimal
  --     A     01     00      0 
  -\     B     02     01      1
  -|     C     03     02      2 
  -/     D     04     03      3
  \-     E     05     10      4
  \\     F     06     11      5
  \|     G     07     12      6
  \/     H     08     13      7
  |-     I     09     20      8
  |\     J     10     21      9
  ||     K     11     22     10
  |/     L     12     23     11
  /-     M     13     30     12
  /\     N     14     31     13
  /|     O     15     32     14
  //     P     16     33     15
&lt;/code&gt;

One last observation is that the 4 signals count up to exactly 255 which is an extended ascii table.  I am really trying hard not to go off on any strange directions with this.  The KISS rule (Keep it simple stupid) has always worked for me in the past.
				
				</description>
				
				<category>Misc</category>
				
				<pubDate>Thu, 26 Oct 2006 21:46:00 -0400</pubDate>
				<guid>http://www.burnette.us/blog/index.cfm/2006/10/26/San-Jose-Semaphore-Observations</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Update to Using AJAX to Load JS into Document Head</title>
				<link>http://www.burnette.us/blog/index.cfm/2006/10/16/Update-to-Using-AJAX-to-Load-JS-into-Document-Head</link>
				<description>
				
				I had a fix for a previous post in which the code did not work in firefox.  This was pointed out by Matt and he has submitted a fix.  I have not tested the fix but Matt did and says it works in firefox.

&lt;code&gt;
var req;
function doRemoteQuery(file) { 
 // branch for native XMLHttpRequest object 
 if (window.XMLHttpRequest) { 
  req = new XMLHttpRequest(); 
  req.onreadystatechange = evalResponse;
  req.open(&quot;GET&quot;, lookupURL + file, true); 
  req.setRequestHeader(&apos;Content-Type&apos;, &apos;application/x-www-form-urlencoded&apos;); 
  req.setRequestHeader(&apos;Content-Length&apos;, &apos;0&apos;);
  req.send(null);
 } 
 else if (window.ActiveXObject) { 
  isIE = true; 
  req = new ActiveXObject(&quot;Microsoft.XMLHTTP&quot;); 
  if (req) { 
   req.onreadystatechange = evalResponse;
   req.open(&quot;GET&quot;, lookupURL + file, true); 
   req.setRequestHeader(&apos;Content-Type&apos;, &apos;application/x-www-form-urlencoded&apos;); 
   req.setRequestHeader(&apos;Content-Length&apos;, &apos;0&apos;);
   req.send(null);
  } 
 } 
}
function evalResponse() {
 if (req.readyState == 4 &amp;&amp; req.status == 200) {           
  try {
   eval(req.responseText);
  }
  catch(e) {              
   //errorWindow=window.open(&quot;&quot;, &quot;&quot;, 
&quot;height=500, width=600, toolbar=no, 
                             scrollbars=yes, menubar=no, resizable=yes&quot;);
   //errorWindow.document.write(xmlHttp.responseText);
   alert(req.statusText);
  }
  //searching = false;         
 } 
}
doRemoteQuery(&apos;loadjs.cfm&apos;);

&lt;/code&gt;

The original post is at &lt;a href=&quot;http://www.burnette.us/blog/index.cfm/2006/2/9/Using-AJAX-to-Load-JS-into-Document-Head&quot; target=&quot;_blank&quot;&gt;Using AJAX to Load JS into Document Head&lt;/a&gt;

Thanks Matt and if anyone has any code suggestions please post a comment.  Especially for my &lt;a href=&quot;http://www.burnette.us/blog/index.cfm/2006/9/21/You-Say-Sudoku-I-Say-Sudoko&quot;  target=&quot;_blank&quot;&gt;Sudoku helper&lt;/a&gt;.  It currently has a bug in the cube section of the code and I have not gotten around to checking out the code.
				
				</description>
				
				<category>JavaScript</category>
				
				<pubDate>Mon, 16 Oct 2006 10:05:00 -0400</pubDate>
				<guid>http://www.burnette.us/blog/index.cfm/2006/10/16/Update-to-Using-AJAX-to-Load-JS-into-Document-Head</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Computerworld Survey</title>
				<link>http://www.burnette.us/blog/index.cfm/2006/10/11/Computerworld-Survey</link>
				<description>
				
				I just read a &lt;a href=&quot;http://www.computerworld.com/action/article.do?command=viewArticleBasic&amp;articleId=266156&quot; target=&quot;_blank&quot;&gt;Computerworld article on Cobol&lt;/a&gt; and they had a survey of 352 readers on what programming languages they use.  Well 15% of respondents said they use coldFusion at work, 2% more than PHP which was at 13%.  Of course according to the survey 7% still use FORTRAN so I&apos;m not sure if this is good or bad news for coldFusion programmers.
				
				</description>
				
				<category>ColdFusion</category>
				
				<pubDate>Wed, 11 Oct 2006 12:48:00 -0400</pubDate>
				<guid>http://www.burnette.us/blog/index.cfm/2006/10/11/Computerworld-Survey</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>You Say Sudoku I Say Sudoko</title>
				<link>http://www.burnette.us/blog/index.cfm/2006/9/21/You-Say-Sudoku-I-Say-Sudoko</link>
				<description>
				
				I am really not into sudoku but some folks at my work are and I thought it would be interesting to write an app that could help you solve the puzzle.  This application creates a session variable called soGrid.  It is a 3 diminsional array with the following structure [row][column][1 or 2].  In 1 we hold the possible  numbers that can go in the square.  2 is the number you have selected if that cell has been clicked on.  When a number is selected any numbers in the row, column, or 3x3 cube that matches that number are removed.  Here is a &lt;a href=&quot;http://www.burnette.us/scratch/sudoku&quot; target=&quot;_blank&quot;&gt;link to the app&lt;/a&gt; and the code for it is as follows:

main.cfm
&lt;code&gt;
&lt;cfset session.soGrid = arrayNew(3)&gt;
&lt;cfloop from=&quot;1&quot; to=&quot;9&quot; index=&quot;r&quot; step=&quot;1&quot;&gt;
  &lt;cfloop from=&quot;1&quot; to=&quot;9&quot; index=&quot;c&quot; step=&quot;1&quot;&gt;
    &lt;cfset session.soGrid[r][c][1] = &apos;1,2,3,4,5,6,7,8,9&apos;&gt;
    &lt;cfset session.soGrid[r][c][2] = 0&gt;
  &lt;/cfloop&gt;
&lt;/cfloop&gt;

&lt;cfoutput&gt;
  &lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; 
         style=&quot;border-style: solid; border-color:black; border-top-width: 1px; 
                border-right-width: 1px; border-bottom-width: 1px; 
                border-left-width: 1px;&quot;&gt;
    &lt;cfloop from=&quot;0&quot; to=&quot;6&quot; index=&quot;row1&quot; step=&quot;3&quot;&gt;      
      &lt;tr&gt;
	&lt;cfloop from=&quot;0&quot; to=&quot;6&quot; index=&quot;col1&quot; step=&quot;3&quot;&gt;
          &lt;td&gt;
            &lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; 
                   style=&quot;border-style: solid; border-color:black; 
                          border-top-width: 1px; border-right-width: 1px; 
                          border-bottom-width: 1px; border-left-width: 1px;&quot;&gt;
              &lt;cfloop from=&quot;1&quot; to=&quot;3&quot; index=&quot;row2&quot; step=&quot;1&quot;&gt;
                &lt;tr&gt;
                  &lt;cfloop from=&quot;1&quot; to=&quot;3&quot; index=&quot;col2&quot; step=&quot;1&quot;&gt;
                    &lt;td&gt;
                      &lt;table cellspacing=&quot;2&quot; 
                             style=&quot;border-style: solid; 
                                    border-color:black;
                                    border-top-width: 1px; 
                                    border-right-width: 1px; 
                                    border-bottom-width: 1px; 
                                    border-left-width: 1px;&quot;&gt;
                        &lt;cfloop from=&quot;0&quot; to=&quot;6&quot; index=&quot;row3&quot; step=&quot;3&quot;&gt;
                          &lt;tr&gt;
                            &lt;cfloop from=&quot;1&quot; to=&quot;3&quot; index=&quot;col3&quot; step=&quot;1&quot;&gt;
                              &lt;td 
       id=&quot;cell#evaluate(row1+row2)##evaluate(col1+col2)##evaluate(row3+col3)#&quot;
                                  style=&quot;cursor:hand; 
                                         font-family: Arial, Helvetica, 
                                                      Verdana, sans-serif;
                                         color:black; font-size: 10px;
                                         line_height:12px;&quot; 
                                  onclick=&quot;
javascript:doRemoteQuery(&apos;actSo.cfm?row=#evaluate(row1+row2)#&amp;
col=#evaluate(col1+col2)#&amp;num=#evaluate(row3+col3)#&apos;);&quot; 
                                  onMouseOver=&quot;this.style.background=&apos;silver&apos;&quot; 
                                  onMouseOut=&quot;this.style.background=&apos;white&apos;&quot;&gt;
                                &amp;nbsp;#evaluate(row3+col3)#&amp;nbsp; 
                              &lt;/td&gt; 	                                   
                            &lt;/cfloop&gt;  
                          &lt;/tr&gt;
                        &lt;/cfloop&gt;
                      &lt;/table&gt;    
                    &lt;/td&gt;  
                  &lt;/cfloop&gt;  
                &lt;/tr&gt;
              &lt;/cfloop&gt;
            &lt;/table&gt;  
          &lt;/td&gt;  
        &lt;/cfloop&gt;  
      &lt;/tr&gt;
    &lt;/cfloop&gt;   
  &lt;/table&gt;
&lt;/cfoutput&gt;  
&lt;/code&gt;

actSo.cfm
&lt;code&gt;
&lt;cfapplication name=&quot;so&quot; setclientcookies=&quot;Yes&quot; sessionmanagement=&quot;Yes&quot; /&gt;

&lt;cfscript&gt;
/**
 * Calculates the cube to check.
 * 
 * @param Row or column of the selected cell 
 * @return Returns the top left cell of the cube 
 * @author Trevor Burnette (trevor@burnette.com) 
 * @version 1, August 18, 2006 
 */
function getStart(cellPos)
{
  if (cellPos lte 3)
    return(1);
  if (cellPos lte 6)
    return(4);
  if (cellPos lte 9)
    return(7);
}
&lt;/cfscript&gt;

&lt;cfoutput&gt;
  &lt;cfif session.soGrid[url.row][url.col][2] eq url.num or 
        listFind(session.soGrid[url.row][url.col][1], url.num, &apos;,&apos;) eq 0&gt;
    alert(&apos;Invalid Selection!&apos;);
    &lt;cfabort /&gt;
  &lt;/cfif&gt;
  &lt;cfset session.soGrid[url.row][url.col][2] = url.num&gt;
  document.getElementById(&quot;cell#url.row##url.col##url.num#&quot;).style.color = 
  &quot;red&quot;;
  &lt;!--- Check Row ---&gt;
  &lt;cfloop index=&quot;i&quot; from=&quot;1&quot; to=&quot;9&quot; step=&quot;1&quot;&gt;
    &lt;!--- Skip if on select element ---&gt;
    &lt;cfif url.col neq i&gt;
      &lt;cfset listPos = listFind(session.soGrid[url.row][i][1], url.num, &apos;,&apos;)&gt;
      &lt;!--- Skip if already out of list ---&gt;
      &lt;cfif listPos neq 0&gt;
        &lt;cfset session.soGrid[url.row][i][1] = 
               listDeleteAt(session.soGrid[url.row][i][1] , listPos, &apos;,&apos;)&gt;
        document.getElementById(&quot;cell#url.row##i##url.num#&quot;).style.color = 
        &quot;white&quot;;
      &lt;/cfif&gt;
    &lt;/cfif&gt;
  &lt;/cfloop&gt;
  &lt;!--- Check Column ---&gt;
  &lt;cfloop index=&quot;i&quot; from=&quot;1&quot; to=&quot;9&quot; step=&quot;1&quot;&gt;
    &lt;!--- Skip if on select element ---&gt;
    &lt;cfif url.row neq i&gt;
      &lt;cfset listPos = listFind(session.soGrid[i][url.col][1], url.num, &apos;,&apos;)&gt;
      &lt;!--- Skip if already out of list ---&gt;
      &lt;cfif listPos neq 0&gt;
        &lt;cfset session.soGrid[i][url.col][1] = 
               listDeleteAt(session.soGrid[i][url.col][1] , listPos, &apos;,&apos;)&gt;
        document.getElementById(&quot;cell#i##url.col##url.num#&quot;).style.color = 
        &quot;white&quot;;
      &lt;/cfif&gt;
    &lt;/cfif&gt;
  &lt;/cfloop&gt;
  &lt;!--- Check Cube ---&gt;
  &lt;cfset startRow = getStart(url.row)&gt;
  &lt;cfset startCol = getStart(url.col)&gt;
  &lt;cfset endRow = startRow + 3&gt;
  &lt;cfset endCol = startCol + 3&gt;
  &lt;cfloop index=&quot;x&quot; from=&quot;#startRow#&quot; to=&quot;#endRow#&quot; step=&quot;1&quot;&gt;
    &lt;cfloop index=&quot;y&quot; from=&quot;#startCol#&quot; to=&quot;#endCol#&quot; step=&quot;1&quot;&gt;
    &lt;!--- Skip if on select element ---&gt;
    &lt;cfif (url.row neq x) and (url.col neq y)&gt;
      &lt;cfset listPos = listFind(session.soGrid[x][y][1], url.num, &apos;,&apos;)&gt;
      &lt;!--- Skip if already out of list ---&gt;
      &lt;cfif listPos neq 0&gt;
        &lt;cfset session.soGrid[x][y][1] = 
               listDeleteAt(session.soGrid[x][y][1] , listPos, &apos;,&apos;)&gt;
        document.getElementById(&quot;cell#x##y##url.num#&quot;).style.color = 
        &quot;white&quot;;
      &lt;/cfif&gt;
    &lt;/cfif&gt;
    &lt;/cfloop&gt;
  &lt;/cfloop&gt;
  &lt;!--- Check Cell ---&gt;
  &lt;cfloop index=&quot;i&quot; from=&quot;1&quot; to=&quot;9&quot; step=&quot;1&quot;&gt;
    &lt;!--- Skip if on select element ---&gt;
    &lt;cfif url.num neq i&gt;
      &lt;cfset listPos = listFind(session.soGrid[url.row][url.col][1], i, &apos;,&apos;)&gt;
      &lt;!--- Skip if already out of list ---&gt;
      &lt;cfif listPos neq 0&gt;
        &lt;cfset session.soGrid[url.row][url.col][1] = 
               listDeleteAt(session.soGrid[url.row][url.col][1] , listPos, &apos;,&apos;)&gt;
        document.getElementById(&quot;cell#url.row##url.col##i#&quot;).style.color = 
        &quot;white&quot;;
      &lt;/cfif&gt;
    &lt;/cfif&gt;
  &lt;/cfloop&gt;
&lt;/cfoutput&gt;
&lt;/code&gt;
				
				</description>
				
				<category>ColdFusion</category>
				
				<category>JavaScript</category>
				
				<pubDate>Thu, 21 Sep 2006 14:05:00 -0400</pubDate>
				<guid>http://www.burnette.us/blog/index.cfm/2006/9/21/You-Say-Sudoku-I-Say-Sudoko</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Opening and Reading a Word Doc using ColdFusion</title>
				<link>http://www.burnette.us/blog/index.cfm/2006/7/14/Opening-and-Reading-a-Word-Doc-using-ColdFusion</link>
				<description>
				
				Here is some code on how to open a word document and extracting the text.  The one catch is your coldFusion server needs to have MS Word loaded on it.

&lt;code&gt;
&lt;cfscript&gt;
  objWord=CreateObject(&quot;COM&quot;, &quot;Word.Application&quot;); 
  objDoc = objWord.Documents; 
  wordDoc = objDoc.Open(&quot;c:\test2.doc&quot;);
  docRange = wordDoc.Range(0);
  docText = docRange.Text;
&lt;/cfscript&gt;  

&lt;cfdump var=&quot;#docText#&quot;&gt;

&lt;cfscript&gt;  
  wordDoc.Close();
  objWord.Quit();
&lt;/cfscript&gt;
&lt;/code&gt;
				
				</description>
				
				<category>ColdFusion</category>
				
				<pubDate>Fri, 14 Jul 2006 17:24:00 -0400</pubDate>
				<guid>http://www.burnette.us/blog/index.cfm/2006/7/14/Opening-and-Reading-a-Word-Doc-using-ColdFusion</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Using Java RegEx in ColdFusion App</title>
				<link>http://www.burnette.us/blog/index.cfm/2006/3/23/Using-Java-RegEx-in-ColdFusion-App</link>
				<description>
				
				I wrote this in response to a post on how slow coldFusion is when processing large files using regular expression pattern matcher.

The only code outsite of the cfscript tag is a variable I set to add an end of line to each line I rewrite in the new file.

Here is the code, I will explain the results later.
&lt;code&gt;
&lt;cfset CrLf = chr(13)&amp;chr(10)&gt; 
 
&lt;cfscript&gt;
  //*** Get filenames to be processed ***//

  oReader = CreateObject(&quot;java&quot;, &quot;java.io.File&quot;); 
  
  //Directory where files are stored

  oReader.init(&quot;C:\your\dir&quot;); 
  if (oReader.exists()) 
  { 
    aFiles = oReader.listFiles(); 
    aDir = arrayNew(1); 
    x = 1; 
    
    for ( i = 1 ; i lte arrayLen(aFiles) ; i=i+1 ) 
    { 
      //Only get log files 

      if (right(aFiles[i].getName(), 4) eq &apos;.log&apos;) 
      { 
        aDir[x] = aFiles[i].getName(); 
        x=x+1; 
      } 
    } 
		
    //*** Read files, execute regex, write files ***//

    oPattern = createObject(&quot;java&quot;,&quot;java.util.regex.Pattern&quot;);
    // Set pattern to match to &apos; &apos; blank space

    oPattern = oPattern.compile(&apos; &apos;);
    oMatch = oPattern.matcher(&apos;&apos;);
		
    // Loop through list of files

    for ( i = 1 ; i lte arrayLen(aDir) ; i=i+1 ) 
    {
      // File read object

      oFile = createObject(&apos;java&apos;, &apos;java.io.FileReader&apos;);
      oFile = oFile.init(C:\your\dir\&apos; &amp; aDir[i]); 
			
      oLine = createObject(&apos;java&apos;, &apos;java.io.LineNumberReader&apos;); 
      oLine = oLine.init(oFile); 
			
      // File write object

      oWrite = createobject(&apos;java&apos;, &apos;java.io.File&apos;);
      oWrite = oWrite.init(&apos;C:\your\dir&apos; &amp; aDir[i] &amp; &apos;.new&apos;);   
			
      oWriteStream = createobject(&apos;java&apos;, &apos;java.io.FileWriter&apos;);
      oWriteStream = oWriteStream.init(oWrite); 
			
      // Read the first line

      readLine = oLine.readLine(); 			
			
      // Loop through file reading each line at bottom of loop

      while (isDefined(&apos;readLine&apos;)) 
      { 
        oMatch.reset(readLine);	
        //Replace &apos; &apos; with &apos;|&apos; and write to file

        oWriteStream.write(oMatch.replaceAll(&apos;|&apos;) &amp; CrLf);			
        //Read next line to be processed

        readLine = oLine.readLine();			 
      } 
			
      oFile.close();
      oLine.close();
      oWriteStream.flush();   
      oWriteStream.close(); 				
    }
  } 
&lt;/cfscript&gt;
&lt;/code&gt;

It processed 33 files with a total of 16,945 lines in 3 seconds. I added more files and a few with a lot more lines and processed 265 files with a total of 1,105,810 lines in 49 seconds.

I ran this code to compare.
&lt;code&gt;
&lt;cfdirectory name=&quot;files&quot; action=&quot;list&quot; filter=&quot;*.log&quot; directory=&quot;C:\your\dir&quot;&gt;
&lt;cfoutput query=&quot;files&quot;&gt;
  &lt;cffile action=&quot;read&quot; file=&quot;C:\your\dir\#files.name#&quot; variable=&quot;fileContents&quot;&gt;
  &lt;cfset newFile = REReplace(fileContents,&quot; &quot;,&quot;|&quot;,&quot;ALL&quot;)&gt;
  &lt;cffile action=&quot;write&quot; file=&quot;C:\your\dir\#files.name#.new&quot; output=&quot;#newFile#&quot;&gt;
&lt;/cfoutput&gt;
&lt;/code&gt;

This gave slightly better results than the java when I was processing the 265 smaller files.  The big difference was when I ran a test on 1 large file.  The file had 636,012 lines and was a little over 100MB in size.  I never could get the straight coldFusion code to process the file.  The java code processed the file in 16 seconds.

According to these results I would use cf tags for small file processing but use the java objects when the files get over 10MB.

I&apos;m sure the cfscript code can be made to run faster, if you improve on it let me know.
				
				</description>
				
				<category>ColdFusion</category>
				
				<pubDate>Thu, 23 Mar 2006 21:37:00 -0400</pubDate>
				<guid>http://www.burnette.us/blog/index.cfm/2006/3/23/Using-Java-RegEx-in-ColdFusion-App</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Hidden Veggies</title>
				<link>http://www.burnette.us/blog/index.cfm/2006/3/16/Hidden-Veggies</link>
				<description>
				
				I can get my kids to take a few bites of healthy vegetables but it is a struggle to get them to eat a whole serving size at dinner.  Well I have recently found a way to cook cauliflower so they eat it and ask for more.  I make them think it is mashed potatoes.

First I dice up one potato and start to boil it in water.  Then take 1/2 a head of cauliflower and cut it up into 4 or 5 pieces.  After about 5-10 minutes add it to the boiling water.  Boil until potato and cauliflower are fully cooked(about 15 minutes).  Drain in colander and then put back in pot.  I add heart smart margarine, salt, and pepper.  Then with a serving fork I mash up the potato and cauliflower.  Sometimes if it is not firm enough I add a handful of shredded cheese.

Now you have mashed potatoes that are 3/4 cauliflower.  It tastes great and my kids have no idea it is not all potatoes.  My wife and I actually like it and forget it&apos;s mostly cauliflower when we eat it.

Let me know if you try this recipe.
				
				</description>
				
				<category>Food!</category>
				
				<pubDate>Thu, 16 Mar 2006 22:22:00 -0400</pubDate>
				<guid>http://www.burnette.us/blog/index.cfm/2006/3/16/Hidden-Veggies</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Reading Java System Variables in Coldfusion</title>
				<link>http://www.burnette.us/blog/index.cfm/2006/3/9/Reading-Java-System-Variables-in-Coldfusion</link>
				<description>
				
				Someone on the coldFusion support forum asked how to determine which server in a cluster errors out if they share a common webroot.  So when the server emails a custom error page how can you display distinct server info.  Both servers would give the exact same CGI variable values.  So I suggested having a text file on each servers local drive with distinct info that could be read and included in the email.

I like that solution but I would prefer to be able to read a system variable to provide this information.  So here is a way to do just that.

First you will need to include your custom variable in the java system variables.  I did this using the java -D command.  This command will set a system variable for the coldFusion service running on your server (I only tried this for developer edition).  I put this in the jvm.config file located in my c:\CFusionMX7\runtime\bin\ directory.  In that file is a line that starts out &quot;java.args=&quot;.  The file already has a few -D commands so at the end of the line I just added one more &quot;-Dthis.computer=trevor&quot;. Then saved the file and restarted the coldFusion service.

To access and view the added java system variable I used the following code.
&lt;code&gt;
&lt;cfscript&gt;
  sysVar = CreateObject(&quot;java&quot;, &quot;java.lang.System&quot;);
  whichServer = sysVar.getProperty(&quot;this.computer&quot;);
&lt;/cfscript&gt;

&lt;cfdump var=&quot;#whichServer#&quot;&gt;
&lt;/code&gt;

To view all available variables just cfdump sysVar.
				
				</description>
				
				<category>ColdFusion</category>
				
				<pubDate>Thu, 09 Mar 2006 22:28:00 -0400</pubDate>
				<guid>http://www.burnette.us/blog/index.cfm/2006/3/9/Reading-Java-System-Variables-in-Coldfusion</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Updating Existing Records With Sequential Numbers</title>
				<link>http://www.burnette.us/blog/index.cfm/2006/2/24/Updating-Existing-Records-With-Sequential-Numbers</link>
				<description>
				
				The other day I needed to add a new field to a table in a SQL Server database.  When I added it I decided I wanted it to be an identity field but I already had hundreds of records.  When I added the field I needed to go ahead and number the column sequentially for the existing records.  Well I found some code at &lt;a href=&quot;http://www.sqlteam.com/item.asp?ItemID=765&quot;&gt;sqlTeam.com&lt;/a&gt; that worked great.

The code I ran against my table is:
&lt;code&gt;
declare @intCounter int
set @intCounter = 0
update employee
set @intCounter = eId = @intCounter + 1
&lt;/code&gt;
				
				</description>
				
				<category>Database</category>
				
				<pubDate>Fri, 24 Feb 2006 18:00:00 -0400</pubDate>
				<guid>http://www.burnette.us/blog/index.cfm/2006/2/24/Updating-Existing-Records-With-Sequential-Numbers</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Using Java Instead of &amp;lt;cffile&amp;gt; to Read from Disk</title>
				<link>http://www.burnette.us/blog/index.cfm/2006/2/17/Using-Java-Instead-of-cffile-to-Read-from-Disk</link>
				<description>
				
				I wrote earlier on using java to write to disk and I thought I would add a section on reading from disk too.  The code that follows is some I use to read log files and then I cfdump them to the browser.

Code to read file.
&lt;code&gt;
&lt;cfdirectory action=&quot;list&quot; directory=&quot;c:\program files\myApp\&quot; 
             filter=&quot;*.log&quot; name=&quot;logFiles&quot;&gt;

&lt;cfloop query=&quot;logFiles&quot;&gt;
  &lt;cfscript&gt;
    logFile = &apos;c:\program files\myApp\#logFiles.name#&apos;;
    
    oFile = createObject(&apos;java&apos;, &apos;java.io.FileReader&apos;);
    oFile = oFile.init(logFile);
    
    oLine = createObject(&apos;java&apos;, &apos;java.io.LineNumberReader&apos;);
    oLine = oLine.init(oFile);
			 
    readLine =  oLine.readLine();
    logData = &apos;&apos;;
	
    while (isDefined(&apos;readLine&apos;)) 
    {
      logData = logData &amp; readLine;
      readLine = oLine.readLine();
    }	
  &lt;/cfscript&gt;
  &lt;cfdump var=&quot;#logData#&quot;&gt;&lt;br&gt;&amp;nbsp;&lt;br&gt;
&lt;/cfloop&gt;
&lt;/code&gt;

If you want to process one line at a time and add it to a database then you can change the code to include a cffunction.  You can place it where logData = logData &amp; readLine.  Then you can process each line within the cffunction and use all the cf tags available to you.  Unlike in the cfscript where cf tags are no longer evaluated.
				
				</description>
				
				<category>ColdFusion</category>
				
				<pubDate>Fri, 17 Feb 2006 23:37:00 -0400</pubDate>
				<guid>http://www.burnette.us/blog/index.cfm/2006/2/17/Using-Java-Instead-of-cffile-to-Read-from-Disk</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Is Google Down?</title>
				<link>http://www.burnette.us/blog/index.cfm/2006/2/15/Is-Google-Down</link>
				<description>
				
				This is really strange but I think Google might be down.  My connection as a whole seems slow but I can&apos;t access gmail, blogger, or Google right now.  Also every site I visit with Google ads shows a connection refused by host.  I know they are loaded by java script so I guess it could be only my connection that is messed up.  I am heading home soon and I will be able to find out if this is a problem that others are experiencing.

5 minutes later:
Well now it works.
				
				</description>
				
				<category>Misc</category>
				
				<pubDate>Wed, 15 Feb 2006 17:25:00 -0400</pubDate>
				<guid>http://www.burnette.us/blog/index.cfm/2006/2/15/Is-Google-Down</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Using AJAX to Load JS into Document Head</title>
				<link>http://www.burnette.us/blog/index.cfm/2006/2/9/Using-AJAX-to-Load-JS-into-Document-Head</link>
				<description>
				
				I wrote this because I was wondering if you could hide your javaScript code from the users.  I know you can&apos;t 100% hide it because of course the browser has to be able to download it in order to execute the script.  Therefore any smart user that finds out the files name can download it.  Not to mention the .js file is stored in the browsers cache.

This example could lead to a few good uses like loading only the .js files needed by the user when they select a specific task on the page and not having to refresh the entire page.

&lt;a href=&quot;http://www.burnette.us/scratch/hidejs/&quot; target=&quot;_blank&quot;&gt;Click Here&lt;/a&gt; to view the script in action.  As you can see the function called is not in the default.cfm page or the init.js file that is loaded.

My example has four files, two coldFusion and two javaScript.

The first is default.cfm
&lt;code&gt;
&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;&gt;
&lt;HTML&gt;
&lt;HEAD&gt;
  &lt;TITLE&gt;
    Hidden JavaScript
  &lt;/TITLE&gt;  
  &lt;script language=&quot;javascript&quot; src=&quot;init.js&quot;&gt;&lt;/script&gt;
&lt;/HEAD&gt;

&lt;BODY&gt;
  I am calling a function that is hidden from you!&lt;br&gt;
  &lt;input type=&quot;button&quot; value=&quot;Press Me&quot; onclick=&quot;javaScript:hiddenFunction();&quot;&gt;
&lt;/BODY&gt;
&lt;/HTML&gt;
&lt;/code&gt;

The default.cfm file loads the init.js file which includes the AJAX code.  It also has a call to a function hiddenFunction() that is not in the default.cfm or the init.js files.

Here is the code for the init.js file.  AJAX code is a mix of code from all the google hack sites and blogs.
&lt;code&gt;
var lookupURL = &apos;http://www.burnette.us/scratch/hidejs/&apos;;
var xmlHttp;

function getXMLHTTP()
{
  var A = null;
  
  try
  {
    A = new ActiveXObject(&quot;Msxml2.XMLHTTP&quot;);
  }
  catch(e)
  {
    try
    {
      A = new ActiveXObject(&quot;Microsoft.XMLHTTP&quot;);
    } 
    catch(oc)
    {
      A = null;
    }
  }
  
  if(!A &amp;&amp; typeof XMLHttpRequest != &quot;undefined&quot;) 
  {
    A = new XMLHttpRequest();
  }
  
  return A;
}

function doRemoteQuery (queryString)
{
	searching = true;
  if(xmlHttp &amp;&amp; xmlHttp.readyState != 0) 
  {
    xmlHttp.abort()
  }	  
  xmlHttp=getXMLHTTP();
  if(xmlHttp)
  {
    xmlHttp.open(&quot;GET&quot;, lookupURL + queryString, true);
    xmlHttp.onreadystatechange = function() 
      {
        if (xmlHttp.readyState == 4 &amp;&amp; xmlHttp.responseText &amp;&amp; searching) 
        {
          try
          {
            eval(xmlHttp.responseText);
          }
          catch(e)
          {
      	    errorWindow=window.open(&quot;&quot;, &quot;&quot;, &quot;height=500, width=600,
              toolbar=no,scrollbars=yes,menubar=no,resizable=yes&quot;);
            errorWindow.document.write(xmlHttp.responseText);
          }
      	  searching = false;
        }
      }
    
    xmlHttp.send(null);
  }	  
}

doRemoteQuery(&apos;loadjs.cfm&apos;);
&lt;/code&gt;

As you can see in the above code the last line in the init.js file does a remote call to loadjs.cfm

The loadjs.cfm file that is called via AJAX is listed below.
&lt;code&gt;
&lt;cfsetting showDebugOutput=&quot;No&quot;&gt;
&lt;cfheader name=&quot;expires&quot; value=&quot;#now()#&quot;&gt; 
&lt;cfheader name=&quot;pragma&quot; value=&quot;no-cache&quot;&gt; 
&lt;cfheader name=&quot;cache-control&quot; value=&quot;no-cache, no-store, must-revalidate&quot;&gt;
var headTag = document.getElementsByTagName(&apos;head&apos;)[0];
script = document.createElement(&apos;script&apos;);
script.id = &apos;hiddenScript&apos;;
script.type = &apos;text/javascript&apos;;
script.src = &apos;hidden.js&apos;;
headTag.appendChild(script);
&lt;/code&gt;

As you can see I have javascript in the file to load the file hidden.js into the calling file, default.cfm&apos;s, head tag.

Hidden.js file that is loaded via AJAX.
&lt;code&gt;
function hiddenFunction ()
{
  alert(&apos;Good Morning Starshine, The Earth Says Helloooo&apos;);
}  
&lt;/code&gt;

I hope some folks can find some use for this.  I know it can be greatly inporved upon so if you do improve it let me know.  More security features could be added to the loadjs.cfm file to keep it from being loaded by anything other than the calling default.cfm page.  Also you can see I have added some no cache code to help hide the hidden.js file but I still found that the file was being stored.

Code for this example has been update at &lt;a href=&quot;http://www.burnette.us/blog/index.cfm/2006/10/16/Update-to-Using-AJAX-to-Load-JS-into-Document-Head&quot; target=&quot;_blank&quot;&gt;Update to Using AJAX to Load JS into Document Head&lt;/a&gt;
				
				</description>
				
				<category>JavaScript</category>
				
				<pubDate>Thu, 09 Feb 2006 20:54:00 -0400</pubDate>
				<guid>http://www.burnette.us/blog/index.cfm/2006/2/9/Using-AJAX-to-Load-JS-into-Document-Head</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Displaying an Error Window When AJAX Script Fails</title>
				<link>http://www.burnette.us/blog/index.cfm/2006/2/8/Displaying-an-Error-Window-When-AJAX-Script-Fails</link>
				<description>
				
				I use AJAX in a few of my projects and I was having trouble figuring out the error messages when the page being called threw an error.  So I added some try / catch code to the eval of the returned javaScript.  I open a window and display the returned text only if an error is thrown.

AJAX script that was mutated from the dozens of google hack sites.  
&lt;code&gt;
&lt;script language=&quot;javascript&quot;&gt; 
  &lt;cfoutput&gt; 
    var lookupURL =
        &apos;http://#cgi.SERVER_NAME##getDirectoryFromPath(cgi.PATH_INFO)#&apos;;
  &lt;/cfoutput&gt;
  var xmlHttp;
  	
  function getXMLHTTP()
  {
    var A = null;
  
    try
    {
      A = new ActiveXObject(&quot;Msxml2.XMLHTTP&quot;);
    }
    catch(e)
    {
      try
      {
        A = new ActiveXObject(&quot;Microsoft.XMLHTTP&quot;);
      } 
      catch(oc)
      {
        A = null;
      }
    }
  
    if(!A &amp;&amp; typeof XMLHttpRequest != &quot;undefined&quot;) 
    {
      A = new XMLHttpRequest();
    }
    return A;
  }

  function doRemoteQuery (queryString)
  {
    searching = true;
    if(xmlHttp &amp;&amp; xmlHttp.readyState != 0) 
    {
      xmlHttp.abort()
    }	  
    xmlHttp=getXMLHTTP();
    if(xmlHttp)
    {
      xmlHttp.open(&quot;GET&quot;, lookupURL + queryString, true);
      xmlHttp.onreadystatechange = function() 
        {
          if (xmlHttp.readyState == 4 &amp;&amp; xmlHttp.responseText &amp;&amp; searching) 
          {
      	    try
            {
              eval(xmlHttp.responseText);
            }
            catch(e)
            {
              errorWindow=window.open(&quot;&quot;, &quot;&quot;, &quot;height=500, width=600,
                toolbar=no,scrollbars=yes,menubar=no,resizable=yes&quot;);
              errorWindow.document.write(xmlHttp.responseText);
            }
            searching = false;
          }
	};
    
      xmlHttp.send(null);
    }	  
  }
&lt;/script&gt;
&lt;/code&gt;

I guess you can tell from my cfoutput tags that this example is from one of my coldFusion pages.

The errorWindow is created only when an error is thrown during the eval of the returned script.

Of course you us doRemoteQuery(remotePageQueryString) when you want the AJAX magic to happen.  I have even put it in the onload of a page and built lookup tables dynamically using javaScript.
				
				</description>
				
				<category>JavaScript</category>
				
				<pubDate>Wed, 08 Feb 2006 20:14:00 -0400</pubDate>
				<guid>http://www.burnette.us/blog/index.cfm/2006/2/8/Displaying-an-Error-Window-When-AJAX-Script-Fails</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Building a Login Page with cfNTauthenticate</title>
				<link>http://www.burnette.us/blog/index.cfm/2006/2/6/Building-a-Login-Page-with-cfNTauthenticate</link>
				<description>
				
				In the past I used cfldap to authenticate users against Microsoft Active Directory.  When coldFusion MX7 was released it contained a new tag that made user authentication much easier.  With cfNTauthenticate you can challenge the AD with a userid and password.  The result set includes any security groups the user is a member of.

Here is an example.
&lt;code&gt;
&lt;cfNTauthenticate username=&quot;#attributes.uid#&quot; 
                  password=&quot;#attributes.pw#&quot; 
                  domain=&quot;myDomain&quot;
                  result=&quot;authResult&quot; 
                  listGroups = &quot;yes&quot;
                  throwOnError = &quot;no&quot;&gt;

&lt;cfif authResult.auth eq &apos;YES&apos;&gt;
  &lt;cfquery name=&quot;qryUser&quot; datasource=&quot;myDSN&quot;&gt;
    select * from userDB where userId = &apos;#attributes.uId#&apos;
  &lt;/cfquery&gt;  
  &lt;cfif qryUser.recordCount gt 0&gt;
    
    &lt;cfset session.userid = attributes.uid&gt;
    &lt;cfset session.fName = qryUser.firstName&gt;
    &lt;cfset session.lName = qryUser.lastName&gt;
    &lt;cfset session.groupList = authResult.groups&gt;
    &lt;cfset session.email = qryUser.emailAddress&gt;
              
    &lt;cflocation url=&quot;default.cfm&quot;&gt;    
  &lt;/cfif&gt;
  &lt;cfset error = &apos;database&apos;&gt;
&lt;cfelse&gt;
  &lt;cfset error = &apos;domain&apos;&gt;
&lt;/cfif&gt;
&lt;cfoutput&gt;
  &lt;cflocation url=&quot;default.cfm?fuseaction=loginFail&amp;error=#error#&quot;&gt;
&lt;/cfoutput&gt; 
&lt;/code&gt;

I used the auth result to check if user was authenticated but you can also look at status.  That would return (success, UserNotInDirFailure, AuthenticationFailure) for success (duh), UserID not found, or password not correct.

On any pages you need secured just check for session.userId, if it does not exist then send them to the login page.

Oh yeah, of course you will need to run this against a Microsoft network and your users will need to be in Active Directory.
				
				</description>
				
				<category>ColdFusion</category>
				
				<pubDate>Mon, 06 Feb 2006 20:06:00 -0400</pubDate>
				<guid>http://www.burnette.us/blog/index.cfm/2006/2/6/Building-a-Login-Page-with-cfNTauthenticate</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Great Dip for Super Bowl</title>
				<link>http://www.burnette.us/blog/index.cfm/2006/2/2/Great-Dip-for-Super-Bowl</link>
				<description>
				
				One of the best dips I make is also the easiest.  Here are the ingredients.

2    Blocks Cream Cheese&lt;br&gt;
1/2  Purple Onion Diced&lt;br&gt;
16oz Frozen Chopped Spinach (Thawed)&lt;br&gt;
1    Tomato Diced&lt;br&gt;

Put cream cheese into a bowl and heat in microwave (30 secs at a time) until you can mix it easily with a spoon.

Add the spinach, onions, and tomato to the bowl.  Mix well and add salt/pepper to taste.  Eat with Tortilla Chips.

Sometimes I add a little bit of shreded cheese when heating and also a spoonful of salsa.  I have had folks tell me they added garlic too.

Thanks to John and Cathy Palmer who told me how to make this dip.

Enjoy!
				
				</description>
				
				<category>Food!</category>
				
				<pubDate>Thu, 02 Feb 2006 21:54:00 -0400</pubDate>
				<guid>http://www.burnette.us/blog/index.cfm/2006/2/2/Great-Dip-for-Super-Bowl</guid>
				
			</item>
			
		 	
			</channel></rss> 
