<?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>BeauCode</title>
	<atom:link href="http://beauwatson.com/beaucode/feed/" rel="self" type="application/rss+xml" />
	<link>http://beauwatson.com/beaucode</link>
	<description>Code, Code, Code</description>
	<lastBuildDate>Tue, 17 Aug 2010 08:35:00 +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>Triple-DES Key Obfuscation in VB.NET</title>
		<link>http://beauwatson.com/beaucode/2010/08/17/triple-des-key-obfuscation-in-vb-net/</link>
		<comments>http://beauwatson.com/beaucode/2010/08/17/triple-des-key-obfuscation-in-vb-net/#comments</comments>
		<pubDate>Tue, 17 Aug 2010 08:35:00 +0000</pubDate>
		<dc:creator>Beau</dc:creator>
				<category><![CDATA[Visual Basic.NET]]></category>
		<category><![CDATA[decryption]]></category>
		<category><![CDATA[encryption]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[vb]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://beauwatson.com/beaucode/?p=74</guid>
		<description><![CDATA[This is meant as a follow up to my previous post where I talked about the dangers of just leaving your keys laying around when you want to decrypt an XML file. Well, I devised just one solution that can help make your code a little harder to crack. This article will be a little [...]]]></description>
			<content:encoded><![CDATA[<p>This is meant as a follow up to my <a href="http://beauwatson.com/beaucode/2010/08/16/xml-encryption-decryption-in-vb-net/">previous post</a> where I talked about the dangers of just leaving your keys laying around when you want to decrypt an XML file. Well, I devised just one solution that can help make your code a little harder to crack. This article will be a little easier to follow (I hope) if you read the last post, because this post is really a supplement to it.</p>
<p><span id="more-74"></span>If you look in the last article, we were writing the key we needed to decrypt to a simple little text file called sharedsampleKey.txt. Anyone who knows what&#8217;s what will be able to simply take your encrypted XML file and your key and write a little program to decrypt your data.</p>
<p>A triple-DES hash looks like a jumbled mess of 32 case-sensitive letters, numbers, and symbols, so, in the sharedsampleKey.txt file, we have a key that looks something like this: p4WyhV3GAAj3hG2PnXhfIDp5JGKJ6mqQ. Wouldn&#8217;t it be nice if we could make it just a little harder to read? Well you&#8217;re in luck, because there&#8217;s a couple ways we can do that.</p>
<p>The method I devised involves padding the key with some dummy keys, so that the would-be code-cracker would have to parse out the correct 32-character string from the garbage mess. But instead of writing out a few dummy keys and then sticking the real key on the end, or in some known place in the middle, I decided to cut the real key into pieces, to make it even harder to get the correct string. I know that sounds a little complicated, and it is, but hopefully looking at the code and reading the comments, it&#8217;ll make more sense:</p>
<pre name="code" class="vb">
 'this variable will hold our dummy key data
            Dim tDESkey As New TripleDESCryptoServiceProvider()
            'this will generate the real key we need to unlock the data
            Dim sharedkey As New TripleDESCryptoServiceProvider()
            'convert the key to a string
            Dim realkey As String = Convert.ToBase64String(sharedkey.Key)

            'open the file writer to write to a text file
            Dim writer1 As IO.StreamWriter = New IO.StreamWriter("C:\Temp\sharedsamplepaddedKey.txt")
            'convert the real key to a character array, so it'll be easier to slice the string up
            Dim ourkey() = realkey.ToCharArray

            'run a for loop with a step count of your choice
            '  I chose 15 to keep things simple
            For x = 0 To 15
                'generate a new key
                tDESkey.GenerateKey()
                'convert it to a string
                Dim str1 As String = Convert.ToBase64String(tDESkey.Key)
                'here I arbitrarily chose an iteration to insert the first half
                ' of my real key; remember how many iterations you used for later
                If x = 4 Then
                    'A nested for loop to write out the first 16 characters
                    For i = 0 To 15
                        writer1.Write(ourkey(i))
                    Next i
                    ' another arbitrary iteration number, a few cycles later
                ElseIf x = 8 Then
                    'start where we left off and write out the last 16 characters
                    For i = 16 To 31
                        writer1.Write(ourkey(i))
                    Next i
                Else
                    'otherwise, just write a dummy key
                    writer1.Write(str1)
                End If
                'continue the loop
            Next x
            'close the file writer
            writer1.Close()
</pre>
<p>If you go look at the sharedsamplepaddedKey.txt file, you&#8217;ll see a nice jumbled mess of code that&#8217;ll be harder to crack. But because we know our arbitrary positions that we inserted each half of the key, we can use the the String.Remove() method to cut through the junk characters and piece together our real string. We can do that by:</p>
<pre name="code" class="vb">
 'A variable to hold our final, real key
            Dim sharedkey As New TripleDESCryptoServiceProvider()

            'open the file with a streamreader
            Dim rd2 As IO.StreamReader = New IO.StreamReader("C:\Temp\sharedsamplepaddedKey.txt")
            'read the contents from the file into a string
            Dim testStr As String = rd2.ReadToEnd()
            'Console.WriteLine(testStr)
            'Here's where it gets a little tricky
            ' Assuming you used the code above, we wrote out 4 full dummy
            ' keys before we inserted the first half of the real one, and
            ' each key is 32 characters long. So starting from 0 (the very
            ' beginning of the line, we remove 128 characters (32 x 4 = 128)
            testStr = testStr.Remove(0, 128)
            'Now, we have the first half (16 characters) so we need to KEEP
            ' those and then cut away 3 more lines to get to the next half
            ' so we start at position 16 and cut away 96 more characters
            testStr = testStr.Remove(16, 96)
            'We have the full 32-character key! but we need to cut away the
            ' trailing 7 lines so we jump 32 characters in, and remove 224
            ' more pieces of junk
            testStr = testStr.Remove(32, 224)
            Console.WriteLine(testStr)
            'then we convert the string to a byte array...
            Dim bytedata() As Byte = Convert.FromBase64String(testStr)
            '...and set our key's value! Hooray!
            sharedkey.Key = bytedata
</pre>
<p>Refer to the previous article on how to use the key to decrypt the data.</p>
<h3>Expanding the Obfuscation</h3>
<p>This is a fairly simple way of going about things, and it<em> still</em> is crackable, but this way it&#8217;s harder to figure out what the real key is. But, you can make it even harder! You can split the real key up into as many pieces as you want, but it&#8217;s going to make your String.Remove()&#8217;s a bigger pain when trying to build the real key. You can pad it with a ton more dummy keys, or you could be tricky and start reversing parts of the real key; you&#8217;ll just have to remember all the steps you took to hide the real key, and the more you use, the sturdier your defenses. But the more you use, the more you have to remember, so it&#8217;s all really about how much trouble you want to go through to protect the data and your own personal paranoia. In the end, everything can be cracked, but it never hurts to make it harder to do so.</p>
<p>There may be a way easier or better way to do all of this, but this was still a fun exercise in Visual Basic.NET. Suggestions, pointers, and questions are welcome &#8211; I&#8217;m not really a VB&#8217;er by trade, and I love getting new info, but hopefully this is helpful to someone.</p>
]]></content:encoded>
			<wfw:commentRss>http://beauwatson.com/beaucode/2010/08/17/triple-des-key-obfuscation-in-vb-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XML Encryption &amp; Decryption in VB.NET</title>
		<link>http://beauwatson.com/beaucode/2010/08/16/xml-encryption-decryption-in-vb-net/</link>
		<comments>http://beauwatson.com/beaucode/2010/08/16/xml-encryption-decryption-in-vb-net/#comments</comments>
		<pubDate>Mon, 16 Aug 2010 21:23:03 +0000</pubDate>
		<dc:creator>Beau</dc:creator>
				<category><![CDATA[Visual Basic.NET]]></category>
		<category><![CDATA[decryption]]></category>
		<category><![CDATA[encryption]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[vb]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://beauwatson.com/beaucode/?p=64</guid>
		<description><![CDATA[One of my professors at Purdue always raved about XML and how it was a powerful language. I thought it was a cool language, sure, because you could make up your own tags, but the ways I could use it escaped me at the time. However, I&#8217;ve begun using XML as a database, and it [...]]]></description>
			<content:encoded><![CDATA[<p>One of my professors at Purdue always raved about XML and how it was a powerful language. I thought it was a cool language, sure, because you could make up your own tags, but the ways I could use it escaped me at the time. However, I&#8217;ve begun using XML as a database, and it coupled with XPATH have opened to my eyes to a dynamic data storage world. It makes it easy to create and read data, but it also makes it easy to share between applications. Up until this &#8220;aha!&#8221; moment, I found XML only to be useful for RSS feeds and weather data.</p>
<p>But, the easy readability of XML comes at a price: if you&#8217;re storing sensitive data, any person who can read has a pretty good shot at understanding it. So, I went on a quest to find out ways to password-protect or encrypt XML files, and found out that recently the .NET framework began supporting a few easy to use methods to make encryption/decryption a fairly simple task. I&#8217;ll cover both of these, with some caveats, in Visual Basic .NET, since that&#8217;s the language I&#8217;ve been writing in.</p>
<p><span id="more-64"></span>I&#8217;ll make the assumption that if you&#8217;re writing this code, you&#8217;re probably using one of the iterations of Visual Studio, since it&#8217;s pretty great for writing anything .NET related. I&#8217;ll also assume that you know how to create and understand XML files, or at the very least have a sample file you&#8217;re willing to use, and that you have basic knowledge of programming in VB. Of course, questions are always welcome!</p>
<p>Before you do anything in your project, you&#8217;ll want to make sure you add references to the Security classes in the framework by right clicking on the project&#8217;s name and clicking on &#8220;Add Reference&#8221; which should make a window pop up with a massive list of different libraries. Scroll down to System.Security, click on it, and then click the Add button. You might be able to get away with skipping this step, but any time I&#8217;ve needed to use the XML Security libraries, Visual Studio has had trouble finding the methods I was trying to use, and adding the reference has always solved those problems.</p>
<p>First, you&#8217;ll want to import the appropriate things for dealing with the encryption:</p>
<pre name="code" class="vb">
Imports System.Xml
Imports System.Security.Cryptography
Imports System.Security.Cryptography.Xml
</pre>
<p>The code for encryption is below. I like to stick it in a &#8220;Save Button&#8221; or similar subroutine, where it copies whatever XML document I&#8217;m working with and saves it to the encrypted file.</p>
<pre name="code" class="vb">
'Declare an object that will load the XML file
        Dim xmldoc As New XmlDocument()

        'Always use the TRY/CATCH block to catch exceptions
        Try
            'Load the XML file
            '  Note that it says "decrypted.xml" (we're either beginning with a new document, or one that has been
'   decrypted when the program loaded so we could work with it)
            xmldoc.Load("C:\Temp\decrypted.xml")

            'Create a shared key using the triple DES algorithm
            '  Useful if we want to use this XML file across different applications
            Dim sharedkey As New TripleDESCryptoServiceProvider()
            'Declare a writer to save the key to a file (I use C:\Temp\ for my directory of choice
            Dim writer As IO.StreamWriter = New IO.StreamWriter("C:\Temp\sharedsampleKey.txt")
            'Convert the key to a String
            Dim str As String = Convert.ToBase64String(sharedkey.Key)
            'Write the string to the file
            writer.WriteLine(str)
            'Close the writer since we're done with it
            writer.Close()

            'Create an encrypted XML object and give the constructor our loaded XML file
            Dim exml As EncryptedXml = New EncryptedXml(xmldoc)

            'Select the XML node/element to be encrpyted
            '  You can select single nodes to encrypt, or choose the root node to encrypt the entire document
            Dim encryptElement As XmlElement = CType(xmldoc.SelectSingleNode("/cookbook"), XmlElement)

            'Encrypt the XML element data using the TripleDES alogrithm and save the results into a byte array
            Dim encryptXML As Byte() = exml.EncryptData(encryptElement, sharedkey, False)

            ' Create an EncryptedData object and tell it how we're encrypting it
            Dim ed As New EncryptedData()
            ed.Type = EncryptedXml.XmlEncElementUrl
            ed.EncryptionMethod = New EncryptionMethod(EncryptedXml.XmlEncTripleDESUrl)
            ' Create a CipherData element
            ed.CipherData = New CipherData()
            'Tell the cipher what we're encrypting
            ed.CipherData.CipherValue = encryptXML
            'Replace the node with the encrypted content
            EncryptedXml.ReplaceElement(encryptElement, ed, False)

            'Save the encrypted version of XML to disk
            xmldoc.Save("C:\Temp\encrypted.xml")

            deleteLbl.Visible = False
            messageLbl.Visible = True
            messageLbl.Text = "Recipe Data Saved"
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
</pre>
<p>In the above code, I alluded to decrypting the file so that it&#8217;s easier to work with in your program, and if you plan on encrypting data, it doesn&#8217;t do you much good if you can&#8217;t go back and read it later. Here&#8217;s how the decryption process works, if we assume that you used the method above to encrypt your XML in the first place. I like to put this in the Form&#8217;s Load subroutine, or you could put it in a &#8220;Load File&#8221; button, for example.</p>
<pre name="code" class="vb">
 Try
            'create a shared key object that we'll use to "unlock" our data
            Dim sharedkey As New TripleDESCryptoServiceProvider()

            'Retrieve shared key from the stored location
            Dim rd As IO.StreamReader = New IO.StreamReader("C:\Temp\sharedsampleKey.txt")
            'read the string fromt he file and convert it to a byte array
            Dim bytedata() As Byte = Convert.FromBase64String(rd.ReadToEnd())
            'set the key in the object
            sharedkey.Key = bytedata

            'Declare an XML object and load our encrypted content
            Dim encryptedDoc As New XmlDocument()
            encryptedDoc.Load("C:\Temp\encrypted.xml")

            'Grab whatever it is that we've encrypted
            Dim EncryptedElement As XmlElement = CType(encryptedDoc.GetElementsByTagName("EncryptedData")(0), XmlElement)

            'Create an EncryptedData object
            Dim ed As New EncryptedData()
            'Load the encrypted node into our ED object
            ed.LoadXml(EncryptedElement)

            'Use the key and the DecryptData method to get the original text
            Dim encryptXML As New EncryptedXml()
            Dim decryptedXML As Byte() = encryptXML.DecryptData(ed, sharedkey)

            'Replace the encryped node with the decrypted one
            encryptXML.ReplaceData(EncryptedElement, decryptedXML)
            'Save the data to a decrypted file
            encryptedDoc.Save("C:\Temp\decrypted.xml")
            'close our stream reader
            rd.Close()
        Catch ex As Exception
            Messag
</pre>
<h3>Caveats</h3>
<p>The above methods are really only for demo purposes, but in production, you&#8217;ll want to be a little more careful with your data. For example, using the above, you&#8217;ll take an encrypted file, decrypt it, and save it to the hard disk. Unless you delete it, the data will be there for just anyone to read. That being said, you should delete it once you&#8217;re done working with it (obviously), by using something like the below:</p>
<pre name="code" class="vb">
Private Sub frmMain_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
        Dim FileToDelete As String

        FileToDelete = "C:\Temp\decrypted.xml"

        If System.IO.File.Exists(FileToDelete) = True Then
            System.IO.File.Delete(FileToDelete)
        End If

    End Sub
</pre>
<p>Or, conversely, you could stick to using one file and just overwrite the encrypted file&#8217;s XML with the decrypted XML using the methods above, but you&#8217;d have to make sure you encrypt it again when you&#8217;re done with it.</p>
<p>Then, there&#8217;s the matter of the key. It&#8217;s just sitting there next to the data, but when you hide a spare key in your backyard, you probably don&#8217;t leave it taped to your door. Anyone with sense could break in just as easily if you&#8217;d left it unlocked. So, that said, you want to keep your shared key in a less-than-obvious place. And then, you may want to pad your key with a few hundred extra characters just to throw off anyone who finds it. I&#8217;ll probably write another post soon describing what I mean, but for now, it&#8217;s back to work for me!</p>
<h3>Further Reading</h3>
<ul>
<li><a href="http://en.wikipedia.org/wiki/Triple_DES">Triple DES on WikiPedia</a></li>
<li><a href="http://msdn.microsoft.com/en-us/library/9eat8fht.aspx">MSDN Cryptography Namespaces</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://beauwatson.com/beaucode/2010/08/16/xml-encryption-decryption-in-vb-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Making a Repreating Wave in Illustrator</title>
		<link>http://beauwatson.com/beaucode/2010/08/11/making-a-repreating-wave-in-illustrator/</link>
		<comments>http://beauwatson.com/beaucode/2010/08/11/making-a-repreating-wave-in-illustrator/#comments</comments>
		<pubDate>Wed, 11 Aug 2010 06:52:30 +0000</pubDate>
		<dc:creator>Beau</dc:creator>
				<category><![CDATA[Illustrator]]></category>

		<guid isPermaLink="false">http://beauwatson.com/beaucode/?p=37</guid>
		<description><![CDATA[I&#8217;ve been insanely busy this last week! I haven&#8217;t had time to work on iPhone app development at all, because I started working with a client on a new site, among my other work. In my last post, I talked about my work in VB.NET and I was planning on doing some HTML5 + AJAX [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been insanely busy this last week! I haven&#8217;t had time to work on iPhone app development at all, because I started working with a client on a new site, among my other work. In my last post, I talked about my work in VB.NET and I was planning on doing some HTML5 + AJAX stuff. The VB work is still underway, and I haven&#8217;t touched any HTML5 yet (this whole working thing is getting in the way of me playing around with stuff), but I did do some templating work for my new client, that involved some work in Illustrator. The project called for creating some wave aspects, and Illustrator was my weapon of choice. I thought I&#8217;d share with you all my little technique for making (x-repeating) waves, Illustrator style!<span id="more-37"></span></p>
<p style="text-align: center;">I&#8217;ve got a bunch of steps planned for you, and if you are familiar with Illustrator, you can probably skip a couple. I tried to write it so someone fairly new to the software can follow along easily. Of course, if you have another method of your own that you love to use, feel free to share it! Now, on with the tutorial:</p>
<div id="attachment_40" class="wp-caption aligncenter" style="width: 410px"><a href="http://beauwatson.com/beaucode/wp-content/uploads/2010/08/step1.jpg"><img class="size-full wp-image-40 " title="step1" src="http://beauwatson.com/beaucode/wp-content/uploads/2010/08/step1.jpg" alt="" width="400" height="400" /></a><p class="wp-caption-text">Step 1: Create a rectangle using the shape tool. Make it whatever color you want; I chose blue since we&#39;re making a wave.</p></div>
<p style="text-align: center;">
<div id="attachment_41" class="wp-caption aligncenter" style="width: 410px"><a href="http://beauwatson.com/beaucode/wp-content/uploads/2010/08/step2.jpg"><img class="size-full wp-image-41 " title="step2" src="http://beauwatson.com/beaucode/wp-content/uploads/2010/08/step2.jpg" alt="" width="400" height="400" /></a><p class="wp-caption-text">Step 2: With the rectangle selected, click Filter -&gt; Distort &amp; Transform -&gt; Zig-Zag</p></div>
<p style="text-align: center;">
<div id="attachment_43" class="wp-caption aligncenter" style="width: 310px"><a href="http://beauwatson.com/beaucode/wp-content/uploads/2010/08/step3.jpg"><img class="size-medium wp-image-43 " title="step3" src="http://beauwatson.com/beaucode/wp-content/uploads/2010/08/step3-300x300.jpg" alt="" width="300" height="300" /></a><p class="wp-caption-text">Step 3: The default settings are okay, but you can play with the settings to adjust the height of your wave. Make sure the preview box is clicked if you want to see what will happen to your rectangle.</p></div>
<div id="attachment_44" class="wp-caption aligncenter" style="width: 410px"><a href="http://beauwatson.com/beaucode/wp-content/uploads/2010/08/step4.jpg"><img class="size-full wp-image-44" title="step4" src="http://beauwatson.com/beaucode/wp-content/uploads/2010/08/step4.jpg" alt="" width="400" height="400" /></a><p class="wp-caption-text">Step 4: With the shape selected, click on Object -&gt; Expand Appearance. We do this because illustrator treats the shape like it&#39;s still a rectangle after you apply the zig zag filter. Expanding the appearance converts your shape into an object with its own control points, allowing us to directly manipulate the path.</p></div>
<div id="attachment_45" class="wp-caption aligncenter" style="width: 410px"><a href="http://beauwatson.com/beaucode/wp-content/uploads/2010/08/step5.jpg"><img class="size-full wp-image-45" title="step5" src="http://beauwatson.com/beaucode/wp-content/uploads/2010/08/step5.jpg" alt="" width="400" height="400" /></a><p class="wp-caption-text">Step 5: Now, we want this to repeat, so we need to just take a portion of our shape. Luckily for us, the Zig Zag filter spaces out all of the waves evenly in a sine-wave type pattern, so we can pick a start point and end point to make an image that will repeat nicely when we use it in our HTML/CSS.  Here we need to use the direct selection tool (the white arrow, not the black one...or hit &quot;A&quot; if you&#39;re into hotkeys) and select the wacky, wavy end of the shape.</p></div>
<div id="attachment_46" class="wp-caption aligncenter" style="width: 410px"><a href="http://beauwatson.com/beaucode/wp-content/uploads/2010/08/step6.jpg"><img class="size-full wp-image-46" title="step6" src="http://beauwatson.com/beaucode/wp-content/uploads/2010/08/step6.jpg" alt="" width="400" height="400" /></a><p class="wp-caption-text">Step 6: Hit the delete key to remove the junk from the end. But now, the path is open, and we want to close it! Grab the pen tool (P for the hotkeyers) and click on the top point (a little / should appear next to the pen nib) and then click on the bottom point (a little o should appear) to close the path up. This is helpful for the next step.</p></div>
<div id="attachment_47" class="wp-caption aligncenter" style="width: 410px"><a href="http://beauwatson.com/beaucode/wp-content/uploads/2010/08/step7.jpg"><img class="size-full wp-image-47" title="step7" src="http://beauwatson.com/beaucode/wp-content/uploads/2010/08/step7.jpg" alt="" width="400" height="400" /></a><p class="wp-caption-text">Step 7: Get the direct selection tool out again, and this time select the junk to the right. Make sure you draw a box to the right of the center of the next trough or &quot;low point&quot; after the crest, or &quot;high point&quot; of the wave.  You&#39;ll notice that everything left of the crest is half of a trough, and everything to the right is another half. This is how we create a seamlessly repeating pattern.</p></div>
<p style="text-align: left;">
<div id="attachment_48" class="wp-caption aligncenter" style="width: 410px"><a href="http://beauwatson.com/beaucode/wp-content/uploads/2010/08/step8.jpg"><img class="size-full wp-image-48" title="step8" src="http://beauwatson.com/beaucode/wp-content/uploads/2010/08/step8.jpg" alt="" width="400" height="400" /></a><p class="wp-caption-text">Step 8: Delete the junk, and you&#39;ll see we have a single crest. If you want just a wavy ribbon, you can stop here, but I needed a boxy bottom to my wave since it was going to be used in a page footer. If you want to keep following along, go ahead and close the ends with the pen tool like we did in step 6.</p></div>
<div id="attachment_49" class="wp-caption aligncenter" style="width: 425px"><a href="http://beauwatson.com/beaucode/wp-content/uploads/2010/08/step9.jpg"><img class="size-full wp-image-49" title="step9" src="http://beauwatson.com/beaucode/wp-content/uploads/2010/08/step9.jpg" alt="" width="415" height="415" /></a><p class="wp-caption-text">Step 9: Use the direct selection tool to grab the lower center point of the shape. This picture here shows that a white square should show up, indicating that you can select the point.</p></div>
<div id="attachment_50" class="wp-caption aligncenter" style="width: 410px"><a href="http://beauwatson.com/beaucode/wp-content/uploads/2010/08/step10.jpg"><img class="size-full wp-image-50" title="step10" src="http://beauwatson.com/beaucode/wp-content/uploads/2010/08/step10.jpg" alt="" width="400" height="400" /></a><p class="wp-caption-text">Step 10: Delete it! This will square up the bottom of your wave, making it ideal for a border of any kind. Here, you can change the color, add a gradient, or copy and paste it into photoshop to do more work on it. Read on for a couple more steps on how to publish it using Illustrator if you don&#39;t have Photoshop, or prefer to use only Illustrator.</p></div>
<div id="attachment_51" class="wp-caption aligncenter" style="width: 410px"><a href="http://beauwatson.com/beaucode/wp-content/uploads/2010/08/step11.jpg"><img class="size-full wp-image-51" title="step11" src="http://beauwatson.com/beaucode/wp-content/uploads/2010/08/step11.jpg" alt="" width="400" height="400" /></a><p class="wp-caption-text">Step 11: Click the crop artboard tool. This will make the area outside the artboard turn gray, indicating that you are resizing the visible area of the final image.</p></div>
<div id="attachment_52" class="wp-caption aligncenter" style="width: 410px"><a href="http://beauwatson.com/beaucode/wp-content/uploads/2010/08/step12.jpg"><img class="size-full wp-image-52" title="step12" src="http://beauwatson.com/beaucode/wp-content/uploads/2010/08/step12.jpg" alt="" width="400" height="400" /></a><p class="wp-caption-text">Step 12: Illustrator will handily crop the artboard automatically for you to fit everything into the image. So, just click on the wave, and voila! It&#39;ll resize the artboard to perfectly contain your wave.</p></div>
<div id="attachment_53" class="wp-caption aligncenter" style="width: 410px"><a href="http://beauwatson.com/beaucode/wp-content/uploads/2010/08/step13.jpg"><img class="size-full wp-image-53" title="step13" src="http://beauwatson.com/beaucode/wp-content/uploads/2010/08/step13.jpg" alt="" width="400" height="400" /></a><p class="wp-caption-text">Step 13: Select any other tool to close the crop artboard tool. You can now save the file for web use using File -&gt; Save for Web and Devices. This will optimize the file for web use. You can save it in any format you wish, but I would recommend using GIF or PNG, since they support transperency, and they use &quot;lossless&quot; compression, so that we don&#39;t have to worry about &quot;artifacting&quot; the edges of our wave.</p></div>
<p style="text-align: left;">Here&#8217;s a quick line of CSS to demonstrate how to use the wave:</p>
<pre name="code" class="css">.element{ background: url(path/to/wave.gif) repeat-x; }
</pre>
<p>That&#8217;s it in a nutshell! I hope the tutorial was easy to follow, but if there&#8217;s problem spots, feel free to ask questions and/or ridicule me in the comments! Now&#8230;back to work on other things. I&#8217;ll try to come back sooner than later with another post.</p>
]]></content:encoded>
			<wfw:commentRss>http://beauwatson.com/beaucode/2010/08/11/making-a-repreating-wave-in-illustrator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iPod Touch App Derailed</title>
		<link>http://beauwatson.com/beaucode/2010/08/03/ipod-touch-app-derailed/</link>
		<comments>http://beauwatson.com/beaucode/2010/08/03/ipod-touch-app-derailed/#comments</comments>
		<pubDate>Wed, 04 Aug 2010 03:57:15 +0000</pubDate>
		<dc:creator>Beau</dc:creator>
				<category><![CDATA[Announcements]]></category>

		<guid isPermaLink="false">http://beauwatson.com/beaucode/?p=34</guid>
		<description><![CDATA[Just making a quick post here to say that I&#8217;m stuck in a little holding pattern with iOS development. Apparently, I needed to have my OSX updated to 10.6 in order to install the iPhone SDK with XCode. Whoops! So, I ordered the upgrade since it wasn&#8217;t too much, and it should arrive sometime this [...]]]></description>
			<content:encoded><![CDATA[<p>Just making a quick post here to say that I&#8217;m stuck in a little holding pattern with iOS development. Apparently, I needed to have my OSX updated to 10.6 in order to install the iPhone SDK with XCode. Whoops! So, I ordered the upgrade since it wasn&#8217;t too much, and it should arrive sometime this week, I hope.</p>
<p>In the meantime, I&#8217;ll be working on client projects. We&#8217;re doing some cool stuff with a point of sale system, and then integrating a load cell with a code project. I&#8217;ll try to share what I learn here, if of course it won&#8217;t give away too many secrets!</p>
<p>I also have plans to make a little rock-paper-scissors game using HTML5 and JavaScript, so that way I&#8217;ll be able to say I&#8217;ve actually used HTML5, and it will be fun to develop. More coming soon!</p>
]]></content:encoded>
			<wfw:commentRss>http://beauwatson.com/beaucode/2010/08/03/ipod-touch-app-derailed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using SimpleXML to get Weather Data from Yahoo!</title>
		<link>http://beauwatson.com/beaucode/2010/07/31/a-very-simple-weather-class-in-php/</link>
		<comments>http://beauwatson.com/beaucode/2010/07/31/a-very-simple-weather-class-in-php/#comments</comments>
		<pubDate>Sat, 31 Jul 2010 20:51:06 +0000</pubDate>
		<dc:creator>Beau</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://beauwatson.com/beaucode/?p=12</guid>
		<description><![CDATA[One of my clients is a baker, and the weather data is very important to him. Things like weather conditions and temperature affect buying patterns, and things like humidity affect water saturation in recipes. So, obviously, collecting the weather data for him to store so he can predict and refine his production was a goal [...]]]></description>
			<content:encoded><![CDATA[<p>One of my clients <a href="http://weather.yahoo.com/"><img class="alignright" title="Yahoo! Weather" src="http://l.yimg.com/a/i/brand/purplelogo//uh/us/news-wea.gif" alt="" width="213" height="30" /></a>is a baker, and the weather data is very important to him. Things like weather conditions and temperature affect buying patterns, and things like humidity affect water saturation in recipes. So, obviously, collecting the weather data for him to store so he can predict and refine his production was a goal of ours. I&#8217;d read a post on <a href="http://css-tricks.com/using-weather-data-to-change-your-websites-apperance-through-php-and-css/">CSS Tricks</a> in the past that showed how to collect weather information from Yahoo! Weather&#8217;s RSS API. I used his code as a base for creating a class so that I could collect the data we needed as an object. Read on for the code.<span id="more-12"></span></p>
<p>Below is the entirety of the class. You can paste it directly where you want to use it, but I like to keep my classes in their own file. I named mine &#8220;weather.class.php,&#8221; for example. I&#8217;m making the assumption you know a little bit of PHP.</p>
<pre name="code" class="php">/************************************************
/ Class: WeatherData
/ Author: Beau Watson
/ Version: 1.1
/ Description: Uses the Yahoo Weather RSS API to get
/  weather info for US cities by zip code
/ Special Thanks: Navarr Barnier (tech.navarr.me)
/************************************************/
class WeatherData
{
private $url; //variable to store our url
private $cond; //variable to store our condition
private $temp; //variable to store our temperature
private $humidity; //variable to store our humidity
private $units; //variable so we can set units f=farenheit, c=celsius
private $data; //array to hold our weather data from Yahoo
private $matches; //array to hold our regex matches
private $xml; //variable to hold the xml data from the RSS feed
private $item; //variable to hold the node we're looking at

//Constructor intializes properties of the class
//pass it a zip code, you can also define units
//defaults to farenheit, but pass in c for celsius
public function __construct( $zip, $units = "f")
{
if($this-&gt;units != "c"){
$this-&gt;units = "f";
}

//set the url given the things passed into the constructor
$this-&gt;url       = 'http://weather.yahooapis.com/forecastrss?p='.$zip.'&amp;u='.$units;
//open the file
$this-&gt;xml = file_get_contents($this-&gt;url);
//reead it using SimpleXML
$this-&gt;xml = simplexml_load_string($this-&gt;xml);
//we grab the channel node using simpleXML
$this-&gt;item = $this-&gt;xml-&gt;channel[0]-&gt;item[0];
//here we set the namespace we're looking for using yahoo's spec
$yweather = $this-&gt;item-&gt;children("http://xml.weather.yahoo.com/ns/rss/1.0");
//we have to redeclare a second namespace to use since yahoo's API sticks the
//  humidity data that we need in a different tag
$yweather2 = $this-&gt;xml-&gt;channel-&gt;children("http://xml.weather.yahoo.com/ns/rss/1.0");
//we grab all of the attributes of the yweather tag for the conditions
$attr = $yweather-&gt;condition-&gt;attributes();
//we grab the temp attribute and set the temperature property
$this-&gt;temp     = $attr["temp"];
//we grab the condition type and set the property
$this-&gt;cond     = $attr["text"];
//we use our attribute finder and our other namespace to get
// the atmosphere tag, where we get the humidity data
$attr = $yweather2-&gt;atmosphere-&gt;attributes();
//set the humidity property
$this-&gt;humidity  = $attr["humidity"];

}

//magic function for setting variables
public function __set($var, $val)
{
$this-&gt;$var = $val;
}

//magic function for returning variables
public function __get($var)
{
return $this-&gt;$var;
}

}
</pre>
<p>Using the class in your scripts (assuming you put it in its own file):</p>
<pre name="code" class="php">
//include the file using whatever name you gave it
include_once("weather.class.php");

//create a new weather object
//make sure you pass in a zip code
//if you want to specify units, pass in "c" as a string for celsius
// units default to farenheit
$weather = new WeatherData($zipcode, $units);

//to access the members, call them like so
$weather->cond; //for the condition, eg "Sunny"
$weather->temp; //for the temperature
$weather->humidity; //for the humidity
</pre>
<p>Since I only needed these three aspects of the weather, that&#8217;s all I bothered to include in the class. If you need more data, you can ask me and I can help you figure it out. There are many ways you could implement this class in your work as well, but I&#8217;ll save those ideas for another post.</p>
<p> Special thanks to my buddy, <a href="http://tech.navarr.me">Navarr Barnier</a>, for helping me integrate SimpleXML with this class. </p>
]]></content:encoded>
			<wfw:commentRss>http://beauwatson.com/beaucode/2010/07/31/a-very-simple-weather-class-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My New Toy: An iPod Touch</title>
		<link>http://beauwatson.com/beaucode/2010/07/29/my-new-toy-an-ipod-touch/</link>
		<comments>http://beauwatson.com/beaucode/2010/07/29/my-new-toy-an-ipod-touch/#comments</comments>
		<pubDate>Thu, 29 Jul 2010 04:37:00 +0000</pubDate>
		<dc:creator>Beau</dc:creator>
				<category><![CDATA[Mobile Development]]></category>
		<category><![CDATA[ios]]></category>
		<category><![CDATA[ipod touch]]></category>
		<category><![CDATA[mobile]]></category>

		<guid isPermaLink="false">http://beauwatson.com/beaucode/?p=10</guid>
		<description><![CDATA[Not so much a post as a simple update: today I picked up an iPod touch. I wrote a dinky little app for my Palm Pre and had fun doing it, and decided I&#8217;d make an investment and learn how to make some iOS apps. It may be a daunting task sure, but I always [...]]]></description>
			<content:encoded><![CDATA[<p>Not so much a post as a simple update: today I picked up an iPod touch. I wrote a dinky little app for my Palm Pre and had fun doing it, and decided I&#8217;d make an investment and learn how to make some iOS apps. It may be a daunting task sure, but I always love learning new things and expanding my skillset.</p>
<p>I&#8217;ve been busy with work, but intend to spend a little time learning about developing for this thing this weekend, and will be sure to post my findings as they come!</p>
]]></content:encoded>
			<wfw:commentRss>http://beauwatson.com/beaucode/2010/07/29/my-new-toy-an-ipod-touch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Purpose of this Blog</title>
		<link>http://beauwatson.com/beaucode/2010/07/13/the-purpose-of-this-blog/</link>
		<comments>http://beauwatson.com/beaucode/2010/07/13/the-purpose-of-this-blog/#comments</comments>
		<pubDate>Tue, 13 Jul 2010 21:32:13 +0000</pubDate>
		<dc:creator>Beau</dc:creator>
				<category><![CDATA[Announcements]]></category>

		<guid isPermaLink="false">http://beauwatson.com/beaucode/?p=4</guid>
		<description><![CDATA[This is just an introductory post for anyone who has stumbled upon this blog before I have written anything in it. I design and develop websites for a living, having gone to school for it at Purdue University. As such I plan to dedicate this blog to things I&#8217;m doing or things I want to [...]]]></description>
			<content:encoded><![CDATA[<p>This is just an introductory post for anyone who has stumbled upon this blog before I have written anything in it. I design and develop websites for a living, having gone to school for it at Purdue University. As such I plan to dedicate this blog to things I&#8217;m doing or things I want to do with code and maybe sometimes with design. I&#8217;m sure the purpose of it will evolve over time, but the posts on this blog will be more of a technical nature than a personal one. I have <a title="My personal blog" href="http://beauwatson.com/beauetry/" target="_blank">another blog</a> dedicated to &#8220;personal&#8221; things for interested readers. I imagine the content will range from little tips with HTML and CSS to full-on tutorials in Object-Oriented ActionScript and PHP. Many of the things I&#8217;ve done are things I&#8217;ve learned from other blogs on the internet, but I find that one of the ways to help me <em>really </em>learn something is to take it and explain it to someone else in my own terms. While a lot of it will be for my own reinforcement, I hope that anyone who reads this will have something to take away as well. Please feel free to comment or <a title="Contact Me" href="mailto:beau@beauwatson.com">contact me</a>, <em>especially</em> if I&#8217;m wrong about something!</p>
]]></content:encoded>
			<wfw:commentRss>http://beauwatson.com/beaucode/2010/07/13/the-purpose-of-this-blog/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- This Quick Cache file was built for (  beauwatson.com/beaucode/feed/ ) in 0.31823 seconds, on May 21st, 2012 at 1:19 am UTC. -->
<!-- This Quick Cache file will automatically expire ( and be re-built automatically ) on May 21st, 2012 at 2:19 am UTC -->
