<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>CyphersTECH Consulting &#187; Programming</title>
	<atom:link href="http://www.cypherstech.com/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cypherstech.com</link>
	<description>turning possibilities in to realities</description>
	<lastBuildDate>Sun, 16 May 2010 15:29:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>REALbasic and Snow Leopard: Redraw what?!</title>
		<link>http://www.cypherstech.com/2010/01/realbasic-and-snow-leopard-redraw-what/</link>
		<comments>http://www.cypherstech.com/2010/01/realbasic-and-snow-leopard-redraw-what/#comments</comments>
		<pubDate>Thu, 14 Jan 2010 05:15:35 +0000</pubDate>
		<dc:creator>Anthony G. Cyphers</dc:creator>
				<category><![CDATA[Code Snipets]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[bugs]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[clients]]></category>
		<category><![CDATA[flicker]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[osx]]></category>
		<category><![CDATA[realbasic]]></category>
		<category><![CDATA[ui]]></category>

		<guid isPermaLink="false">http://www.cypherstech.com/?p=746</guid>
		<description><![CDATA[A customer has tasked me with updating some of the UI elements in their application. Among the problems they listed was a redraw bug in Snow Leopard, where the controls on windows with a set background color would display a slightly different color in their background even with the Composite property set to True. After [...]]]></description>
			<content:encoded><![CDATA[<p>A customer has tasked me with updating some of the UI elements in their application.  Among the problems they listed was a redraw bug in Snow Leopard, where the controls on windows with a set background color would display a slightly different color in their background even with the Composite property set to True.  After about an hour of testing different workarounds, I found what I believe to be an excellent solution.<br />
<span id="more-746"></span><br />
In this application, all of the windows have a set background color, but only a few displayed the error.  I had absolutely no luck in determining the difference, so I can only assume that it&#8217;s an inconsistent REALbasic bug.  Here&#8217;s how I fixed it:</p>
<ol>
<li>Add a new object to your project, mine is named &#8220;WindowHack,&#8221; and set it&#8217;s Super to &#8220;Window.&#8221;</li>
<li>Open the window subclass, and navigate to the &#8220;Paint&#8221; event.</li>
<li>Inside the &#8220;Paint&#8221; event, add the following block of code:<br />
<code>  #if TargetMacOS then<br />
    If Me.HasBackColor Then<br />
      g.ForeColor = me.BackColor<br />
      g.FillRect( 0, 0, g.Width, g.Height )<br />
    End If<br />
  #endif</code></li>
<li>Now set the Super of the windows with the problem to &#8220;WindowHack&#8221; and test.</li>
</ol>
<p>This seemed to be the most elegant solution I could find to the problem and, quite honestly, the root of the issue still eludes me.  Any thoughts on what might be causing this inconsistency?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cypherstech.com/2010/01/realbasic-and-snow-leopard-redraw-what/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A weekend with C#</title>
		<link>http://www.cypherstech.com/2009/09/a-weekend-with-c/</link>
		<comments>http://www.cypherstech.com/2009/09/a-weekend-with-c/#comments</comments>
		<pubDate>Tue, 08 Sep 2009 00:53:28 +0000</pubDate>
		<dc:creator>Anthony G. Cyphers</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.cypherstech.com/?p=545</guid>
		<description><![CDATA[I&#8217;ve spent the majority of my time this weekend learning the finer points of design in C#, and I have to say that I&#8217;m quite impressed. See, I&#8217;m a BASIC developer &#8212; or have been since QuickBasic &#8212; so I was looking at C# like it was the devil. Pure evil. Ugh. C-Based nonsense. With [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve spent the majority of my time this weekend learning the finer points of design in C#, and I have to say that I&#8217;m quite impressed.<br />
<span id="more-545"></span></p>
<p>See, I&#8217;m a BASIC developer &#8212; or have been since QuickBasic &#8212; so I was looking at C# like it was the devil.  Pure evil.  Ugh.  C-Based nonsense.  With a little pushing from friends, I decided to give it a go and see where I ended up.</p>
<p>It&#8217;s hard to compare C# to any of the BASIC variants I&#8217;m used to, but I&#8217;m going to try.</p>
<p><strong>Variables</strong><br />
This is a change up that I had a tiny bit of trouble adjusting to.  In C#(and any other C style language), there&#8217;s no &#8220;Dim X As (Type)&#8221;.  Instead, you simply have the Type name, Variable name, then any assignments.  For instance:</p>
<div class="codeexample"><code>int XPosition = 100;</code></div>
<p>Not too bad.  &#8220;int&#8221; is our type, &#8220;XPosition&#8221; is our variable name, and &#8220;100&#8243; is the value we&#8217;re assigning to it.</p>
<p><strong>Methods</strong><br />
This one isn&#8217;t too different.  Instead of like I&#8217;m used to in BASIC, having the method definition look like Scope Name(Parameters) As Type, C# moves one thing.  It&#8217;s Scope Type Name(Parameters).  If your method isn&#8217;t going to be returning a value?  Easy, your type is &#8220;void&#8221;.</p>
<div class="codeexample"><code>private void myMethod(string myName)<br />
{<br />
}</code></div>
<p>Easy to grasp, right?</p>
<p><strong>Events</strong><br />
Events aren&#8217;t as tough to figure out as I thought they&#8217;d be.  Visual Studio holds your hand the entire way.  Start by checking out the &#8220;Events&#8221; tab of the Property listbox, then go to the language ref and check out what EventArgs etc you need.  After that, you simply code up the event, something like&#8230;</p>
<div class="codeexample"><code>private void myControl_Paint(object Sender, PaintEventArgs e)<br />
{<br />
}</code></div>
<p>Then go right on back to the &#8220;Events&#8221; tab in the Property listbox, find the event you want to implement, hit the dropdown, and select the event handler you just coded.  Pie.</p>
<p>I&#8217;ll be sure to write up more of these articles as I learn the language.  Wish me luck!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cypherstech.com/2009/09/a-weekend-with-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RB:  Hate that flicker</title>
		<link>http://www.cypherstech.com/2009/08/rb-hate-that-flicker/</link>
		<comments>http://www.cypherstech.com/2009/08/rb-hate-that-flicker/#comments</comments>
		<pubDate>Sun, 30 Aug 2009 20:24:53 +0000</pubDate>
		<dc:creator>Anthony G. Cyphers</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[flicker]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[realbasic]]></category>
		<category><![CDATA[ui]]></category>
		<category><![CDATA[win32]]></category>

		<guid isPermaLink="false">http://www.cypherstech.com/?p=293</guid>
		<description><![CDATA[I&#8217;m currently working on a project for a client that requires a cross-platform UI class which is pretty standard. It has working alternatives on Windows, Mac, Linux, and anything else you can think of. They want a certain style within the application, regardless of OS, and I don&#8217;t blame them for it. Now, that&#8217;s all [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m currently working on a project for a client that requires a cross-platform UI class which is pretty standard.  It has working alternatives on Windows, Mac, Linux, and anything else you can think of.  They want a certain style within the application, regardless of OS, and I don&#8217;t blame them for it.<br />
<span id="more-293"></span><br />
Now, that&#8217;s all fine and dandy&#8230;so what&#8217;s the problem?  Windows + REALBasic = Problem.  We all know that flicker on Win32 is a pain in RB.  I&#8217;ve managed, over the years, to work out a system to negate that issue.  Except, of course, in this circumstance.</p>
<p>We have a custom UI class, inside that we have a PagePanel, and inside that we have various different elements. On Mac, everything works beautifully.  Once we switch over to Win32, however&#8230;ugh.  See, that class itself is flicker-free.  Until we put the PagePanel on it and start changing values, that is.  Anytime that PagePanel&#8217;s value changes, our entire custom class has to be redrawn with one of those beautiful little flickers.  What a pain.</p>
<p>About the only thing I can think of to get around this problem, would be to manage showing/hiding of child elements in code, and drop the PagePanel.  Of course, that&#8217;s not the route we want to take with this project.</p>
<p>Anyone else have an idea?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cypherstech.com/2009/08/rb-hate-that-flicker/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JS: Multiple lines in a cookie</title>
		<link>http://www.cypherstech.com/2009/08/js-multiple-lines-in-a-cookie/</link>
		<comments>http://www.cypherstech.com/2009/08/js-multiple-lines-in-a-cookie/#comments</comments>
		<pubDate>Mon, 24 Aug 2009 17:32:23 +0000</pubDate>
		<dc:creator>Anthony G. Cyphers</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[cookies]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[replace]]></category>

		<guid isPermaLink="false">http://www.cypherstech.com/?p=179</guid>
		<description><![CDATA[Coming from my buddy Shawn over at Lyme Team is an easy way to store multiple lines of data in a single cookie! First we&#8217;ll start off with our HTML. This is an example template from which we&#8217;ll work. &#60;!DOCTYPE html PUBLIC &#34;-//W3C//DTD XHTML 1.0 Strict//EN&#34; &#34;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&#34;&#62; &#60;html xmlns=&#34;http://www.w3.org/1999/xhtml&#34;&#62; &#60;head&#62; &#60;title&#62;Multi-line cookie example&#60;/title&#62; &#60;/head&#62; &#60;body&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>Coming from my buddy Shawn over at <a href="http://www.lymeteam.org/">Lyme Team</a> is an easy way to store multiple lines of data in a single cookie!<br />
<span id="more-179"></span><br />
First we&#8217;ll start off with our HTML.  This is an example template from which we&#8217;ll work.</p>
<div class="codeexample"><code>&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot;<br />
	&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;<br />
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;<br />
&lt;head&gt;<br />
	&lt;title&gt;Multi-line cookie example&lt;/title&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
	&lt;h1&gt;Multi-line cookie example&lt;/h1&gt;<br />
	&lt;form name=&quot;ExampleForm&quot;&gt;<br />
		&lt;table&gt;<br />
			&lt;tr&gt;<br />
				&lt;td&gt;<br />
					Text to be stored in a cookie:&lt;br /&gt;<br />
					&lt;textarea name=&quot;TxtIn&quot;&gt;<br />
this is some<br />
example text<br />
					&lt;/textarea&gt;<br />
	  		&lt;/td&gt;<br />
	  		&lt;td&gt;<br />
	  			Data Stored in cookie:&lt;br /&gt;<br />
					&lt;textarea name='RawOut'&gt;&lt;/textarea&gt;&lt;br /&gt;<br />
					Decoded data from cookie:&lt;br /&gt;<br />
					&lt;textarea name='TxtOut'&gt;&lt;/textarea&gt;&lt;br /&gt;<br />
				&lt;/td&gt;<br />
			&lt;/tr&gt;<br />
	  	&lt;tr&gt;<br />
		  	&lt;td&gt;<br />
					&lt;input type=&quot;button&quot; value=&quot;Encode&quot; /&gt;<br />
					&lt;input type=&quot;button&quot; value=&quot;Decode&quot; /&gt;	<br />
				&lt;/td&gt;<br />
			&lt;/tr&gt;<br />
		&lt;/table&gt;<br />
	&lt;/form&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</code></div>
<p>Now that we have our template, we can dive in to the JavaScript.</p>
<p>We&#8217;ll start with a few generic methods to control our cookie, and we&#8217;re going to put these in &#8216;cookie.js&#8217;</p>
<div class="codeexample"><code>function createCookie(name,value,days) {<br />
  if (days) {<br />
    var date = new Date();<br />
    date.setTime(date.getTime()+(days*24*60*60*1000));<br />
    var expires = &quot;; expires=&quot;+date.toGMTString();<br />
  }<br />
  else var expires = &quot;&quot;;<br />
  document.cookie = name+&quot;=&quot;+value+expires+&quot;; path=/&quot;;<br />
}</p>
<p>function readCookie(name) {<br />
  var nameEQ = name + &quot;=&quot;;<br />
  var ca = document.cookie.split(';');<br />
  for(var i=0;i &lt; ca.length;i++) {<br />
    var c = ca[i];<br />
    while (c.charAt(0)==' ') c = c.substring(1,c.length);<br />
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);<br />
  }<br />
  return null;<br />
}</p>
<p>function eraseCookie(name) {<br />
  createCookie(name,&quot;&quot;,-1);<br />
}<br />
</code></div>
<p>Since these aren&#8217;t the meat of the magic, I won&#8217;t explain their function.  The names should be self-explanatory.</p>
<p>Now the good stuff.</p>
<p>Starting with our function to encode the value for storage in to a cookie.  <code>encodeTA{}</code> is a simple function which takes the value of our textarea above(TxtIn), and replaces all of the line endings with <code>&lt;br&gt;</code> tags.</p>
<div class="codeexample"><code>		function encodeTA()<br />
		{<br />
			var big_string = document.ExampleForm.TxtIn.value; //Get the value that we want to encode<br />
			createCookie('multiline', big_string.replace(/\r\n|\r|\n/g, '&lt;br&gt;'), 1); // This will replace line endings with a &lt;br&gt;<br />
		}<br />
</code></div>
<p>On the other side, <code>decodeTA{}</code> takes the output from <code>encodeTA{}</code>, which comes from the cookie, and replaces all those lovely<code>&lt;br&gt;</code> tags with line endings.</p>
<div class="codeexample"><code>function decodeTA()<br />
		{<br />
			var txt = readCookie('multiline'); //Read in our cookie<br />
			document.ExampleForm.RawOut.value = txt; //Display the cookie's value in it's raw form.<br />
			document.ExampleForm.TxtOut.value = txt.replace(/&lt;br&gt;/g, 'n'); //Now we're going to replace those &lt;br&gt;s with line endings.<br />
		}<br />
</code></div>
<p>Now, all that&#8217;s left is to modify our HTML to call these functions, and include them in the document.  For this and more, download the example below.</p>
<div class="fileattachment"><a href="http://www.cypherstech.com/wp-content/uploads/2009/08/multi-line-cookie.zip">multiline-cookie.zip</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.cypherstech.com/2009/08/js-multiple-lines-in-a-cookie/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP: SQL2XML</title>
		<link>http://www.cypherstech.com/2009/08/php-sql2xml/</link>
		<comments>http://www.cypherstech.com/2009/08/php-sql2xml/#comments</comments>
		<pubDate>Mon, 24 Aug 2009 02:24:54 +0000</pubDate>
		<dc:creator>Anthony G. Cyphers</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.cypherstech.com/?p=90</guid>
		<description><![CDATA[This bit of code will connect to a MySQL database, run the passed query, and return the results as XML. I wrote this for use with FLEX, and it works quite well. &#60;?php // Database configuration. define(&#34;db_host&#34;, &#34;localhost&#34;); define(&#34;db_user&#34;, &#34;some_user&#34;); define(&#34;db_pass&#34;, &#34;mypass&#34;); define(&#34;db_name&#34;, &#34;mydb&#34;); // Authenticate calling application define(&#34;auth_user&#34;, &#34;someUserName&#34;); define(&#34;auth_pass&#34;, &#34;someUniquePhrase&#34;); //Set our header&#8230; [...]]]></description>
			<content:encoded><![CDATA[<p>This bit of code will connect to a MySQL database, run the passed query, and return the results as XML.  I wrote this for use with FLEX, and it works quite well.<br />
<span id="more-90"></span></p>
<div class="codeexample" id="sql2xml">&lt;?php</p>
<p>// Database configuration.<br />
define(&quot;db_host&quot;, &quot;localhost&quot;);<br />
define(&quot;db_user&quot;, &quot;some_user&quot;);<br />
define(&quot;db_pass&quot;, &quot;mypass&quot;);<br />
define(&quot;db_name&quot;, &quot;mydb&quot;);</p>
<p>// Authenticate calling application<br />
define(&quot;auth_user&quot;, &quot;someUserName&quot;);<br />
define(&quot;auth_pass&quot;, &quot;someUniquePhrase&quot;);</p>
<p>//Set our header&#8230;<br />
header(&quot;Content-type: text/xml&quot;); <br />
// and send our first line&#8230;<br />
?&gt;<br />
&lt;?xml version=&#8217;1.0&#8242;?&gt;<br />
&lt;?php</p>
<p>// Kick things off&#8230;<br />
user_authenticate();</p>
<p>function db_connect ()<br />
{<br />
	mysql_connect(db_host,db_user,db_pass);<br />
	mysql_select_db(db_name);<br />
}</p>
<p>function print_error($error)<br />
{<br />
	// We print the error as XML so that the FLEX app can handle these problems.<br />
	echo(&quot;&lt;flexsqlresult&gt;&quot;);<br />
	echo(&quot;&lt;error&gt;&quot; . $error . &quot;&lt;/error&gt;&quot;);<br />
	echo(&quot;&lt;/flexsqlresult&gt;&quot;);<br />
}</p>
<p>function user_authenticate ()<br />
{<br />
	// Make sure they send user and pass data that matches our globals defined above.<br />
	if(isset($_REQUEST['authuser']) &amp;&amp; isset($_REQUEST['authpass']))<br />
	{<br />
		if(($_REQUEST['authuser'] == auth_user) &amp;&amp; ($_REQUEST['authpass'] == auth_pass))<br />
		{<br />
			if(isset($_REQUEST['qry']))<br />
			{<br />
				// Everything checks out, let&#8217;s run the query.<br />
				run_Query(trim(urldecode($_REQUEST['qry'])));<br />
			} else {<br />
				// The query was empty, error.<br />
				print_error(&quot;Bad query&quot;);<br />
			}<br />
		} else {<br />
			// Their user/pass info didn&#8217;t match, error.<br />
			print_error(&quot;Authentication invalid&quot;);<br />
		}<br />
	} else {<br />
		// No user/pass info, error.<br />
		print_error(&quot;No authentication specified.&quot;);<br />
	}<br />
}</p>
<p>function run_Query ($query)<br />
{<br />
	// Connect to our database&#8230;<br />
	db_connect();<br />
	// Run our query&#8230;<br />
	$resultID = mysql_query($query) or print_error(&quot;SQL Error: &quot; . mysql_errno($resultID) . &quot; &#8211; &quot; . mysql_error($resultID));<br />
	// Start XML output&#8230;<br />
	echo(&quot;&lt;flexsqlresult&gt;&quot;);<br />
	$rowcount = 0;<br />
	while ($row = mysql_fetch_array($resultID))<br />
	{<br />
		echo(&quot;&lt;datarow&quot; . $rowcount . &quot;&gt;&quot;);<br />
		foreach($row as $key=&gt;$value)<br />
		{<br />
			// Make sure the column name isn&#8217;t numeric, otherwise the XML will be invalid.<br />
			if(is_integer($key) != true)<br />
			{<br />
				/// Spit out our Name/Value row.<br />
				echo(&quot;&lt;&quot; . $key . &quot;&gt;&quot; . $value . &quot;&lt;/&quot; . $key . &quot;&gt;&quot;);<br />
			}<br />
		}<br />
		echo(&quot;&lt;/datarow&quot; . $rowcount . &quot;&gt;&quot;);<br />
		$rowcount++;<br />
	}<br />
	echo(&quot;&lt;/flexsqlresult&gt;&quot;);<br />
}<br />
?&gt;</div>
]]></content:encoded>
			<wfw:commentRss>http://www.cypherstech.com/2009/08/php-sql2xml/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
