<?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>Flight School</title>
	<atom:link href="http://flightschool.acylt.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://flightschool.acylt.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Thu, 27 Oct 2011 03:37:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Javascript Closures and Memory Leaks</title>
		<link>http://flightschool.acylt.com/devnotes/javascript-closures-and-memory-leaks/</link>
		<comments>http://flightschool.acylt.com/devnotes/javascript-closures-and-memory-leaks/#comments</comments>
		<pubDate>Sat, 05 Mar 2011 01:24:35 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[DevNotes]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=471</guid>
		<description><![CDATA[This is me improving my understanding of closures in Javascript. Closures are a powerful part of the language but can also cause memory leaks, so here I&#8217;ll first define what they are, how they can be useful, followed by how they cause memory leaks. (I&#8217;m basically abridging with slight rewording what I read here and [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>This is me improving my understanding of closures in Javascript.  Closures are a powerful part of the language but can also cause memory leaks, so here I&#8217;ll first define what they are, how they can be useful, followed by how they cause memory leaks. (I&#8217;m basically abridging with slight rewording what I read <a href="http://zadasnotes.blogspot.com/2010/10/leaky-ie-javascript-closures.html" target="_blank">here</a> and <a href="http://stackoverflow.com/questions/111102/how-do-javascript-closures-work">here</a> so I take no credit for the content&#8230;).</p>
<h2>What is a closure?</h2>
<p>If you think a closure is a function within a function, you&#8217;re close but not quite there.  Here are two examples of the same code, the first is not a closure, the second is:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> notClosure<span style="color: #009900;">&#40;</span>x<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> tmp <span style="color: #339933;">=</span> <span style="color: #CC0000;">3</span><span style="color: #339933;">;</span>
    <span style="color: #003366; font-weight: bold;">function</span> foo<span style="color: #009900;">&#40;</span>y<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>x<span style="color: #339933;">+</span>y<span style="color: #339933;">+</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">++</span>tmp<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    foo<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">10</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
notClosure<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// Returns 16, no matter how many times you call it</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> closureExample<span style="color: #009900;">&#40;</span>x<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> tmp <span style="color: #339933;">=</span> <span style="color: #CC0000;">3</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #006600; font-style: italic;">// This returned function is the actual closure</span>
    <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>y<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>x<span style="color: #339933;">+</span>y<span style="color: #339933;">+</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">++</span>tmp<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #003366; font-weight: bold;">var</span> foo <span style="color: #339933;">=</span> closureExample<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
foo<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">10</span><span style="color: #009900;">&#41;</span> <span style="color: #006600; font-style: italic;">// Returns 16</span>
foo<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">10</span><span style="color: #009900;">&#41;</span> <span style="color: #006600; font-style: italic;">// Returns 17 because as a closure it had access to tmp</span></pre></td></tr></table></div>

<p>So the idea here is the first one didn&#8217;t return a function (or at least didn&#8217;t have an inner function accessible from outside), and the second one did.  What made it a closure is that the inner function <i>closed over</i> a variable from the outer function (in this case the variable tmp).  This allowed us to access tmp even though it wasn&#8217;t in the immediate scope of the inner function and it wasn&#8217;t in the scope of our foo call.  Another way of changing the non-closure function above into a closure would be:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// First example above modified to be a closure</span>
<span style="color: #003366; font-weight: bold;">var</span> foo<span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">function</span> nowaClosure<span style="color: #009900;">&#40;</span>x<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> tmp <span style="color: #339933;">=</span> <span style="color: #CC0000;">3</span><span style="color: #339933;">;</span>
    foo <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>y<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>x<span style="color: #339933;">+</span>y<span style="color: #339933;">+</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">++</span>tmp<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    foo<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">10</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
notClosure<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// Returns 16, no matter how many times you call it</span>
foo<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">10</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// Returns 17 because it has access to tmp again</span></pre></td></tr></table></div>

<p>Again in this example we had a pointer to a closure function so we could call it somewhere else and still have access to the variables it closed over.  Javascript gives a pointer in closures to the variables in its original scope to make this possible.  These pointers are what lead to the issues in memory leaks, which I&#8217;ll get to in a second.  I</p>
<h2>When are closures useful?</h2>
<p>Before that I want to show instances where closures are very useful.  When writing setTimeout&#8217;s often it is helpful to pass a parameter.  The problem is that writing something like:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// WRONG!!!</span>
setTimeout<span style="color: #009900;">&#40;</span>speak<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;hello&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> speak<span style="color: #009900;">&#40;</span>word<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>word<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>doesn&#8217;t work because setTimeout wants a reference to a function and since we&#8217;re trying to execute the function we&#8217;ll get the error that it&#8217;s not defined.  If instead we use a closure:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">setTimeout<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>speak<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;hello&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> speak<span style="color: #009900;">&#40;</span>word<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>word<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>it works great because inside the closure we refer to the function we&#8217;re calling (if the anonymous function trips you up this is the same):</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">setTimeout<span style="color: #009900;">&#40;</span>closure<span style="color: #339933;">,</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> closure<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    speak<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;hello&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #003366; font-weight: bold;">function</span> speak<span style="color: #009900;">&#40;</span>word<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>word<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<h2>How do closures cause memory leaks?</h2>
<p>Now, getting to the matter of memory leaks (this is a digest version of a more complete treatment <a href="http://zadasnotes.blogspot.com/2010/10/leaky-ie-javascript-closures.html" target="_blank">here</a>).  Javascript is a garbage collected language, which is why we don&#8217;t have to worry about allocating memory and all that jazz.  It decides to give memory back to the heap when all references to an object are gone, like the ones we get in closures.  However there are cases where there is circular reference (one object points to another that points back to the same) which is where the problems come in.  Most systems handle it well, but IE doesn&#8217;t because it has two separate garbage collectors, one for native Javascript and the other for HTML DOM.  So when native points to DOM, and DOM points back neither is aware of the other pointer and the circular reference slips under the radar.  Ergo memory leaks in IE.  For example:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> leakyFunction<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> domElement <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;div_id&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    domElement.<span style="color: #660066;">onclick</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #006600; font-style: italic;">// Closure over DOM element</span>
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;I'm a leak&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>There are a couple ways to fix this.  First the no closure route:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> notsoLeakyFunction<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> domElement <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;div_id&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    domElement.<span style="color: #660066;">onclick</span> <span style="color: #339933;">=</span> clickHandler<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> clickHandler<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;Not leaking anymore&quot;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Or just nullify the object after putting on the click event:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> notsoLeakyFunction<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> domElement <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;div_id&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    domElement.<span style="color: #660066;">onclick</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #006600; font-style: italic;">// Closure over DOM element</span>
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;I won't be a leak as soon as the circular ref is nullified below&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    domElement <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">;</span>  <span style="color: #006600; font-style: italic;">// Sigh of relief!  Circular avoided</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<div class="shr-publisher-471"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/devnotes/javascript-closures-and-memory-leaks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Window.open Window Events (like onload)</title>
		<link>http://flightschool.acylt.com/devnotes/window-open-onload-window-events/</link>
		<comments>http://flightschool.acylt.com/devnotes/window-open-onload-window-events/#comments</comments>
		<pubDate>Wed, 30 Mar 2011 23:34:43 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[DevNotes]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=483</guid>
		<description><![CDATA[Creating a cross browser compatible solution based on parent/child-window communication is surprisingly difficult (because of Microsoft, I wish IE would die already). This situation arises when using window.open, which returns a reference to the child window. Limited events are available from parent to child, due to security concerns, but for the most part it isn&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>Creating a cross browser compatible solution based on parent/child-window communication is surprisingly difficult (because of Microsoft, I wish IE would die already).  This situation arises when using window.open, which returns a reference to the child window.  Limited events are available from parent to child, due to security concerns, but for the most part it isn&#8217;t difficult to connect to window onblur, onfocus, and other events.</p>
<p>Something like:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> win <span style="color: #339933;">=</span> window.<span style="color: #000066;">open</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;my/file&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
win.<span style="color: #000066;">onload</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #006600; font-style: italic;">// Do something</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>would work in just about all browsers (Safari doesn&#8217;t open the window without an event for security, and IE just doesn&#8217;t work).</p>
<h2>Accessing Parent Window Functions</h2>
<p>Accessing parent scripts is easy since that wouldn&#8217;t create a security issue.  Any code can be accessed like this:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> parent <span style="color: #339933;">=</span> window.<span style="color: #660066;">opener</span><span style="color: #339933;">;</span>
parent.<span style="color: #660066;">globalFunction</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h2>IE child window onload &#038; running scripts on child windows</h2>
<p>So what about IE?  And what if we want to run scripts in the child window?  Both are possible but require a little bit of gymnastics to accomplish.  First the reason IE doesn&#8217;t allow you to connect to the onload event isn&#8217;t because it can&#8217;t be connected to, it&#8217;s because window.open may return before the window has actually been created.  Any manipulation will subsequently give you an error telling you the window you&#8217;re working with is &#8220;null or not defined&#8221;.  Instead you have to use setTimeout.  The example below includes both that technique as well as a technique for injecting javascript in the child which works on all browsers:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> win <span style="color: #339933;">=</span> window.<span style="color: #000066;">open</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'example.html'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> body<span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">function</span> ieLoaded<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    body <span style="color: #339933;">=</span> win.<span style="color: #660066;">document</span>.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;body&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>body<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">==</span><span style="color: #003366; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #006600; font-style: italic;">// Page isn't ready yet!</span>
        setTimeout<span style="color: #009900;">&#40;</span>ieLoaded<span style="color: #339933;">,</span> <span style="color: #CC0000;">10</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #000066; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span>
        <span style="color: #006600; font-style: italic;">// Here you can inject javascript if you like</span>
        <span style="color: #003366; font-weight: bold;">var</span> n <span style="color: #339933;">=</span> win.<span style="color: #660066;">document</span>.<span style="color: #660066;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;script&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        n.<span style="color: #660066;">src</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;injectableScript.js&quot;</span><span style="color: #339933;">;</span>
        body.<span style="color: #660066;">appendChild</span><span style="color: #009900;">&#40;</span>n<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
ieLoaded<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<div class="shr-publisher-483"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/devnotes/window-open-onload-window-events/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Top Ten Books!</title>
		<link>http://flightschool.acylt.com/humanz/top-ten-books/</link>
		<comments>http://flightschool.acylt.com/humanz/top-ten-books/#comments</comments>
		<pubDate>Sun, 17 Apr 2011 23:44:56 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[Humanz]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=487</guid>
		<description><![CDATA[Top ten books of all time according to some great authors: Anna Karenina by Leo Tolstoy Madame Bovary by Gustave Flaubert War and Peace by Leo Tolstoy Lolita by Vladimir Nabokov The Adventures of Huckleberry Finn by Mark Twain Hamlet by William Shakespeare The Great Gatsby F. Scott Fitzgerald In Search of Lost Time by [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>Top ten books of all time according to some great authors:</p>
<p>Anna Karenina by Leo Tolstoy<br />
Madame Bovary by Gustave Flaubert<br />
War and Peace by Leo Tolstoy<br />
Lolita by Vladimir Nabokov<br />
The Adventures of Huckleberry Finn by Mark Twain<br />
Hamlet by William Shakespeare<br />
The Great Gatsby F. Scott Fitzgerald<br />
In Search of Lost Time by Marcel Proust<br />
The Stories of Anton Chekhov by Anton Chekhov<br />
Middlemarch by George Eliot</p>
<p>Of course now I have to read the ones on this list that I haven&#8217;t yet.</p>
<p>This comes from these articles: <a title="Times article" href="http://www.time.com/time/arts/article/0,8599,1578073,00.html#ixzz1JNPALQ8q">http://www.time.com/time/arts/article/0,8599,1578073,00.html#ixzz1JNPALQ8q</a>, <a title="Top Ten" href="http://www.toptenbooks.net/newsingle.cgi?1270583875">http://www.toptenbooks.net/newsingle.cgi?1270583875</a>.</p>
<div class="shr-publisher-487"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/humanz/top-ten-books/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ford-Fulkerson &#8211; Capacity Scaling &#8211; C++</title>
		<link>http://flightschool.acylt.com/devnotes/ford-fulkerson-capacity-scaling-c/</link>
		<comments>http://flightschool.acylt.com/devnotes/ford-fulkerson-capacity-scaling-c/#comments</comments>
		<pubDate>Fri, 06 May 2011 02:23:25 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[DevNotes]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=490</guid>
		<description><![CDATA[I recently implemented Ford-Fulkerson&#8217;s using Capacity Scaling in C++ and I thought I&#8217;d put it up. It&#8217;s not perfect but it works alright. First I have a graph class that can keep track of edges and edge weights as well as a source and sink node. My assumptions are that vertices start at 1 and [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>I recently implemented Ford-Fulkerson&#8217;s using Capacity Scaling in  C++ and I thought I&#8217;d put it up.  It&#8217;s not perfect but it works alright.  First I have a graph class that can keep track of edges and edge weights as well as a source and sink node.  My assumptions are that vertices start at 1 and are contiguous.  The edges are numbered that way too.  I only care about positive edge weights because those are the only that could have positive flow come across them.  So here it is:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
</pre></td><td class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #ff0000; font-style: italic;">/* Summary:
 *		All of the edges and verteces are consecutive so I
 *		can use an array to store them.
 *
 *		The graph will be initialized with a dyn allocated
 *		array of
*/</span>
&nbsp;
<span style="color: #0000ff;">struct</span> nodeEdge <span style="color: #008000;">&#123;</span>
	<span style="color: #666666;">// Summary:</span>
	<span style="color: #666666;">//		Each node actually only needs to be identified</span>
	<span style="color: #666666;">//		by index.  This is meant to pair it with an edge</span>
	<span style="color: #666666;">//		weight in the graph.</span>
	nodeEdge<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> v, <span style="color: #0000ff;">int</span> w<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	nodeEdge<span style="color: #000040;">*</span> next<span style="color: #008080;">;</span>
	<span style="color: #0000ff;">int</span> weight<span style="color: #008080;">;</span>
	<span style="color: #0000ff;">int</span> vertex<span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span><span style="color: #008080;">;</span>
&nbsp;
<span style="color: #0000ff;">class</span> Graph	<span style="color: #008000;">&#123;</span>
	<span style="color: #666666;">// Summary:</span>
	<span style="color: #666666;">//		The graph has a dyn allocated array of size nV.</span>
	<span style="color: #666666;">//		Each index is the vertex it represents, and out of</span>
	<span style="color: #666666;">//		it is a pointer to a list of nodes with their weight</span>
	<span style="color: #666666;">//		in that adj list.</span>
	<span style="color: #0000ff;">public</span><span style="color: #008080;">:</span>
		<span style="color: #0000ff;">int</span> nV, nE, s, t<span style="color: #008080;">;</span>
		nodeEdge <span style="color: #000040;">**</span>nodes<span style="color: #008080;">;</span>
		Graph<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> nV,<span style="color: #0000ff;">int</span> nE<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
		Graph<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">const</span> Graph<span style="color: #000040;">*</span> other<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
		Graph<span style="color: #000040;">*</span> bottleneckGraph<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> b<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
		~Graph<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
		<span style="color: #0000ff;">void</span> setSourceSink<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> s,<span style="color: #0000ff;">int</span> t<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
		<span style="color: #0000ff;">void</span> addEdge<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> u, nodeEdge<span style="color: #000040;">*</span> v<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
		<span style="color: #0000ff;">void</span> removeEdge<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> u, nodeEdge<span style="color: #000040;">*</span> v<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
		<span style="color: #0000ff;">int</span> updateEdgeWeight<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> u, <span style="color: #0000ff;">int</span> v, <span style="color: #0000ff;">int</span> w<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
		<span style="color: #0000ff;">void</span> toString<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">private</span><span style="color: #008080;">:</span>
		<span style="color: #0000ff;">int</span> updateWeight<span style="color: #008000;">&#40;</span>nodeEdge<span style="color: #000040;">*</span> u, <span style="color: #0000ff;">int</span> v, <span style="color: #0000ff;">int</span> w<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
		<span style="color: #0000ff;">void</span> insertEdge<span style="color: #008000;">&#40;</span>nodeEdge<span style="color: #000040;">*</span> u, nodeEdge<span style="color: #000040;">*</span> v<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
		<span style="color: #0000ff;">void</span> extractEdge<span style="color: #008000;">&#40;</span>nodeEdge<span style="color: #000040;">*</span> u, nodeEdge<span style="color: #000040;">*</span> v<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
		<span style="color: #0000ff;">void</span> deleteNodes<span style="color: #008000;">&#40;</span>nodeEdge <span style="color: #000040;">*</span>n<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span><span style="color: #008080;">;</span></pre></td></tr></table></div>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
</pre></td><td class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #339900;">#include &lt;cstddef&gt;</span>
<span style="color: #339900;">#include &lt;iostream&gt;</span>
<span style="color: #339900;">#include &quot;Graph.h&quot;</span>
<span style="color: #0000ff;">using</span> <span style="color: #0000ff;">namespace</span> std<span style="color: #008080;">;</span>
&nbsp;
nodeEdge<span style="color: #008080;">::</span><span style="color: #007788;">nodeEdge</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> v,<span style="color: #0000ff;">int</span> w<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span>
	weight <span style="color: #000080;">=</span> w<span style="color: #008080;">;</span>
	vertex <span style="color: #000080;">=</span> v<span style="color: #008080;">;</span>
	next <span style="color: #000080;">=</span> <span style="color: #0000ff;">NULL</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span><span style="color: #008080;">;</span>
&nbsp;
Graph<span style="color: #008080;">::</span><span style="color: #007788;">Graph</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> nV,<span style="color: #0000ff;">int</span> nE<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span>
	this<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>nV <span style="color: #000080;">=</span> nV<span style="color: #000040;">+</span><span style="color: #0000dd;">1</span><span style="color: #008080;">;</span> <span style="color: #666666;">// Offsetting by 1 b/c node index starts at 1</span>
	this<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>nE <span style="color: #000080;">=</span> nE<span style="color: #008080;">;</span>
&nbsp;
	nodes <span style="color: #000080;">=</span> <span style="color: #0000dd;">new</span> nodeEdge<span style="color: #000040;">*</span><span style="color: #008000;">&#91;</span>this<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>nV<span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
	nodeEdge<span style="color: #000040;">*</span> edge <span style="color: #000080;">=</span> <span style="color: #0000dd;">new</span> nodeEdge<span style="color: #008000;">&#40;</span>nE, <span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">for</span> <span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> i<span style="color: #000080;">=</span><span style="color: #0000dd;">0</span><span style="color: #008080;">;</span> i<span style="color: #000080;">&lt;</span>this<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>nV<span style="color: #008080;">;</span> i<span style="color: #000040;">++</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
		nodes<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span> <span style="color: #000080;">=</span> i<span style="color: #000080;">==</span><span style="color: #0000dd;">0</span> <span style="color: #008080;">?</span> edge <span style="color: #008080;">:</span> <span style="color: #0000ff;">NULL</span><span style="color: #008080;">;</span>
		<span style="color: #666666;">//cout &lt;&lt; &quot;Initializing: &quot; &lt;&lt; i &lt;&lt; &quot; val: &quot; &lt;&lt; nodes[i] &lt;&lt; endl;</span>
	<span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span><span style="color: #008080;">;</span>
&nbsp;
Graph<span style="color: #008080;">::</span><span style="color: #007788;">Graph</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">const</span> Graph<span style="color: #000040;">*</span> other<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span>
	nV <span style="color: #000080;">=</span> other<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>nV<span style="color: #008080;">;</span>
	nE <span style="color: #000080;">=</span> other<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>nE<span style="color: #008080;">;</span>
	s <span style="color: #000080;">=</span> other<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>s<span style="color: #008080;">;</span>
	t <span style="color: #000080;">=</span> other<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>t<span style="color: #008080;">;</span>
	nodes <span style="color: #000080;">=</span> <span style="color: #0000dd;">new</span> nodeEdge<span style="color: #000040;">*</span><span style="color: #008000;">&#91;</span>nV<span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">for</span> <span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> i <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span> i <span style="color: #000080;">&lt;</span> nV<span style="color: #008080;">;</span> i<span style="color: #000040;">++</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
		nodeEdge<span style="color: #000040;">*</span> n <span style="color: #000080;">=</span> other<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>nodes<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
		<span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>n<span style="color: #000040;">!</span><span style="color: #000080;">=</span><span style="color: #0000ff;">NULL</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
			nodeEdge<span style="color: #000040;">*</span> o <span style="color: #000080;">=</span> nodes<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span> <span style="color: #000080;">=</span> <span style="color: #0000dd;">new</span> nodeEdge<span style="color: #008000;">&#40;</span>n<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>vertex, n<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>weight<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
			<span style="color: #0000ff;">while</span> <span style="color: #008000;">&#40;</span>n<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #000040;">!</span><span style="color: #000080;">=</span><span style="color: #0000ff;">NULL</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
				o<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next <span style="color: #000080;">=</span> <span style="color: #0000dd;">new</span> nodeEdge<span style="color: #008000;">&#40;</span>n<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>vertex, n<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>weight<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
				o <span style="color: #000080;">=</span> o<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #008080;">;</span>
				n <span style="color: #000080;">=</span> n<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #008080;">;</span>
			<span style="color: #008000;">&#125;</span>
		<span style="color: #008000;">&#125;</span> <span style="color: #0000ff;">else</span> <span style="color: #008000;">&#123;</span>
			nodes<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #000080;">=</span><span style="color: #0000ff;">NULL</span><span style="color: #008080;">;</span>
		<span style="color: #008000;">&#125;</span>
	<span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
Graph<span style="color: #000040;">*</span> Graph<span style="color: #008080;">::</span><span style="color: #007788;">bottleneckGraph</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> b<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span>
	Graph<span style="color: #000040;">*</span> g <span style="color: #000080;">=</span> <span style="color: #0000dd;">new</span> Graph<span style="color: #008000;">&#40;</span>nV<span style="color: #000040;">-</span><span style="color: #0000dd;">1</span>,nE<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	g<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>s <span style="color: #000080;">=</span> s<span style="color: #008080;">;</span>
	g<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>t <span style="color: #000080;">=</span> t<span style="color: #008080;">;</span>
	<span style="color: #0000ff;">for</span> <span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> i<span style="color: #000080;">=</span><span style="color: #0000dd;">0</span><span style="color: #008080;">;</span> i<span style="color: #000080;">&lt;</span>nV<span style="color: #008080;">;</span> i<span style="color: #000040;">++</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
		nodeEdge<span style="color: #000040;">*</span> n <span style="color: #000080;">=</span> nodes<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
		<span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>n<span style="color: #000040;">!</span><span style="color: #000080;">=</span><span style="color: #0000ff;">NULL</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
			<span style="color: #666666;">// Only copy nodes with high enough weight</span>
			<span style="color: #0000ff;">while</span> <span style="color: #008000;">&#40;</span>n<span style="color: #000040;">!</span><span style="color: #000080;">=</span><span style="color: #0000ff;">NULL</span> <span style="color: #000040;">&amp;&amp;</span> n<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>weight<span style="color: #000080;">&lt;</span>b<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
				n <span style="color: #000080;">=</span> n<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #008080;">;</span>
			<span style="color: #008000;">&#125;</span>
			g<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>nodes<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span> <span style="color: #000080;">=</span> n<span style="color: #000080;">==</span><span style="color: #0000ff;">NULL</span> <span style="color: #008080;">?</span> <span style="color: #0000ff;">NULL</span> <span style="color: #008080;">:</span> <span style="color: #0000dd;">new</span> nodeEdge<span style="color: #008000;">&#40;</span>n<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>vertex, n<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>weight<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
			nodeEdge<span style="color: #000040;">*</span> o <span style="color: #000080;">=</span> g<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>nodes<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
			<span style="color: #0000ff;">while</span> <span style="color: #008000;">&#40;</span>n<span style="color: #000040;">!</span><span style="color: #000080;">=</span><span style="color: #0000ff;">NULL</span> <span style="color: #000040;">&amp;&amp;</span> n<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #000040;">!</span><span style="color: #000080;">=</span><span style="color: #0000ff;">NULL</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
				<span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>n<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>weight<span style="color: #000080;">&gt;=</span>b<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
					o<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next <span style="color: #000080;">=</span> <span style="color: #0000dd;">new</span> nodeEdge<span style="color: #008000;">&#40;</span>n<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>vertex, n<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>weight<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
					o <span style="color: #000080;">=</span> o<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #008080;">;</span>
					n <span style="color: #000080;">=</span> n<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #008080;">;</span>
				<span style="color: #008000;">&#125;</span> <span style="color: #0000ff;">else</span> <span style="color: #008000;">&#123;</span>
					<span style="color: #666666;">// Skip this one, not high enough weight</span>
					n <span style="color: #000080;">=</span> n<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #008080;">;</span>
				<span style="color: #008000;">&#125;</span>
			<span style="color: #008000;">&#125;</span>
		<span style="color: #008000;">&#125;</span> <span style="color: #0000ff;">else</span> <span style="color: #008000;">&#123;</span>
			g<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>nodes<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span> <span style="color: #000080;">=</span> <span style="color: #0000ff;">NULL</span><span style="color: #008080;">;</span>
		<span style="color: #008000;">&#125;</span>
	<span style="color: #008000;">&#125;</span>
	<span style="color: #0000ff;">return</span> g<span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
Graph<span style="color: #008080;">::</span>~Graph<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span>
	<span style="color: #0000ff;">for</span> <span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> i<span style="color: #000080;">=</span><span style="color: #0000dd;">0</span><span style="color: #008080;">;</span> i <span style="color: #000080;">&lt;</span> nV<span style="color: #008080;">;</span> i<span style="color: #000040;">++</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
		<span style="color: #666666;">// Go through nodes and tear down linked</span>
		<span style="color: #666666;">// list (each node should be from the heap)</span>
		<span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>nodes<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #000040;">!</span><span style="color: #000080;">=</span><span style="color: #0000ff;">NULL</span><span style="color: #008000;">&#41;</span> deleteNodes<span style="color: #008000;">&#40;</span>nodes<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #008000;">&#125;</span>
	<span style="color: #0000dd;">delete</span><span style="color: #008000;">&#40;</span>nodes<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span><span style="color: #008080;">;</span>
&nbsp;
<span style="color: #0000ff;">void</span> Graph<span style="color: #008080;">::</span><span style="color: #007788;">deleteNodes</span><span style="color: #008000;">&#40;</span>nodeEdge <span style="color: #000040;">*</span>n<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span>
	<span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>n<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #000040;">!</span><span style="color: #000080;">=</span><span style="color: #0000ff;">NULL</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
		deleteNodes<span style="color: #008000;">&#40;</span>n<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #008000;">&#125;</span><span style="color: #008080;">;</span>
	<span style="color: #0000dd;">delete</span> n<span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span><span style="color: #008080;">;</span>
&nbsp;
<span style="color: #0000ff;">void</span> Graph<span style="color: #008080;">::</span><span style="color: #007788;">setSourceSink</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> s,<span style="color: #0000ff;">int</span> t<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span>
	<span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #0000dd;">1</span> <span style="color: #000080;">&gt;</span> s <span style="color: #000040;">||</span> nV <span style="color: #000080;">&lt;=</span> s <span style="color: #000040;">||</span> <span style="color: #0000dd;">1</span> <span style="color: #000080;">&gt;</span> t <span style="color: #000040;">||</span> nV <span style="color: #000080;">&lt;=</span> t<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
		<span style="color: #0000dd;">cout</span> <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;Attempting to set a source or sink node that is outside the node range&quot;</span> <span style="color: #000080;">&lt;&lt;</span> endl<span style="color: #008080;">;</span>
		<span style="color: #0000dd;">exit</span><span style="color: #008000;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #008000;">&#125;</span>
	this<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>s <span style="color: #000080;">=</span> s<span style="color: #008080;">;</span>
	this<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>t <span style="color: #000080;">=</span> t<span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span><span style="color: #008080;">;</span>
&nbsp;
<span style="color: #0000ff;">void</span> Graph<span style="color: #008080;">::</span><span style="color: #007788;">addEdge</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> u, nodeEdge<span style="color: #000040;">*</span> v<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span>
	<span style="color: #666666;">// summary:</span>
	<span style="color: #666666;">//		This takes an edge and tries to insert it.</span>
	<span style="color: #666666;">//		If there is no linked list, this starts it,</span>
	<span style="color: #666666;">//		otherwise it finds the end with insertEdge</span>
	<span style="color: #666666;">//</span>
	<span style="color: #666666;">//		Currently there is no check for double edges</span>
	<span style="color: #666666;">//		as this was not a requirements</span>
	<span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span><span style="color: #0000dd;">1</span> <span style="color: #000080;">&gt;</span> u <span style="color: #000040;">||</span> nV <span style="color: #000080;">&lt;=</span> u<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span>
		<span style="color: #0000dd;">cout</span> <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;Attempting to add an edge with a non-existant vertex&quot;</span> <span style="color: #000080;">&lt;&lt;</span> endl<span style="color: #008080;">;</span>
		<span style="color: #0000dd;">exit</span><span style="color: #008000;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #008000;">&#125;</span>
	<span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>nodes<span style="color: #008000;">&#91;</span>u<span style="color: #008000;">&#93;</span><span style="color: #000080;">==</span><span style="color: #0000ff;">NULL</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span>
		<span style="color: #666666;">// This is the first in the list</span>
		nodes<span style="color: #008000;">&#91;</span>u<span style="color: #008000;">&#93;</span> <span style="color: #000080;">=</span> v<span style="color: #008080;">;</span>
	<span style="color: #008000;">&#125;</span> <span style="color: #0000ff;">else</span> <span style="color: #008000;">&#123;</span>
		insertEdge<span style="color: #008000;">&#40;</span>nodes<span style="color: #008000;">&#91;</span>u<span style="color: #008000;">&#93;</span>, v<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #0000ff;">void</span> Graph<span style="color: #008080;">::</span><span style="color: #007788;">removeEdge</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> u, nodeEdge<span style="color: #000040;">*</span> v<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span>
	<span style="color: #666666;">// summary:</span>
	<span style="color: #666666;">//		We have a node pointer to remove from list</span>
	<span style="color: #666666;">//		of vertex v.  Easy if it's the end of the list</span>
	<span style="color: #666666;">//		rewire if it's not.  If it's the only one...</span>
	nodeEdge<span style="color: #000040;">*</span> tmp <span style="color: #000080;">=</span> <span style="color: #0000ff;">NULL</span><span style="color: #008080;">;</span>
&nbsp;
	<span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>nodes<span style="color: #008000;">&#91;</span>u<span style="color: #008000;">&#93;</span><span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>vertex <span style="color: #000080;">==</span> v<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>vertex<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
		<span style="color: #666666;">// This is if it's the first one</span>
		tmp <span style="color: #000080;">=</span> nodes<span style="color: #008000;">&#91;</span>u<span style="color: #008000;">&#93;</span><span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next <span style="color: #000040;">!</span><span style="color: #000080;">=</span> <span style="color: #0000ff;">NULL</span> <span style="color: #008080;">?</span> nodes<span style="color: #008000;">&#91;</span>u<span style="color: #008000;">&#93;</span><span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next <span style="color: #008080;">:</span> <span style="color: #0000ff;">NULL</span><span style="color: #008080;">;</span>
		<span style="color: #0000dd;">delete</span> nodes<span style="color: #008000;">&#91;</span>u<span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
		nodes<span style="color: #008000;">&#91;</span>u<span style="color: #008000;">&#93;</span> <span style="color: #000080;">=</span> tmp<span style="color: #008080;">;</span>
		<span style="color: #0000ff;">return</span><span style="color: #008080;">;</span>
	<span style="color: #008000;">&#125;</span>
	extractEdge<span style="color: #008000;">&#40;</span>nodes<span style="color: #008000;">&#91;</span>u<span style="color: #008000;">&#93;</span>, v<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #0000ff;">int</span> Graph<span style="color: #008080;">::</span><span style="color: #007788;">updateEdgeWeight</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> u, <span style="color: #0000ff;">int</span> v, <span style="color: #0000ff;">int</span> w<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span>
	<span style="color: #666666;">// Returns 0 if it needed to create an edge, 1 if it updates</span>
&nbsp;
	nodeEdge<span style="color: #000040;">*</span> nu <span style="color: #000080;">=</span> nodes<span style="color: #008000;">&#91;</span>u<span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>nu <span style="color: #000080;">==</span> <span style="color: #0000ff;">NULL</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span>
		<span style="color: #666666;">// No edge yet, create it!</span>
		nodes<span style="color: #008000;">&#91;</span>u<span style="color: #008000;">&#93;</span> <span style="color: #000080;">=</span> <span style="color: #0000dd;">new</span> nodeEdge<span style="color: #008000;">&#40;</span>v, w<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
		<span style="color: #0000ff;">return</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>
	<span style="color: #008000;">&#125;</span> <span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>nu<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>vertex <span style="color: #000080;">==</span> v<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
		nu<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>weight <span style="color: #000040;">+</span><span style="color: #000080;">=</span> w<span style="color: #008080;">;</span>
		<span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>nu<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>weight <span style="color: #000080;">==</span> <span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
			<span style="color: #666666;">// Remove me!</span>
			removeEdge<span style="color: #008000;">&#40;</span>u, nu<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
		<span style="color: #008000;">&#125;</span>
		<span style="color: #0000ff;">return</span> <span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>
	<span style="color: #008000;">&#125;</span> <span style="color: #0000ff;">else</span> <span style="color: #008000;">&#123;</span>
		<span style="color: #0000ff;">return</span> updateWeight<span style="color: #008000;">&#40;</span>nu, v, w<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #0000ff;">void</span> Graph<span style="color: #008080;">::</span><span style="color: #007788;">toString</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span>
	<span style="color: #0000dd;">cout</span> <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;====Graph Details====&quot;</span> <span style="color: #000080;">&lt;&lt;</span> endl<span style="color: #008080;">;</span>
	<span style="color: #0000dd;">cout</span> <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;Source: &quot;</span> <span style="color: #000080;">&lt;&lt;</span> s <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot; Sink: &quot;</span> <span style="color: #000080;">&lt;&lt;</span> t <span style="color: #000080;">&lt;&lt;</span> endl<span style="color: #008080;">;</span>
	<span style="color: #0000dd;">cout</span> <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;----Adj List---------&quot;</span> <span style="color: #000080;">&lt;&lt;</span> endl<span style="color: #008080;">;</span>
	<span style="color: #0000ff;">for</span> <span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> i<span style="color: #000080;">=</span><span style="color: #0000dd;">1</span><span style="color: #008080;">;</span> i <span style="color: #000080;">&lt;</span> nV<span style="color: #008080;">;</span> i<span style="color: #000040;">++</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
		<span style="color: #0000dd;">cout</span> <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;Node &quot;</span> <span style="color: #000080;">&lt;&lt;</span> i <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;: &quot;</span> <span style="color: #000080;">&lt;&lt;</span> endl<span style="color: #008080;">;</span>
		nodeEdge<span style="color: #000040;">*</span> n <span style="color: #000080;">=</span> nodes<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
		<span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>n<span style="color: #000080;">==</span><span style="color: #0000ff;">NULL</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span>
			<span style="color: #0000dd;">cout</span> <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;NULL&quot;</span> <span style="color: #000080;">&lt;&lt;</span> endl<span style="color: #008080;">;</span>
		<span style="color: #008000;">&#125;</span> <span style="color: #0000ff;">else</span> <span style="color: #008000;">&#123;</span>
			<span style="color: #0000ff;">while</span><span style="color: #008000;">&#40;</span>n<span style="color: #000040;">!</span><span style="color: #000080;">=</span><span style="color: #0000ff;">NULL</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
				<span style="color: #666666;">// Verify something first</span>
				<span style="color: #0000dd;">cout</span> <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;v: &quot;</span> <span style="color: #000080;">&lt;&lt;</span> n<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>vertex <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot; w: &quot;</span> <span style="color: #000080;">&lt;&lt;</span> n<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>weight <span style="color: #000080;">&lt;&lt;</span> endl<span style="color: #008080;">;</span>
				n <span style="color: #000080;">=</span> n<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #008080;">;</span>
			<span style="color: #008000;">&#125;</span><span style="color: #008080;">;</span>
		<span style="color: #008000;">&#125;</span>
	<span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #0000ff;">int</span> Graph<span style="color: #008080;">::</span><span style="color: #007788;">updateWeight</span><span style="color: #008000;">&#40;</span>nodeEdge<span style="color: #000040;">*</span> u, <span style="color: #0000ff;">int</span> v, <span style="color: #0000ff;">int</span> w<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span>
	<span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>u<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #000080;">==</span><span style="color: #0000ff;">NULL</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
		<span style="color: #666666;">// I'm next</span>
		u<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next <span style="color: #000080;">=</span> <span style="color: #0000dd;">new</span> nodeEdge<span style="color: #008000;">&#40;</span>v, w<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
		<span style="color: #0000ff;">return</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>
	<span style="color: #008000;">&#125;</span> <span style="color: #0000ff;">else</span> <span style="color: #008000;">&#123;</span>
		<span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>u<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>vertex <span style="color: #000080;">==</span> v<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
			u<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>weight <span style="color: #000040;">+</span><span style="color: #000080;">=</span> w<span style="color: #008080;">;</span>
			<span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>u<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>weight <span style="color: #000080;">==</span> <span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
				<span style="color: #666666;">// Remove me!</span>
				extractEdge<span style="color: #008000;">&#40;</span>u, u<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
			<span style="color: #008000;">&#125;</span>
			<span style="color: #0000ff;">return</span> <span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>
		<span style="color: #008000;">&#125;</span> <span style="color: #0000ff;">else</span> <span style="color: #008000;">&#123;</span>
			<span style="color: #0000ff;">return</span> updateWeight<span style="color: #008000;">&#40;</span>u<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next, v, w<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
		<span style="color: #008000;">&#125;</span>
	<span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #0000ff;">void</span> Graph<span style="color: #008080;">::</span><span style="color: #007788;">insertEdge</span><span style="color: #008000;">&#40;</span>nodeEdge<span style="color: #000040;">*</span> u, nodeEdge<span style="color: #000040;">*</span> v<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span>
	<span style="color: #666666;">// summary:</span>
	<span style="color: #666666;">//		This takes a node, already inserted, and sees</span>
	<span style="color: #666666;">//		if it's the last in the linked list.  If not</span>
	<span style="color: #666666;">//		it will call this recursively with the next</span>
	<span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>u<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next <span style="color: #000080;">==</span> <span style="color: #0000ff;">NULL</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span>
		<span style="color: #666666;">// Insert me here</span>
		u<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next <span style="color: #000080;">=</span> v<span style="color: #008080;">;</span>
	<span style="color: #008000;">&#125;</span> <span style="color: #0000ff;">else</span> <span style="color: #008000;">&#123;</span>
		<span style="color: #666666;">// Look at the next one</span>
		insertEdge<span style="color: #008000;">&#40;</span>u<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next, v<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #0000ff;">void</span> Graph<span style="color: #008080;">::</span><span style="color: #007788;">extractEdge</span><span style="color: #008000;">&#40;</span>nodeEdge<span style="color: #000040;">*</span> u, nodeEdge<span style="color: #000040;">*</span> v<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span>
	<span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>u<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next <span style="color: #000080;">==</span> <span style="color: #0000ff;">NULL</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
		<span style="color: #0000dd;">cout</span> <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;Error, didn't find the node&quot;</span> <span style="color: #000080;">&lt;&lt;</span> endl<span style="color: #008080;">;</span>
		<span style="color: #0000dd;">exit</span><span style="color: #008000;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #008000;">&#125;</span>
	<span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>u<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>vertex <span style="color: #000080;">==</span> v<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>vertex<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
		nodeEdge <span style="color: #000040;">*</span>tmp <span style="color: #000080;">=</span> u<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #008080;">;</span>
		<span style="color: #0000dd;">delete</span> u<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #008080;">;</span>
		u<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next <span style="color: #000080;">=</span> tmp<span style="color: #008080;">;</span>
	<span style="color: #008000;">&#125;</span> <span style="color: #0000ff;">else</span> <span style="color: #008000;">&#123;</span>
		u <span style="color: #000080;">=</span> u<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #008080;">;</span>
		extractEdge<span style="color: #008000;">&#40;</span>u, v<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>That&#8217;s the hardest part of implementing Ford-Fulkerson.  After that the algorithm is pretty simple.  First I needed to find a path and the easiest way to do that was a specialized version of breadth first search.  My implementation returns an array with the path and weights if minCut is set to false, and the minCut if it is true (just so I could output the min cut at the end if I want to).  The bottleneck function finds the minimum edge weight on the discovered path which maxFlow uses to implement Ford-Fulkerson.  Here it is:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
</pre></td><td class="code"><pre class="cpp" style="font-family:monospace;"><span style="color: #339900;">#include &quot;Graph.h&quot;</span>
<span style="color: #339900;">#include &lt;iostream&gt;</span>
<span style="color: #339900;">#include &lt;fstream&gt;</span>
<span style="color: #339900;">#include &lt;sstream&gt;</span>
<span style="color: #339900;">#include &lt;algorithm&gt;</span>
<span style="color: #339900;">#include &lt;vector&gt;</span>
<span style="color: #339900;">#include &lt;string&gt;</span>
<span style="color: #339900;">#include &lt;iterator&gt;</span>
<span style="color: #339900;">#include &lt;queue&gt;</span>
<span style="color: #0000ff;">using</span> <span style="color: #0000ff;">namespace</span> std<span style="color: #008080;">;</span>
&nbsp;
&nbsp;
<span style="color: #ff0000; font-style: italic;">/** Summary:
 *		A special version of BFS which returns useful
 *		information for maxFlow: path with associated
 *		weights.  If minCut is set to true, BFS will
 *		instead return the set of nodes it can reach
 */</span>
&nbsp;
<span style="color: #0000ff;">int</span><span style="color: #000040;">*</span> BFS<span style="color: #008000;">&#40;</span>Graph <span style="color: #000040;">*</span>g, <span style="color: #0000ff;">int</span> s, <span style="color: #0000ff;">int</span> t, <span style="color: #0000ff;">bool</span> minCut<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span>
	<span style="color: #0000ff;">int</span> nV <span style="color: #000080;">=</span> g<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>nV<span style="color: #008080;">;</span>
	queue<span style="color: #000080;">&lt;</span><span style="color: #0000ff;">int</span><span style="color: #000080;">&gt;</span> visit<span style="color: #008080;">;</span>
	<span style="color: #0000ff;">bool</span> found <span style="color: #000080;">=</span> <span style="color: #0000ff;">false</span><span style="color: #008080;">;</span>
&nbsp;
	<span style="color: #666666;">// Initialize values to be used in the search</span>
	<span style="color: #666666;">// keeping track of parent and whether node has</span>
	<span style="color: #666666;">// been visited or not.</span>
	<span style="color: #0000ff;">int</span><span style="color: #000040;">*</span> visited <span style="color: #000080;">=</span> <span style="color: #0000dd;">new</span> <span style="color: #0000ff;">int</span><span style="color: #008000;">&#91;</span>nV<span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">int</span><span style="color: #000040;">*</span> parent <span style="color: #000080;">=</span> <span style="color: #0000dd;">new</span> <span style="color: #0000ff;">int</span><span style="color: #008000;">&#91;</span>nV<span style="color: #000040;">*</span><span style="color: #0000dd;">2</span><span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span> <span style="color: #666666;">// This is a horrible hack of making a 2D array</span>
	<span style="color: #0000ff;">int</span><span style="color: #000040;">*</span> path <span style="color: #000080;">=</span> <span style="color: #0000dd;">new</span> <span style="color: #0000ff;">int</span><span style="color: #008000;">&#91;</span>nV<span style="color: #000040;">*</span><span style="color: #0000dd;">2</span><span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">for</span> <span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> i<span style="color: #000080;">=</span><span style="color: #0000dd;">0</span><span style="color: #008080;">;</span> i<span style="color: #000080;">&lt;</span>nV<span style="color: #008080;">;</span> i<span style="color: #000040;">++</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
		<span style="color: #666666;">// Visited: 0 hasn't been visited, 1 is on the frontier, 2 is done</span>
		visited<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span> <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>
		parent<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span> <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span> <span style="color: #666666;">//Only worry about 0 - keys, if a key is set I set the weight</span>
		path<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span> <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>
	<span style="color: #008000;">&#125;</span>
&nbsp;
	<span style="color: #666666;">// Enqueue the entry node, s, and search for t</span>
	visit.<span style="color: #007788;">push</span><span style="color: #008000;">&#40;</span>s<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	visited<span style="color: #008000;">&#91;</span>s<span style="color: #008000;">&#93;</span> <span style="color: #000080;">=</span> <span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">while</span> <span style="color: #008000;">&#40;</span><span style="color: #000040;">!</span>visit.<span style="color: #007788;">empty</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
		<span style="color: #666666;">// Search</span>
		<span style="color: #0000ff;">int</span> u <span style="color: #000080;">=</span> visit.<span style="color: #007788;">front</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
		visit.<span style="color: #007788;">pop</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
		<span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>u<span style="color: #000080;">==</span>t<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span>
			<span style="color: #666666;">// Found it - build path array.</span>
			found <span style="color: #000080;">=</span> <span style="color: #0000ff;">true</span><span style="color: #008080;">;</span>
			<span style="color: #0000ff;">int</span> c <span style="color: #000080;">=</span> t<span style="color: #008080;">;</span>
			<span style="color: #0000ff;">int</span> p <span style="color: #000080;">=</span> parent<span style="color: #008000;">&#91;</span>t<span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
			<span style="color: #0000ff;">do</span> <span style="color: #008000;">&#123;</span>
				path<span style="color: #008000;">&#91;</span>c<span style="color: #008000;">&#93;</span> <span style="color: #000080;">=</span> p<span style="color: #008080;">;</span>
				path<span style="color: #008000;">&#91;</span>c<span style="color: #000040;">+</span>nV<span style="color: #008000;">&#93;</span> <span style="color: #000080;">=</span> parent<span style="color: #008000;">&#91;</span>c<span style="color: #000040;">+</span>nV<span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
				c <span style="color: #000080;">=</span> p<span style="color: #008080;">;</span>
				p <span style="color: #000080;">=</span> parent<span style="color: #008000;">&#91;</span>c<span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
			<span style="color: #008000;">&#125;</span> <span style="color: #0000ff;">while</span> <span style="color: #008000;">&#40;</span>p<span style="color: #000040;">!</span><span style="color: #000080;">=</span><span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
			<span style="color: #0000ff;">break</span><span style="color: #008080;">;</span>
		<span style="color: #008000;">&#125;</span> <span style="color: #0000ff;">else</span> <span style="color: #008000;">&#123;</span>
			<span style="color: #666666;">// Color me, enqueue my children and color them</span>
			visited<span style="color: #008000;">&#91;</span>u<span style="color: #008000;">&#93;</span> <span style="color: #000080;">=</span> <span style="color: #0000dd;">2</span><span style="color: #008080;">;</span>
			nodeEdge<span style="color: #000040;">*</span> adjList <span style="color: #000080;">=</span> g<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>nodes<span style="color: #008000;">&#91;</span>u<span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
			<span style="color: #0000ff;">while</span> <span style="color: #008000;">&#40;</span>adjList<span style="color: #000040;">!</span><span style="color: #000080;">=</span><span style="color: #0000ff;">NULL</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
				<span style="color: #666666;">// Get adj node, see if it's been visited and</span>
				<span style="color: #666666;">// if not it's my child</span>
				<span style="color: #0000ff;">int</span> v <span style="color: #000080;">=</span> adjList<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>vertex<span style="color: #008080;">;</span>
				<span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>visited<span style="color: #008000;">&#91;</span>v<span style="color: #008000;">&#93;</span><span style="color: #000080;">==</span><span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span>
					visit.<span style="color: #007788;">push</span><span style="color: #008000;">&#40;</span>v<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
					parent<span style="color: #008000;">&#91;</span>v<span style="color: #008000;">&#93;</span> <span style="color: #000080;">=</span> u<span style="color: #008080;">;</span>
					parent<span style="color: #008000;">&#91;</span>v<span style="color: #000040;">+</span>nV<span style="color: #008000;">&#93;</span> <span style="color: #000080;">=</span> adjList<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>weight<span style="color: #008080;">;</span>
					visited<span style="color: #008000;">&#91;</span>v<span style="color: #008000;">&#93;</span> <span style="color: #000080;">=</span> <span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>
				<span style="color: #008000;">&#125;</span>
				adjList <span style="color: #000080;">=</span> adjList<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #008080;">;</span>
			<span style="color: #008000;">&#125;</span>
		<span style="color: #008000;">&#125;</span>		
	<span style="color: #008000;">&#125;</span>
&nbsp;
	<span style="color: #000040;">!</span>found <span style="color: #000040;">&amp;&amp;</span> <span style="color: #008000;">&#40;</span>path <span style="color: #000080;">=</span> <span style="color: #0000ff;">NULL</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	minCut <span style="color: #008080;">?</span> <span style="color: #0000dd;">delete</span> path <span style="color: #008080;">:</span> <span style="color: #0000dd;">delete</span> visited<span style="color: #008080;">;</span>
	<span style="color: #0000dd;">delete</span> parent<span style="color: #008080;">;</span>
&nbsp;
	<span style="color: #0000ff;">return</span> minCut <span style="color: #008080;">?</span> visited <span style="color: #008080;">:</span> path<span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
<span style="color: #ff0000; font-style: italic;">/** Summary:
 *		This finds the minimum edge weight along
 *		a path and returns it, since the flow cannot
 *		exceed that.
 */</span>
<span style="color: #0000ff;">int</span> bottleNeck<span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> <span style="color: #000040;">*</span>path, <span style="color: #0000ff;">int</span> t, <span style="color: #0000ff;">int</span> nV<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span>
	<span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>path<span style="color: #000080;">==</span><span style="color: #0000ff;">NULL</span><span style="color: #008000;">&#41;</span> <span style="color: #0000ff;">return</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">int</span> m <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span>, p <span style="color: #000080;">=</span> path<span style="color: #008000;">&#91;</span>t<span style="color: #008000;">&#93;</span>, last<span style="color: #000080;">=</span>t<span style="color: #008080;">;</span>
	<span style="color: #0000ff;">do</span> <span style="color: #008000;">&#123;</span>
		m <span style="color: #000080;">=</span> m<span style="color: #000080;">==</span><span style="color: #0000dd;">0</span> <span style="color: #008080;">?</span> path<span style="color: #008000;">&#91;</span>last<span style="color: #000040;">+</span>nV<span style="color: #008000;">&#93;</span> <span style="color: #008080;">:</span> min<span style="color: #008000;">&#40;</span>path<span style="color: #008000;">&#91;</span>last<span style="color: #000040;">+</span>nV<span style="color: #008000;">&#93;</span>, m<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
		last <span style="color: #000080;">=</span> p<span style="color: #008080;">;</span>
		p <span style="color: #000080;">=</span> path<span style="color: #008000;">&#91;</span>last<span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
	<span style="color: #008000;">&#125;</span> <span style="color: #0000ff;">while</span> <span style="color: #008000;">&#40;</span>p<span style="color: #000040;">!</span><span style="color: #000080;">=</span><span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #666666;">//cout &lt;&lt; &quot;Bottleneck: &quot; &lt;&lt; m &lt;&lt; endl;</span>
	<span style="color: #0000ff;">return</span> m<span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #ff0000; font-style: italic;">/** Summary:
 *		Capacity scaling implementation of Ford-
 *		Fulkerson algorithm.
 */</span>
<span style="color: #0000ff;">int</span> maxFlow<span style="color: #008000;">&#40;</span>Graph <span style="color: #000040;">*</span>g<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span>
	ofstream output<span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;output.txt&quot;</span>, ios<span style="color: #008080;">::</span><span style="color: #007788;">out</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #000040;">!</span>output<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
		<span style="color: #0000dd;">cout</span> <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;Error: failed create output file&quot;</span> <span style="color: #000080;">&lt;&lt;</span> endl<span style="color: #008080;">;</span>
		<span style="color: #0000ff;">return</span> <span style="color: #000040;">-</span><span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>
	<span style="color: #008000;">&#125;</span>
	<span style="color: #666666;">// First create the residual graph by copying the original</span>
	Graph <span style="color: #000040;">*</span>bG, <span style="color: #000040;">*</span>rG <span style="color: #000080;">=</span> <span style="color: #0000dd;">new</span> Graph<span style="color: #008000;">&#40;</span>g<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #666666;">// C-capacity from source, mC-max capacity from A={s}, delta-nearest power of 2, rC-residual capacity</span>
	<span style="color: #0000ff;">int</span> C<span style="color: #000080;">=</span><span style="color: #0000dd;">0</span>, mC<span style="color: #000080;">=</span><span style="color: #0000dd;">0</span>, delta<span style="color: #000080;">=</span><span style="color: #0000dd;">1</span>, rC<span style="color: #000080;">=</span><span style="color: #0000dd;">0</span>, s<span style="color: #000080;">=</span>g<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>s, t<span style="color: #000080;">=</span>g<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>t, nV<span style="color: #000080;">=</span>g<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>nV<span style="color: #008080;">;</span>
&nbsp;
	<span style="color: #666666;">// Get an upper bound on the flow by summing the</span>
	<span style="color: #666666;">// capacity coming out of the source node</span>
	nodeEdge <span style="color: #000040;">*</span>src <span style="color: #000080;">=</span> rG<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>nodes<span style="color: #008000;">&#91;</span>s<span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">while</span> <span style="color: #008000;">&#40;</span>src<span style="color: #000040;">!</span><span style="color: #000080;">=</span><span style="color: #0000ff;">NULL</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
		<span style="color: #0000ff;">int</span> tmp <span style="color: #000080;">=</span> src<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>weight<span style="color: #008080;">;</span>
		mC<span style="color: #000080;">=</span>max<span style="color: #008000;">&#40;</span>tmp,mC<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
		C<span style="color: #000040;">+</span><span style="color: #000080;">=</span>tmp<span style="color: #008080;">;</span>
		src <span style="color: #000080;">=</span> src<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #008080;">;</span>
	<span style="color: #008000;">&#125;</span>
&nbsp;
	<span style="color: #666666;">//cout &lt;&lt; &quot;Capacity: &quot; &lt;&lt; C &lt;&lt; endl;</span>
	<span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>mC<span style="color: #000080;">&gt;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span>
		<span style="color: #666666;">// Technically should also check for an upper bound which</span>
		<span style="color: #666666;">// depends on architecture, 32/64 bit.</span>
		<span style="color: #0000ff;">while</span> <span style="color: #008000;">&#40;</span>delta<span style="color: #000080;">&lt;</span>mC<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
			delta<span style="color: #000080;">&lt;&lt;=</span><span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>
		<span style="color: #008000;">&#125;</span>
		<span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>delta<span style="color: #000080;">&gt;</span>mC<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
			<span style="color: #666666;">// Shift it back one so it's less than or equal to C</span>
			delta<span style="color: #000080;">&gt;&gt;=</span><span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>
		<span style="color: #008000;">&#125;</span>
	<span style="color: #008000;">&#125;</span><span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>mC<span style="color: #000080;">==</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span>
		delta <span style="color: #000080;">=</span> <span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>
		<span style="color: #0000dd;">cout</span> <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;Edge weight is 1 so setting delta as 1 since lower power of 2 is 0&quot;</span> <span style="color: #000080;">&lt;&lt;</span> endl<span style="color: #008080;">;</span>
	<span style="color: #008000;">&#125;</span> <span style="color: #0000ff;">else</span> <span style="color: #008000;">&#123;</span>
		<span style="color: #0000dd;">cout</span> <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;There is no positive capacity, no positive flow exists&quot;</span> <span style="color: #000080;">&lt;&lt;</span> endl<span style="color: #008080;">;</span>
		<span style="color: #0000dd;">exit</span><span style="color: #008000;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #008000;">&#125;</span>
&nbsp;
	bG <span style="color: #000080;">=</span> rG<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>bottleneckGraph<span style="color: #008000;">&#40;</span>delta<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #666666;">// Now find an aug path</span>
	<span style="color: #0000ff;">int</span><span style="color: #000040;">*</span> augPath <span style="color: #000080;">=</span> BFS<span style="color: #008000;">&#40;</span>bG, s, t, <span style="color: #0000ff;">false</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">while</span> <span style="color: #008000;">&#40;</span>delta<span style="color: #000080;">&gt;=</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
		<span style="color: #666666;">// Keep getting augPaths until down on delta</span>
		output <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;With DELTA=&quot;</span> <span style="color: #000080;">&lt;&lt;</span> delta <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;, &quot;</span><span style="color: #008080;">;</span>
		<span style="color: #0000ff;">while</span> <span style="color: #008000;">&#40;</span>augPath<span style="color: #000040;">!</span><span style="color: #000080;">=</span><span style="color: #0000ff;">NULL</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
			<span style="color: #666666;">// Get all augmenting paths for current delta	</span>
			<span style="color: #0000ff;">int</span> p, c, b<span style="color: #008080;">;</span>
			<span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>augPath<span style="color: #000080;">==</span><span style="color: #0000ff;">NULL</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
				c <span style="color: #000080;">=</span> b <span style="color: #000080;">=</span> p <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>
			<span style="color: #008000;">&#125;</span> <span style="color: #0000ff;">else</span> <span style="color: #008000;">&#123;</span>
				b <span style="color: #000080;">=</span> bottleNeck<span style="color: #008000;">&#40;</span>augPath, t, nV<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
				c <span style="color: #000080;">=</span> t<span style="color: #008080;">;</span>
				p <span style="color: #000080;">=</span> augPath<span style="color: #008000;">&#91;</span>t<span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
			<span style="color: #008000;">&#125;</span>
&nbsp;
			<span style="color: #0000ff;">while</span> <span style="color: #008000;">&#40;</span>p<span style="color: #000040;">!</span><span style="color: #000080;">=</span><span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span>
				<span style="color: #666666;">// I have an edge.  First reduce the weight on all edges we sent flow</span>
				<span style="color: #666666;">// through of the form p-&gt;c.  </span>
				<span style="color: #0000ff;">int</span> success <span style="color: #000080;">=</span> rG<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>updateEdgeWeight<span style="color: #008000;">&#40;</span>p, c, <span style="color: #000040;">-</span>b<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
				<span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>success<span style="color: #000080;">==</span><span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span>
					<span style="color: #666666;">// Means we created an edge, shouldn't have happened throw error</span>
					<span style="color: #0000dd;">cout</span> <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;Error, didn't find edge in adj list&quot;</span> <span style="color: #000080;">&lt;&lt;</span> endl<span style="color: #008080;">;</span>
					<span style="color: #0000dd;">exit</span><span style="color: #008000;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
				<span style="color: #008000;">&#125;</span>
&nbsp;
				<span style="color: #666666;">// Now update the residual graph by either creating a c-&gt;p edge, or </span>
				<span style="color: #666666;">// adding weight</span>
				rG<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>updateEdgeWeight<span style="color: #008000;">&#40;</span>c, p, b<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
				c <span style="color: #000080;">=</span> p<span style="color: #008080;">;</span>
				p <span style="color: #000080;">=</span> augPath<span style="color: #008000;">&#91;</span>c<span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
			<span style="color: #008000;">&#125;</span>
			<span style="color: #666666;">// Destroy my last bottleneck graph and make a new one</span>
			<span style="color: #0000dd;">delete</span> bG<span style="color: #008080;">;</span>
			bG <span style="color: #000080;">=</span> rG<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>bottleneckGraph<span style="color: #008000;">&#40;</span>delta<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
			augPath <span style="color: #000080;">=</span> BFS<span style="color: #008000;">&#40;</span>bG, s, t, <span style="color: #0000ff;">false</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
		<span style="color: #008000;">&#125;</span>
		<span style="color: #666666;">// I want to see my new graph for each augmentation</span>
		<span style="color: #666666;">//rG-&gt;toString();</span>
&nbsp;
		rC <span style="color: #000080;">=</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>
		src <span style="color: #000080;">=</span> rG<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>nodes<span style="color: #008000;">&#91;</span>s<span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
		<span style="color: #0000ff;">while</span> <span style="color: #008000;">&#40;</span>src<span style="color: #000040;">!</span><span style="color: #000080;">=</span><span style="color: #0000ff;">NULL</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
			rC<span style="color: #000040;">+</span><span style="color: #000080;">=</span>src<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>weight<span style="color: #008080;">;</span>
			src <span style="color: #000080;">=</span> src<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #008080;">;</span>
		<span style="color: #008000;">&#125;</span>
		output <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;Flow value=&quot;</span> <span style="color: #000080;">&lt;&lt;</span> C<span style="color: #000040;">-</span>rC <span style="color: #000080;">&lt;&lt;</span> endl<span style="color: #008080;">;</span>
		<span style="color: #666666;">// My residual graph has been updated with my last flow, find a new</span>
		<span style="color: #666666;">// augmenting path and try it again.</span>
		delta <span style="color: #000080;">=</span>  delta<span style="color: #000040;">/</span><span style="color: #0000dd;">2</span><span style="color: #008080;">;</span>
		bG <span style="color: #000080;">=</span> rG<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>bottleneckGraph<span style="color: #008000;">&#40;</span>delta<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
		augPath <span style="color: #000080;">=</span> BFS<span style="color: #008000;">&#40;</span>bG, s, t, <span style="color: #0000ff;">false</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #008000;">&#125;</span>
&nbsp;
	output <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;Max-flow value=&quot;</span> <span style="color: #000080;">&lt;&lt;</span> C<span style="color: #000040;">-</span>rC <span style="color: #000080;">&lt;&lt;</span> endl<span style="color: #008080;">;</span>
&nbsp;
	output <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;The max-flow:&quot;</span> <span style="color: #000080;">&lt;&lt;</span> endl<span style="color: #008080;">;</span>
	<span style="color: #666666;">// Print the max flow by going through the edges in the original</span>
	<span style="color: #666666;">// graph and subtracting the</span>
	<span style="color: #0000ff;">for</span> <span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> i<span style="color: #000080;">=</span><span style="color: #0000dd;">1</span><span style="color: #008080;">;</span> i<span style="color: #000080;">&lt;</span>g<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>nV<span style="color: #008080;">;</span> i<span style="color: #000040;">++</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
		nodeEdge <span style="color: #000040;">*</span>r, <span style="color: #000040;">*</span>n <span style="color: #000080;">=</span> g<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>nodes<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span>
		<span style="color: #0000ff;">while</span> <span style="color: #008000;">&#40;</span>n<span style="color: #000040;">!</span><span style="color: #000080;">=</span><span style="color: #0000ff;">NULL</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
			r <span style="color: #000080;">=</span> rG<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>nodes<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span> <span style="color: #666666;">// Start at the beginning each time since edges could be gone</span>
			<span style="color: #0000ff;">while</span> <span style="color: #008000;">&#40;</span>r<span style="color: #000040;">!</span><span style="color: #000080;">=</span><span style="color: #0000ff;">NULL</span> <span style="color: #000040;">&amp;&amp;</span> r<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>vertex<span style="color: #000040;">!</span><span style="color: #000080;">=</span>n<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>vertex<span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
				r <span style="color: #000080;">=</span> r<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #008080;">;</span>
			<span style="color: #008000;">&#125;</span>
			<span style="color: #0000ff;">int</span> wt <span style="color: #000080;">=</span> r<span style="color: #000080;">==</span><span style="color: #0000ff;">NULL</span> <span style="color: #008080;">?</span> n<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>weight <span style="color: #008080;">:</span> n<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>weight <span style="color: #000040;">-</span> r<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>weight<span style="color: #008080;">;</span>
			<span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>wt<span style="color: #000080;">&gt;</span><span style="color: #0000dd;">0</span><span style="color: #008000;">&#41;</span> output <span style="color: #000080;">&lt;&lt;</span> i <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot; &quot;</span> <span style="color: #000080;">&lt;&lt;</span> n<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>vertex <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot; &quot;</span> <span style="color: #000080;">&lt;&lt;</span> wt <span style="color: #000080;">&lt;&lt;</span> endl<span style="color: #008080;">;</span>
&nbsp;
			n <span style="color: #000080;">=</span> n<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>next<span style="color: #008080;">;</span>
		<span style="color: #008000;">&#125;</span>
	<span style="color: #008000;">&#125;</span>
&nbsp;
	<span style="color: #666666;">// Now find and print the min-cut</span>
	output <span style="color: #000080;">&lt;&lt;</span> endl <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;Min-cut capacity=&quot;</span> <span style="color: #000080;">&lt;&lt;</span> C<span style="color: #000040;">-</span>rC <span style="color: #000080;">&lt;&lt;</span> endl<span style="color: #008080;">;</span>
	output <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;The min-cut:&quot;</span> <span style="color: #000080;">&lt;&lt;</span> endl<span style="color: #008080;">;</span>
&nbsp;
	<span style="color: #666666;">// This assumes a connected graph</span>
	<span style="color: #0000ff;">int</span><span style="color: #000040;">*</span> minCut <span style="color: #000080;">=</span> BFS<span style="color: #008000;">&#40;</span>rG, rG<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>s, rG<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>t, <span style="color: #0000ff;">true</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	vector<span style="color: #000080;">&lt;</span><span style="color: #0000ff;">int</span><span style="color: #000080;">&gt;</span> S, T<span style="color: #008080;">;</span>
	<span style="color: #0000ff;">for</span> <span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> i<span style="color: #000080;">=</span><span style="color: #0000dd;">1</span><span style="color: #008080;">;</span> i<span style="color: #000080;">&lt;</span>rG<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>nV<span style="color: #008080;">;</span> i<span style="color: #000040;">++</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
		minCut<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #000080;">&gt;</span><span style="color: #0000dd;">0</span> <span style="color: #008080;">?</span> S.<span style="color: #007788;">push_back</span><span style="color: #008000;">&#40;</span>i<span style="color: #008000;">&#41;</span> <span style="color: #008080;">:</span> T.<span style="color: #007788;">push_back</span><span style="color: #008000;">&#40;</span>i<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #008000;">&#125;</span>
&nbsp;
	output <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;The set S:&quot;</span> <span style="color: #000080;">&lt;&lt;</span> endl<span style="color: #008080;">;</span>	
	<span style="color: #0000ff;">for</span> <span style="color: #008000;">&#40;</span><span style="color: #0000ff;">size_t</span> i<span style="color: #000080;">=</span><span style="color: #0000dd;">0</span><span style="color: #008080;">;</span> i<span style="color: #000080;">&lt;</span>S.<span style="color: #007788;">size</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> i<span style="color: #000040;">++</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
		output <span style="color: #000080;">&lt;&lt;</span> S<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span> <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;, &quot;</span><span style="color: #008080;">;</span>
	<span style="color: #008000;">&#125;</span>
	output <span style="color: #000080;">&lt;&lt;</span> endl <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;The set T:&quot;</span> <span style="color: #000080;">&lt;&lt;</span> endl<span style="color: #008080;">;</span>
	<span style="color: #0000ff;">for</span> <span style="color: #008000;">&#40;</span><span style="color: #0000ff;">size_t</span> i<span style="color: #000080;">=</span><span style="color: #0000dd;">0</span><span style="color: #008080;">;</span> i<span style="color: #000080;">&lt;</span>T.<span style="color: #007788;">size</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span> i<span style="color: #000040;">++</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
		output <span style="color: #000080;">&lt;&lt;</span> T<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span> <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;, &quot;</span><span style="color: #008080;">;</span>
	<span style="color: #008000;">&#125;</span>
	output <span style="color: #000080;">&lt;&lt;</span> endl<span style="color: #008080;">;</span>
	output.<span style="color: #007788;">close</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #0000dd;">delete</span> rG<span style="color: #008080;">;</span>
	<span style="color: #0000ff;">return</span> C<span style="color: #000040;">-</span>rC<span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span><span style="color: #008080;">;</span>
&nbsp;
<span style="color: #0000ff;">int</span> main <span style="color: #008000;">&#40;</span><span style="color: #0000ff;">int</span> argc, <span style="color: #0000ff;">char</span> <span style="color: #000040;">*</span> <span style="color: #0000ff;">const</span> argv<span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
	<span style="color: #666666;">// Read in the data and construct the graph</span>
	string line<span style="color: #008080;">;</span>
	ifstream myfile<span style="color: #008080;">;</span>
	myfile.<span style="color: #007788;">open</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;input.txt&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
	<span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>myfile.<span style="color: #007788;">is_open</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span>
		<span style="color: #0000ff;">int</span> edgeCount, counter <span style="color: #000080;">=</span> <span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>
		Graph<span style="color: #000040;">*</span> g <span style="color: #000080;">=</span> <span style="color: #0000ff;">NULL</span><span style="color: #008080;">;</span>
&nbsp;
		<span style="color: #0000dd;">cout</span> <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;Successfully opened file&quot;</span> <span style="color: #000080;">&lt;&lt;</span> endl<span style="color: #008080;">;</span>
		<span style="color: #0000ff;">while</span> <span style="color: #008000;">&#40;</span><span style="color: #000040;">!</span>myfile.<span style="color: #007788;">eof</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
			getline<span style="color: #008000;">&#40;</span>myfile, line<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
			vector<span style="color: #000080;">&lt;</span>string<span style="color: #000080;">&gt;</span> tokens<span style="color: #008080;">;</span>
			<span style="color: #0000ff;">int</span> a, b, c<span style="color: #008080;">;</span>
&nbsp;
			<span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>line.<span style="color: #007788;">empty</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span>
				<span style="color: #666666;">// Skip me</span>
			<span style="color: #008000;">&#125;</span><span style="color: #0000ff;">else</span> <span style="color: #008000;">&#123;</span>
				stringstream iss<span style="color: #008000;">&#40;</span>line<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
				copy<span style="color: #008000;">&#40;</span>istream_iterator<span style="color: #000080;">&lt;</span>string<span style="color: #000080;">&gt;</span><span style="color: #008000;">&#40;</span>iss<span style="color: #008000;">&#41;</span>, 
					istream_iterator<span style="color: #000080;">&lt;</span>string<span style="color: #000080;">&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>, 
					back_inserter<span style="color: #000080;">&lt;</span>vector<span style="color: #000080;">&lt;</span>string<span style="color: #000080;">&gt;</span> <span style="color: #000080;">&gt;</span><span style="color: #008000;">&#40;</span>tokens<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
				<span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>tokens.<span style="color: #007788;">size</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #000080;">&gt;</span><span style="color: #0000dd;">3</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span>
					<span style="color: #0000dd;">cout</span> <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;Input error: too many values/line&quot;</span> <span style="color: #000080;">&lt;&lt;</span> endl<span style="color: #008080;">;</span>
					myfile.<span style="color: #007788;">close</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
					<span style="color: #0000ff;">return</span> <span style="color: #000040;">-</span><span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>
				<span style="color: #008000;">&#125;</span>
				<span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>tokens.<span style="color: #007788;">size</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #000040;">!</span><span style="color: #000080;">=</span><span style="color: #0000dd;">2</span> <span style="color: #000040;">&amp;&amp;</span> counter<span style="color: #000080;">&lt;=</span><span style="color: #0000dd;">2</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span>
					<span style="color: #0000dd;">cout</span> <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;Input error: only two values allowed in first two lines: nV and nE or s and t&quot;</span> <span style="color: #000080;">&lt;&lt;</span> endl<span style="color: #008080;">;</span>
					<span style="color: #0000ff;">return</span> <span style="color: #000040;">-</span><span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>
				<span style="color: #008000;">&#125;</span>
				<span style="color: #666666;">// Now that we have the vector, we need to make sure</span>
				<span style="color: #666666;">// the input is integer and then create our graph</span>
				<span style="color: #666666;">// Values here would be greater than 0</span>
				a <span style="color: #000080;">=</span> <span style="color: #0000dd;">atoi</span><span style="color: #008000;">&#40;</span>tokens<span style="color: #008000;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #008000;">&#93;</span>.<span style="color: #007788;">c_str</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
				b <span style="color: #000080;">=</span> <span style="color: #0000dd;">atoi</span><span style="color: #008000;">&#40;</span>tokens<span style="color: #008000;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#93;</span>.<span style="color: #007788;">c_str</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
				c <span style="color: #000080;">=</span> tokens.<span style="color: #007788;">size</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #000080;">&gt;</span><span style="color: #0000dd;">2</span> <span style="color: #008080;">?</span> <span style="color: #0000dd;">atoi</span><span style="color: #008000;">&#40;</span>tokens<span style="color: #008000;">&#91;</span><span style="color: #0000dd;">2</span><span style="color: #008000;">&#93;</span>.<span style="color: #007788;">c_str</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span> <span style="color: #008080;">:</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>
&nbsp;
				<span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>a<span style="color: #000080;">&lt;</span><span style="color: #0000dd;">1</span> <span style="color: #000040;">||</span> b<span style="color: #000080;">&lt;</span><span style="color: #0000dd;">1</span> <span style="color: #000040;">||</span> <span style="color: #008000;">&#40;</span>counter<span style="color: #000080;">&gt;</span><span style="color: #0000dd;">2</span> <span style="color: #000040;">&amp;&amp;</span> c<span style="color: #000080;">&lt;</span><span style="color: #0000dd;">1</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span>
					<span style="color: #666666;">// I asked professor XUE and he said throw an error for 0</span>
					<span style="color: #666666;">// edge weight as well as non integer.</span>
					<span style="color: #0000dd;">cout</span> <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;Input error: Non integer (or 0) input&quot;</span> <span style="color: #000080;">&lt;&lt;</span> endl<span style="color: #008080;">;</span>
					myfile.<span style="color: #007788;">close</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
					<span style="color: #0000ff;">return</span> <span style="color: #000040;">-</span><span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>
				<span style="color: #008000;">&#125;</span>
&nbsp;
				<span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>counter <span style="color: #000080;">==</span> <span style="color: #0000dd;">1</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span>
					<span style="color: #666666;">// Initialize graph</span>
					edgeCount <span style="color: #000080;">=</span> b<span style="color: #008080;">;</span>
					g <span style="color: #000080;">=</span> <span style="color: #0000dd;">new</span> Graph<span style="color: #008000;">&#40;</span>a,b<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
				<span style="color: #008000;">&#125;</span>	
				<span style="color: #666666;">// Other setup</span>
				<span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>counter <span style="color: #000080;">==</span> <span style="color: #0000dd;">2</span><span style="color: #008000;">&#41;</span> g<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>setSourceSink<span style="color: #008000;">&#40;</span>a,b<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
				<span style="color: #0000ff;">if</span><span style="color: #008000;">&#40;</span>counter <span style="color: #000080;">&gt;</span> <span style="color: #0000dd;">2</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#123;</span>
					<span style="color: #666666;">// Adding vertices and edges baby</span>
					nodeEdge <span style="color: #000040;">*</span>n <span style="color: #000080;">=</span> <span style="color: #0000dd;">new</span> nodeEdge<span style="color: #008000;">&#40;</span>b,c<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
					g<span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>addEdge<span style="color: #008000;">&#40;</span>a,n<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
				<span style="color: #008000;">&#125;</span>
				counter<span style="color: #000040;">++</span><span style="color: #008080;">;</span>
			<span style="color: #008000;">&#125;</span>
			<span style="color: #666666;">//cout &lt;&lt; &quot;Vector size: &quot; &lt;&lt; tokens.size() &lt;&lt; &quot; 1: &quot; &lt;&lt; a &lt;&lt; &quot; 2: &quot; &lt;&lt; b &lt;&lt; &quot; 3: &quot; &lt;&lt; c &lt;&lt; endl;</span>
&nbsp;
		<span style="color: #008000;">&#125;</span>
		myfile.<span style="color: #007788;">close</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
&nbsp;
		<span style="color: #666666;">// One last check, now that I've gone through the file does the</span>
		<span style="color: #666666;">// number of expected edges match with the number of actual edges given?</span>
		<span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>edgeCount <span style="color: #000040;">!</span><span style="color: #000080;">=</span> counter<span style="color: #000040;">-</span><span style="color: #0000dd;">3</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
			<span style="color: #0000dd;">cout</span> <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;Expected &quot;</span> <span style="color: #000080;">&lt;&lt;</span> edgeCount <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot; edges but found &quot;</span> <span style="color: #000080;">&lt;&lt;</span> counter<span style="color: #000040;">-</span><span style="color: #0000dd;">3</span> <span style="color: #000080;">&lt;&lt;</span> endl<span style="color: #008080;">;</span>
			<span style="color: #0000ff;">return</span> <span style="color: #000040;">-</span><span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>
		<span style="color: #008000;">&#125;</span>
&nbsp;
		<span style="color: #666666;">// Begin max flow algorithm! -- I should do this from a function</span>
		maxFlow<span style="color: #008000;">&#40;</span>g<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span>
		<span style="color: #666666;">//cout &lt;&lt; &quot;Flow value: &quot; &lt;&lt; flow &lt;&lt; endl;</span>
&nbsp;
	<span style="color: #008000;">&#125;</span> <span style="color: #0000ff;">else</span> <span style="color: #008000;">&#123;</span>
		<span style="color: #666666;">// ELSE to opening file.  Major fail</span>
		<span style="color: #0000dd;">cout</span> <span style="color: #000080;">&lt;&lt;</span> <span style="color: #FF0000;">&quot;Error opening file&quot;</span> <span style="color: #000080;">&lt;&lt;</span> endl<span style="color: #008080;">;</span>
		<span style="color: #0000ff;">return</span> <span style="color: #000040;">-</span><span style="color: #0000dd;">1</span><span style="color: #008080;">;</span>
	<span style="color: #008000;">&#125;</span>
	<span style="color: #0000ff;">return</span> <span style="color: #0000dd;">0</span><span style="color: #008080;">;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>This expects a file formatted with the first line having number of vertices and number of edges.  The next line has the number of the source and the sink node.  All the remaining lines are edges with the first number being the source, the second the destination, and the third the edge weight.  An example input with 6 vertices and 8 edges, with a start node of 1 and sink node of 4, and a first example edge starting at 1 ending in 2 with an edge weight of 3 looking like this:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="readme" style="font-family:monospace;">6 8
1 4
1 2 3
1 4 1
1 6 4
2 3 3
2 5 4
3 4 3
5 4 8
6 5 4</pre></td></tr></table></div>

<p>The output is:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre></td><td class="code"><pre class="readme" style="font-family:monospace;">With DELTA=4, Flow Value=4
With DELTA=2, Flow Value=7
With DELTA=1, Flow Value=8
Max-flow value=8
The max-flow:
1 2 3
1 4 1
1 6 4
2 3 3
3 4 3
5 4 4
6 5 4
&nbsp;
Min-cut capacity=8
The min-cut:
The set S:
1, 
The set T:
2, 3, 4, 5, 6,</pre></td></tr></table></div>

<p>I&#8217;ll throw in my makefile just for kicks:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
</pre></td><td class="code"><pre class="makefile" style="font-family:monospace;">CC=g++
CFLAGS=-c -Wall
LDFLAGS=
&nbsp;
all: run
&nbsp;
run: main.o Graph.o
		$(CC) main.o Graph.o -o run
&nbsp;
main.o: main.cpp
		$(CC) $(CFLAGS) main.cpp
&nbsp;
Graph.o: Graph.cpp Graph.h
		$(CC) $(CFLAGS) Graph.cpp
&nbsp;
clean:
		rm -rf *o run</pre></td></tr></table></div>

<div class="shr-publisher-490"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/devnotes/ford-fulkerson-capacity-scaling-c/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Zazzer &#8211; Some Real World RTMPF Application</title>
		<link>http://flightschool.acylt.com/devnotes/zazzer-some-real-world-rtmpf-application/</link>
		<comments>http://flightschool.acylt.com/devnotes/zazzer-some-real-world-rtmpf-application/#comments</comments>
		<pubDate>Tue, 18 Oct 2011 00:45:29 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[DevNotes]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=515</guid>
		<description><![CDATA[I&#8217;ve put up a few examples using Red5 with some bare bones video chat stuff, so I thought I&#8217;d follow up and say a little about why I did it. The reason was to create http://Zazzer.me &#8211; a video chat based game. At first I thought I&#8217;d stream through the servers but then I heard [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>I&#8217;ve put up a few examples using Red5 with some bare bones video chat stuff, so I thought I&#8217;d follow up and say a little about why I did it.  The reason was to create <a href="http://zazzer.me">http://Zazzer.me</a> &#8211; a video chat based game.  At first I thought I&#8217;d stream through the servers but then I heard about Cirrus and how they allow peer to peer connections and then I decided that was the way to go for me.  So I wrote a simple chat application in flash with a Javascript control and a PHP backend.  Maybe I&#8217;ll post the technical details later&#8230; for now here is just a little about how the game actually works (from how I describe it on the site).</p>
<h1>WHAT IS ZAZZER ANYWAY</h1>
<p>Ok you brave soul, here is a quick overview of Zazzer.  The idea is, it&#8217;s an artificial intelligence built to introduce you to people in a fun way.  Basically you&#8217;ve got a human social game. You get points by playing and meeting other people.  You LOSE points by doing stupid stuff and offending people (don&#8217;t be a jerk &#8211; keep your clothes on).</p>
<p><img src="http://zazzer.me/images/screen11.jpg" alt="normal screen" /></p>
<p>I guess I should start by saying Zazzer is first and foremost a game, but you have some features baked in here to help you keep track of the new friends you make here. You can change colors, minimize labels and panels, upload a picture (if you click the house button at the top left it takes you to your profile &#8211; then just hover over your pic and you&#8217;ll see the camera icon you can see on mine at the top left of my head in screen shot below), and all kinds of stuff. Play around.  When you add friends they&#8217;re always put in Zazzee (since Zazzer, presumably, introduced you) and from there you can put them in three different labels if you like.  As you can see in mine above none of my friends have added their pictures yet.  But mines up and this is here so there&#8217;s hope.</p>
<h1>STARTING THE GAME</h1>
<p>I hope you&#8217;ve noticed your notification, it pops up and lets you know what&#8217;s going on from time to time.  Hovering over Zazzer&#8217;s little blue head at the bottom left will get him to talk to you (or at least show you what he&#8217;s said previously).  Anyway that&#8217;s what the screen shot below is meant to show you.  TO PLAY THE GAME just click the PLAY button and Zazzer will start looking for a match for you.  Once it&#8217;s found one it will move your screen over to the game area for you (waaaaay to the right).</p>
<p><img src="http://zazzer.me/images/screen12.jpg" alt="play" /></p>
<p>At that point if Flash isn&#8217;t being stupid, it will ask you for permission to your camera and you can start the game with your partner (right click on it and click settings if your camera or sound aren&#8217;t working). You should see something like this:</p>
<p><img src="http://zazzer.me/images/screen1.jpg" alt="Pic of the game start" /></p>
<h1>DONT BE A JERK</h1>
<p>You&#8217;ll notice that there&#8217;s a report button &#8211; if you click it takes serious points away from your partner and immediately stops the game.  IMPORTANT though, is that in your notification bubble that pops up with info &#8211; you can filter people based on their points.  IF YOU REPORT someone who isn&#8217;t being a serious jerk then they&#8217;ll get filtered out of games.  If you feel like you&#8217;ve been filtered unfairly, get in touch and we&#8217;ll look into it.  Anyway bottom line, don&#8217;t be a jerk.</p>
<p><img src="http://zazzer.me/images/screen5.jpg" alt="Pic during the game" /></p>
<h1>GAME PLAY/RULES</h1>
<p>SO!  On to the game (that&#8217;s why you&#8217;re here right?)!  There are 2 60 second rounds; one for you to try to figure out what Zazzer matched you on and 1 for your partner.  The purpose is for you to figure out the strongest thing you have in common faster than your partner (or at least be able to convince them that your idea is better).  You see, at the end the videos pause and then you both choose which you thought was the best.  If you both choose one you input, you get 10 points and they get 5.  If you choose differently though, then choosing your own will get you 2 points, and choosing theirs will get you a big fat 0.  So will you risk choosing theirs?</p>
<p>Also as you get more points you unlock special features (like being able to create labels instead of using the pre-set ones.  Many more features are being worked on currently and quite a few of them will be tied to point  totals.  Also you can filter your games based on how high you want their points per game average to be (to help you avoid jerks.</p>
<p><img src="http://zazzer.me/images/screen6.jpg" alt="During game" /></p>
<p>Below is a screen shot of choosing the item at the end of the game&#8230;</p>
<p><img src="http://zazzer.me/images/screen7.jpg" alt="Choose" /></p>
<p>One last curve ball.  You can hang out and talk to the person after the game.  You can add them as a friend. But you&#8217;re also allowed to give them +10 or -10 just for the heck of it (this is after scoring and they don&#8217;t find out).</p>
<h1>ONE LAST THING</h1>
<p>You can also be matched and just plain video chat with a random partner without having to play the game. Just uncheck game in your notification area.  And if you&#8217;re really shy and want to just be matched with no game and be given the option to add that person&#8230; you have that too &#8211; menu that&#8217;s always at the bottom of your screen</p>
<p>I&#8217;m sure no one ever reads this far so I&#8217;m stopping now.<br />
<div class="shr-publisher-515"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/devnotes/zazzer-some-real-world-rtmpf-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Chrome-script not running from loaded HTML in dojo.Dialog</title>
		<link>http://flightschool.acylt.com/devnotes/chrome-script-not-running-from-loaded-html/</link>
		<comments>http://flightschool.acylt.com/devnotes/chrome-script-not-running-from-loaded-html/#comments</comments>
		<pubDate>Thu, 12 May 2011 03:15:13 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[DevNotes]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=500</guid>
		<description><![CDATA[While working on a site I&#8217;m building I had a dojo.Dialog that I was adding as a click event. It was supposed to load some HTML with script tags from a relative path and it worked on every browser just fine, just not Chrome. The HTML would still load in Chrome, it&#8217;s just that none [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>While working on a site I&#8217;m building I had a dojo.Dialog that I was adding as a click event.  It was supposed to load some HTML with script tags from a relative path and it worked on every browser just fine, just not Chrome.  The HTML would still load in Chrome, it&#8217;s just that none of the scripts would execute.</p>
<p>I found out that lots of developers have run into this and the reason it happens is Chrome considers them outside of the local domain, so for security it doesn&#8217;t allow it.  One workaround is to start Chrome from the command line with the parameter: &#8211;allow-file-access-from-files.</p>
<p>However the best option was just to use dojox.widget.DialogSimple.  It is basically a dijit.Dialog with dojox.layout.ContentPane (which is a dijit.layout.ContentPane but with the ability to execute scripts on by default, and load css &#8211; off by default).</p>
<p>For more information on the first solution:<br />
<a href="http://stackoverflow.com/questions/3430638/accessing-relative-urls-via-ajax-from-file-content"> http://stackoverflow.com/questions/3430638/accessing-relative-urls-via-ajax-from-file-content</a><br />
<a href="http://code.google.com/p/chromium/issues/detail?id=40787"> http://code.google.com/p/chromium/issues/detail?id=40787</a><br />
<a href="http://code.google.com/p/chromium/issues/detail?id=47416"> http://code.google.com/p/chromium/issues/detail?id=47416</a></p>
<div class="shr-publisher-500"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/devnotes/chrome-script-not-running-from-loaded-html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Little About Zazzer</title>
		<link>http://flightschool.acylt.com/devnotes/a-little-about-zazzer/</link>
		<comments>http://flightschool.acylt.com/devnotes/a-little-about-zazzer/#comments</comments>
		<pubDate>Sun, 23 Oct 2011 05:52:03 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[DevNotes]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=525</guid>
		<description><![CDATA[WHAT IS ZAZZER ANYWAY First off here&#8217;s a blip from the homepage zazzer.me. Ok you brave soul, here is a quick overview of Zazzer. I had the thought a while ago &#8211; wouldn&#8217;t it be cool if there were some technology, like an AI wingman, who could introduce you to people you&#8217;d want to hang [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><h2>WHAT IS ZAZZER ANYWAY</h2>
<p>First off here&#8217;s a blip from the homepage <a href="http://zazzer.me">zazzer.me</a>.</p>
<p>Ok you brave soul, here is a quick overview of Zazzer.  I had the thought a while ago &#8211; wouldn&#8217;t it be cool if there were some technology, like an AI wingman, who could introduce you to people you&#8217;d want to hang out with?  Not by introducing you to profiles with blind emails &#8211; I&#8217;m not in 4th grade anymore, anonymous notes don&#8217;t appeal to me.  I wanted real life, face to face!</p>
<p>That idea grew into my graduate thesis, which required a real world implementation. That&#8217;s what this is.  Now if you move into a new city and want someone to play tennis with you&#8217;ve got Zazzer to introduce you!  The introductions happen through quick, video chat GAMES.</p>
<p>You should know I&#8217;ve actually spent a long time building this (longer than I&#8217;d care to admit) and that I have a long long list of killer ideas.  What&#8217;s the point?  That this is just the beginning.  If you like it at all, support this by telling your friends about it, telling me when something doesn&#8217;t work, and just playing the game, and it will continue improving every day!</p>
<h2>ABOUT the GAME</h2>
<p>By the way I&#8217;m in rapid development cycles so these pictures are out of date, they&#8217;ll be updated soon and a movie will be posted to show the game</p>
<p><img src="http://zazzer.me/images/screen11.jpg" alt="normal screen" /></p>
<p>I guess I should start by saying Zazzer is first and foremost a game, but you have some features baked in here to help you keep track of the new friends you make here. You can change colors, minimize labels and panels, upload a picture (if you click the house button at the top left it takes you to your profile &#8211; then just hover over your pic and you&#8217;ll see the camera icon you can see on mine at the top left of my head in screen shot below), and all kinds of stuff. Play around.  When you add friends they&#8217;re always put in Zazzee (since Zazzer, presumably, introduced you) and from there you can put them in three different labels if you like.  As you can see in mine above none of my friends have added their pictures yet.  But mines up and this is here so there&#8217;s hope.</p>
<h2>STARTING THE GAME</h2>
<p>I hope you&#8217;ve noticed your notification, it pops up and lets you know what&#8217;s going on from time to time.  Hovering over Zazzer&#8217;s little blue head at the bottom left will get him to talk to you (or at least show you what he&#8217;s said previously).  Anyway that&#8217;s what the screen shot below is meant to show you.  TO PLAY THE GAME just click the PLAY button and Zazzer will start looking for a match for you.  Once it&#8217;s found one it will move your screen over to the game area for you (waaaaay to the right).</p>
<p><img src="http://zazzer.me/images/screen12.jpg" alt="play" /></p>
<p>At that point if Flash isn&#8217;t being stupid, it will ask you for permission to your camera and you can start the game with your partner (right click on it and click settings if your camera or sound aren&#8217;t working). You should see something like this:</p>
<p><img src="http://zazzer.me/images/screen1.jpg" alt="Pic of the game start" /></p>
<h2>DONT BE A JERK</h2>
<p>You&#8217;ll notice that there&#8217;s a report button &#8211; if you click it takes serious points away from your partner and immediately stops the game.  IMPORTANT though, is that in your notification bubble that pops up with info &#8211; you can filter people based on their points.  IF YOU REPORT someone who isn&#8217;t being a serious jerk then they&#8217;ll get filtered out of games.  If you feel like you&#8217;ve been filtered unfairly, get in touch and we&#8217;ll look into it.  Anyway bottom line, don&#8217;t be a jerk.</p>
<p><img src="http://zazzer.me/images/screen5.jpg" alt="Pic during the game" /></p>
<h2>GAME PLAY/RULES</h2>
<p>SO!  On to the game (that&#8217;s why you&#8217;re here right?)!  There are 2 60 second rounds; one for you to try to figure out what Zazzer matched you on and 1 for your partner.  The purpose is for you to figure out the strongest thing you have in common faster than your partner (or at least be able to convince them that your idea is better).  You see, at the end the videos pause and then you both choose which you thought was the best.  If you both choose one you input, you get 10 points and they get 5.  If you choose differently though, then choosing your own will get you 2 points, and choosing theirs will get you a big fat 0.  So will you risk choosing theirs?</p>
<p>Also as you get more points you unlock special features (like being able to create labels instead of using the pre-set ones.  Many more features are being worked on currently and quite a few of them will be tied to point  totals.  Also you can filter your games based on how high you want their points per game average to be (to help you avoid jerks.</p>
<p><img src="http://zazzer.me/images/screen6.jpg" alt="During game" /></p>
<p>Below is a screen shot of choosing the item at the end of the game&#8230;</p>
<p><img src="http://zazzer.me/images/screen7.jpg" alt="Choose" /></p>
<p>One last curve ball.  You can hang out and talk to the person after the game.  You can add them as a friend. But you&#8217;re also allowed to give them +10 or -10 just for the heck of it (this is after scoring and they don&#8217;t find out).</p>
<h2>ONE LAST THING</h2>
<p>You can also be matched and just plain video chat with a random partner without having to play the game. Just uncheck game in your notification area.  And if you&#8217;re really shy and want to just be matched with no game and be given the option to add that person&#8230; you have that too &#8211; menu that&#8217;s always at the bottom of your screen</p>
<p>I&#8217;m sure no one ever reads this far so I&#8217;m stopping now.<br />
<div class="shr-publisher-525"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/devnotes/a-little-about-zazzer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zazzer &#8211; the Anti-Depressant</title>
		<link>http://flightschool.acylt.com/futurizing/zazzer-the-anti-depressant/</link>
		<comments>http://flightschool.acylt.com/futurizing/zazzer-the-anti-depressant/#comments</comments>
		<pubDate>Thu, 27 Oct 2011 03:37:51 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[Futurizing]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=532</guid>
		<description><![CDATA[You might have read articles before on how Facebook leads to depression. People have come up with all sorts of reasons why, but the one that makes the most sense to me is that when you get on you&#8217;re always presented with how awesome everyone else&#8217;s lives are. They have pictures, events, and it&#8217;s easy [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>You might have read articles before on how Facebook leads to depression.  People have come up with all sorts of reasons why, but the one that makes the most sense to me is that when you get on you&#8217;re always presented with how awesome everyone else&#8217;s lives are.  They have pictures, events, and it&#8217;s easy to feel left out (or at least like you&#8217;re not having quite as good a time).</p>
<p>The trouble with Facebook and other social networking sites is that they&#8217;re geared towards exactly that.  They&#8217;re there to let you post things about your life and to read about other people&#8217;s lives &#8211; and to talk I suppose &#8211; but they&#8217;re not there to get you actively involved with other people.</p>
<p><a href="http://zazzer.me" title="Zazzer" target="_blank">Zazzer</a> changes all that by being centered around social games that require actual face to face interaction.  It lets you write messages to people, organize your friends, input interests, but it also helps you meet people!</p>
<p>How does the game work?  If you hit play you ask Zazzer (your artificial intelligence wingman) to find you someone you could be friends with.  As soon as you&#8217;ve got a match your screen whizzes over to the game area.</p>
<p>There you have two 60 second rounds during which to guess what you were matched on (and what you have in common).  This all happens face to face via video chat!  As you input options they show up on the right and at the video pauses while each of you chooses which you thought was the best match.</p>
<p>If you choose the same one, the person that input that option into the list gets 10 points and the other gets 5.  If you choose differently then you get either 2 points or 0 points &#8211; 2 points if you choose your own, 0 points if you choose your partners and they&#8217;ve chosen a different one.</p>
<p>After the game is over you also can either give 10 points to your partner or take ten away if you like.  You can keep video chatting or you can end the stream and start a new game.</p>
<p>Why care about points?  Well as you get more points you get more control over who you&#8217;re matched with.  You can start putting in that you&#8217;d like to meet people who have similar interests &#8211; if you&#8217;re into baking well you can meet a fellow baker and collaborate on recipes!  You can also begin choosing different kinds of games and you can customize your profile and interests more than those just starting out.</p>
<p>More importantly though you can screen people through points.  In the notification area at the bottom there&#8217;s a little box that you can put points into.  If you set it at 0 you won&#8217;t be matched with anyone who has a points per game total less than 0.  That means if someone is a jerk and gets -10 in every game, their average will be -10 and you having 0 set means you won&#8217;t have to worry about being matched with them.  It also means if someone exposes themselves and you click on the report button, they&#8217;ll get -50 points and unless you&#8217;re allowing people with negative points to play you, you&#8217;ll never have to worry about being exposed to that sort of thing.</p>
<p>Anyway I&#8217;m going to put up a better description soon along with pictures so it&#8217;s easer to follow, but that&#8217;s a quick overview of why <a href="http://zazzer.me" title="Zazzer" target="_blank">http://Zazzer.me</a> is good for your health!</p>
<div class="shr-publisher-532"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/futurizing/zazzer-the-anti-depressant/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Novel</title>
		<link>http://flightschool.acylt.com/the_novel/the-novel/</link>
		<comments>http://flightschool.acylt.com/the_novel/the-novel/#comments</comments>
		<pubDate>Sun, 13 Feb 2011 22:24:20 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[The Novel]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=460</guid>
		<description><![CDATA[I have a novel in my mind that wants to be written somewhere so I&#8217;ve decided it&#8217;ll be here if I ever get around to it. I&#8217;ll release chapter by chapter as posts on this blog.]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>I have a novel in my mind that wants to be written somewhere so I&#8217;ve decided it&#8217;ll be here if I ever get around to it.  I&#8217;ll release chapter by chapter as posts on this blog.</p>
<div class="shr-publisher-460"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/the_novel/the-novel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dojo.forEach Error: No match found</title>
		<link>http://flightschool.acylt.com/devnotes/dojo-foreach-error-no-match-found/</link>
		<comments>http://flightschool.acylt.com/devnotes/dojo-foreach-error-no-match-found/#comments</comments>
		<pubDate>Mon, 18 Oct 2010 21:59:07 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[DevNotes]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=424</guid>
		<description><![CDATA[Errors in Javascript can be irritating sometimes, so I thought I&#8217;d start posting when I ran across one that didn&#8217;t show up when I googled for it. Here&#8217;s my first one, it&#8217;s a simple error thrown by dojo.forEach. I got this very descriptive error message in my console: &#8220;Error: No match found&#8221;. I stared at [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>Errors in Javascript can be irritating sometimes, so I thought I&#8217;d start posting when I ran across one that didn&#8217;t show up when I googled for it.  Here&#8217;s my first one, it&#8217;s a simple error thrown by dojo.forEach.</p>
<p>I got this very descriptive error message in my console: &#8220;Error: No match found&#8221;.<br />
<div id="attachment_427" class="wp-caption aligncenter" style="width: 471px"><a href="http://flightschool.acylt.com/wp-content/uploads/2010/10/error1.jpg"><img src="http://flightschool.acylt.com/wp-content/uploads/2010/10/error1.jpg" alt="Firebug Error for Dojo.forEach" title="error" width="461" height="234" class="size-full wp-image-427" /></a><p class="wp-caption-text">Firebug Error for Dojo.forEach</p></div><br />
I stared at it and then my code for a while before realizing that I had a reference to &#8220;this&#8221; inside my forEach loop, without giving the scope.  I&#8217;d written:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">dojo.<span style="color: #660066;">forEach</span><span style="color: #009900;">&#40;</span>array<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>entry<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
     <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">something</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>When what I should have written was:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">dojo.<span style="color: #660066;">forEach</span><span style="color: #009900;">&#40;</span>array<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>entry<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
     <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">something</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>The third parameter here, &#8220;this&#8221;, gave the scope forEach needed to be able to access the scope in the loop.</p>
<div class="shr-publisher-424"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/devnotes/dojo-foreach-error-no-match-found/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting Up Apple&#8217;s Aluminum Keyboard on Windows 7</title>
		<link>http://flightschool.acylt.com/devnotes/setting-up-apples-aluminum-keyboard-on-windows-7/</link>
		<comments>http://flightschool.acylt.com/devnotes/setting-up-apples-aluminum-keyboard-on-windows-7/#comments</comments>
		<pubDate>Tue, 19 Oct 2010 04:38:23 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[DevNotes]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=431</guid>
		<description><![CDATA[I found this and it worked almost perfectly (I get an error on startup that says &#8220;HFS+ Disk Support did not start&#8221; which doesn&#8217;t bother me since my sound control etc work on the keyboard) so I decided to post to make sure I don&#8217;t lose it on the net. It works for both 64 [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>I found this and it worked almost perfectly (I get an error on startup that says &#8220;HFS+ Disk Support did not start&#8221; which doesn&#8217;t bother me since my sound control etc work on the keyboard) so I decided to post to make sure I don&#8217;t lose it on the net.  It works for both 64 and 32 bit systems.  This is how to install the drivers for Apple&#8217;s keyboard on a Windows machine.  Let me know if you want me to post the files themselves.</p>
<p>First of all boot in windows, then insert your Snow Leopard disc.  Open a new window to explore disc content.  Go to Folder &#8220;Boot Camp&#8221; > &#8220;Drivers&#8221; > &#8220;Apple&#8221;</p>
<p>Copy &#8220;BootCamp.msi&#8221; or &#8220;BootCamp64.msi&#8221; to your desktop.</p>
<p>In the same folder copy the file &#8220;AppleKeyboardInstaller.exe&#8221; or take the one in &#8220;x64&#8243; folder if you&#8217;re on x64 system.  When the two files are copied on your desktop you can eject the disk.</p>
<p>Then with an utility like Winrar or 7-Zip extract the &#8220;AppleKeyboardInstaller.exe&#8221; content.  When it&#8217;s done run the file &#8220;DPInst.exe&#8221;</p>
<p>The keyboard will work now.</p>
<p>After that, search you need to run &#8220;BootCamp.msi&#8221; as administrator.</p>
<p>To run &#8220;BootCamp.msi&#8221; as administrator, first of all, you need to open cmd as administrator (&#8220;start menu&#8221; > &#8220;all programs&#8221; > accessories > &#8220;command prompt&#8221; then right click &#8220;run as administrator&#8221;).  In the command prompt, go to your desktop (cd /Users/*your users&#8217; name*/Desktop).  Then type &#8220;BootCamp.msi&#8221;.</p>
<p>When the install is finish, reboot and it&#8217;s ok!</p>
<div class="shr-publisher-431"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/devnotes/setting-up-apples-aluminum-keyboard-on-windows-7/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Git fatal: write error: Broken pipe</title>
		<link>http://flightschool.acylt.com/devnotes/git-fatal-write-error-broken-pipe/</link>
		<comments>http://flightschool.acylt.com/devnotes/git-fatal-write-error-broken-pipe/#comments</comments>
		<pubDate>Thu, 04 Nov 2010 03:34:21 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[DevNotes]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=441</guid>
		<description><![CDATA[When doing a large commit with Git over HTTP, sometimes I get &#8220;fatal: write error: Broken pipe&#8221; and it hangs. The fix is pretty simple, it&#8217;s just adding to the buffer: 1 git config http.postBuffer 104857600]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>When doing a large commit with Git over HTTP, sometimes I get &#8220;fatal: write error: Broken pipe&#8221; and it hangs.  The fix is pretty simple, it&#8217;s just adding to the buffer:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> config http.postBuffer <span style="color: #000000;">104857600</span></pre></td></tr></table></div>

<div class="shr-publisher-441"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/devnotes/git-fatal-write-error-broken-pipe/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Magick++, VS 2010 and Access violation writing location</title>
		<link>http://flightschool.acylt.com/devnotes/the-nightmare-that-is-magick-and-vs-2010/</link>
		<comments>http://flightschool.acylt.com/devnotes/the-nightmare-that-is-magick-and-vs-2010/#comments</comments>
		<pubDate>Wed, 03 Nov 2010 05:27:43 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[DevNotes]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=433</guid>
		<description><![CDATA[I&#8217;ve done the majority of my coding in Unix and Linux environments, so I&#8217;ve gotten used to the way they do things. Visual Studio 2010 has been a bit of an adjustment (with one or two headaches). I thought I&#8217;d write some tips in case this happens to be one of your headaches too. I [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>I&#8217;ve done the majority of my coding in Unix and Linux environments, so I&#8217;ve gotten used to the way they do things.  Visual Studio 2010 has been a bit of an adjustment (with one or two headaches).  I thought I&#8217;d write some tips in case this happens to be one of your headaches too.</p>
<p>I kept getting the error: &#8220;Unhandled exception &#8230; in &#8230;exe Access violation writing location&#8221; when trying to run Magick++ using the image class image(&#8220;my.image.jpg&#8221;).  Everything else worked fine, and it took a while to figure out the problem so I provide the solution below (and everything else I did so you can get the whole picture).  </p>
<p>If you&#8217;re trying to configure Magick++, there are a few things you want to make sure to do.  First off open up the demo that installs as Magick++_Demo and right click on any of the projects.  After clicking properties you&#8217;ll get the Property Page.</p>
<p>From there you&#8217;ll want to go to click on the arrow next to the &#8220;Linker&#8221; group, click on it and then click on &#8220;Input&#8221;.  There you&#8217;ll find &#8220;Additional Dependencies&#8221;.  In my case I copied all of this which happened to be:</p>
<p>CORE_RL_magick_.lib<br />
CORE_RL_Magick++_.lib<br />
X11.lib<br />
odbc32.lib<br />
odbccp32.lib<br />
winmm.lib<br />
wsock32.lib</p>
<p>You&#8217;ll also want to go to the &#8220;General&#8221; tab (also under &#8220;Linker&#8221;), and find the folder pointed to in the demo and put it in yours with the right path for &#8220;Additional Library Directories&#8221;.</p>
<p>Under &#8220;C/C++&#8221; click on &#8220;General&#8221; and do the same with &#8220;Additional Include Directories&#8221; there.  It&#8217;s also good to go to &#8220;VC++ Directories&#8221; and choose &#8220;Include Directories&#8221; and add ImageMagick&#8217;s include (for me that was ImageMagick-6.6.5-Q16\include) and under &#8220;Library Directories&#8221; add the lib directory (same as last but lib instead of include).</p>
<p>The kicker, and the setting that took me the longest to discover and change is under  &#8220;Configuration Properties/C/C++/Code Generation&#8221;.  Make sure the &#8220;Runtime Library&#8221; is set to &#8220;Multi-Threaded DLL (/MD)&#8221; and not to &#8220;Multi-Threaded Debug DLL (/MDd)&#8221; which is the default for the Debug setup. Then under &#8220;Configuration Properties/C/C++/Preprocessor&#8221; I read some people had to change the &#8220;Preprocessor Definition&#8221; that is set to &#8220;_DEBUG&#8221; to &#8220;NDEBUG&#8221; (for me nothing was set so I left it alone).</p>
<p>Hopefully this helps anyone else that ran into the dreaded &#8220;Unhandled exception at&#8230; in&#8230; Access violation writing location&#8221; error.  I&#8217;ll post screen shots if I get a minute (chances are I won&#8217;t unless you ask).</p>
<div class="shr-publisher-433"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/devnotes/the-nightmare-that-is-magick-and-vs-2010/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Zend_Json_Server and Dojox RPC</title>
		<link>http://flightschool.acylt.com/devnotes/zend_json_server-and-dojox-rpc-service/</link>
		<comments>http://flightschool.acylt.com/devnotes/zend_json_server-and-dojox-rpc-service/#comments</comments>
		<pubDate>Fri, 18 Feb 2011 03:26:37 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[DevNotes]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=462</guid>
		<description><![CDATA[If you&#8217;re anything like me you happened on this while searching through all of the other tutorials that get you everything EXCEPT the last little bit to get this rolling. Honestly two more lines on most of the things I read would have made this the easiest thing in the world to do. Instead here [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>If you&#8217;re anything like me you happened on this while searching through all of the other tutorials that get you everything <i>EXCEPT</i> the last little bit to get this rolling.  Honestly two more lines on most of the things I read would have made this the easiest thing in the world to do.  Instead here I am, writing it in case someone else has the same problem I did.</p>
<p>The first thing you&#8217;ll notice if you read tutorials about setting up Zend_Json_Server is that the json_rpc.php file gets put all over the place (some people even put the script in the bootstrap).  If you&#8217;re wondering, the right place to place it is in the public folder (I&#8217;m assuming you set up the Zend Framework with their <a href="http://zendframework.com/manual/en/learning.quickstart.create-project.html" target="_blank">default configuration</a> that has an application folder with the Controllers, Views, and Models a Library folder, etc).</p>
<p>This is what public/api/json_rpc.php should look like:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #990000;">set_include_path</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">implode</span><span style="color: #009900;">&#40;</span>PATH_SEPARATOR<span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
    <span style="color: #990000;">realpath</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">dirname</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/../../library'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
    <span style="color: #990000;">get_include_path</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">require_once</span> <span style="color: #0000ff;">&quot;Zend/Loader/Autoloader.php&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">require_once</span> <span style="color: #0000ff;">&quot;MyAppFolder/RPC.php&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$loader</span> <span style="color: #339933;">=</span> Zend_Loader_Autoloader<span style="color: #339933;">::</span><span style="color: #004000;">getInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$server</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Json_Server<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$server</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setClass</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'RPC'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// RPC is my handler class that I included above</span>
&nbsp;
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'GET'</span><span style="color: #339933;">==</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REQUEST_METHOD'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">// Here the target is the path of the $server-&gt;handle() which happens</span>
    <span style="color: #666666; font-style: italic;">// to be this exact path</span>
    <span style="color: #000088;">$server</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setTarget</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/api/json-rpc.php'</span><span style="color: #009900;">&#41;</span>
            <span style="color: #339933;">-&gt;</span><span style="color: #004000;">setEnvelope</span><span style="color: #009900;">&#40;</span>Zend_Json_Server_Smd<span style="color: #339933;">::</span><span style="color: #004000;">ENV_JSONRPC_2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$smd</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$server</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getServiceMap</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// I read articles that said you need to do this to set Dojo Compatibility</span>
    <span style="color: #666666; font-style: italic;">// but it turns out that including the line below actually made it not work</span>
    <span style="color: #666666; font-style: italic;">// so I commented it out below just as an FYI</span>
    <span style="color: #666666; font-style: italic;">// $smd-&gt;setDojoCompatible(true);</span>
&nbsp;
    <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$smd</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">return</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000088;">$server</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">handle</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>As you can see from above, none of my RPC handling happens in the MVC framework.  I avoid all of the overhead by doing this and it&#8217;s easier to deal with anyway.  The json_rpc.php is in the public folder, and my RPC handling class is in the library folder alongside the Zend folder in a folder I named MyAppFolder.</p>
<p>Another important note.  The class that I included and then loaded for the Zend_Json_Server needs to be parameterized in order for it to be able to create the SMD file to send to the client.  If you don&#8217;t know what an SMD file is, take a look <a href="http://www.sitepen.com/blog/2008/03/19/pluggable-web-services-with-smd/" target="_blank">here</a>.  It defines the functions you can call remotely and defines what to expect in return.</p>
<p>What I mean by parameterize is:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> RPC 
<span style="color: #009900;">&#123;</span>
    <span style="color: #009933; font-style: italic;">/**
     * Return a friendly message
     *
     * @param int id
     * @return string
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getMessage<span style="color: #009900;">&#40;</span><span style="color: #000088;">$id</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #0000ff;">&quot;You sent: &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$id</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The javascript for your front end is pretty easy too.  I implemented mine with Dojo (which is awesome, I recommend it above all the other Javascript toolkits), and it looked like this:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">dojo.<span style="color: #660066;">require</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;dojox.rpc.Service&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> myRpc <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> dojox.<span style="color: #660066;">rpc</span>.<span style="color: #660066;">Service</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;api/json-rpc.php&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> dojoDeferredObject <span style="color: #339933;">=</span> myRpc.<span style="color: #660066;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">123</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
dojoDeferredObject.<span style="color: #660066;">then</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>result<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
     <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;You said: &quot;</span><span style="color: #339933;">+</span>result<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>This gives me a deferred object (has to wait for the server trip) which I can then use to create the alert or do whatever I want to with the result.</p>
<p>For a great article on dealing with deferred objects look <a href="http://www.sitepen.com/blog/2010/05/03/robust-promises-with-dojo-deferred-1-5/" target="_blank">here</a>.</p>
<p>For the original information from Zend, look <a href="http://framework.zend.com/manual/en/zend.json.server.html" _target="blank">here</a>.</p>
<div class="shr-publisher-462"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/devnotes/zend_json_server-and-dojox-rpc-service/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Javascript Truthy Falsy</title>
		<link>http://flightschool.acylt.com/devnotes/javascript-truthy-falsy/</link>
		<comments>http://flightschool.acylt.com/devnotes/javascript-truthy-falsy/#comments</comments>
		<pubDate>Sat, 14 Aug 2010 19:34:33 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[DevNotes]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=341</guid>
		<description><![CDATA[Every once in a while I get confused on truthy falsies in javascript, so I thought I&#8217;d compile some things I&#8217;ve found and write down the cases so I have something for future reference (and so it sticks). First I&#8217;ll list the truthy/falsy cases, and then I&#8217;ll go over the difference between Javascript and traditional [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>Every once in a while I get confused on truthy falsies in javascript, so I thought I&#8217;d compile some things I&#8217;ve found and write down the cases so I have something for future reference (and so it sticks).</p>
<p>First I&#8217;ll list the truthy/falsy cases, and then I&#8217;ll go over the difference between Javascript and traditional languages in what they return from operators such as &amp;&amp; and || (Javascript doesn&#8217;t return true or false is what I&#8217;m driving at, that&#8217;ll make sense in a minute).</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> emptyString <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//falsy</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> nonEmptyString <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;this is text&quot;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// truthy</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> numberZero <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// falsy</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> numberOne <span style="color: #339933;">=</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// truthy</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> emptyArray <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// truthy, BUT []==false is true. More below.</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> emptyObject <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// truthy</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> notANumber <span style="color: #339933;">=</span> <span style="color: #CC0000;">5</span> <span style="color: #339933;">/</span> <span style="color: #3366CC;">&quot;tree&quot;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// falsy</span>
<span style="color: #006600; font-style: italic;">// NaN is a special javascript object for &quot;Not a Number&quot;.</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> exampleFunction<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
      <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Test&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #006600; font-style: italic;">// examleFunction is truthy</span>
<span style="color: #006600; font-style: italic;">// BUT exampleFunction() is falsy because it has no return (undefined)</span></pre></td></tr></table></div>

<p>Strings of some falsies from above are true:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> test <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;0&quot;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// this is a string, not a number</span>
&nbsp;
<span style="color: #009900;">&#40;</span>test <span style="color: #339933;">==</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// returns false, test string is truthy</span>
&nbsp;
<span style="color: #009900;">&#40;</span>test <span style="color: #339933;">*</span> <span style="color: #CC0000;">1</span> <span style="color: #339933;">==</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// returns true, test is now a number, falsy</span></pre></td></tr></table></div>

<p>Arrays can cause trouble.  An empty array is already set aside, so it comes up as true.  But comparing an empty array to a boollean is false.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
     <span style="color: #006600; font-style: italic;">// code runs</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
     <span style="color: #006600; font-style: italic;">// runs too</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
     <span style="color: #006600; font-style: italic;">// doesn't run</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
     <span style="color: #006600; font-style: italic;">// doesn't run either</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Difference between Javascript and PHP, Javascript: empty arrays are true.  PHP they&#8217;re false.  In PHP the string &#8220;0&#8243; is also false.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?</span> php
&nbsp;
<span style="color: #000088;">$emptyArray</span> <span style="color: #339933;">=</span> arra<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// falsy in PHP</span>
&nbsp;
<span style="color: #000088;">$stringZero</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;0&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// falsy in PHP</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Ok so those are some of the basic for what evaluates as true and false, here they are in action.  What happens is Javascript evaluates whether or not things are true and then returns them if they meet the criteria.  For example:</p>
<p>Logical or, ||</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;first string&quot;</span> <span style="color: #339933;">||</span> <span style="color: #3366CC;">&quot;second string&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// returns first string</span>
&nbsp;
<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;first string&quot;</span> <span style="color: #339933;">||</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// returns first string</span>
&nbsp;
<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span> <span style="color: #339933;">||</span> <span style="color: #3366CC;">&quot;second string&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// returns &quot;second string&quot;</span>
&nbsp;
<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span> <span style="color: #339933;">||</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// returns false</span></pre></td></tr></table></div>

<p>That allows functions to have optional parameters:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> speak<span style="color: #009900;">&#40;</span>word<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> word <span style="color: #339933;">=</span> word <span style="color: #339933;">||</span> <span style="color: #3366CC;">&quot;You gave me no word&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>word<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
&nbsp;
speak<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Hello&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// alerts Hello</span>
&nbsp;
speak<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// alerts You gave me no word</span>
<span style="color: #006600; font-style: italic;">//word is null when function is started</span></pre></td></tr></table></div>

<p>Logical and, &amp;&amp;:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;first string&quot;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #3366CC;">&quot;second string&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// returns &quot;second string&quot;</span>
&nbsp;
<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;first string&quot;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// returns &quot;&quot;</span>
&nbsp;
<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #3366CC;">&quot;test two&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #006600; font-style: italic;">// returns 0</span></pre></td></tr></table></div>

<p>That&#8217;s sweet because one variable can depend on other:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> checkbox <span style="color: #339933;">=</span> dojo.<span style="color: #660066;">byId</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;agreeToTerms&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//or getElementById if you're not using dojo</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> <span style="color: #000066;">name</span> <span style="color: #339933;">=</span> checkbox.<span style="color: #660066;">checked</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000066;">prompt</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;What is your name&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">//name is either their name, or false if they haven't checked the agreeToTerms checkbox</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// IMPORTANT NOTE: Internet Explorer 8 sucks as usual and breaks the prompt function.</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> createArrowNav <span style="color: #339933;">=</span> createArrowNav <span style="color: #339933;">||</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//parameter passed for creating arrow nav</span>
&nbsp;
createArrowNav <span style="color: #339933;">&amp;&amp;</span> createArrowNav<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// function createArrowNav runs if the parameter is true, returns false otherwise</span></pre></td></tr></table></div>

<p>Logical not, ! (this one actually turns what it gets to the opposite truth value, as opposed to || and &amp;&amp; returning the truth value)</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #3366CC;">&quot;first string&quot;</span> <span style="color: #339933;">||</span> <span style="color: #3366CC;">&quot;second string&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// returns first string</span>
&nbsp;
<span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #3366CC;">&quot;first string&quot;</span> <span style="color: #339933;">||</span> <span style="color: #3366CC;">&quot;second string&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// returns false</span>
&nbsp;
<span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #CC0000;">0</span> <span style="color: #339933;">||</span> <span style="color: #339933;">!</span><span style="color: #3366CC;">&quot;second string&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// returns true</span>
<span style="color: #006600; font-style: italic;">// 0 converts to true and is returned</span></pre></td></tr></table></div>

<p>You can use that to get true or false no matter what you&#8217;ve been given</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#40;</span><span style="color: #339933;">!!</span><span style="color: #3366CC;">&quot;test&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// returns true</span>
&nbsp;
<span style="color: #009900;">&#40;</span><span style="color: #339933;">!!</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// returns false</span>
&nbsp;
<span style="color: #009900;">&#40;</span><span style="color: #339933;">!!</span>variableThatDoesntExist<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// returns false even though checking for undefined variable</span></pre></td></tr></table></div>

<div class="shr-publisher-341"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/devnotes/javascript-truthy-falsy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Javascript Functions, Scope, Call, Apply, and Gobblygook</title>
		<link>http://flightschool.acylt.com/devnotes/javascript-functions-scope-call-apply-and-gobblygook/</link>
		<comments>http://flightschool.acylt.com/devnotes/javascript-functions-scope-call-apply-and-gobblygook/#comments</comments>
		<pubDate>Wed, 01 Sep 2010 05:48:02 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[DevNotes]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=363</guid>
		<description><![CDATA[If that title didn&#8217;t make any sense and you&#8217;re wondering if you came to the right place this will be about Javascript functions. I&#8217;ll touch on everything from how scope works with Javascript, to using it with objects and even bending it using call/apply. This is meant to be the beginning of an exploration of [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>If that title didn&#8217;t make any sense and you&#8217;re wondering if you came to the right place this will be about Javascript functions.  I&#8217;ll touch on everything from how scope works with Javascript, to using it with objects and even bending it using call/apply.  This is meant to be the beginning of an exploration of how Javascript can be an object oriented, class driven language even though at first its prototypal nature doesn&#8217;t seem to lend itself to it (with some Dojo Toolkit cheerleading along the way-because Dojo is awesome and for any who haven&#8217;t used it, it&#8217;s like JQuery on steroids.  It supports classes and inheritance with its dojo.declare() object.  To learn more look that up over at <a href="http://docs.dojotoolkit.org/" target="_blank">docs.dojotoolkit.org</a>).</p>
<p>Before I get started I need to do a quick aside on firebug and the javascript console.  If you already know all about it skip to the =======Done with the firebug aside===== line.</p>
<p>If you don&#8217;t know about it, firebug will make coding javascript much easier.  It will also let you test my examples.  So go to <a href="http://getfirebug.com/" target="_blank">http://getfirebug.com/</a>, install it on FireFox (the best browser to develop javascript in, that&#8217;s not just my opinion), and read a little about it.  For this tutorial I&#8217;ll just use console.log() to show values returned by functions.  If you read nothing else over there, at least glance at that.</p>
<p>=======Done with the firebug aside=======<br />
Ok, now that&#8217;s out of the way lets start with functions.  In javascript creating functions and calling them is as simple as:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> createArray<span style="color: #009900;">&#40;</span>a<span style="color: #339933;">,</span> b<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
     <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #009900;">&#91;</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span> a<span style="color: #339933;">,</span> b <span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> myArray <span style="color: #339933;">=</span> createArray<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'testing'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'check'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>myArray<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">// array members: window, &quot;testing&quot;, and &quot;check&quot; print out in the console</span></pre></td></tr></table></div>

<p>If you want to create a well designed web app, this is not so good.  Why?  Because you created and called the function in the global namespace (notice that &#8220;this&#8221;, the first member returned in the array came back as &#8220;window&#8221;).</p>
<p>Context is a big deal in javascript, and if you don&#8217;t supply the context Javascript supplies it for you (hence the window, global object).  It picks up all your stray functions, like a giant comfortable bus would pick up homeless in a perfect world.  That doesn&#8217;t mean it&#8217;s a loose global function though.  Instead it&#8217;s a method of the window object, which means you can call the function like this:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> myArray <span style="color: #339933;">=</span> window.<span style="color: #660066;">createArray</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'testing'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'check'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>myArray<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #006600; font-style: italic;">// [ window, 'testing', 'check' ]</span>
&nbsp;
console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span><span style="color: #009900;">&#40;</span>window.<span style="color: #660066;">nonExistantMethod</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">//undefined</span>
console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span><span style="color: #009900;">&#40;</span>window.<span style="color: #660066;">createArray</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">//function</span></pre></td></tr></table></div>

<p>So if you want to avoid globals in Javascript (as you should), then you should start playing with objects.  An object is simply something between curly braces ({}).  So lets make an object to attach this function to:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">//First store the object as a var.  This would be its namespace</span>
<span style="color: #003366; font-weight: bold;">var</span> arrayEr <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
     someProperty<span style="color: #339933;">:</span> <span style="color: #3366CC;">'a value of this object'</span><span style="color: #339933;">,</span>
     ourFunction<span style="color: #339933;">:</span> <span style="color: #3366CC;">'createArray'</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #006600; font-style: italic;">//Notice that in an object the value name is followed by a colon</span>
<span style="color: #006600; font-style: italic;">//and then the value in the object</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> test <span style="color: #339933;">=</span> arrayEr.<span style="color: #660066;">ourFunction</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'testing'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'check'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>test<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">//[ arrayEr, 'testing','check' ]</span>
&nbsp;
<span style="color: #006600; font-style: italic;">//You could also call the function as if it were an array</span>
<span style="color: #003366; font-weight: bold;">var</span> test <span style="color: #339933;">=</span> arrayEr<span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'ourFunction'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'testing'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'check'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>test<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">//[ arrayEr, 'testing','check' ]</span></pre></td></tr></table></div>

<p>We made the object &#8220;arrayEr&#8221; and for its method ourFunction we wrote the string &#8216;createArray&#8217;.  That made it so that when we called arrayEr.ourFunction() as a method it looked for the function named &#8216;createArray&#8217; and called it.  The cool thing here is it called it in its scope.  Instead of window it was arrayEr.  We did this as an exercise, the best way to define this sort of thing would actually be like this:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> arrayEr <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
     someProperty<span style="color: #339933;">:</span> <span style="color: #3366CC;">'a value of this object'</span><span style="color: #339933;">,</span>
     ourFunction<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>a<span style="color: #339933;">,</span> b<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
          <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #009900;">&#91;</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">someProperty</span><span style="color: #339933;">,</span> a<span style="color: #339933;">,</span> b <span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
     <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #003366; font-weight: bold;">var</span> test <span style="color: #339933;">=</span> arrayEr.<span style="color: #660066;">ourFunction</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'testing'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'whatever'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>test<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">//[arrayEr, 'a value of this object', 'testing', 'whatever' ]</span></pre></td></tr></table></div>

<p>Here instead of looking the function up by the name &#8216;createArray&#8217; we have created it as a method named &#8216;ourFunction&#8217;.  I added a little bit of code that would return the property of the object too, and it showed up in the returned array.  Cool huh!</p>
<p>Scope can be a little tricky, so here&#8217;s an example that lets you get an idea of how it works:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;input type=&quot;button&quot; value=&quot;Button 1&quot; id=&quot;btn1&quot;  /&gt;  
&lt;input type=&quot;button&quot; value=&quot;Button 2&quot; id=&quot;btn2&quot;  /&gt;  
&lt;input type=&quot;button&quot; value=&quot;Button 3&quot; id=&quot;btn3&quot;  onclick=&quot;buttonClicked();&quot;/&gt;  
&nbsp;
&lt;script type=&quot;text/javascript&quot;&gt;  
function buttonClicked(){  
    var text = (this === window) ? 'window' : this.id;  
    alert( text );  
}  
var button1 = document.getElementById('btn1');  
var button2 = document.getElementById('btn2');  
&nbsp;
button1.onclick = buttonClicked;  
button2.onclick = function(){   buttonClicked();   };  
&lt;/script&gt;</pre></td></tr></table></div>

<p>Click the first button and you get &#8220;btn1&#8243; because it&#8217;s a method invocation and this will be assigned the owner object (the button input element).  Click the second button and you get &#8220;window&#8221; because buttonClicked is being called directly (i.e. not like obj.buttonClicked()). Clicking the third gives the same result, because assigning the event handler in the element&#8217;s tag calls it directly like the second did.</p>
<p>Dojo has handy functions for event handling, like dojo.connect().  With dojo.connect() you can specify the scope you want, again for a better look at that docs.dojotoolkit.org is a good place to go.</p>
<p>This can happen because Javascript has two handy functions, call and apply.  These let you call functions in different scopes than their own.  For example:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> Dog <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
     sound<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;woof&quot;</span><span style="color: #339933;">,</span>
     talk<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #000066;">name</span><span style="color: #339933;">,</span> nature<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
          console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">sound</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;, &quot;</span><span style="color: #339933;">+</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">sound</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;, my name is &quot;</span><span style="color: #339933;">+</span><span style="color: #000066;">name</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot; &quot;</span><span style="color: #339933;">+</span>nature<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #003366; font-weight: bold;">var</span> Cat <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
     sound<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;meow&quot;</span><span style="color: #339933;">,</span>
     talk<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #000066;">name</span><span style="color: #339933;">,</span> nature<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
          console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">sound</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;, &quot;</span><span style="color: #339933;">+</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">sound</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;, my name is &quot;</span><span style="color: #339933;">+</span><span style="color: #000066;">name</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot; &quot;</span><span style="color: #339933;">+</span>nature<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
Dog.<span style="color: #660066;">talk</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;fido&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;the dog&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">//woof, woof, my name is fido the dog</span>
Cat.<span style="color: #660066;">talk</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;felix&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;the cat&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">//meow, meow, my name is felix the cat</span>
Cat.<span style="color: #660066;">talk</span>.<span style="color: #660066;">call</span><span style="color: #009900;">&#40;</span>Dog<span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;felix&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;the cat&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">//woof, woof, my name is felix the cat</span>
Dog.<span style="color: #660066;">talk</span>.<span style="color: #660066;">apply</span><span style="color: #009900;">&#40;</span>Cat<span style="color: #339933;">,</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">&quot;fido&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;the dog&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">//meow, meow, my name is fido the dog</span></pre></td></tr></table></div>

<p>Pretty cool right?  Call and apply require the new scope, then call takes the parameters as separate arguments while apply takes them as an array.  That lets you call functions in different scopes!  A Cat object can be made to &#8220;woof&#8221; while a Dog can be made to &#8220;meow&#8221;.  This may not seem like a lot at first glance, but it is one of the most powerful features in Javascript and mastering it lets you do all kinds of awesome things.</p>
<div class="shr-publisher-363"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/devnotes/javascript-functions-scope-call-apply-and-gobblygook/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Abstract Factory vs Factory Method</title>
		<link>http://flightschool.acylt.com/devnotes/abstract-factory-vs-factory-method/</link>
		<comments>http://flightschool.acylt.com/devnotes/abstract-factory-vs-factory-method/#comments</comments>
		<pubDate>Wed, 15 Sep 2010 05:38:59 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[DevNotes]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=374</guid>
		<description><![CDATA[Here&#8217;s a friendly dip into design patterns. It&#8217;s based on the ideas presented by the gang of four. The Abstract Factory and Factory Method design patterns are similar in that they both decouple the creation of an object from its code. While Abstract Factory is used to create families of objects, the Factory Method is [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>Here&#8217;s a friendly dip into design patterns.  It&#8217;s based on the ideas presented by the gang of four.</p>
<p>The Abstract Factory and Factory Method design patterns are similar in that they both decouple the creation of an object from its code.  While Abstract Factory is used to create families of objects, the Factory Method is geared towards deferring creation of objects to subclasses in order to improve reusability of code among other things.  Because of this they differ in many ways in the structure and use of classes (class relationships).</p>
<h3>Abstract Factory</h3>
<p>The Abstract Factory design takes a part of a program and encapsulates it (lets say the classes of objects determining look and feel).  If we had different themes- tundra, nihilo, etc., the Abstract Factory would make it so that we could define which theme we wanted to be active at the outset of the program.  That way we would have the flexibility to easily change from one to another.</p>
<p>The Abstract Factory class declares the interface for creating objects etc, but it’s the concrete classes that actually implement them.  That ensures the interface stays uniform across all concrete subclasses.  For example to make a button, the abstract factory would have the make_button() interface.  However the individual themes would have code that would actually build the button to the theme’s specification when make_button() was called.  That way none of the other classes have to know which theme was actually instantiated.</p>
<h3>Factory Method</h3>
<p>The Factory Method similarly defines an interface for creating objects.  However the difference is that it lets subclasses decide how to instantiate.</p>
<p>For example, say we have an object that needs a window to contain it.  As part of the constructor we could just write: new window().  The problem is that if I wanted a more flexible scrolling_window, I would have to write an entirely new class with: new scrolling_window() in the constructor to achieve the simple difference.</p>
<p>The Factory Method solves this by writing the class with functions that create the new object themselves.  Instead of writing: new window(), I create a hook for subclasses, like a function create_window().  If the parent is an abstract class, create_window() will be blank for the concrete children to fill with things like: new window() or new scrolling_window().  If the parent isn’t abstract it will have a reasonable default value (like new window()) to be overwritten by application-specific children.  In this way I maintain the interface while the subclasses instantiate with what they need and minimal extra code.</p>
<h3>Compared</h3>
<p>The structure and class relationships are similar in the sense that often they use subclassing to move from abstract classes to concrete classes in order to create flexibility.  They maintain interfaces and they encapsulate the different implementations.</p>
<p>They differ in that the Abstract Factory is usually implemented as a Singleton which would create a family of objects.  It’s usually set while the application loads and not changed afterwards.  It is good for big groups of changes that need to happen based on which OS you’d be using, which theme, etc.  It’s not to give flexibility for creating objects on demand, since usually once one concrete factory is chosen, it won’t be changed.  An example diagram would be:</p>
<p style="text-align: center;"><a href="http://flightschool.acylt.com/wp-content/uploads/2010/09/abstractFac.jpg"><img class="size-full wp-image-375 aligncenter" title="Abstract Factory" src="http://flightschool.acylt.com/wp-content/uploads/2010/09/abstractFac.jpg" alt="Abstract Factory Example" width="600" height="303" /></a></p>
<p>The Factory Method on the other hand isn’t usually a thematic group or a Singleton.  Instead it is an implementation that allows flexibility in object creation.  Thus it doesn’t necessarily create a family of objects as much as it gives a family of possible customizations.  It isn’t set during loading like the Abstract Factory is, so any of its children can be instantiated during execution and interact with other objects.  An example diagram here is:</p>
<p><a href="http://flightschool.acylt.com/wp-content/uploads/2010/09/factoryMethod.jpg"><img class="aligncenter size-full wp-image-376" title="Factory Method" src="http://flightschool.acylt.com/wp-content/uploads/2010/09/factoryMethod.jpg" alt="Example Factory Method" width="600" height="250" /></a></p>
<div class="shr-publisher-374"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/devnotes/abstract-factory-vs-factory-method/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Snow Leopard Defrag &#8220;Files cannot be moved&#8221;</title>
		<link>http://flightschool.acylt.com/devnotes/snow-leopard-defragmentation/</link>
		<comments>http://flightschool.acylt.com/devnotes/snow-leopard-defragmentation/#comments</comments>
		<pubDate>Sun, 10 Oct 2010 02:54:40 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[DevNotes]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=381</guid>
		<description><![CDATA[I tried to set up Bootcamp and got the dreaded &#8220;Files cannot be moved&#8221; error. Basically what it was saying was even though I had 50 some odd gigs of extra space, I couldn&#8217;t get a 30 GB block of data. In other words my hard drive was fragmented. If you read about that online [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>I tried to set up Bootcamp and got the dreaded &#8220;Files cannot be moved&#8221; error.  Basically what it was saying was even though I had 50 some odd gigs of extra space, I couldn&#8217;t get a 30 GB block of data.  In other words my hard drive was fragmented.</p>
<p>If you read about that online you&#8217;ll find many Mac users that are adamant that OS X defrags automatically.  It does, for small files, but for big ones it doesn&#8217;t.  Then people argue over whether it makes a difference or not in system performance.  That&#8217;s a no brainer, yes, your system runs better when it is defragmented (even if it&#8217;s just a little bit).</p>
<p>So I needed to defragment.</p>
<p>The next question was, how?  After searching online the best option seemed to be iDefrag.  It was one of the only options if you look at defragmenting a drive from a Windows perspective, and since the only drives I&#8217;ve ever formatted have been Windows drives, that&#8217;s how I was looking at it.  While reading I came across people supporting this software by saying Apple&#8217;s official position of restoring the drive was ridiculous.  At first I thought, yeah, that&#8217;s ridiculous.  After thinking about it more I realized that not only did Apple&#8217;s position have merit, but it was by far the best one.  This is why.</p>
<p>Restoring from Time Machine is faster and cleaner than iDefrag.</p>
<p>If you don&#8217;t have Time Machine set up, today is the day you will finally do what you should have had all along.  You will buy an external drive and set it up.  First of all not only does it back up your drive in case of a catastrophic error, it also backs up files from YOUR errors (we&#8217;ve all deleted files on accident).  Second of all, if you have it set up, then this is what happens.  Instead of having code run on all your files and try (based on algorithms) to place them in optimal positions and taking forever to do it, all you need to do is a system restore from Time Machine.  Why is that better?</p>
<p>Because when Time Machine backs up your files and restores them, it doesn&#8217;t put them back in their same fragmented placement.  It puts them back better than it could have put them there in the first place when you installed all of your files, because it already KNOWS exactly what you want to put on there ahead of time.</p>
<p>I had 240 GB of information to defrag and it took me 2 hours.  All I did was put in my Snow Leopard DVD, and then when I got to the installer menu chose from utilities and restore from backup.  That&#8217;s it.  Afterwards I used the free version of iDefrag to see how well it worked and it was perfect.  Beautiful.</p>
<p>PLUS, I magically gained over 10 GB!  A lot was hiding in my mess of a disk.</p>
<p>Moral of the story.  If you want to defrag your OS X system, just restore from your Time Machine backup every once in a while.  It&#8217;s Apple&#8217;s suggestion and it works perfectly.</p>
<div class="shr-publisher-381"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/devnotes/snow-leopard-defragmentation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Iptables and Virtual Networks</title>
		<link>http://flightschool.acylt.com/devnotes/iptables-and-virtual-networks/</link>
		<comments>http://flightschool.acylt.com/devnotes/iptables-and-virtual-networks/#comments</comments>
		<pubDate>Sun, 10 Oct 2010 18:52:04 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[DevNotes]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=386</guid>
		<description><![CDATA[I&#8217;ve been messing around with Networks lately. DHCP servers, Iptables, DNS, FTP, SSH, HTTP, and on. The best way to do it that I&#8217;ve found is through virtual machines. That way you can monitor everything all from one computer. Personally I&#8217;ve gone with a lightweight Fedora 8 install on VMWare. This post will be about [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>I&#8217;ve been messing around with Networks lately.  DHCP servers, Iptables, DNS, FTP, SSH, HTTP, and on.  The best way to do it that I&#8217;ve found is through virtual machines.  That way you can monitor everything all from one computer.  Personally I&#8217;ve gone with a lightweight Fedora 8 install on VMWare.  This post will be about Iptables, so for the network configuration I used two custom networks, both host-only.</p>
<p>I started by making three machines.  One represented the private network (192.168.0.0/24), one represented the gateway/firewall, and one represented the public network (10.0.0.0/8).  I then configured the machines so that the private network could access the public via only http, ping, and ftp.  The public could access the private only via http and ssh, which were configured to map to a specific node (or web server).  The gateway itself could access both public and private networks with ping and ssh, but could only be accessed via ssh by the private network.  The forwarding was handled with NAT, or Network Address Translation.</p>
<h2>Network Setup</h2>
<p>Here&#8217;s what my network looks like.  The words in all caps are variables that I use in my Iptables configuration file.  I&#8217;ll include that at the end.<br />
<a href="http://flightschool.acylt.com/wp-content/uploads/2010/10/proj2network.jpg"><img class="aligncenter size-full wp-image-387" title="Network Description" src="http://flightschool.acylt.com/wp-content/uploads/2010/10/proj2network.jpg" alt="" width="470" height="213" /></a></p>
<h2>Software Packages</h2>
<ul>
<li>-Wireshark-gnome</li>
<li>-Vsftpd</li>
<li>-And the other common packages such as Apache</li>
</ul>
<h2>Quick Overview of Iptables</h2>
<p>I&#8217;m not going to talk so much about what Iptables as I am about how to implement them.  Because of that I&#8217;ll only give a quick, high level view of how they work.  If this is your first time looking at Iptables I recommend reading something else to give you a little more background information&#8230; but this might be enough if you&#8217;re a learn by doing kind of person.</p>
<p>When packets arrive at the firewall, they&#8217;re processed and checked to see if the NAT (network address translation) table needs to translate them.  This is because sometimes a server sits behind a firewall on a private network but needs a presence in the public internet.  It uses the gateway&#8217;s public address, but the gateway has to know to forward those on.  NAT does that.</p>
<p>It&#8217;s important that happen first because then the packets are processed.  The packets being forwarded are added to the FORWARD chain.  The packets meant for the gateway enter the INPUT chain.  The packets ready to leave the gateway (not forwarded from the gateway, but originating from the gateway) go into the OUTPUT chain.</p>
<p>Each chain can have rules added to it (-A) and they are all processed sequentially.  A packet will continue through the rules until it is accepted (ACCEPT) or dropped (DROP).  Along the way it is common to see jump commands (-j) sending types of packets to rules meant to process together.</p>
<p>If the packet is accepted it reaches the firewall lets it through to its destination.  DROP makes the packet go *poof, and REJECT sends a nice message to the sender of the packet that their communication has not been accepted so they don&#8217;t wait with the little spinner on their browser going until it times out.</p>
<p>Ok enough of the high level, lets get to the implementation.</p>
<h2>Description</h2>
<p>I used the whitelist approach, which is the most secure.  This means that by default I drop all packets, only accepting those on my whitelist.  (Blacklist is accepting all by default and marking packets to drop &#8211; not much of a firewall).  During this description I&#8217;ll type relevant lines from my Iptables file and then include it in completed form at the end.</p>
<p>As I mentioned before I set up the network with two host-only networks (simulated switches).  I set the private network to have the static IP 192.168.0.1 with the subnet mask 255.255.255.0 and the GW 192.168.0.254.  The public network’s IP was 10.0.0.1 with a subnet mask 255.0.0.0 and a GW of 10.0.0.254 (in Fedora 8 setting this up is as simple as typing neat&amp; in the command line and then adding a network adapter with the IP as static).  The gateway had two ports (one to connect to the public network and one to connect to the private), which I matched to their respective pairs (public side to the public server, etc) so they’d be on the same switch.  One was 192.168.0.254 with the same subnet mask as its pair (255.255.255.0) and itself as the gateway.  The other followed the same pattern with its IP as 10.0.0.254.</p>
<p>After the network was ready I started working on my firewall.  I set up the default drops like so:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-P</span> INPUT DROP
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-P</span> OUTPUT DROP
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-P</span> FORWARD DROP</pre></div></div>

<h2>FORWARDING and NAT</h2>
<p>Once that was done I got to work on my first task.  This was all about forwarding traffic correctly, and to save myself time later I set up the NAT (Network address translation.  This setting makes it so my server changes my address so that whichever computer I&#8217;m talking to on the internet knows to send messages to it, and then it sends them to me).  My settings were:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-t</span> nat <span style="color: #660033;">-A</span> PREROUTING <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">-d</span> <span style="color: #007800;">$LAN_0_IP</span> <span style="color: #660033;">--dport</span> <span style="color: #000000;">80</span> <span style="color: #660033;">-j</span> DNAT <span style="color: #660033;">--to</span> <span style="color: #007800;">$WEB_IP_ADDRESS</span>:<span style="color: #000000;">80</span>
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-t</span> nat <span style="color: #660033;">-A</span> POSTROUTING <span style="color: #660033;">-s</span> <span style="color: #007800;">$INTERNAL_PRIVATE_SUBNET</span> <span style="color: #660033;">-o</span> <span style="color: #007800;">$LAN_0_IFACE</span> <span style="color: #660033;">-j</span> SNAT <span style="color: #660033;">--to</span> <span style="color: #007800;">$LAN_0_IP</span></pre></div></div>

<p>For now making sense of this should be easy just referring to the network image above (again the variables are at the end of this post).  The important point is that for pre-routing, when the destination was the public side of the gateway and was HTTP (port 80), it was forwarded to a node in the private network.  Post routing took as a source the internal network’s IP address range and converted it as it left the public interface and gave it the gateway’s public address.</p>
<p>-A adds the chain, -p is the protocol, -d the destination &#8211;dport the destination port, &#8211;sport would be source port, -j is where to jump in the chain (this case jumps to DNAT &#8211; destination network address translation), -o is the output interface, -s the source, -t the table.  This isn&#8217;t an exhaustive list, a good reference for a more in-depth look at the commands can be found here: <a href="http://www.dd-wrt.com/wiki/index.php/Iptables_command" target="_blank">http://www.dd-wrt.com/wiki/index.php/Iptables_command</a>.</p>
<p>There will be screenshots showing this in motion soon.  For now it lay the foundation so I could do task 1 without worrying about having to change anything later.</p>
<p>My next step was to enable HTTP, FTP, and ping from private to public.  I did this by adding a new set of rules (-N) for TCP packets and adding rules (-A) allowing them:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-N</span> tcp_packets
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-N</span> allowed
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> tcp_packets <span style="color: #660033;">-p</span> TCP <span style="color: #660033;">-s</span> <span style="color: #007800;">$INTERNAL_PRIVATE_SUBNET</span> <span style="color: #660033;">-m</span> multiport <span style="color: #660033;">--dport</span> <span style="color: #000000;">80</span>,<span style="color: #000000;">20</span>,<span style="color: #000000;">21</span> <span style="color: #660033;">-j</span> allowed
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> allowed <span style="color: #660033;">-p</span> TCP <span style="color: #660033;">--syn</span> <span style="color: #660033;">-j</span> ACCEPT
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> allowed <span style="color: #660033;">-p</span> TCP <span style="color: #660033;">-m</span> state <span style="color: #660033;">--state</span> ESTABLISHED,RELATED <span style="color: #660033;">-j</span> ACCEPT
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> allowed <span style="color: #660033;">-p</span> TCP <span style="color: #660033;">-j</span> DROP</pre></div></div>

<p>These rules take TCP packets that originate from the private subnet with FTP (20 &amp; 21) and HTTP (80) ports and allow them to be forwarded.  They also allow communications that have been established or are created by established communications (-m state &#8211;state ESTABLISHED,RELATED &gt;side note make sure there&#8217;s no space between ESTABLISHED,RELATED).  All that’s left to do is attach the rules to the forwarding chain (since they’re not for the gateway) like so:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> FORWARD <span style="color: #660033;">-p</span> TCP <span style="color: #660033;">-j</span> tcp_packets
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> FORWARD <span style="color: #660033;">-p</span> TCP <span style="color: #660033;">-m</span> state <span style="color: #660033;">--state</span> ESTABLISHED,RELATED <span style="color: #660033;">-j</span> ACCEPT</pre></div></div>

<p>The second line allowed return traffic (for both ftp and http) once it had been initiated.</p>
<p>In order to get ping working I created another chain for ICMP packets:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-N</span> icmp_packets
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> icmp_packets <span style="color: #660033;">-p</span> ICMP <span style="color: #660033;">--icmp-type</span> <span style="color: #000000;">0</span> <span style="color: #660033;">-j</span> ACCEPT
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> icmp_packets <span style="color: #660033;">-p</span> ICMP <span style="color: #660033;">--icmp-type</span> <span style="color: #000000;">8</span> <span style="color: #660033;">-j</span> ACCEPT
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> FORWARD <span style="color: #660033;">-p</span> ICMP <span style="color: #660033;">-j</span> icmp_packets</pre></div></div>

<p>These accept all 8 (ping) and 0 (response) ICMP requests.  With that I had FTP, HTTP, and ping ready to go so I started my firewall by typing &#8220;service iptables start&#8221;, and then I executed my script (in /etc/rc.d/) named rc.firewall by typing ./rc.firewall.   That got the first bit working, below are screen shots for each scenario:</p>
<div id="attachment_392" class="wp-caption aligncenter" style="width: 445px"><a href="http://flightschool.acylt.com/wp-content/uploads/2010/10/1-ftp.jpg"><img class="size-full wp-image-392 " title="FTP" src="http://flightschool.acylt.com/wp-content/uploads/2010/10/1-ftp.jpg" alt="FTP Example" width="435" height="278" /></a><p class="wp-caption-text">Here the private address 192.168.0.1 successfully gets a login to 10.0.0.1’s FTP server.</p></div>
<div id="attachment_396" class="wp-caption aligncenter" style="width: 592px"><a href="http://flightschool.acylt.com/wp-content/uploads/2010/10/1-http.jpg"><img class="size-full wp-image-396" title="HTTP" src="http://flightschool.acylt.com/wp-content/uploads/2010/10/1-http.jpg" alt="HTTP Example" width="582" height="383" /></a><p class="wp-caption-text">Here the ifconfig shows that our private network (192.168.0.1) successfully pulls up an HTML page from 10.0.0.1 via HTTP.</p></div>
<div id="attachment_397" class="wp-caption aligncenter" style="width: 610px"><a href="http://flightschool.acylt.com/wp-content/uploads/2010/10/1-ping.jpg"><img class="size-full wp-image-397" title="Ping" src="http://flightschool.acylt.com/wp-content/uploads/2010/10/1-ping.jpg" alt="Ping Example" width="600" height="213" /></a><p class="wp-caption-text">Again ifconfig shows a private address able to ping a public one.</p></div>
<h2>FORWARDING &#8211; Disable Ping and FTP from Public</h2>
<p>For my next task I disabled ping and FTP from the public network to the private.</p>
<p>I did ping by simply denying anyone outside from sending an 8 (ping) message into the network (this is a blacklist technique):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> icmp_packets <span style="color: #660033;">-p</span> icmp <span style="color: #660033;">-d</span> <span style="color: #007800;">$INTERNAL_PRIVATE_SUBNET</span> <span style="color: #660033;">--icmp-type</span> <span style="color: #000000;">8</span> <span style="color: #660033;">-j</span> REJECT</pre></div></div>

<p>FTP was already denied by default (b/c of my blacklist policy).  Below I have screen shots of both of these scenarios working.  In the second I get the information about the packet source, destination, and content by using wireshark.  So check it out if you haven&#8217;t yet.</p>
<div id="attachment_400" class="wp-caption aligncenter" style="width: 610px"><a href="http://flightschool.acylt.com/wp-content/uploads/2010/10/2-ping.jpg"><img class="size-full wp-image-400" title="Ping Disabled" src="http://flightschool.acylt.com/wp-content/uploads/2010/10/2-ping.jpg" alt="Ping Disabled" width="600" height="217" /></a><p class="wp-caption-text">Here the ifconfig command shows we are at 10.0.0.1, and its ping command returns that the destination port is unreachable.  This is because it is not allowed to communicate.</p></div>
<div id="attachment_402" class="wp-caption aligncenter" style="width: 610px"><a href="http://flightschool.acylt.com/wp-content/uploads/2010/10/2-ftp1.jpg"><img class="size-full wp-image-402" title="FTP Disabled" src="http://flightschool.acylt.com/wp-content/uploads/2010/10/2-ftp1.jpg" alt="FTP Disabled" width="600" height="282" /></a><p class="wp-caption-text">As you can see above, the source is my public IP - 10.0.0.1, with the destination FTP never getting or responding to the SYN message.</p></div>
<p>If you&#8217;re not familiar with TCP protocols like FTP/HTTP etc, there&#8217;s usually a three way handshake where one party initiates by sending a [SYN] message, another acknowledges by sending [SYN,ACK], and then it is finalized with an [ACK] message.  I don&#8217;t cover those here either but if you want to know more about the contents of these headers, I recommend looking at them with wireshark (a program that lets you inspect packets), and reading the information at these links: <a href="http://www.ietf.org/rfc/rfc793.txt" target="_blank">TCP header</a> , and <a href="http://www.ietf.org/rfc/rfc791.txt" target="_blank">IP header</a> (for both section 3 gives the specifications of the header).</p>
<h2>NAT &#8211; HTTP Traffic</h2>
<p>HTTP traffic needed to be enabled from public to private and it needed to map to an internal node.  As I mentioned previously, I already implemented NAT which does this mapping for us.  With the settings above it mapped to the internal node 192.168.0.1.</p>
<p>In order to enable the HTTP traffic I added another line to tcp_packets:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> tcp_packets <span style="color: #660033;">-p</span> TCP <span style="color: #660033;">-d</span> <span style="color: #007800;">$WEB_IP_ADDRESS</span> <span style="color: #660033;">--dport</span> <span style="color: #000000;">80</span> <span style="color: #660033;">-j</span> allowed</pre></td></tr></table></div>

<p>This allowed HTTP packets destined for my internal node (which $WEB_IP_ADDRESS was set to).</p>
<p>In order to demonstrate this working, first I turned off iptables and accessed my Gateway’s HTTP server.  The address was 10.0.0.254 and the html page (from the apache server) said “I am the GW”:</p>
<div id="attachment_406" class="wp-caption aligncenter" style="width: 403px"><a href="http://flightschool.acylt.com/wp-content/uploads/2010/10/3-gw.jpg"><img src="http://flightschool.acylt.com/wp-content/uploads/2010/10/3-gw.jpg" alt="The Gateway for 10.0.0.254" title="Gateway" width="393" height="208" class="size-full wp-image-406" /></a><p class="wp-caption-text">Here the gateway's html is showing for 10.0.0.254</p></div><br />
Next I turn my iptables back on, and attempt to access the same address from the same computer.  Now the packet is forwarded on and I get my private server’s web page:<br />
<div id="attachment_407" class="wp-caption aligncenter" style="width: 461px"><a href="http://flightschool.acylt.com/wp-content/uploads/2010/10/3-http.jpg"><img src="http://flightschool.acylt.com/wp-content/uploads/2010/10/3-http.jpg" alt="Private network now" title="Private now" width="451" height="346" class="size-full wp-image-407" /></a><p class="wp-caption-text">10.0.0.254 is now shows the private network</p></div><br />
Even though the private server’s actual IP address is 192.168.0.1, it displays because it has been correctly mapped with NAT.</p>
<h2>INPUT &#8211; Enable SSH</h2>
<p>Next I wanted to enable ssh connections to the firewall from both public and private networks, but have the access from the public side go to the inner node again.</p>
<p>These rules need to attach to the INPUT chain as well as the FORWARD, because in one case the SSH is destined for the Gateway.  I used the following command in order to allow this communication:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> TCP <span style="color: #660033;">-m</span> state <span style="color: #660033;">--state</span> ESTABLISHED,RELATED <span style="color: #660033;">-j</span> ACCEPT
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> TCP <span style="color: #660033;">-i</span> <span style="color: #007800;">$LAN_1_IFACE</span> <span style="color: #660033;">-s</span> <span style="color: #007800;">$LAN_1_IP_RANGE</span> <span style="color: #660033;">--dport</span> <span style="color: #000000;">22</span> <span style="color: #660033;">-j</span> ACCEPT</pre></td></tr></table></div>

<p>The first command allows all established communication to continue.  The second takes the private network’s range and allows it to connect to the private side of the gateway.</p>
<p>In order to get the public side to connect to the private network again, I simply added another entry to the forwarding chain:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> tcp_packets <span style="color: #660033;">-p</span> TCP <span style="color: #660033;">-d</span> <span style="color: #007800;">$WEB_IP_ADDRESS</span> <span style="color: #660033;">--dport</span> <span style="color: #000000;">22</span> <span style="color: #660033;">-j</span> allowed</pre></td></tr></table></div>

<p>This connection is shown below:<br />
<div id="attachment_408" class="wp-caption aligncenter" style="width: 610px"><a href="http://flightschool.acylt.com/wp-content/uploads/2010/10/4-ssh-public-to-gw.jpg"><img src="http://flightschool.acylt.com/wp-content/uploads/2010/10/4-ssh-public-to-gw.jpg" alt="SSH to Gateway" title="SSH to Gateway" width="600" height="368" class="size-full wp-image-408" /></a><p class="wp-caption-text">SSH to gateway from the public side</p></div><br />
As you can see the communication was initiated by 10.0.0.1, the public side, and its destination was 10.0.0.254, its side of the gateway.  But after logging in with the ssh, typing ifconfig shows that the address logged into is in fact 192.168.0.1, the private server.<br />
<div id="attachment_409" class="wp-caption aligncenter" style="width: 610px"><a href="http://flightschool.acylt.com/wp-content/uploads/2010/10/4-ssh-to-firewall-from-private.jpg"><img src="http://flightschool.acylt.com/wp-content/uploads/2010/10/4-ssh-to-firewall-from-private.jpg" alt="SSH from Private" title="SSH from Private" width="600" height="305" class="size-full wp-image-409" /></a><p class="wp-caption-text">SSH from private to gateway</p></div><br />
Here the SSH is initiated by the private network (192.168.0.1) and it connects to 192.168.0.254.  Both addresses of the gateway came up after typing ifconfig, but in the picture only 10.0.0.254 is evident.  Also notice that wireshark has SSH as the protocol.</p>
<h2>OUTPUT &#8211; From the Firewall</h2>
<p>Next I wanted to enable both SSH and ping from the firewall to public networks.  Because they originate with the gateway, we add their entries to the output chain:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> OUTPUT <span style="color: #660033;">-m</span> state <span style="color: #660033;">--state</span> ESTABLISHED,RELATED <span style="color: #660033;">-j</span> ACCEPT
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> OUTPUT <span style="color: #660033;">-p</span> ICMP <span style="color: #660033;">-j</span> ACCEPT
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> OUTPUT <span style="color: #660033;">-p</span> TCP <span style="color: #660033;">-j</span> tcp_packets
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> tcp_packets <span style="color: #660033;">-p</span> TCP <span style="color: #660033;">-s</span> <span style="color: #007800;">$LAN_1_IP</span> <span style="color: #660033;">--dport</span> <span style="color: #000000;">22</span> <span style="color: #660033;">-j</span> allowed
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> tcp_packets <span style="color: #660033;">-p</span> TCP <span style="color: #660033;">-s</span> <span style="color: #007800;">$LAN_0_IP</span> <span style="color: #660033;">--dport</span> <span style="color: #000000;">22</span> <span style="color: #660033;">-j</span> allowed</pre></td></tr></table></div>

<p>The first line again allows established communication to continue, while the second allows pings to be sent from the Gateway.  The last three lines say that when originating from the gateway, TCP and SSH packets are allowed.</p>
<h2>NAT in Action</h2>
<p>This last bit is just to show a little bit of Wireshark and a little bit of NAT in action.<br />
<div id="attachment_410" class="wp-caption aligncenter" style="width: 610px"><a href="http://flightschool.acylt.com/wp-content/uploads/2010/10/3-mapping-NAT-6a.jpg"><img src="http://flightschool.acylt.com/wp-content/uploads/2010/10/3-mapping-NAT-6a.jpg" alt="Inbound packets shown with wireshark" title="Inbound Mapping" width="600" height="369" class="size-full wp-image-410" /></a><p class="wp-caption-text">Inbound Packets Changed</p></div><br />
Here you see the public address 10.0.0.1 accessing 10.0.0.254, the Public side of the Gateway.  That address is then changed as we move over to the interface on the Private side of the Gateway, and it becomes 192.168.0.1 (the correct destination of the internal client).</p>
<p>The opposite also works:<br />
<div id="attachment_411" class="wp-caption aligncenter" style="width: 610px"><a href="http://flightschool.acylt.com/wp-content/uploads/2010/10/6b.jpg"><img src="http://flightschool.acylt.com/wp-content/uploads/2010/10/6b.jpg" alt="Outbound packets shown with wireshark" title="Outbound Packets" width="600" height="365" class="size-full wp-image-411" /></a><p class="wp-caption-text">Outbound Packets Changed</p></div>
<h2>Last Words and Appendix</h2>
<p>This is a very simple implementation, but Iptables can be much more sophisticated.  Maybe at some point in the future I&#8217;ll do a part 2 with some of those features.  Here&#8217;s the configuration file I promised:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Static IP address of public network</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #007800;">LAN_0_IP</span>=<span style="color: #ff0000;">&quot;10.0.0.254&quot;</span>
<span style="color: #007800;">LAN_0_IP_RANGE</span>=<span style="color: #ff0000;">&quot;10.0.0.0/8&quot;</span>
<span style="color: #007800;">LAN_0_BCAST_ADRESS</span>=<span style="color: #ff0000;">&quot;10.255.255.255&quot;</span>
<span style="color: #007800;">LAN_0_IFACE</span>=<span style="color: #ff0000;">&quot;eth5&quot;</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># 1.2 Local area network configuration.</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Internal firewall private side</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #007800;">LAN_1_IP</span>=<span style="color: #ff0000;">&quot;192.168.0.254&quot;</span>
<span style="color: #007800;">LAN_1_IP_RANGE</span>=<span style="color: #ff0000;">&quot;192.168.0.0/24&quot;</span>
<span style="color: #007800;">LAN_1_BCAST_ADRESS</span>=<span style="color: #ff0000;">&quot;192.168.0.255&quot;</span>
<span style="color: #007800;">LAN_1_IFACE</span>=<span style="color: #ff0000;">&quot;eth6&quot;</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># IP aliases</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #007800;">LO_IFACE</span>=<span style="color: #ff0000;">&quot;lo&quot;</span>
<span style="color: #007800;">LO_IP</span>=<span style="color: #ff0000;">&quot;127.0.0.1&quot;</span>
<span style="color: #007800;">WEB_IP_ADDRESS</span>=<span style="color: #ff0000;">&quot;192.168.0.1&quot;</span>
<span style="color: #007800;">INTERNAL_PRIVATE_SUBNET</span>=<span style="color: #ff0000;">&quot;192.168.0.0/24&quot;</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># 1.3 IPTables Configuration.</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #007800;">IPTABLES</span>=<span style="color: #ff0000;">&quot;/sbin/iptables&quot;</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">###########################################################################</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># 2. Module loading.</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Needed to initially load modules</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">depmod</span> <span style="color: #660033;">-a</span>	 
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># flush iptables</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>iptables <span style="color: #660033;">-F</span> 
<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>iptables <span style="color: #660033;">-F</span> <span style="color: #660033;">-t</span> nat
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># 2.1 Required modules</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>modprobe ip_tables
<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>modprobe ip_conntrack
<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>modprobe iptable_filter
<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>modprobe iptable_mangle
<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>modprobe iptable_nat
<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>modprobe ipt_LOG
<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>modprobe ipt_limit
<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>modprobe ipt_state
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># 2.2 Non-Required modules</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#/sbin/modprobe ipt_owner</span>
<span style="color: #666666; font-style: italic;">#/sbin/modprobe ipt_REJECT</span>
<span style="color: #666666; font-style: italic;">#/sbin/modprobe ipt_MASQUERADE</span>
<span style="color: #666666; font-style: italic;">#/sbin/modprobe ip_conntrack_ftp</span>
<span style="color: #666666; font-style: italic;">#/sbin/modprobe ip_conntrack_irc</span>
<span style="color: #666666; font-style: italic;">#/sbin/modprobe ip_nat_ftp</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">###########################################################################</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># 3. /proc set up.</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># 3.1 Required proc configuration</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Enable ip_forward, this is critical since it is turned off as defaul in </span>
<span style="color: #666666; font-style: italic;"># Linux.</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>proc<span style="color: #000000; font-weight: bold;">/</span>sys<span style="color: #000000; font-weight: bold;">/</span>net<span style="color: #000000; font-weight: bold;">/</span>ipv4<span style="color: #000000; font-weight: bold;">/</span>ip_forward
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># 3.2 Non-Required proc configuration</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Dynamic IP users:</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#echo &quot;1&quot; &gt; /proc/sys/net/ipv4/ip_dynaddr</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">###########################################################################</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># 4. rules set up.</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># The kernel starts with three lists of rules; these lists are called firewall</span>
<span style="color: #666666; font-style: italic;"># chains or just chains. The three chains are called INPUT, OUTPUT and FORWARD.</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># The chains are arranged like so:</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#                     _____</span>
<span style="color: #666666; font-style: italic;">#                    /     \</span>
<span style="color: #666666; font-style: italic;">#  --&gt;[Routing ]---&gt;|FORWARD|-------&gt;</span>
<span style="color: #666666; font-style: italic;">#     [Decision]     \_____/        ^</span>
<span style="color: #666666; font-style: italic;">#          |                        |</span>
<span style="color: #666666; font-style: italic;">#          v                       ____</span>
<span style="color: #666666; font-style: italic;">#         ___                     /    \</span>
<span style="color: #666666; font-style: italic;">#        /   \                   |OUTPUT|</span>
<span style="color: #666666; font-style: italic;">#       |INPUT|                   \____/</span>
<span style="color: #666666; font-style: italic;">#        \___/                      ^</span>
<span style="color: #666666; font-style: italic;">#          |                        |</span>
<span style="color: #666666; font-style: italic;">#           ----&gt; Local Process ----</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># 1. When a packet comes in (say, through the Ethernet card) the kernel first </span>
<span style="color: #666666; font-style: italic;">#    looks at the destination of the packet: this is called `routing'.</span>
<span style="color: #666666; font-style: italic;"># 2. If it's destined for this box, the packet passes downwards in the diagram, </span>
<span style="color: #666666; font-style: italic;">#    to the INPUT chain. If it passes this, any processes waiting for that </span>
<span style="color: #666666; font-style: italic;">#    packet will receive it. </span>
<span style="color: #666666; font-style: italic;"># 3. Otherwise, if the kernel does not have forwarding enabled, or it doesn't </span>
<span style="color: #666666; font-style: italic;">#    know how to forward the packet, the packet is dropped. If forwarding is </span>
<span style="color: #666666; font-style: italic;">#    enabled, and the packet is destined for another network interface (if you </span>
<span style="color: #666666; font-style: italic;">#    have another one), then the packet goes rightwards on our diagram to the </span>
<span style="color: #666666; font-style: italic;">#    FORWARD chain. If it is ACCEPTed, it will be sent out. </span>
<span style="color: #666666; font-style: italic;"># 4. Finally, a program running on the box can send network packets. These </span>
<span style="color: #666666; font-style: italic;">#    packets pass through the OUTPUT chain immediately: if it says ACCEPT, then </span>
<span style="color: #666666; font-style: italic;">#    the packet continues out to whatever interface it is destined for. </span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">######</span>
<span style="color: #666666; font-style: italic;"># 4.1 Filter table</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># 4.1.1 Set policies</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Set default policies for the INPUT, FORWARD and OUTPUT chains</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-P</span> INPUT DROP
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-P</span> OUTPUT DROP
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-P</span> FORWARD DROP
<span style="color: #666666; font-style: italic;"># </span>
<span style="color: #666666; font-style: italic;">##################################################</span>
<span style="color: #666666; font-style: italic;"># Create custom chains</span>
<span style="color: #666666; font-style: italic;">##################################################</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-N</span> allowed
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-N</span> tcp_packets
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-N</span> icmp_packets
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># allowed rules</span>
<span style="color: #666666; font-style: italic;"># new connections, established ones</span>
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> allowed <span style="color: #660033;">-p</span> TCP <span style="color: #660033;">--syn</span> <span style="color: #660033;">-j</span> ACCEPT
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> allowed <span style="color: #660033;">-p</span> TCP <span style="color: #660033;">-m</span> state <span style="color: #660033;">--state</span> ESTABLISHED,RELATED <span style="color: #660033;">-j</span> ACCEPT
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> allowed <span style="color: #660033;">-p</span> TCP <span style="color: #660033;">-j</span> DROP
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># TCP rules</span>
<span style="color: #666666; font-style: italic;"># </span>
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> tcp_packets <span style="color: #660033;">-p</span> TCP <span style="color: #660033;">-s</span> <span style="color: #007800;">$INTERNAL_PRIVATE_SUBNET</span> <span style="color: #660033;">-m</span> multiport <span style="color: #660033;">--dport</span> <span style="color: #000000;">20</span>,<span style="color: #000000;">21</span>,<span style="color: #000000;">80</span> <span style="color: #660033;">-j</span> allowed
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> tcp_packets <span style="color: #660033;">-p</span> TCP <span style="color: #660033;">-d</span> <span style="color: #007800;">$WEB_IP_ADDRESS</span> <span style="color: #660033;">-m</span> multiport <span style="color: #660033;">--dport</span> <span style="color: #000000;">22</span>,<span style="color: #000000;">80</span> <span style="color: #660033;">-j</span> allowed
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> tcp_packets <span style="color: #660033;">-p</span> TCP <span style="color: #660033;">-s</span> <span style="color: #007800;">$INTERNAL_PRIVATE_SUBNET</span> <span style="color: #660033;">-d</span> <span style="color: #007800;">$LAN_1_IP</span> <span style="color: #660033;">--dport</span> <span style="color: #000000;">22</span> <span style="color: #660033;">-j</span> allowed
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> tcp_packets <span style="color: #660033;">-p</span> TCP <span style="color: #660033;">-s</span> <span style="color: #007800;">$LAN_1_IP</span> <span style="color: #660033;">--dport</span> <span style="color: #000000;">22</span> <span style="color: #660033;">-j</span> allowed
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> tcp_packets <span style="color: #660033;">-p</span> TCP <span style="color: #660033;">-s</span> <span style="color: #007800;">$LAN_0_IP</span> <span style="color: #660033;">--dport</span> <span style="color: #000000;">22</span> <span style="color: #660033;">-j</span> allowed
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># ICMP rules</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> icmp_packets <span style="color: #660033;">-p</span> icmp <span style="color: #660033;">-d</span> <span style="color: #007800;">$INTERNAL_PRIVATE_SUBNET</span> <span style="color: #660033;">--icmp-type</span> <span style="color: #000000;">8</span> <span style="color: #660033;">-j</span> REJECT
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> icmp_packets <span style="color: #660033;">-p</span> icmp <span style="color: #660033;">--icmp-type</span> <span style="color: #000000;">0</span> <span style="color: #660033;">-j</span> ACCEPT
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> icmp_packets <span style="color: #660033;">-p</span> icmp <span style="color: #660033;">--icmp-type</span> <span style="color: #000000;">8</span> <span style="color: #660033;">-j</span> ACCEPT
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">##############################################</span>
<span style="color: #666666; font-style: italic;"># INPUT chain</span>
<span style="color: #666666; font-style: italic;">###############################################</span>
<span style="color: #666666; font-style: italic;"># </span>
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> TCP <span style="color: #660033;">-m</span> state <span style="color: #660033;">--state</span> ESTABLISHED,RELATED <span style="color: #660033;">--sport</span> <span style="color: #000000;">22</span> <span style="color: #660033;">-j</span> ACCEPT
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> TCP <span style="color: #660033;">-i</span> <span style="color: #007800;">$LAN_1_IFACE</span> <span style="color: #660033;">-s</span> <span style="color: #007800;">$LAN_1_IP_RANGE</span> <span style="color: #660033;">--dport</span> <span style="color: #000000;">22</span> <span style="color: #660033;">-j</span> ACCEPT
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> ICMP <span style="color: #660033;">--icmp-type</span> <span style="color: #000000;">0</span> <span style="color: #660033;">-j</span> ACCEPT
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">##############################################</span>
<span style="color: #666666; font-style: italic;"># FORWARD chain</span>
<span style="color: #666666; font-style: italic;">#############################################</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> FORWARD <span style="color: #660033;">-p</span> TCP <span style="color: #660033;">-m</span> state <span style="color: #660033;">--state</span> ESTABLISHED,RELATED <span style="color: #660033;">-j</span> ACCEPT
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> FORWARD <span style="color: #660033;">-p</span> TCP <span style="color: #660033;">-j</span> tcp_packets
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> FORWARD <span style="color: #660033;">-p</span> ICMP <span style="color: #660033;">-j</span> icmp_packets
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#############################################</span>
<span style="color: #666666; font-style: italic;"># OUTPUT chain</span>
<span style="color: #666666; font-style: italic;">#############################################</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> OUTPUT <span style="color: #660033;">-m</span> state <span style="color: #660033;">--state</span> ESTABLISHED,RELATED <span style="color: #660033;">-j</span> ACCEPT
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> OUTPUT <span style="color: #660033;">-p</span> TCP <span style="color: #660033;">-j</span> tcp_packets
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> OUTPUT <span style="color: #660033;">-p</span> ICMP <span style="color: #660033;">-s</span> <span style="color: #007800;">$LO_IP</span> <span style="color: #660033;">-j</span> ACCEPT
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-A</span> OUTPUT <span style="color: #660033;">-p</span> ICMP <span style="color: #660033;">-j</span> ACCEPT
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">############################################</span>
<span style="color: #666666; font-style: italic;"># NAT routing</span>
<span style="color: #666666; font-style: italic;">############################################</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Prerouting</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-t</span> nat <span style="color: #660033;">-A</span> PREROUTING <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">-d</span> <span style="color: #007800;">$LAN_0_IP</span> <span style="color: #660033;">--dport</span> <span style="color: #000000;">80</span> <span style="color: #660033;">-j</span> DNAT <span style="color: #660033;">--to</span> <span style="color: #007800;">$WEB_IP_ADDRESS</span>:<span style="color: #000000;">80</span>
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-t</span> nat <span style="color: #660033;">-A</span> PREROUTING <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">-d</span> <span style="color: #007800;">$LAN_0_IP</span> <span style="color: #660033;">--dport</span> <span style="color: #000000;">22</span> <span style="color: #660033;">-j</span> DNAT <span style="color: #660033;">--to</span> <span style="color: #007800;">$WEB_IP_ADDRESS</span>:<span style="color: #000000;">22</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># POSTROUTING chain.</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">-t</span> nat <span style="color: #660033;">-A</span> POSTROUTING <span style="color: #660033;">-s</span> <span style="color: #007800;">$INTERNAL_PRIVATE_SUBNET</span> <span style="color: #660033;">-o</span> <span style="color: #007800;">$LAN_0_IFACE</span> <span style="color: #660033;">-j</span> SNAT <span style="color: #660033;">--to</span> <span style="color: #007800;">$LAN_0_IP</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#</span></pre></td></tr></table></div>

<div class="shr-publisher-386"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/devnotes/iptables-and-virtual-networks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Red5 Server</title>
		<link>http://flightschool.acylt.com/devnotes/red5-server/</link>
		<comments>http://flightschool.acylt.com/devnotes/red5-server/#comments</comments>
		<pubDate>Fri, 02 Jul 2010 04:44:26 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[DevNotes]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=250</guid>
		<description><![CDATA[Setting up the Red5 server turned out to be a little more of a challenge than I thought it would (just a reminder, as always I&#8217;m doing this on Snow Leopard). I installed the stand alone version in my applications folder (you can download it from http://red5.org/wiki/Releases), double clicked it and didn&#8217;t see anything happen. [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>Setting up the Red5 server turned out to be a little more of a challenge than I thought it would (just a reminder, as always I&#8217;m doing this on Snow Leopard).  I installed the stand alone version in my applications folder (you can download it from <a href="http://red5.org/wiki/Releases" target="_blank">http://red5.org/wiki/Releases</a>), double clicked it and didn&#8217;t see anything happen.  I was at least expecting some sort of interface to let me know it was running, but nothing.  With a little searching I found that opening my browser with http://localhost:5080 would show me that it was up and running.  Installing a few of the demos proved it was the real deal, but now I had to figure out the man behind the curtain: how the server was running, and how to make it run my stuff.</p>
<p>That simply took right clicking on the Red5 application and choosing &#8220;show package contents&#8221;.  Annoyingly simple for the time it took me to figure out, I&#8217;m embarrassed to say.  Under Content/Resources/Java you find the folder webapps, and that&#8217;s where the magic happens.  Anything you want running on the server should be here.</p>
<p>Before I get to making Apps run on the server, I have to make a plug for the Red5 plugin for Eclipse.  It makes a huge difference during development and has been a lifesaver for me.  Long story short, use this tutorial to set up the Red5 plugin on your machine: <a href="http://red5.org/wiki/Red5Plugin" target="_blank">http://red5.org/wiki/Red5Plugin</a>.  It didn&#8217;t quite match up with my version of Eclipse but it was close enough to make it work.  Once you have that plugin installed, you&#8217;re ready to start working on your App.</p>
<p>On the same Red5 wiki they walk through creating a new Red5 project <a href="http://red5.org/wiki/Red5Plugin/CreatingRed5Projects" target="_blank">http://red5.org/wiki/Red5Plugin/CreatingRed5Projects</a>.  The only problem is that there really isn&#8217;t much there.  So I thought I&#8217;d fill in a few of the gaps here, and if you see any more you&#8217;d like me to fill let me know.  For now I&#8217;m just putting this up as a reference for myself, since getting a working app has taken me all over the web and back.</p>
<p>I was interested in creating a video chat application using flash.  That&#8217;s why I needed Red5 in the first place instead of other open source servers out there.  Red5 allows streaming with RTMP, which is necessary for live chats and overkill for non-streaming.</p>
<p>My video chat would need server side Java code (it turns out I used Cirrus Flash peer 2 peer instead and didn&#8217;t even need Red5 &#8211; if you want to see take a look at <a href="http://zazzer.me">http://Zazzer.me</a>) and probably PHP, along with the client stuff.  In order to set up the server so that the client could actually find it took a decent amount of searching.  I&#8217;m assuming you&#8217;ve already started by creating the project, and now you&#8217;re writing the Java source.  Here is an example of what needs to be in the source for it to interact with the client:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">myPackageName</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.red5.server.adapter.ApplicationAdapter</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Application <span style="color: #000000; font-weight: bold;">extends</span> ApplicationAdapter
<span style="color: #009900;">&#123;</span>
     <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> hello<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> name<span style="color: #009900;">&#41;</span>
     <span style="color: #009900;">&#123;</span>
          <span style="color: #000000; font-weight: bold;">return</span> name <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;I see you&quot;</span><span style="color: #339933;">;</span>
     <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Here I&#8217;ve extended the ApplicationAdapter class, which is the one that listens for the client.  So the big part is good to go, but the devil is in the details.  What else do I have to configure in order to get this to work?  Well there are a few simple files that are not configured for you (at least they weren&#8217;t for me) that you have to fix before any flash client will find this application.  Those files are web.xml, red5-web.xml, and red5-web.properties.</p>
<p>In web.xml you must include:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;">        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;context-param<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>webAppRootKey<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/param-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param-value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>/yourAppName<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/param-value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/context-param<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>rtmpt<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.red5.server.net.rtmpt.RTMPTServlet<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;load-on-startup<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/load-on-startup<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-mapping<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>rtmpt<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;url-pattern<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>/fcs/*<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/url-pattern<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-mapping<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-mapping<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>rtmpt<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;url-pattern<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>/open/*<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/url-pattern<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-mapping<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-mapping<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>rtmpt<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;url-pattern<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>/close/*<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/url-pattern<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-mapping<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-mapping<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>rtmpt<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;url-pattern<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>/send/*<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/url-pattern<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-mapping<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-mapping<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>rtmpt<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;url-pattern<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>/idle/*<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/url-pattern<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-mapping<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>Red5 uses webAppRootKey to create the handshake with the NetConnection class in Flash.  In this case rtmp://yourServerName/yourAppName would be the string you pass to NetConnection in order make the connection.</p>
<p>Web.xml is done, next up: red5-web.xml.  This one was tricky because every resource I came across just told me to include a bean specifying the web.handler.  However it didn&#8217;t work until I had everything else you&#8217;ll find here.  It may work with less for you, but like I said this is more a reference for me anyway so I&#8217;m putting it all up:</p>
<p>I didn&#8217;t really bother to check to see why it didn&#8217;t work before but did after the extra beans.  If you&#8217;re interested you tell me!  Last of all red5-web.properties is simple enough:</p>
<p>webapp.contextPath=/yourAppName<br />
webapp.virtualHosts=*, localhost, localhost:8088, 127.0.0.1:8088</p>
<p>That should do it for the server.  Once that&#8217;s rollin it&#8217;s just a matter of writing the client and connecting with the rtmp I mentioned before.  For example:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;">package
<span style="color: #66cc66;">&#123;</span>
  <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">net</span>.<span style="color: #0066CC;">NetConnection</span>;
        <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Sprite</span>;
  <span style="color: #0066CC;">import</span> flash.<span style="color: #0066CC;">text</span>.<span style="color: #0066CC;">TextField</span>;
  <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">NetStatusEvent</span>;
&nbsp;
  <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> FMS3Connect <span style="color: #0066CC;">extends</span> Sprite
  <span style="color: #66cc66;">&#123;</span>
        <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> nc:<span style="color: #0066CC;">NetConnection</span>;
        <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> rtmpNow:<span style="color: #0066CC;">String</span>;
        <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> msg:<span style="color: #0066CC;">String</span>;
        <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> connectText:<span style="color: #0066CC;">TextField</span>;
        <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> posX:<span style="color: #0066CC;">Number</span>;
&nbsp;
        <span style="color: #000000; font-weight: bold;">var</span> responder:Responder = <span style="color: #000000; font-weight: bold;">new</span> Responder<span style="color: #66cc66;">&#40;</span>setValue, <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> setValue<span style="color: #66cc66;">&#40;</span>obj:<span style="color: #0066CC;">Object</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
		<span style="color: #66cc66;">&#123;</span>
                    <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>obj.<span style="color: #0066CC;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
                <span style="color: #66cc66;">&#125;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #0066CC;">Connect</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#123;</span>
             nc=<span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">NetConnection</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
             nc.<span style="color: #006600;">addEventListener</span> <span style="color: #66cc66;">&#40;</span>NetStatusEvent.<span style="color: #006600;">NET_STATUS</span>,checkConnect<span style="color: #66cc66;">&#41;</span>;
             rtmpNow=<span style="color: #ff0000;">&quot;rtmp://yourServerName/yourAppName&quot;</span>;
             nc.<span style="color: #0066CC;">connect</span> <span style="color: #66cc66;">&#40;</span>rtmpNow<span style="color: #66cc66;">&#41;</span>;
        <span style="color: #66cc66;">&#125;</span>
        <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> checkConnect <span style="color: #66cc66;">&#40;</span>event:NetStatusEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
        <span style="color: #66cc66;">&#123;</span>
             <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>event.<span style="color: #006600;">info</span>.<span style="color: #006600;">code</span><span style="color: #66cc66;">&#41;</span>;
             <span style="color: #b1b100;">switch</span><span style="color: #66cc66;">&#40;</span>event.<span style="color: #006600;">info</span>.<span style="color: #006600;">code</span><span style="color: #66cc66;">&#41;</span>
             <span style="color: #66cc66;">&#123;</span>
                  <span style="color: #b1b100;">case</span> <span style="color: #ff0000;">&quot;NetConnection.Connect.Success&quot;</span>:
                        nc.<span style="color: #0066CC;">call</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;hello&quot;</span>,responder,<span style="color: #ff0000;">&quot;billy&quot;</span><span style="color: #66cc66;">&#41;</span>;
                        <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;success&quot;</span><span style="color: #66cc66;">&#41;</span>;
                        <span style="color: #b1b100;">break</span>;
                  <span style="color: #000000; font-weight: bold;">default</span>:
                        <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;no luck amigo&quot;</span><span style="color: #66cc66;">&#41;</span>;
        <span style="color: #66cc66;">&#125;</span>
  <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>Ok so I won&#8217;t swear by that code because I just wrote it now, but if it doesn&#8217;t work it&#8217;s damn close because it&#8217;s almost the same as what I have in my app and that works.</p>
<p>I think this is quite enough for one post.  Hopefully it&#8217;s helpful to any hapless readers, let me know if I should fix anything (assuming anyone makes it to this line).</p>
<p>Also if you&#8217;re looking for more information to fill in the gaps, I&#8217;ll start posting links to resources I find below:</p>
<p><a href="http://www.red5tutorials.net/index.php/Tutorials:Getting_Started_With_Red5_Server" target="_blank">http://www.red5tutorials.net/index.php/Tutorials:Getting_Started_With_Red5_Server</a></p>
<div class="shr-publisher-250"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/devnotes/red5-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Red5 Video Chat Example</title>
		<link>http://flightschool.acylt.com/devnotes/red5-video-chat-example/</link>
		<comments>http://flightschool.acylt.com/devnotes/red5-video-chat-example/#comments</comments>
		<pubDate>Fri, 16 Jul 2010 18:42:44 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[DevNotes]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=313</guid>
		<description><![CDATA[Alright so I&#8217;ve finally got my Red5 server up, running and working with a simple video chat. It took some looking around, mostly because there aren&#8217;t a lot of comprehensive tutorials out there and most of the ones I did find were outdated, so hopefully this will make it easier for beginners to get up [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>Alright so I&#8217;ve finally got my Red5 server up, running and working with a simple video chat.  It took some looking around, mostly because there aren&#8217;t a lot of comprehensive tutorials out there and most of the ones I did find were outdated, so hopefully this will make it easier for beginners to get up and running.</p>
<p>By the way, if you want to see my final product actually working, go to <a href="http://zazzer.me">http://Zazzer.me</a>!  It actually doesn&#8217;t use the Red5 component (I decided Cirrus and peer to peer was much better for my purposes) but it covers part of this.</p>
<p>Debugging the server-side code, however, has still has been a bit of a mystery to me.  I&#8217;ve been running the standalone Red5 server that you can find here: <a href="http://red5.org/wiki/0_9_1" target="_blank">http://red5.org/wiki/0_9_1</a> (that&#8217;s the latest release at the time of this post, 9.1).  From the searching I&#8217;ve done until now the only answer I got was to run the war from inside tomcat and debug it that way.  I&#8217;ll probably resort to that once I run across a problem that logging doesn&#8217;t fix, but that hasn&#8217;t happened yet so I may follow this up later.</p>
<p>If you&#8217;re not using Eclipse, this won&#8217;t be quite as useful to you.  I&#8217;m using the Red5 plugin which builds the project and deploys it to the Red5 server for you.  Getting it working involves creatively following: <a href="http://red5.org/wiki/Red5Plugin" target="_blank">http://red5.org/wiki/Red5Plugin</a> and then, <a href="http://red5.org/wiki/Red5Plugin/CreatingRed5Projects" target="_blank">http://red5.org/wiki/Red5Plugin/CreatingRed5Projects</a>.</p>
<p>Those two together should get you up and running with a new dynamic web project.  For the sake of this tutorial I&#8217;m going to assume you called yours Chatter.  From there you need to edit your web.xml file.  Mine looks like this:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;">       <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;display-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Chatter<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/display-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;context-param<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>webAppRootKey<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/param-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param-value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>/Chatter<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/param-value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/context-param<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;context-param<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>globalScope<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/param-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param-value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>default<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/param-value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/context-param<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;context-param<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>contextConfigLocation<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/param-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param-value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>/WEB-INF/red5-*.xml<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/param-value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/context-param<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;context-param<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>locatorFactorySelector<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/param-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param-value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>red5.xml<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/param-value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/context-param<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;context-param<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>parentContextKey<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/param-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param-value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>default.context<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/param-value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/context-param<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>rtmpt<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.red5.server.net.rtmpt.RTMPTServlet<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;load-on-startup<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/load-on-startup<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-mapping<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>rtmpt<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;url-pattern<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>/fcs/*<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/url-pattern<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-mapping<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-mapping<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>rtmpt<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;url-pattern<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>/open/*<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/url-pattern<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-mapping<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-mapping<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>rtmpt<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;url-pattern<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>/close/*<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/url-pattern<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-mapping<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-mapping<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>rtmpt<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;url-pattern<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>/send/*<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/url-pattern<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-mapping<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-mapping<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>rtmpt<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;url-pattern<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>/idle/*<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/url-pattern<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/servlet-mapping<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>That will tell Red5 where it&#8217;s configuration files are.  They should be placed along side it (in the WebContent/WEB-INF/ folder).  The first, red5-web.properties should include:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">webapp.contextPath=<span style="color: #000000; font-weight: bold;">/</span>Chatter
webapp.virtualHosts=<span style="color: #000000; font-weight: bold;">*</span>, localhost, localhost:<span style="color: #000000;">8088</span>, 127.0.0.1:<span style="color: #000000;">8088</span></pre></td></tr></table></div>

<p>Next red5-web.xml should include:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;">&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #00bbdd;">&lt;!DOCTYPE beans PUBLIC &quot;-//SPRING//DTD BEAN//EN&quot; &quot;http://www.springframework.org/dtd/spring-beans.dtd&quot;&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;beans<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;placeholderConfig&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.springframework.beans.factory.config.PropertyPlaceholderConfigurer&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
	    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;location&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;/WEB-INF/red5-web.properties&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;web.context&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.red5.server.Context&quot;</span> </span>
<span style="color: #009900;">		<span style="color: #000066;">autowire</span>=<span style="color: #ff0000;">&quot;byType&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;web.scope&quot;</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;org.red5.server.WebScope&quot;</span></span>
<span style="color: #009900;">		 <span style="color: #000066;">init-method</span>=<span style="color: #ff0000;">&quot;register&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;server&quot;</span> <span style="color: #000066;">ref</span>=<span style="color: #ff0000;">&quot;red5.server&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;parent&quot;</span> <span style="color: #000066;">ref</span>=<span style="color: #ff0000;">&quot;global.scope&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;context&quot;</span> <span style="color: #000066;">ref</span>=<span style="color: #ff0000;">&quot;web.context&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;handler&quot;</span> <span style="color: #000066;">ref</span>=<span style="color: #ff0000;">&quot;web.handler&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;contextPath&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;${webapp.contextPath}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;virtualHosts&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;${webapp.virtualHosts}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;web.handler&quot;</span> </span>
<span style="color: #009900;">	    <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;chatter.Application&quot;</span> </span>
<span style="color: #009900;">		<span style="color: #000066;">singleton</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/beans<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>The most important feature here is the &#8220;web.handler&#8221; bean.  It directs red5 to where you keep your Java class that people connect to.  In this case I wrote chatter.Application.  Chatter is the package, Application is the name of the class.  It extends ApplicationAdapter and is called Application by convention.</p>
<p>Here is an example Application file:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">chatter</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.HashMap</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.red5.server.adapter.ApplicationAdapter</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.red5.server.api.IConnection</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.red5.server.api.IScope</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.red5.server.api.Red5</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.red5.server.api.service.*</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">static</span> java.<span style="color: #006633;">lang</span>.<span style="color: #003399;">System</span>.<span style="color: #339933;">*;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Stack</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Application <span style="color: #000000; font-weight: bold;">extends</span> ApplicationAdapter<span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">//private static final Log log = LogFactory.getLog( Application.class );</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> HashMap<span style="color: #339933;">&lt;</span>String,User<span style="color: #339933;">&gt;</span> users <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HashMap<span style="color: #339933;">&lt;</span>String,User<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">public</span> Stack<span style="color: #339933;">&lt;</span>String<span style="color: #339933;">&gt;</span> vidStreams <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Stack</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">boolean</span> appStart<span style="color: #009900;">&#40;</span>IScope scope<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		out.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Setting up&quot;</span><span style="color: #339933;">+</span>vidStreams.<span style="color: #006633;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		vidStreams.<span style="color: #006633;">push</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;left&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		vidStreams.<span style="color: #006633;">push</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;right&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> appStop<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	    <span style="color: #666666; font-style: italic;">// This function fires when the app is closing</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">double</span> addSomething<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">double</span> a, <span style="color: #000066; font-weight: bold;">double</span> b<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            <span style="color: #666666; font-style: italic;">// This is a method we will call from our flash client</span>
		out.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Adding: &quot;</span><span style="color: #339933;">+</span>a<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot; + &quot;</span><span style="color: #339933;">+</span>b<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">return</span> a<span style="color: #339933;">+</span>b<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> streamer<span style="color: #009900;">&#40;</span><span style="color: #003399;">Object</span> name<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            <span style="color: #666666; font-style: italic;">// Here is another example of a method we'll call from the flash client</span>
            <span style="color: #666666; font-style: italic;">// I'm using System.outs instead of logging because I've had some trouble</span>
            <span style="color: #666666; font-style: italic;">// with the logging.  I'll update it if I get it working.</span>
&nbsp;
		out.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;StreamSelect parameter: &quot;</span><span style="color: #339933;">+</span> name.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		IConnection current <span style="color: #339933;">=</span> Red5.<span style="color: #006633;">getConnectionLocal</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">String</span> uid <span style="color: #339933;">=</span> current.<span style="color: #006633;">getClient</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getId</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		out.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;current: &quot;</span><span style="color: #339933;">+</span>current.<span style="color: #006633;">getClient</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		User user <span style="color: #339933;">=</span> users.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>uid<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		out.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;username: &quot;</span><span style="color: #339933;">+</span>user.<span style="color: #006633;">username</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		out.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;uid: &quot;</span><span style="color: #339933;">+</span>uid<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		out.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;stream: &quot;</span><span style="color: #339933;">+</span>user.<span style="color: #006633;">stream</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">return</span> user.<span style="color: #006633;">stream</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">boolean</span> connect<span style="color: #009900;">&#40;</span>IConnection conn, IScope scope, <span style="color: #003399;">Object</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> params<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #666666; font-style: italic;">// This is the master connection method called every time someone connects</span>
            <span style="color: #666666; font-style: italic;">// to the server.</span>
&nbsp;
		out.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Number of parameters passed: &quot;</span><span style="color: #339933;">+</span> params.<span style="color: #006633;">length</span><span style="color: #339933;">+</span><span style="color: #0000ff;">&quot; Value: &quot;</span><span style="color: #339933;">+</span>params<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		out.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;vidStreams peek: &quot;</span><span style="color: #339933;">+</span>vidStreams.<span style="color: #006633;">peek</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// Check if the user passed valid parameters.</span>
		<span style="color: #666666; font-style: italic;">//params = pseudo onlineStatus role sexe  room world</span>
&nbsp;
&nbsp;
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>params <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span> <span style="color: #339933;">||</span> params.<span style="color: #006633;">length</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			out.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;No Username Passed&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #666666; font-style: italic;">//Reject client terminates the execution of current client</span>
			rejectClient<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Username required, client rejected.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>vidStreams.<span style="color: #006633;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			out.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Quota full, rejected&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			rejectClient<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Quota full, rejected&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//ID increments each connection</span>
		<span style="color: #003399;">String</span> uid <span style="color: #339933;">=</span> conn.<span style="color: #006633;">getClient</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getId</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">String</span> username <span style="color: #339933;">=</span> params<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>		
		<span style="color: #003399;">String</span> stream <span style="color: #339933;">=</span> vidStreams.<span style="color: #006633;">pop</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		out.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;User setup, username:&quot;</span><span style="color: #339933;">+</span>username<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot; stream: &quot;</span><span style="color: #339933;">+</span>stream<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">// Call original method of parent class.</span>
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">connect</span><span style="color: #009900;">&#40;</span>conn, scope, params<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">false</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>	
		out.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;1&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		User user <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> User<span style="color: #009900;">&#40;</span>uid,username,stream<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		users.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span>uid, user<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		ServiceUtils.<span style="color: #006633;">invokeOnAllConnections</span><span style="color: #009900;">&#40;</span>scope, <span style="color: #0000ff;">&quot;joinuser&quot;</span>, <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Object</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#123;</span>username,uid<span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>		
		<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #666666; font-style: italic;">/*
	 * (non-Javadoc)
	 * @see org.red5.server.adapter.ApplicationAdapter#disconnect(org.red5.server.api.IConnection, org.red5.server.api.IScope)
	 * disconnect an user form the chat and notify all others users 
	 */</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> disconnect<span style="color: #009900;">&#40;</span>IConnection conn, IScope scope<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #666666; font-style: italic;">// Function called every time someone disconnects from the server.</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// Get the previously stored username.</span>
		<span style="color: #003399;">String</span> uid <span style="color: #339933;">=</span> conn.<span style="color: #006633;">getClient</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getId</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	
		<span style="color: #666666; font-style: italic;">//out.println(&quot;Disconnection: &quot;+uid);</span>
		<span style="color: #666666; font-style: italic;">// Unregister user.</span>
		<span style="color: #003399;">String</span> stream <span style="color: #339933;">=</span> users.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>uid<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">stream</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">String</span> username <span style="color: #339933;">=</span> users.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>uid<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">username</span><span style="color: #339933;">;</span>
		users.<span style="color: #006633;">remove</span><span style="color: #009900;">&#40;</span>uid<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		vidStreams.<span style="color: #006633;">push</span><span style="color: #009900;">&#40;</span>stream<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		out.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Removed: &quot;</span><span style="color: #339933;">+</span>username<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot; with: &quot;</span><span style="color: #339933;">+</span>stream<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot; and uid:&quot;</span><span style="color: #339933;">+</span>uid<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		ServiceUtils.<span style="color: #006633;">invokeOnAllConnections</span><span style="color: #009900;">&#40;</span>scope, <span style="color: #0000ff;">&quot;removeuser&quot;</span>, <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Object</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#123;</span>username,uid<span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">disconnect</span><span style="color: #009900;">&#40;</span>conn, scope<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>	
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">boolean</span> joinuser<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> username, <span style="color: #003399;">String</span> uid<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		out.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;join invoked: &quot;</span><span style="color: #339933;">+</span>username<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot; &quot;</span><span style="color: #339933;">+</span>uid<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">boolean</span> removeuser<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> username, <span style="color: #003399;">String</span> uid<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		out.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;remove invoked: &quot;</span><span style="color: #339933;">+</span>username<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot; &quot;</span><span style="color: #339933;">+</span>uid<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>I also have a separate class for Users:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">chatter</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> User <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> uid <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> username <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> stream <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> User<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> uid,<span style="color: #003399;">String</span> username,<span style="color: #003399;">String</span> stream<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	      <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">uid</span> <span style="color: #339933;">=</span> uid<span style="color: #339933;">;</span>
	      <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">username</span> <span style="color: #339933;">=</span> username<span style="color: #339933;">;</span>
	      <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">stream</span> <span style="color: #339933;">=</span> stream<span style="color: #339933;">;</span>		      
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Now that all of the server stuff is ready, create a new .fla file and in the properties inspector for the stage, go to Class and write whatever you want there.  Since we&#8217;ve already named everything else Chatter we&#8217;ll stick with that.  Flash will use the name of that class to look for .as files associated with it.  Create a new file named &#8220;Chatter.as&#8221; (remember this name has to match whatever you named the class in Flash), and then put this actionscript in it:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
</pre></td><td class="code"><pre class="actionscript" style="font-family:monospace;">package
<span style="color: #66cc66;">&#123;</span>
  <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Sprite</span>;
  <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #0066CC;">MovieClip</span>;
  <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">NetStatusEvent</span>;
  <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">net</span>.<span style="color: #0066CC;">NetConnection</span>;
  <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">net</span>.<span style="color: #0066CC;">NetStream</span>;
  <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">media</span>.<span style="color: #0066CC;">Camera</span>;
  <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">media</span>.<span style="color: #0066CC;">Microphone</span>;
  <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">media</span>.<span style="color: #0066CC;">Video</span>;
  <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">net</span>.<span style="color: #006600;">Responder</span>;
&nbsp;
  <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Chatter <span style="color: #0066CC;">extends</span> Sprite
  <span style="color: #66cc66;">&#123;</span>
        <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> nc:<span style="color: #0066CC;">NetConnection</span>;
        <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> good:<span style="color: #0066CC;">Boolean</span>;
        <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> netOut:<span style="color: #0066CC;">NetStream</span>;
        <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> netIn:<span style="color: #0066CC;">NetStream</span>;
        <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> cam:<span style="color: #0066CC;">Camera</span>;
        <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> mic:<span style="color: #0066CC;">Microphone</span>;
        <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> responder:Responder;
	<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> r:Responder;
        <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> vidOut:<span style="color: #0066CC;">Video</span>;
        <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> vidIn:<span style="color: #0066CC;">Video</span>;
        <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> outStream:<span style="color: #0066CC;">String</span>;
        <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> inStream:<span style="color: #0066CC;">String</span>;
&nbsp;
        <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> Chatter<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#123;</span>
             <span style="color: #000000; font-weight: bold;">var</span> rtmpNow:<span style="color: #0066CC;">String</span>=<span style="color: #ff0000;">&quot;rtmp://localhost/Chatter&quot;</span>;
             nc=<span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">NetConnection</span>;
             nc.<span style="color: #0066CC;">connect</span><span style="color: #66cc66;">&#40;</span>rtmpNow,<span style="color: #ff0000;">&quot;testName&quot;</span><span style="color: #66cc66;">&#41;</span>;
             nc.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>NetStatusEvent.<span style="color: #006600;">NET_STATUS</span>,getStream<span style="color: #66cc66;">&#41;</span>;
        <span style="color: #66cc66;">&#125;</span>
&nbsp;
        <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> getStream<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">e</span>:NetStatusEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
        <span style="color: #66cc66;">&#123;</span>
             good=<span style="color: #0066CC;">e</span>.<span style="color: #006600;">info</span>.<span style="color: #006600;">code</span> == <span style="color: #ff0000;">&quot;NetConnection.Connect.Success&quot;</span>;
             <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>good<span style="color: #66cc66;">&#41;</span>
             <span style="color: #66cc66;">&#123;</span>
                  <span style="color: #808080; font-style: italic;">// Here we call functions in our Java Application</span>
                   responder=<span style="color: #000000; font-weight: bold;">new</span> Responder<span style="color: #66cc66;">&#40;</span>streamNow<span style="color: #66cc66;">&#41;</span>;
		   r = <span style="color: #000000; font-weight: bold;">new</span> Responder<span style="color: #66cc66;">&#40;</span>adder<span style="color: #66cc66;">&#41;</span>;
		   nc.<span style="color: #0066CC;">call</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;addSomething&quot;</span>,r,<span style="color: #cc66cc;">2</span>,<span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#41;</span>;
                   nc.<span style="color: #0066CC;">call</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;streamer&quot;</span>,responder,<span style="color: #ff0000;">&quot;test&quot;</span><span style="color: #66cc66;">&#41;</span>;
             <span style="color: #66cc66;">&#125;</span>
        <span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> adder <span style="color: #66cc66;">&#40;</span>obj:<span style="color: #0066CC;">Object</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span><span style="color: #66cc66;">&#123;</span>
			<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Total = &quot;</span>,obj.<span style="color: #0066CC;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
        <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> streamNow<span style="color: #66cc66;">&#40;</span>streamSelect:<span style="color: #0066CC;">Object</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
        <span style="color: #66cc66;">&#123;</span>
             setCam<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
             setMic<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
             setVid<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	     <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;We've got our object&quot;</span>,streamSelect.<span style="color: #0066CC;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
             <span style="color: #b1b100;">switch</span><span style="color: #66cc66;">&#40;</span>streamSelect.<span style="color: #0066CC;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
             <span style="color: #66cc66;">&#123;</span>
                   <span style="color: #b1b100;">case</span> <span style="color: #ff0000;">&quot;left&quot;</span> :
                        outStream=<span style="color: #ff0000;">&quot;left&quot;</span>;
                        inStream=<span style="color: #ff0000;">&quot;right&quot;</span>;
                        <span style="color: #b1b100;">break</span>;
                   <span style="color: #b1b100;">case</span> <span style="color: #ff0000;">&quot;right&quot;</span> :
                        outStream=<span style="color: #ff0000;">&quot;right&quot;</span>;
                        inStream=<span style="color: #ff0000;">&quot;left&quot;</span>;
                        <span style="color: #b1b100;">break</span>;
             <span style="color: #66cc66;">&#125;</span>
&nbsp;
             <span style="color: #808080; font-style: italic;">//Publish local video</span>
             netOut=<span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">NetStream</span><span style="color: #66cc66;">&#40;</span>nc<span style="color: #66cc66;">&#41;</span>;
             netOut.<span style="color: #0066CC;">attachAudio</span><span style="color: #66cc66;">&#40;</span>mic<span style="color: #66cc66;">&#41;</span>;
             netOut.<span style="color: #006600;">attachCamera</span><span style="color: #66cc66;">&#40;</span>cam<span style="color: #66cc66;">&#41;</span>;
             vidOut.<span style="color: #006600;">attachCamera</span><span style="color: #66cc66;">&#40;</span>cam<span style="color: #66cc66;">&#41;</span>;
             netOut.<span style="color: #006600;">publish</span><span style="color: #66cc66;">&#40;</span>outStream, <span style="color: #ff0000;">&quot;live&quot;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
             <span style="color: #808080; font-style: italic;">//Play streamed video</span>
             netIn=<span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">NetStream</span><span style="color: #66cc66;">&#40;</span>nc<span style="color: #66cc66;">&#41;</span>;
             vidIn.<span style="color: #006600;">attachNetStream</span><span style="color: #66cc66;">&#40;</span>netIn<span style="color: #66cc66;">&#41;</span>;
             netIn.<span style="color: #0066CC;">play</span><span style="color: #66cc66;">&#40;</span>inStream<span style="color: #66cc66;">&#41;</span>;
        <span style="color: #66cc66;">&#125;</span>
&nbsp;
        <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> setCam<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
        <span style="color: #66cc66;">&#123;</span>
             cam=<span style="color: #0066CC;">Camera</span>.<span style="color: #006600;">getCamera</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
             cam.<span style="color: #0066CC;">setMode</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">240</span>,<span style="color: #cc66cc;">180</span>,<span style="color: #cc66cc;">15</span><span style="color: #66cc66;">&#41;</span>;
             cam.<span style="color: #0066CC;">setQuality</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">85</span><span style="color: #66cc66;">&#41;</span>;
        <span style="color: #66cc66;">&#125;</span>
&nbsp;
        <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> setMic<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
        <span style="color: #66cc66;">&#123;</span>
             mic=<span style="color: #0066CC;">Microphone</span>.<span style="color: #006600;">getMicrophone</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
             mic.<span style="color: #0066CC;">rate</span>=<span style="color: #cc66cc;">11</span>;
             mic.<span style="color: #0066CC;">setSilenceLevel</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">12</span>,<span style="color: #cc66cc;">2000</span><span style="color: #66cc66;">&#41;</span>;
        <span style="color: #66cc66;">&#125;</span>
&nbsp;
        <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> setVid<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
        <span style="color: #66cc66;">&#123;</span>
             vidOut=<span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Video</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">240</span>,<span style="color: #cc66cc;">180</span><span style="color: #66cc66;">&#41;</span>;
             addChild<span style="color: #66cc66;">&#40;</span>vidOut<span style="color: #66cc66;">&#41;</span>;
             vidOut.<span style="color: #006600;">x</span>=<span style="color: #cc66cc;">25</span>;
             vidOut.<span style="color: #006600;">y</span>=<span style="color: #cc66cc;">110</span>;
&nbsp;
             vidIn=<span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Video</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">240</span>,<span style="color: #cc66cc;">180</span><span style="color: #66cc66;">&#41;</span>;
             addChild<span style="color: #66cc66;">&#40;</span>vidIn<span style="color: #66cc66;">&#41;</span>;
             vidIn.<span style="color: #006600;">x</span>=vidOut.<span style="color: #006600;">x</span>+<span style="color: #cc66cc;">260</span>;
             vidIn.<span style="color: #006600;">y</span>=<span style="color: #cc66cc;">110</span>;
        <span style="color: #66cc66;">&#125;</span>
  <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>And that should be all of the pieces that you need to get a basic flash based, red5 using video chat up and running.</p>
<div class="shr-publisher-313"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/devnotes/red5-video-chat-example/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Unix Symbolic Links</title>
		<link>http://flightschool.acylt.com/devnotes/unix-symbolic-links/</link>
		<comments>http://flightschool.acylt.com/devnotes/unix-symbolic-links/#comments</comments>
		<pubDate>Thu, 01 Jul 2010 23:21:41 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[DevNotes]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=245</guid>
		<description><![CDATA[I run quite a few servers on my machine so I use symbolic links quite a bit. That lets me have the files in one place, but still be able to access them on my server in another place, etc etc. I don&#8217;t make these links very often and when I do I usually look [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>I run quite a few servers on my machine so I use symbolic links quite a bit.  That lets me have the files in one place, but still be able to access them on my server in another place, etc etc.  I don&#8217;t make these links very often and when I do I usually look up how, so I thought I&#8217;d just post something about it so I remember for next time.</p>
<p>Using Unix (or Mac OSX) it&#8217;s a simple process.  First open your Terminal in Applications/Utilities and then write:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>Location<span style="color: #000000; font-weight: bold;">/</span>of<span style="color: #000000; font-weight: bold;">/</span>fileorFolder <span style="color: #000000; font-weight: bold;">/</span>Location<span style="color: #000000; font-weight: bold;">/</span>of<span style="color: #000000; font-weight: bold;">/</span>alias<span style="color: #000000; font-weight: bold;">/</span>with<span style="color: #000000; font-weight: bold;">/</span>name<span style="color: #000000; font-weight: bold;">/</span>at<span style="color: #000000; font-weight: bold;">/</span>end</pre></td></tr></table></div>

<p>ln for link, -s for symbolic, and the source and destination.</p>
<p>So an actual example of this is:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> ~<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span> dev</pre></td></tr></table></div>

<p>That created a link to the folder &#8220;dev&#8221; in the folder I was in.</p>
<p>If you&#8217;re still getting the error &#8220;Forbidden: You don&#8217;t have permission to access / on this server&#8221; or the 403 forbidden &#8220;Symbolic link not allowed or link target not accessible&#8221; it&#8217;s probably because of the permissions in <em>the original folder</em> (not the link).  You can change those by navigating to them and typing:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">755</span> fileNameHere</pre></td></tr></table></div>

<p>So if the filename path was home/Documents/fileNameHere, then you would do the chmod like this:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">755</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>Documents</pre></td></tr></table></div>

<div class="shr-publisher-245"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/devnotes/unix-symbolic-links/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Caret Position Woes</title>
		<link>http://flightschool.acylt.com/devnotes/caret-position-woes/</link>
		<comments>http://flightschool.acylt.com/devnotes/caret-position-woes/#comments</comments>
		<pubDate>Thu, 08 Jul 2010 23:10:00 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[DevNotes]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=285</guid>
		<description><![CDATA[Anyone that has tried to create a rich in-browser HTML text editor has had to deal with Internet Explorer and its caret positioning issues (For those wondering that&#8217;s the blinking line that shows where you&#8217;re typing. It&#8217;s also called a cursor but people usually reserve that to refer to the mouse). It isn&#8217;t too difficult [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>Anyone that has tried to create a rich in-browser HTML text editor has had to deal with Internet Explorer and its caret positioning issues (For those wondering that&#8217;s the blinking line that shows where you&#8217;re typing.  It&#8217;s also called a cursor but people usually reserve that to refer to the mouse).  It isn&#8217;t too difficult if you use BODY, BUTTON, TEXTAREA, or an INPUT element having text type (TYPE=&#8221;text&#8221;).  In that case it&#8217;s just a matter of using createTextRange() and finding the text position.  For anyone trying to figure out how to do that, here is some example code:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;html&gt;
&nbsp;
 &lt;body style=&quot;font-family: tahoma; font-size: 8pt;&quot;&gt;
&nbsp;
  &lt;script language=&quot;JavaScript&quot;&gt;
&nbsp;
   /*
   **  Returns the caret (cursor) position of the specified text field.
   **  Return value range is 0-oField.length.
   */
   function doGetCaretPosition (oField) {
&nbsp;
     // Initialize
     var iCaretPos = 0;
&nbsp;
     // IE Support
     if (document.selection) { 
&nbsp;
       // Set focus on the element
       oField.focus ();
&nbsp;
       // To get cursor position, get empty selection range
       var oSel = document.selection.createRange ();
&nbsp;
       // Move selection start to 0 position
       oSel.moveStart ('character', -oField.value.length);
&nbsp;
       // The caret position is selection length
       iCaretPos = oSel.text.length;
     }
&nbsp;
     // Firefox support
     else if (oField.selectionStart || oField.selectionStart == '0')
       iCaretPos = oField.selectionStart;
&nbsp;
     // Return results
     return (iCaretPos);
   }
&nbsp;
&nbsp;
   /*
   **  Sets the caret (cursor) position of the specified text field.
   **  Valid positions are 0-oField.length.
   */
   function doSetCaretPosition (oField, iCaretPos) {
&nbsp;
     // IE Support
     if (document.selection) { 
&nbsp;
       // Set focus on the element
       oField.focus ();
&nbsp;
       // Create empty selection range
       var oSel = document.selection.createRange ();
&nbsp;
       // Move selection start and end to 0 position
       oSel.moveStart ('character', -oField.value.length);
&nbsp;
       // Move selection start and end to desired position
       oSel.moveStart ('character', iCaretPos);
       oSel.moveEnd ('character', 0);
       oSel.select ();
     }
&nbsp;
     // Firefox support
     else if (oField.selectionStart || oField.selectionStart == '0') {
       oField.selectionStart = iCaretPos;
       oField.selectionEnd = iCaretPos;
       oField.focus ();
     }
   }
&nbsp;
  &lt;/script&gt;
&nbsp;
  &lt;form name=&quot;blah&quot;&gt;
&nbsp;
   Text Field: &lt;input type=&quot;text&quot; name=&quot;nameEdit&quot; value=&quot;&quot;&gt;
   &lt;input type=&quot;button&quot; value=&quot;Get Caret&quot; onClick=&quot;document.getElementById('where').value=doGetCaretPosition (document.forms[0].elements[0]);&quot;&gt;
&lt;input id=&quot;where&quot;&gt;
   &lt;hr size=1 noshade&gt;
   New Position: &lt;input type=&quot;text&quot; name=&quot;newPosValue&quot; value=&quot;&quot;&gt;
   &lt;input type=&quot;button&quot; value=&quot;Set Caret&quot; onClick=&quot;doSetCaretPosition (document.blah.nameEdit, parseInt (document.blah.newPosValue.value));&quot;&gt;
&nbsp;
  &lt;/form&gt;
&nbsp;
 &lt;/body&gt;
&nbsp;
&lt;/html&gt;</pre></td></tr></table></div>

<p>Need something more powerful?  Here&#8217;s a nifty little <a href="http://laboratorium.0xab.cd/jquery/fieldselection/0.1.0/test.html" target="_blank">JQuery plugin</a>.</p>
<p>If you&#8217;ve tried doing that with a contentEditable div, you&#8217;ll have realized that it&#8217;s much more difficult.  You see friendly Internet Explorer doesn&#8217;t support createTextRange() for contentEditable divs, and since they are better for rich html, this creates a problem.</p>
<p>Solution: be tricky too.  Instead of creating the text range on the node, create it on the BODY and then <em>move</em> it to the node!  I&#8217;m a dojo man (take a look at the <a href="http://dojotoolkit.org/" target="_blank">Dojo Toolkit here</a>), so in dojo you type:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> range <span style="color: #339933;">=</span> dojo.<span style="color: #660066;">doc</span>.<span style="color: #660066;">selection</span>.<span style="color: #660066;">createRange</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> rs <span style="color: #339933;">=</span> dojo.<span style="color: #660066;">body</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">createTextRange</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
rs.<span style="color: #660066;">moveToElementText</span><span style="color: #009900;">&#40;</span>yourContentEditableDivNode<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">//Now duplicate the range so we can use one to get the end point</span>
<span style="color: #003366; font-weight: bold;">var</span> re <span style="color: #339933;">=</span> rs.<span style="color: #660066;">duplicate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
rs.<span style="color: #660066;">moveToBookmark</span><span style="color: #009900;">&#40;</span>range.<span style="color: #660066;">getBookmark</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
re.<span style="color: #660066;">setEndPoint</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'EndToStart'</span><span style="color: #339933;">,</span> rs<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">//Now re is only the text up until the caret</span>
console.<span style="color: #660066;">warn</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;The text before the cursor is: &quot;</span><span style="color: #339933;">,</span>re.<span style="color: #660066;">text</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot; Its position is: &quot;</span><span style="color: #339933;">,</span>re.<span style="color: #660066;">text</span>.<span style="color: #660066;">length</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Dojo has a rich text editor, and it uses a class dijit._editor.range which is a singleton and has quite a bit of useful text for getting ranges in IE.  If you haven&#8217;t used dojo before for Javascript development I&#8217;d recommend it, it&#8217;s an incredible open source library.  <a href="http://jaredj.dojotoolkit.org/editor_dojo15/" target="_blank">Click here</a> to see an example implementation (you should really look at this it&#8217;s fantastic).</p>
<p>Google has some code that should give IE w3c selections.  It&#8217;s <a href="http://code.google.com/p/ierange/" target="_blank"> here</a>.</p>
<div class="shr-publisher-285"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/devnotes/caret-position-woes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Refactoring</title>
		<link>http://flightschool.acylt.com/devnotes/refactoring/</link>
		<comments>http://flightschool.acylt.com/devnotes/refactoring/#comments</comments>
		<pubDate>Fri, 02 Jul 2010 17:52:41 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[DevNotes]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=261</guid>
		<description><![CDATA[I&#8217;ve recently been introduced to refactoring code. It&#8217;s basically cleaning it up, making it more readable, and matching logic. High level blocks of code should be together and call mid level blocks of code, which should be grouped and call low level blocks of code (which would be the most detailed code). Naming should be [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>I&#8217;ve recently been introduced to refactoring code.  It&#8217;s basically cleaning it up, making it more readable, and matching logic.  High level blocks of code should be together and call mid level blocks of code, which should be grouped and call low level blocks of code (which would be the most detailed code).  Naming should be intuitive, and so forth.</p>
<p>Refactoring is an essential part of the software development cycle, so I&#8217;ve decided to start paying more attention to it.</p>
<p>If you are like me and you&#8217;re just discovering this topic, there are some great screencasts available to give a clear idea of what it is.  These are examples of code refactoring in Ruby using a plugin for Eclipse and can be found at <a href="http://r2.ifs.hsr.ch/trac/wiki/Screencasts" target="_blank">http://r2.ifs.hsr.ch/trac/wiki/Screencasts</a>.  As I find more resources I&#8217;ll post them here.  Until then here are a few other links I found useful:</p>
<p><a href="http://www.refactoring.com/" target="_blank">http://www.refactoring.com/</a></p>
<p><a href="http://en.wikipedia.org/wiki/Code_refactoring" target="_blank">http://en.wikipedia.org/wiki/Code_refactoring</a></p>
<div class="shr-publisher-261"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/devnotes/refactoring/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing/Removing Gems</title>
		<link>http://flightschool.acylt.com/devnotes/installingremoving-gems/</link>
		<comments>http://flightschool.acylt.com/devnotes/installingremoving-gems/#comments</comments>
		<pubDate>Wed, 07 Jul 2010 16:03:51 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[DevNotes]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=280</guid>
		<description><![CDATA[When installing gems I forget to use sudo all the time. What I end up with is warnings and gems being paced in my home folder ~/.gems instead of where I want them. It looks like this: 1 2 3 4 5 $ gem install &#60;gem-name&#62; WARNING: Installing to ~/.gem since /usr/local/ruby-1.8.6-p287/lib/ruby/gems/1.8 and /usr/local/ruby-1.8.6-p287/bin aren't [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>When installing gems I forget to use sudo all the time.  What I end up with is warnings and gems being paced in my home folder ~/.gems instead of where I want them.  It looks like this:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">$ gem <span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #000000; font-weight: bold;">&lt;</span>gem-name<span style="color: #000000; font-weight: bold;">&gt;</span>
  WARNING:  Installing to ~<span style="color: #000000; font-weight: bold;">/</span>.gem since <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>ruby-1.8.6-p287<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>ruby<span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1.8</span> and
    <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>ruby-1.8.6-p287<span style="color: #000000; font-weight: bold;">/</span>bin aren<span style="color: #ff0000;">'t both writable.
  WARNING:  You don'</span>t have <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>jamesmead<span style="color: #000000; font-weight: bold;">/</span>.gem<span style="color: #000000; font-weight: bold;">/</span>ruby<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1.8</span><span style="color: #000000; font-weight: bold;">/</span>bin <span style="color: #000000; font-weight: bold;">in</span> your PATH,
    gem executables will not run.</pre></td></tr></table></div>

<p>If you just don&#8217;t like using sudo, here&#8217;s a good article on that: <a href="http://dev.innovationfactory.nl/2009/10/26/never-use-sudo-gem-install-again/" target="_blank">http://dev.innovationfactory.nl/2009/10/26/never-use-sudo-gem-install-again/</a>.</p>
<p>If you installed them without using sudo and now want them in the right place, first you&#8217;ll need to uninstall them.  A normal uninstall will give this error:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">$ gem uninstall <span style="color: #000000; font-weight: bold;">&lt;</span>gem-name<span style="color: #000000; font-weight: bold;">&gt;</span>
  ERROR:  While executing gem ... <span style="color: #7a0874; font-weight: bold;">&#40;</span>Gem::InstallError<span style="color: #7a0874; font-weight: bold;">&#41;</span>
    Unknown gem <span style="color: #000000; font-weight: bold;">&lt;</span>gem-name<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">&gt;</span>= <span style="color: #000000;">0</span></pre></td></tr></table></div>

<p>You might be tempted to just delete the gems folder (~/.gems).  I tried that but when it gets installed the paths are stored somewhere else&#8230; long story short it won&#8217;t be pretty.  Instead you need to use the &#8211;install-dir parameter when uninstalling like this:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">$ gem uninstall <span style="color: #000000; font-weight: bold;">&lt;</span>gem-name<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #660033;">--install-dir</span>=~<span style="color: #000000; font-weight: bold;">/</span>.gem<span style="color: #000000; font-weight: bold;">/</span>ruby<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1.8</span><span style="color: #000000; font-weight: bold;">/</span>
  Successfully uninstalled <span style="color: #000000; font-weight: bold;">&lt;</span>gem-name<span style="color: #000000; font-weight: bold;">&gt;</span>-x.y.z</pre></td></tr></table></div>

<div class="shr-publisher-280"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/devnotes/installingremoving-gems/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Andes Tutor Intro</title>
		<link>http://flightschool.acylt.com/devnotes/310/</link>
		<comments>http://flightschool.acylt.com/devnotes/310/#comments</comments>
		<pubDate>Wed, 14 Jul 2010 21:10:02 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[DevNotes]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=310</guid>
		<description><![CDATA[One of my current projects is the Andes Physics Tutor. This is a project being developed at ASU, and occasionally I&#8217;ll be posting help videos that show how to use it. To watch it as it develops check http://gideon.eas.asu.edu/web-UI/login.html and try some problems. Before you do that check this video out to get an idea [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>One of my current projects is the Andes Physics Tutor.  This is a project being developed at ASU, and occasionally I&#8217;ll be posting help videos that show how to use it.  To watch it as it develops check <a href="http://gideon.eas.asu.edu/web-UI/login.html" target="_blank">http://gideon.eas.asu.edu/web-UI/login.html</a> and try some problems.  Before you do that check this video out to get an idea of how it works: </p>
<p><object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/aeKmxMjJvnY&amp;hl=en_US&amp;fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/aeKmxMjJvnY&amp;hl=en_US&amp;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object></p>
<div class="shr-publisher-310"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/devnotes/310/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WhatATool (Assignment 1B &amp; 2A)</title>
		<link>http://flightschool.acylt.com/iphone/whatatool/</link>
		<comments>http://flightschool.acylt.com/iphone/whatatool/#comments</comments>
		<pubDate>Sun, 10 Jan 2010 11:23:59 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=156</guid>
		<description><![CDATA[The WhatATool Project I&#8217;m going through the CS 193P iPhone Dev course that Stanford has put up on iTunes U, and I thought I&#8217;d go ahead and publish my code in case anyone else is going through it too and wants to see alternate ways of doing things. This is my solution for assignment 1B [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><h2>The WhatATool Project</h2>
<p>I&#8217;m going through the CS 193P iPhone Dev course that Stanford has put up on iTunes U, and I thought I&#8217;d go ahead and publish my code in case anyone else is going through it too and wants to see alternate ways of doing things.  This is my solution for assignment 1B and 2A.</p>
<h3>WhatATool.m</h3>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
</pre></td><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #6e371a;">#import &lt;Foundation/Foundation.h&gt;</span>
<span style="color: #6e371a;">#import &quot;PolygonShape.h&quot;</span>
&nbsp;
<span style="color: #a61390;">void</span> PrintPathInfo<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
&nbsp;
	NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;===Print Path Info====&quot;</span><span style="color: #002200;">&#41;</span>;
	<span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>path <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;~&quot;</span>;
&nbsp;
	<span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>expand <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>path stringByExpandingTildeInPath<span style="color: #002200;">&#93;</span>;
	NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;My home folder is at '%@'&quot;</span>, expand<span style="color: #002200;">&#41;</span>;
&nbsp;
	<span style="color: #400080;">NSArray</span> <span style="color: #002200;">*</span>comp <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>expand pathComponents<span style="color: #002200;">&#93;</span>;
	<span style="color: #a61390;">for</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>pc <span style="color: #a61390;">in</span> comp<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#123;</span>
		NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;%@&quot;</span>,pc<span style="color: #002200;">&#41;</span>;
	<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #a61390;">void</span> PrintProcessInfo<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#123;</span>
&nbsp;
	NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;<span style="color: #2400d9;">\n</span>&quot;</span><span style="color: #002200;">&#41;</span>;
	NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;===Print Process Info====&quot;</span><span style="color: #002200;">&#41;</span>;
&nbsp;
	<span style="color: #11740a; font-style: italic;">//NSString *processName = [[NSProcessInfo processInfo] processName];</span>
	<span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>processName <span style="color: #002200;">=</span> <span style="color: #400080;">NSProcessInfo</span>.processInfo.processName;
	NSInteger processID <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSProcessInfo</span> processInfo<span style="color: #002200;">&#93;</span> processIdentifier<span style="color: #002200;">&#93;</span>;
&nbsp;
	NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Process Name: %@ Process ID: '%d'&quot;</span>, processName, processID<span style="color: #002200;">&#41;</span>;
&nbsp;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #a61390;">void</span> PrintBookmarkInfo<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#123;</span>
&nbsp;
	NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;<span style="color: #2400d9;">\n</span>&quot;</span><span style="color: #002200;">&#41;</span>;
	NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;===Print Bookmark Info====&quot;</span><span style="color: #002200;">&#41;</span>;
&nbsp;
	<span style="color: #400080;">NSMutableDictionary</span> <span style="color: #002200;">*</span>bookInfo <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSMutableDictionary</span> dictionaryWithCapacity<span style="color: #002200;">:</span><span style="color: #2400d9;">10</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>bookInfo setObject<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSURL</span> URLWithString<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;http://www.stanford.edu&quot;</span><span style="color: #002200;">&#93;</span> forKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Stanford University&quot;</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>bookInfo setObject<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSURL</span> URLWithString<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;http://www.apple.com&quot;</span><span style="color: #002200;">&#93;</span> forKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Apple&quot;</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>bookInfo setObject<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSURL</span> URLWithString<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;http://www.cs193p.stanford.edu&quot;</span><span style="color: #002200;">&#93;</span> forKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;CS193P&quot;</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>bookInfo setObject<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSURL</span> URLWithString<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;http://www.itunes.stanford.edu&quot;</span><span style="color: #002200;">&#93;</span> forKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Stanford on iTunes U&quot;</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>bookInfo setObject<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSURL</span> URLWithString<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;http://www.stanfordshop.com&quot;</span><span style="color: #002200;">&#93;</span> forKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Stanford Mall&quot;</span><span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #a61390;">for</span> <span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>info <span style="color: #a61390;">in</span> bookInfo<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#123;</span>
		<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span>info hasPrefix<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Stanford&quot;</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
			NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Key: '%@' URL: '%@'&quot;</span>, info, <span style="color: #002200;">&#91;</span>bookInfo objectForKey<span style="color: #002200;">:</span>info<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span>;
		<span style="color: #002200;">&#125;</span>
&nbsp;
	<span style="color: #002200;">&#125;</span>
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #a61390;">void</span> PrintIntrospectionInfo<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#123;</span>
&nbsp;
	NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;<span style="color: #2400d9;">\n</span>&quot;</span><span style="color: #002200;">&#41;</span>;
	NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;===Print Introspection Info====&quot;</span><span style="color: #002200;">&#41;</span>;
&nbsp;
	<span style="color: #400080;">NSMutableArray</span> <span style="color: #002200;">*</span>introSpec <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSMutableArray</span> arrayWithCapacity<span style="color: #002200;">:</span><span style="color: #2400d9;">10</span><span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #400080;">NSURL</span> <span style="color: #002200;">*</span>url <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSURL</span> URLWithString<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;http://www.stanford.edu&quot;</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>str <span style="color: #002200;">=</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Here's a string&quot;</span>;
	<span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>processName <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSProcessInfo</span> processInfo<span style="color: #002200;">&#93;</span> processName<span style="color: #002200;">&#93;</span>;
	<span style="color: #400080;">NSDictionary</span> <span style="color: #002200;">*</span>dict <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSDictionary</span> dictionary<span style="color: #002200;">&#93;</span>;
	<span style="color: #400080;">NSMutableString</span> <span style="color: #002200;">*</span>mstr <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSMutableString</span> <span style="color: #a61390;">string</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>mstr appendString<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;My hard &quot;</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>mstr appendFormat<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;work paid off&quot;</span><span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #002200;">&#91;</span>introSpec addObject<span style="color: #002200;">:</span>url<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>introSpec addObject<span style="color: #002200;">:</span>str<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>introSpec addObject<span style="color: #002200;">:</span>processName<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>introSpec addObject<span style="color: #002200;">:</span>dict<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>introSpec addObject<span style="color: #002200;">:</span>mstr<span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #a61390;">for</span><span style="color: #002200;">&#40;</span><span style="color: #400080;">NSObject</span> <span style="color: #002200;">*</span>intro <span style="color: #a61390;">in</span> introSpec<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#123;</span>
		NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Class name: %@&quot;</span>, <span style="color: #002200;">&#91;</span>intro className<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span>;
		NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Is Member of NSString: %@&quot;</span>, <span style="color: #002200;">&#91;</span>intro isMemberOfClass<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSString</span> class<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span> ? <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;YES&quot;</span> <span style="color: #002200;">:</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;NO&quot;</span><span style="color: #002200;">&#41;</span>;
		NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Is Kind of NSString: %@&quot;</span>, <span style="color: #002200;">&#91;</span>intro isKindOfClass<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSString</span> class<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span> ? <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;YES&quot;</span> <span style="color: #002200;">:</span> <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;NO&quot;</span><span style="color: #002200;">&#41;</span>;
		<span style="color: #11740a; font-style: italic;">//NSLog(@&quot;Responds to lowercaseString: %@&quot;, [intro respondsToSelector:@selector(lowercaseString)] ? @&quot;YES&quot; : @&quot;NO&quot;);</span>
&nbsp;
		<span style="color: #a61390;">SEL</span> sel <span style="color: #002200;">=</span> <span style="color: #a61390;">@selector</span><span style="color: #002200;">&#40;</span>lowercaseString<span style="color: #002200;">&#41;</span>;
&nbsp;
		<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span>intro respondsToSelector<span style="color: #002200;">:</span>sel<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
			NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Responds to lowercaseString: YES&quot;</span><span style="color: #002200;">&#41;</span>;
			NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;lowercaseString is: %@&quot;</span>, <span style="color: #002200;">&#91;</span>intro performSelector<span style="color: #002200;">:</span>sel withObject<span style="color: #002200;">:</span>intro<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span>;
		<span style="color: #002200;">&#125;</span> <span style="color: #a61390;">else</span> <span style="color: #002200;">&#123;</span>
			NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Responds to lowercaseString: NO&quot;</span><span style="color: #002200;">&#41;</span>;
		<span style="color: #002200;">&#125;</span>
&nbsp;
		NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;==============================&quot;</span><span style="color: #002200;">&#41;</span>;
&nbsp;
	<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #a61390;">void</span> PrintPolygonInfo<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#123;</span>
&nbsp;
	NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;===Print Polygon Info====&quot;</span><span style="color: #002200;">&#41;</span>;
&nbsp;
	<span style="color: #400080;">NSMutableArray</span> <span style="color: #002200;">*</span>polygons <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSMutableArray</span> alloc<span style="color: #002200;">&#93;</span> init<span style="color: #002200;">&#93;</span>;
&nbsp;
	PolygonShape <span style="color: #002200;">*</span>poly1 <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>PolygonShape alloc<span style="color: #002200;">&#93;</span> initWithNumberOfSides<span style="color: #002200;">:</span><span style="color: #2400d9;">4</span> minimumNumberOfSides<span style="color: #002200;">:</span><span style="color: #2400d9;">3</span> maximumNumberOfSides<span style="color: #002200;">:</span><span style="color: #2400d9;">7</span><span style="color: #002200;">&#93;</span>;
	PolygonShape <span style="color: #002200;">*</span>poly2 <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>PolygonShape alloc<span style="color: #002200;">&#93;</span> initWithNumberOfSides<span style="color: #002200;">:</span><span style="color: #2400d9;">6</span> minimumNumberOfSides<span style="color: #002200;">:</span><span style="color: #2400d9;">5</span> maximumNumberOfSides<span style="color: #002200;">:</span><span style="color: #2400d9;">9</span><span style="color: #002200;">&#93;</span>;
	PolygonShape <span style="color: #002200;">*</span>poly3 <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>PolygonShape alloc<span style="color: #002200;">&#93;</span> init<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>poly3 setNumberOfSides<span style="color: #002200;">:</span><span style="color: #2400d9;">12</span><span style="color: #002200;">&#93;</span>;
	poly3.minimumNumberOfSides <span style="color: #002200;">=</span> <span style="color: #2400d9;">9</span>;
	poly3.maximumNumberOfSides <span style="color: #002200;">=</span> <span style="color: #2400d9;">12</span>;
&nbsp;
	<span style="color: #002200;">&#91;</span>polygons addObject<span style="color: #002200;">:</span>poly1<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>polygons addObject<span style="color: #002200;">:</span>poly2<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#91;</span>polygons addObject<span style="color: #002200;">:</span>poly3<span style="color: #002200;">&#93;</span>;
&nbsp;
	<span style="color: #a61390;">for</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span> poly <span style="color: #a61390;">in</span> polygons<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
		NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;%@&quot;</span>,<span style="color: #002200;">&#91;</span>poly description<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span>;
	<span style="color: #002200;">&#125;</span>
&nbsp;
	<span style="color: #a61390;">for</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span> poly <span style="color: #a61390;">in</span> polygons<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
		<span style="color: #002200;">&#91;</span>poly setNumberOfSides<span style="color: #002200;">:</span><span style="color: #2400d9;">10</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#125;</span>
&nbsp;
	<span style="color: #a61390;">for</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span> poly <span style="color: #a61390;">in</span> polygons<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
		<span style="color: #11740a; font-style: italic;">//NSLog(@&quot;Releasing the %@&quot;,[poly name]);</span>
		<span style="color: #002200;">&#91;</span>poly release<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#125;</span>
&nbsp;
	<span style="color: #002200;">&#91;</span>polygons release<span style="color: #002200;">&#93;</span>;
&nbsp;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #a61390;">int</span> main <span style="color: #002200;">&#40;</span><span style="color: #a61390;">int</span> argc, <span style="color: #a61390;">const</span> <span style="color: #a61390;">char</span> <span style="color: #002200;">*</span> argv<span style="color: #002200;">&#91;</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
	<span style="color: #400080;">NSAutoreleasePool</span> <span style="color: #002200;">*</span> pool <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSAutoreleasePool</span> alloc<span style="color: #002200;">&#93;</span> init<span style="color: #002200;">&#93;</span>;
&nbsp;
	PrintPathInfo<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span>; <span style="color: #11740a; font-style: italic;">// Section 1</span>
	PrintProcessInfo<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span>; <span style="color: #11740a; font-style: italic;">// Section 2</span>
	PrintBookmarkInfo<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span>; <span style="color: #11740a; font-style: italic;">// Section 3</span>
	PrintIntrospectionInfo<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span>; <span style="color: #11740a; font-style: italic;">// Section 4</span>
	PrintPolygonInfo<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span>; <span style="color: #11740a; font-style: italic;">//Section 6</span>
&nbsp;
	<span style="color: #002200;">&#91;</span>pool release<span style="color: #002200;">&#93;</span>;
	<span style="color: #a61390;">return</span> <span style="color: #2400d9;">0</span>;
<span style="color: #002200;">&#125;</span></pre></td></tr></table></div>

<h3>PolygonShape.h</h3>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
</pre></td><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #6e371a;">#import &lt;Cocoa/Cocoa.h&gt;</span>
&nbsp;
<span style="color: #a61390;">@interface</span> PolygonShape <span style="color: #002200;">:</span> <span style="color: #400080;">NSObject</span> <span style="color: #002200;">&#123;</span>
	<span style="color: #a61390;">int</span> numberOfSides;
	<span style="color: #a61390;">int</span> minimumNumberOfSides;
	<span style="color: #a61390;">int</span> maximumNumberOfSides;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #11740a; font-style: italic;">//Properties</span>
<span style="color: #a61390;">@property</span> <span style="color: #a61390;">int</span> numberOfSides;
<span style="color: #a61390;">@property</span> <span style="color: #a61390;">int</span> minimumNumberOfSides;
<span style="color: #a61390;">@property</span> <span style="color: #a61390;">int</span> maximumNumberOfSides;
<span style="color: #a61390;">@property</span> <span style="color: #002200;">&#40;</span>readonly<span style="color: #002200;">&#41;</span> <span style="color: #a61390;">float</span> angleInDegrees;
<span style="color: #a61390;">@property</span> <span style="color: #002200;">&#40;</span>readonly<span style="color: #002200;">&#41;</span> <span style="color: #a61390;">float</span> angleInRadians;
<span style="color: #a61390;">@property</span> <span style="color: #002200;">&#40;</span>readonly<span style="color: #002200;">&#41;</span> <span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>name;
<span style="color: #a61390;">@property</span> <span style="color: #002200;">&#40;</span>readonly<span style="color: #002200;">&#41;</span> <span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>description;
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>init;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>initWithNumberOfSides<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">int</span><span style="color: #002200;">&#41;</span>sides minimumNumberOfSides<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">int</span><span style="color: #002200;">&#41;</span>min maximumNumberOfSides<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">int</span><span style="color: #002200;">&#41;</span>max;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>dealloc;
&nbsp;
<span style="color: #a61390;">@end</span></pre></td></tr></table></div>

<h3>PolygonShape.m</h3>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
</pre></td><td class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #11740a; font-style: italic;">//</span>
<span style="color: #11740a; font-style: italic;">//  PolygonShape.m</span>
<span style="color: #11740a; font-style: italic;">//  WhatATool</span>
<span style="color: #11740a; font-style: italic;">//</span>
<span style="color: #11740a; font-style: italic;">//  Created by Ace Sorensen on 1/9/10.</span>
<span style="color: #11740a; font-style: italic;">//  Copyright 2010 __MyCompanyName__. All rights reserved.</span>
<span style="color: #11740a; font-style: italic;">//</span>
&nbsp;
<span style="color: #6e371a;">#import &quot;PolygonShape.h&quot;</span>
&nbsp;
&nbsp;
<span style="color: #a61390;">@implementation</span> PolygonShape
&nbsp;
<span style="color: #a61390;">@synthesize</span> numberOfSides;
<span style="color: #a61390;">@synthesize</span> minimumNumberOfSides;
<span style="color: #a61390;">@synthesize</span> maximumNumberOfSides;
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>dealloc <span style="color: #002200;">&#123;</span>
	NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Deallocating&quot;</span><span style="color: #002200;">&#41;</span>;
	<span style="color: #002200;">&#91;</span>super dealloc<span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>init <span style="color: #002200;">&#123;</span>
	<span style="color: #a61390;">return</span> <span style="color: #002200;">&#91;</span>self initWithNumberOfSides<span style="color: #002200;">:</span><span style="color: #2400d9;">5</span> minimumNumberOfSides<span style="color: #002200;">:</span><span style="color: #2400d9;">2</span> maximumNumberOfSides<span style="color: #002200;">:</span><span style="color: #2400d9;">12</span><span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">id</span><span style="color: #002200;">&#41;</span>initWithNumberOfSides<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">int</span><span style="color: #002200;">&#41;</span>sides minimumNumberOfSides<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">int</span><span style="color: #002200;">&#41;</span>min maximumNumberOfSides<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">int</span><span style="color: #002200;">&#41;</span>max <span style="color: #002200;">&#123;</span>
	<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>self <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>super init<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
		<span style="color: #002200;">&#91;</span>self setMaximumNumberOfSides<span style="color: #002200;">:</span>max<span style="color: #002200;">&#93;</span>;
		<span style="color: #002200;">&#91;</span>self setMinimumNumberOfSides<span style="color: #002200;">:</span>min<span style="color: #002200;">&#93;</span>;
		<span style="color: #002200;">&#91;</span>self setNumberOfSides<span style="color: #002200;">:</span>sides<span style="color: #002200;">&#93;</span>;
	<span style="color: #002200;">&#125;</span>
	<span style="color: #a61390;">return</span> self;
&nbsp;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>setNumberOfSides<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">int</span><span style="color: #002200;">&#41;</span>sides<span style="color: #002200;">&#123;</span>
	<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>sides&lt;minimumNumberOfSides || sides&gt;maximumNumberOfSides<span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
		<span style="color: #a61390;">if</span><span style="color: #002200;">&#40;</span>sides&lt;minimumNumberOfSides<span style="color: #002200;">&#41;</span><span style="color: #002200;">&#123;</span>
			NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Invalid number of sides: %d is less than the minimum number of %d allowed&quot;</span>,sides,minimumNumberOfSides<span style="color: #002200;">&#41;</span>;
		<span style="color: #002200;">&#125;</span> <span style="color: #a61390;">else</span> <span style="color: #002200;">&#123;</span>
			NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Invalid number of sides: %d is more than the maximum number of %d allowed&quot;</span>, sides, maximumNumberOfSides<span style="color: #002200;">&#41;</span>;
		<span style="color: #002200;">&#125;</span>
	<span style="color: #002200;">&#125;</span> <span style="color: #a61390;">else</span> <span style="color: #002200;">&#123;</span>
		numberOfSides <span style="color: #002200;">=</span> sides;
	<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>setMinimumNumberOfSides<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">int</span><span style="color: #002200;">&#41;</span>min<span style="color: #002200;">&#123;</span>
	<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>min&lt;<span style="color: #2400d9;">3</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
		NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Attempting to set too low&quot;</span><span style="color: #002200;">&#41;</span>;
	<span style="color: #002200;">&#125;</span> <span style="color: #a61390;">else</span> <span style="color: #002200;">&#123;</span>
		minimumNumberOfSides <span style="color: #002200;">=</span> min;
	<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">void</span><span style="color: #002200;">&#41;</span>setMaximumNumberOfSides<span style="color: #002200;">:</span><span style="color: #002200;">&#40;</span><span style="color: #a61390;">int</span><span style="color: #002200;">&#41;</span>max<span style="color: #002200;">&#123;</span>
	<span style="color: #a61390;">if</span> <span style="color: #002200;">&#40;</span>max&gt;<span style="color: #2400d9;">12</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">&#123;</span>
		NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Attempting to set higher than min&quot;</span><span style="color: #002200;">&#41;</span>;
	<span style="color: #002200;">&#125;</span> <span style="color: #a61390;">else</span> <span style="color: #002200;">&#123;</span>
		maximumNumberOfSides <span style="color: #002200;">=</span> max;
	<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">float</span><span style="color: #002200;">&#41;</span>angleInDegrees <span style="color: #002200;">&#123;</span>
	<span style="color: #a61390;">return</span> <span style="color: #002200;">&#40;</span><span style="color: #2400d9;">180</span> <span style="color: #002200;">*</span> <span style="color: #002200;">&#40;</span>numberOfSides <span style="color: #002200;">-</span> <span style="color: #2400d9;">2</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">/</span> numberOfSides<span style="color: #002200;">&#41;</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #a61390;">float</span><span style="color: #002200;">&#41;</span>angleInRadians <span style="color: #002200;">&#123;</span>
	<span style="color: #a61390;">return</span> <span style="color: #002200;">&#40;</span>M_PI <span style="color: #002200;">*</span> <span style="color: #002200;">&#40;</span>numberOfSides <span style="color: #002200;">-</span> <span style="color: #2400d9;">2</span><span style="color: #002200;">&#41;</span> <span style="color: #002200;">/</span> numberOfSides<span style="color: #002200;">&#41;</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>name <span style="color: #002200;">&#123;</span>
	<span style="color: #400080;">NSDictionary</span> <span style="color: #002200;">*</span>names <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSDictionary</span> dictionaryWithObjectsAndKeys<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Triangle&quot;</span>, <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSNumber</span> numberWithInt<span style="color: #002200;">:</span><span style="color: #2400d9;">3</span><span style="color: #002200;">&#93;</span>,
						   <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Square&quot;</span>, <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSNumber</span> numberWithInt<span style="color: #002200;">:</span><span style="color: #2400d9;">4</span><span style="color: #002200;">&#93;</span>,
						   <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Pentagon&quot;</span>, <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSNumber</span> numberWithInt<span style="color: #002200;">:</span><span style="color: #2400d9;">5</span><span style="color: #002200;">&#93;</span>,
						   <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Hexagon&quot;</span>, <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSNumber</span> numberWithInt<span style="color: #002200;">:</span><span style="color: #2400d9;">6</span><span style="color: #002200;">&#93;</span>,
						   <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Heptagon&quot;</span>, <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSNumber</span> numberWithInt<span style="color: #002200;">:</span><span style="color: #2400d9;">7</span><span style="color: #002200;">&#93;</span>,
						   <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Octagon&quot;</span>, <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSNumber</span> numberWithInt<span style="color: #002200;">:</span><span style="color: #2400d9;">8</span><span style="color: #002200;">&#93;</span>,
						   <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Nonagon&quot;</span>, <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSNumber</span> numberWithInt<span style="color: #002200;">:</span><span style="color: #2400d9;">9</span><span style="color: #002200;">&#93;</span>,
						   <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Decagon&quot;</span>, <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSNumber</span> numberWithInt<span style="color: #002200;">:</span><span style="color: #2400d9;">10</span><span style="color: #002200;">&#93;</span>,
						   <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Hendecagon&quot;</span>, <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSNumber</span> numberWithInt<span style="color: #002200;">:</span><span style="color: #2400d9;">11</span><span style="color: #002200;">&#93;</span>,
						   <span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Dodecagon&quot;</span>, <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSNumber</span> numberWithInt<span style="color: #002200;">:</span><span style="color: #2400d9;">12</span><span style="color: #002200;">&#93;</span>, <span style="color: #a61390;">nil</span><span style="color: #002200;">&#93;</span>;
	<span style="color: #a61390;">return</span> <span style="color: #002200;">&#91;</span>names objectForKey<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span><span style="color: #400080;">NSNumber</span> numberWithInt<span style="color: #002200;">:</span><span style="color: #002200;">&#91;</span>self numberOfSides<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #002200;">-</span> <span style="color: #002200;">&#40;</span><span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span><span style="color: #002200;">&#41;</span>description <span style="color: #002200;">&#123;</span>
	<span style="color: #a61390;">return</span> <span style="color: #002200;">&#91;</span><span style="color: #400080;">NSString</span> stringWithFormat<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Hello I am a %d-sided polygon (aka a %@) with angles of %.0f degrees (%f radians).&quot;</span>, <span style="color: #002200;">&#91;</span>self numberOfSides<span style="color: #002200;">&#93;</span>, <span style="color: #002200;">&#91;</span>self name<span style="color: #002200;">&#93;</span>, <span style="color: #002200;">&#91;</span>self angleInDegrees<span style="color: #002200;">&#93;</span>, <span style="color: #002200;">&#91;</span>self angleInRadians<span style="color: #002200;">&#93;</span><span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#125;</span>
&nbsp;
<span style="color: #a61390;">@end</span></pre></td></tr></table></div>

<div class="shr-publisher-156"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/iphone/whatatool/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Auto Draft</title>
		<link>http://flightschool.acylt.com/the_novel/</link>
		<comments>http://flightschool.acylt.com/the_novel/#comments</comments>
		<pubDate>Wed, 30 Nov -0001 00:00:00 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
		
		<guid isPermaLink="false">http://flightschool.acylt.com/?p=445</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/the_novel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Curse of Personality Theory</title>
		<link>http://flightschool.acylt.com/humanz/the-curse-of-personality-theory/</link>
		<comments>http://flightschool.acylt.com/humanz/the-curse-of-personality-theory/#comments</comments>
		<pubDate>Thu, 12 Aug 2010 19:34:56 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[Humanz]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=328</guid>
		<description><![CDATA[I was 16 when I took my first Myers-Briggs Type Indicator personality test.  I don&#8217;t know whether it was just the normal teenage narcissism of loving to hear about oneself or whether it was the fact that my personality only comprised 1-3% of the US population (which in my mind made me extraordinary), but I [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p><a href="http://flightschool.acylt.com/wp-content/uploads/2010/08/Personality-Test.jpg"><img class="alignleft size-full wp-image-333" title="Personality Test" src="http://flightschool.acylt.com/wp-content/uploads/2010/08/Personality-Test.jpg" alt="" width="302" height="360" /></a>I was 16 when I took my first <a href="http://en.wikipedia.org/wiki/Myers-Briggs_Type_Indicator" target="_blank">Myers-Briggs Type Indicator</a> personality test.  I don&#8217;t know whether it was just the normal teenage narcissism of loving to hear about oneself or whether it was the fact that my personality only comprised 1-3% of the US population (which in my mind made me extraordinary), but I was hooked.  I went on to take psychology just for the personality theory and read all the literature that I could find on it including <a href="http://www.amazon.com/gp/product/1885705026?ie=UTF8&amp;tag=flightschoo01-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=1885705026">Please Understand Me II</a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=flightschoo01-20&amp;l=as2&amp;o=1&amp;a=1885705026" border="0" alt="" width="1" height="1" />, which was a revelation to me.  From then on I&#8217;ve understood people from this context.</p>
<p>To me understanding &#8220;blue&#8221; or &#8220;red&#8221; personalities (or their roughly equivalent ENFJ&#8217;s and ENTJ&#8217;s) was much easier within this framework (in this article I&#8217;ll use colors since most people don&#8217;t know the types-blue being motivated by intimacy, red by power, white by peace, and yellow by fun).  Everything about personality theory was good.</p>
<p>My perspective on that didn&#8217;t change until a course I took in college when I started to realize people were using the theories in a subtly different way.  Instead of understanding <em>other people</em> through personality theory, they tried to understand themselves.  I probably would have done this too except that I have the sometimes regrettable trait of never taking anyone else&#8217;s opinions on things that I should be able to figure out on my own (even if it takes me years to do).</p>
<p>The problem wasn&#8217;t that they were using it as a foundation of understanding, that wouldn&#8217;t have been as bad.  The problem was that they were using it as an excuse.  This would come up in conversation when a &#8220;red&#8221; person would say something tactless and when confronted say &#8220;Sorry I can&#8217;t help it, I&#8217;m red.&#8221;  Or a white personality would avoid confronting problems and say, &#8220;I can&#8217;t help it I&#8217;m white&#8221;.</p>
<p>The minute personality theory goes from a framework to a definition, that&#8217;s when there are huge problems.  That simple misunderstanding can make someone who should be thinking &#8220;I have a personality that makes me prone to certain weaknesses&#8221; think, &#8220;I have a personality with weaknesses.&#8221;  The first uses personality theory to pinpoint weaknesses to improve on, the second uses it as an excuse.</p>
<p>This isn&#8217;t a conscious decision, it just happens when people are lazy thinkers (which happens to be most of the time).  As a result I wonder if personality theory has done more damage than good.</p>
<div class="shr-publisher-328"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/humanz/the-curse-of-personality-theory/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Great Lumbering Machine</title>
		<link>http://flightschool.acylt.com/humanz/great-lumbering-machine/</link>
		<comments>http://flightschool.acylt.com/humanz/great-lumbering-machine/#comments</comments>
		<pubDate>Sun, 05 Sep 2010 21:52:03 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[Humanz]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=366</guid>
		<description><![CDATA[My mind is like a great lumbering machine. I approach a new problem or subject and it looks daunting, not because the problem is too difficult, but because it will take so much sweat to begin the machine. So I heave and I strain and the engine shows signs of life until finally, after I [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>My mind is like a great lumbering machine.  I approach a new problem or subject and it looks daunting, not because the problem is too difficult, but because it will take so much sweat to begin the machine.  So I heave and I strain and the engine shows signs of life until finally, after I feel near exhaustion the pistons catch and it roars to life.  </p>
<p>After that everything is child&#8217;s play, it&#8217;s as if I see the world with pure understanding.  I get a rush, a high from the effort, but if ever I relax then I am faced again with the effort of going.</p>
<p>I suppose it&#8217;s that way with everything.  Nothing worthwhile comes without a price.</p>
<div class="shr-publisher-366"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/humanz/great-lumbering-machine/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Guilt</title>
		<link>http://flightschool.acylt.com/humanz/guilt/</link>
		<comments>http://flightschool.acylt.com/humanz/guilt/#comments</comments>
		<pubDate>Mon, 06 Sep 2010 20:15:23 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[Humanz]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=371</guid>
		<description><![CDATA[Guilt is an essential emotion, but like every emotion it has a degenerate form. Here I want to look at both and contrast them. To me guilt is the experience of the mind realizing that the individuals actions do not meet the requirements of society (mostly based on ones self perception of what society would [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>Guilt is an essential emotion, but like every emotion it has a degenerate form.  Here I want to look at both and contrast them.</p>
<p>To me guilt is the experience of the mind realizing that the individuals actions do not meet the requirements of society (mostly based on ones self perception of what society would be if their personality were multiplied a few billion times).  In other words it is the mind realizing the individual is not living up to the golden rule.  It is meant to be a motivating emotion that helps the individual be socially acceptable.  Since we are social beings, this is an essential experience.</p>
<p>Correct instances are when the child steals and realizes that they took advantage of another person.  They feel motivation to correct the imbalance by returning it to the owner and offering reparation for the temporary loss.  These cases are always characterized by the individual having done something to cause the imbalance and having the responsibility to set it right.</p>
<p>Incorrect instances would be a situation like a thin person feeling responsible for a large person&#8217;s feeling bad about themselves and their largeness in their presence.  This happens most often with females, and the guilt usually comes when the larger female develops an eating disorder (but there are cases all across the board, the important thing here is the pattern).</p>
<p>This is the crippling form of guilt.  It is not what the emotion was designed for and as a result has very damaging results from anxiety to depression.  The fundamental error here is that people are taking responsibility for things that aren&#8217;t their fault.  It&#8217;s not their fault that the other individual feels bad about themselves for being larger.  They can&#8217;t take responsibility for it and fix the error.  All they can really do is fret, which explains the anxiety.</p>
<p>What should really happen in cases like these is the person should feel empathy for the other individual and offer help so the individual can remedy their situation and no longer feel badly.  In that case both parties sleep better at night.</p>
<p>The bottom line is that the difference is in responsibility.  If I have done wrong, I feel guilt and make amends.  If I have done no wrong but my presence creates a situation that feels wrong, I feel empathy or even sympathy but that is not my burden.  It is the others.</p>
<div class="shr-publisher-371"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/humanz/guilt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Self Pity</title>
		<link>http://flightschool.acylt.com/humanz/self-pity/</link>
		<comments>http://flightschool.acylt.com/humanz/self-pity/#comments</comments>
		<pubDate>Thu, 07 Oct 2010 07:31:26 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[Humanz]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=378</guid>
		<description><![CDATA[I&#8217;m sitting here, late at night thinking about self pity. It&#8217;s like comfort food, or any other self destructive behavior that we as human beings just can&#8217;t get away from. Why are we such a self destructive race? The answer off the top of my head is that it&#8217;s self preservation in a shortsighted way [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>I&#8217;m sitting here, late at night thinking about self pity.  It&#8217;s like comfort food, or any other self destructive behavior that we as human beings just can&#8217;t get away from.  Why are we such a self destructive race?</p>
<p>The answer off the top of my head is that it&#8217;s self preservation in a shortsighted way (usually in circumstances where people feel helpless and think the comforting act will add more help than damage.  I mean what can one indulgence do, right?  Except that &#8220;one&#8221; in sentences like those really means endless &#8220;ones&#8221;).  Endorphines now to shield the immediate pain by adding more later.  I don&#8217;t know.</p>
<p>I do know that I hate self pity and I&#8217;m probably too critical of those that indulge in it.  I remember crying on the playground in fourth grade, feeling sorry for myself; when I got to looking around everyone had gone.  No one wanted to be around me that way.  It was the last time I cried in public.  It was the first time I started taking a firm hold on any moments where I wanted to feel self pity.</p>
<p>I realized that much of the time I felt self pity because it let me feel better about myself when I knew I wasn&#8217;t living up to my standards.  I think that one came while reading the Sword of Shannara (still a grade school experience-the book is built around the fascinating premise of a magical sword that has the power to make people face the truth about themselves, which is agonizing to everyone founded on lies).  I realized how hard it is to really face the truth about ourselves.</p>
<p>Since then I&#8217;ve made it a practice of trying to do that as often as possible, because I&#8217;ve realized that if I throw away the paralyzing feelings of guilt, all of a sudden all I have is powerful motivation to be better.  And it works better than almost anything.  That&#8217;s probably why it causes so much pain, because it has such great potential for growth when used correctly.  But used incorrectly and it will blight a person and forever stunt them. </p>
<div class="shr-publisher-378"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/humanz/self-pity/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get You Back Syndrome</title>
		<link>http://flightschool.acylt.com/humanz/get-you-back-syndrome/</link>
		<comments>http://flightschool.acylt.com/humanz/get-you-back-syndrome/#comments</comments>
		<pubDate>Fri, 09 Jul 2010 23:46:17 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[Humanz]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=296</guid>
		<description><![CDATA[Going along with the Reactive Disorder is the less serious but much more immature Get You Back Syndrome. How do you identify these people? Usually these are the type that are preoccupied with what other people are doing. They are critical, willing to pick apart anyone in any conversation, and have an insecure, faked confident [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>Going along with the Reactive Disorder is the less serious but much more immature Get You Back Syndrome.  How do you identify these people?  Usually these are the type that are preoccupied with what other people are doing.  They are critical, willing to pick apart anyone in any conversation, and have an insecure, faked confident disdain for everyone else.</p>
<p>What actions characterize these people?  They will usually get upset if asked to do something and reply &#8220;but you didn&#8217;t&#8230;&#8221;.  They also take offense easily and assume that anything you do is meant to slight them.</p>
<p>Their motivations are nearly always selfish, and they can&#8217;t fathom a world where people act unselfishly for others.  So any actions that might be unselfish they see as mind games, and attempts to convince them otherwise are seen as more evidence that there really is a mind game going on.</p>
<p>These people are warped by their own selfish, critical eye and are nearly impossible to deal with.</p>
<p>All of this stems from selfishness.  You see the purpose of much of their criticism is to level the playing field, because these people at heart feel outmatched.  The devilish irony in this disease is that all of their looking around assures that they will be outmatched.  Other people who don&#8217;t care what people think and who are just doing things to make themselves better will become better.  No brainer.</p>
<p>These people who stand around worrying about what other people think are always standing.</p>
<p>So their inaction digs their own grave.</p>
<p>Example situation-the classic one here is parent and child.  Parent works all day to support the child.  The child watches TV all day and eats the parents food.  The parent makes dinner for the child, the child eats it and then is upset when asked to help with the dishes.  &#8220;But you&#8217;re not doing them!&#8221; the child says in a whiny voice to the parent.  Maybe the parent isn&#8217;t doing them, but they have already proven that they will act very unselfishly for the relationship to work.  The child on the other hand is very willing to take as many handouts as he/she can, but very unwilling to do anything unselfish for the relationship.</p>
<p>Bottom line, selfish people in relationships suck.  Avoid them like the plague because their relationships never end well.  You either end the relationship or are stuck with a free-loader on your hands.</p>
<div class="shr-publisher-296"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/humanz/get-you-back-syndrome/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Measure a Man (or woman)</title>
		<link>http://flightschool.acylt.com/humanz/measure-a-man-or-woman/</link>
		<comments>http://flightschool.acylt.com/humanz/measure-a-man-or-woman/#comments</comments>
		<pubDate>Sun, 11 Jul 2010 22:54:18 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[Humanz]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=298</guid>
		<description><![CDATA[My modus operandi with people has always been based on the quote: &#8220;If you treat an individual as he is, he will stay as he is; but if you treat him as if he were what he ought to be and could be, he will become what he ought to be and could be” (Johann [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>My modus operandi with people has always been based on the quote: &#8220;If you treat an individual as he is, he will stay as he is; but if you treat him as if he were what he ought to be and could be, he will become what he ought to be and could be” (Johann Wolfgang von Goethe).  Couple that with the golden rule and I thought this was the best way to treat people.  It sets a high bar, but makes all kinds of room for mistakes as long as the person is making an effort to improve.  I like to call it laid back perfectionism.</p>
<p>The problem I&#8217;ve discovered is not a lot of people live up to what they ought to and should be.  They LOVE being seen in this positive light (in fact more often than not they present themselves this way), but for some reason they don&#8217;t embrace what it takes to be that way.  This isn&#8217;t because it&#8217;s difficult, which, if the only reason, would be admirable because honestly perfection is just unreasonable (it&#8217;s the goal because of the old adage, shoot for the stars land on the moon).  They don&#8217;t live up to who they could be because of an ignoble lack of effort.</p>
<p>The worst part part about it is they <em>try</em> to tell themselves their lack of performance is ok.  It&#8217;s not in the form of admitting, &#8220;I&#8217;m just totally ok with being mediocre&#8221;.  Most people can&#8217;t admit to themselves that&#8217;s what their lack of action means.  Admitting that would mean that they&#8217;re a lazy, smoke in mirrors representation of what they could be.  </p>
<p>No, instead it comes in the form of a long string of excuses, lies these people tell themselves to feel better about their half-assed lives.</p>
<p>&#8220;If it weren&#8217;t for _____, I would be something to behold.&#8221;</p>
<p>The truth is that they&#8217;d rather feel depressed about their lives than do something about it.  That&#8217;s what their actions scream anyway.  Why would anyone be ok with that?  </p>
<p>Because it&#8217;s easy.  </p>
<p>It&#8217;s easy and the self-spoken lies numb the burn of their insignificant, passable, second-rate-at-best efforts.</p>
<p>But that&#8217;s only half of the reason.  The other half is much more subtle, and I would argue much more&#8230; <em>persuasive</em> for keeping these people from action.</p>
<p>The second half is that, in this imaginary world where the lie that&#8217;s holding them back isn&#8217;t holding them back, they would have succeeded.  They don&#8217;t say, &#8220;If it weren&#8217;t for _____, I would have still failed for another reason&#8221;; they always say they would have succeeded.  The excuse gives them a reason not to try, because then they might actually fail.  And failing after trying for these people would mean that they really were failures after all, which is something they are only vaguely aware of in the foggy depths of this sad way of thinking.</p>
<p>At some level they are aware that they lie to themselves to protect themselves from failure, but they only see this fleeting thought in the form of blind anger, lashing out at people who try to help them succeed, because to hold the thought would be unbearable.  What they don&#8217;t understand is, if they tried they might actually have a chance at succeeding.  And even if they didn&#8217;t succeed, they would be able to look in the mirror with self respect.</p>
<p>The path that they choose is inevitable failure and shame.</p>
<p>The saddest part about the situation is that this fear of failure usually hampers the unusually capable.  These individuals really could be something special if they would make a pact with themselves to be able to look themselves in the eyes every night after a valiant days efforts.  Even if they didn&#8217;t reach what they hoped they&#8217;d be, they would still be great.  They would be infinitely better than they are with the lies and the excuses.  The lies and excuses leave only the shell of themselves, the insides ravaged by the disease.</p>
<p>And that&#8217;s why I&#8217;ve begun to wonder if this is the best way to treat people.  Giving everyone the benefit of the doubt, the benefit of what they could be, coupled with the fact that so many people don&#8217;t have the strength or capacity to let go of their pride and try, means that life will present a long string of stinging disappointments.  I see people like I see my favorite sports teams.  I&#8217;m elated when they perform, and heartbroken when they turn in half hearted efforts.</p>
<p>But I can&#8217;t stop treating people this way, because I wouldn&#8217;t accept it if someone stopped treating me this way.  And who knows, maybe persistance is enough to get people to change after long strings of failures.  And maybe when they see love in you, like the love of a die hard team fan still believing in a championship from a championship-less team, they will finally hang up their coat of lies and give life the effort it deserves.</p>
<div class="shr-publisher-298"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/humanz/measure-a-man-or-woman/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Auto Draft</title>
		<link>http://flightschool.acylt.com/the_novel/</link>
		<comments>http://flightschool.acylt.com/the_novel/#comments</comments>
		<pubDate>Wed, 30 Nov -0001 00:00:00 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
		
		<guid isPermaLink="false">http://flightschool.acylt.com/?p=380</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/the_novel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Beginning: Cloud Computing</title>
		<link>http://flightschool.acylt.com/futurizing/the-beginning-cloud-computing/</link>
		<comments>http://flightschool.acylt.com/futurizing/the-beginning-cloud-computing/#comments</comments>
		<pubDate>Fri, 29 Jan 2010 21:57:11 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[Futurizing]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=163</guid>
		<description><![CDATA[Well here it is. The future. Or at least the future the way I see it, dream it, or want to make it. Everything under the title &#8220;futurizing&#8221; will be my view of the future role computers will play with people and projects I&#8217;d like to take on to do my part in getting them [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p><a href="http://flightschool.acylt.com/wp-content/uploads/2010/01/cloud_computing.jpg"><img src="http://flightschool.acylt.com/wp-content/uploads/2010/01/cloud_computing-300x153.jpg" alt="" title="cloud_computing" width="300" height="153" class="alignleft size-medium wp-image-197" /></a>Well here it is.  The future.  Or at least the future the way I see it, dream it, or want to make it.  Everything under the title &#8220;futurizing&#8221; will be my view of the future role computers will play with people and projects I&#8217;d like to take on to do my part in getting them there.</p>
<p>So getting right into it, there&#8217;s one subject I&#8217;ve thought about for a long time.  I got my start with computers as a web developer.  This idea was already in my head before then but it wasn&#8217;t until then that I could finally articulate it.  Drum roll&#8230; I wanted to have all of my digital data accessible to me via any electronic device I was using at the time.</p>
<p>I know, I know, you&#8217;re probably thinking &#8220;here we go, Al Gore number two.  This guy thinks he invented the idea of cloud computing and is too stupid to realize that it&#8217;s already happening&#8221;.  You&#8217;re very smart, I am going to be talking about cloud computing.  But not the way that it&#8217;s being done now.</p>
<p>Now cloud computing means, for the most part that data is kept on <em>someone&#8217;s</em> cloud.  Whether it&#8217;s Google&#8217;s, Apple&#8217;s, etc etc, your data is on someone else&#8217;s machine (and controlled by them).  While Google&#8217;s been the biggest force pushing for this with their docs, the new Android phones, and the soon to be Chrome OS, Apple is following suit with Mobile Me and even recent acquisitions (<a href="http://www.techcrunch.com/2010/01/19/apples-secret-cloud-strategy-and-why-lala-is-critical/" target="_blank">Apple&#8217;s Secret Cloud Strategy</a>).  And for the sake of being unbiased Microsoft is jumping on board too with mobile versions of office etc.</p>
<p>I like that everything can synch up easily this way and I like that things are moving towards a more unified cross platform solution, but there are some things I&#8217;m not so hot on.</p>
<p>Call me old fashioned but I like owning my stuff.  I like having control over it and I don&#8217;t love the idea of depending on Google to keep its servers up and not poke around.  I&#8217;m not paranoid, I don&#8217;t mind them gathering data to make my searches better and what have you, but I do like having a measure of privacy.  So the version of cloud computing that I would like to have is more of a limited cloud.</p>
<p>What I would like to see is a cloud where we could set up our main computer as a server of sorts.  All of our data could be kept on it, so that&#8217;s where we&#8217;d need all of our memory.  Then we could access it from any other device that we wanted: laptops, phones, iPads, whatever.  But more than that, ideally I&#8217;d like all of my other machines that are connected to my main machine to feel like they&#8217;re just smaller versions.  So I&#8217;d still be using my computer, just a smaller version when all I have is my phone.  This is more than the unified feel of the iPhone, iPad and Mac (though I love the coherence between the operating systems).  While they are all versions of the same system there are still breaks between them.</p>
<p>I&#8217;m thinking more along the lines of browsers.  This is where I think the genius of Google&#8217;s Chrome OS lies.  What Chrome does is it makes the browser the main portal to computing and data.  It&#8217;s the obvious choice because the web needs to be standard in order to be viewed by all computers alike.  It is the natural glue that will make every operating system support it.  But if we could have our own private cloud which we could connect to with all of our devices, and browser technology went one step further letting it be full screen so it feels like a desktop, we could run most of our applications from our phones, computers, netbooks, and they&#8217;d all look the same.  Then only the memory intensive programs would be restricted to our main machines (programs like Photoshop or Pro Tools).  All of a sudden we&#8217;d have access to all of our information in a uniform way from anywhere.  Then we could stream our own music instead of subscribing to some streaming service.  Our phones would only need enough memory to cache enough data to keep load times to a minimum.</p>
<p>Browsers are already making leaps and bounds in Javascript performance (except for Internet Explorer that despicable excuse for a browser).  There are libraries now, like Dojo, which support very complex and rich browser applications.  I think this is a very possible future and that future is very near.  Google has almost done it.  But to have private clouds that don&#8217;t need someone to be computer savvy to setup.  That would be amazing.</p>
<div class="shr-publisher-163"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/futurizing/the-beginning-cloud-computing/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Cyber Terror</title>
		<link>http://flightschool.acylt.com/futurizing/cyber-terror/</link>
		<comments>http://flightschool.acylt.com/futurizing/cyber-terror/#comments</comments>
		<pubDate>Sat, 30 Jan 2010 07:05:04 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[Futurizing]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=172</guid>
		<description><![CDATA[Originally I posted this article about a week before the Google attacks; I feel like an oracle or something.  Since then there has been considerable press on cyber terror that rounds this article out nicely. I&#8217;m updating this accordingly. The FBI director has warned that there has been a shift towards cyber terror and that [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p><a href="http://flightschool.acylt.com/wp-content/uploads/2010/01/cyber.jpg"><img class="size-full wp-image-219 alignright" title="cyber" src="http://flightschool.acylt.com/wp-content/uploads/2010/01/cyber.jpg" alt="" width="306" height="320" /></a>Originally I posted this article about a week before the Google attacks; I feel like an oracle or something.  Since then there has been considerable press on cyber terror that rounds this article out nicely.  I&#8217;m updating this accordingly.</p>
<p>The FBI director has warned that there has been a shift towards cyber terror and that it has the same effect as a <a href="http://www.reuters.com/article/idUSN0410902320100305" target="_blank">&#8220;well placed bomb&#8221;</a>.  The interesting thing about this is the phrasing.  It&#8217;s moving away from characteristic, traditional ways of describing cyber terror (stolen credit card numbers and identities), towards actual terror fears.  The idea is that cyber terror could begin to have physically devastating effects.</p>
<p>Have you seen the iPhone commercial where the woman turns off her lights remotely?  As more and more goes on the grid, we become more and more susceptible to these smart bombs.  If an embassy had systems like this and hackers were able to gain control, they could gain access to the compound just as if they had a &#8220;well placed bomb&#8221;.</p>
<p>That&#8217;s all the future still, you say.  Not something to worry about now.  Actually it is something we need to worry about now and to not worry about it would be naive.  Maybe not with embassies, but our power plants are vulnerable and could be hit and that could be devastating.  During WWII plants were built in secure locations to make it extremely hard for enemies to knock them out (Geneva Steel is one example in the mountains of Utah).  Now, with our <a href="http://www.newscientist.com/article/mg19826566.200-power-plants-open-to-hacker-attack.html" target="_blank">power plants online</a>, they suddenly become accessible anywhere to someone with the right technology and resources.  The article I linked to was just one of many.</p>
<p>What brings this all together is the recent Google attacks.  To me it makes sense that the FBI would bring this up now because they realize the level government-pushed cyber terror could reach (China denies ties to the recent attacks, but Google has traced the source back to <a href="http://www.nytimes.com/2010/02/19/technology/19china.html" target="_blank">Chinese schools with strong military ties</a>) .  These hackers were able to get into Google and Intel among other tech companies.  If they could hack into companies that are constantly warding off attacks and filled top to bottom with software engineers, then what about a power plant which has software written for it and doesn&#8217;t have the top minds monitoring networks all of the time?</p>
<p>That&#8217;s a real threat, leaving cities without power or other utilities could have pretty devastating effects.  It&#8217;s also just one scenario where cyber terror becomes more physical and more terrifying.</p>
<p>As if it shouldn&#8217;t be terrifying enough already.  Stolen intelligence means terrorists learn to duplicate our technologies which include nuclear weapons.  This sort of attack doesn&#8217;t command the level of fear it probably should since the actual effects don&#8217;t manifest for quite a while.  If we got into a war with a technologically advanced country it could be surprising find that our unbreakable navajo code wasn&#8217;t so unbreakable for hackers.  Or that our missile tracking technology had already been countered by engineers who had the design to work from.</p>
<p>I&#8217;m not a doomsday guy and I&#8217;m not writing this to stir up fear.  Honestly this kind of stuff doesn&#8217;t really keep me up at night.  More than anything it was just a demonstration of the kinds of things that make me believe cyber terror will take the front seat as public fear no. 1.  As we rely more and more on machines we become more vulnerable, and strong security is usually something learned, not planned.</p>
<p>On an unrelated note, I think it would be exciting if computer language was taught alongside Spanish, French and other foreign languages.  It&#8217;s becoming increasingly more important as we tie ourselves more and more to computers, and being able to code makes things like starting a business many times easier than before.  Instead of opening an actual physical space and fighting for clients, people familiar with web development can create an online store and reach millions of customers with little or no overhead.  And maybe they could become heroes at their local power plants if they happened upon a security breach.</p>
<div class="shr-publisher-172"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/futurizing/cyber-terror/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why something better than Facebook could save the world</title>
		<link>http://flightschool.acylt.com/futurizing/social-networks/</link>
		<comments>http://flightschool.acylt.com/futurizing/social-networks/#comments</comments>
		<pubDate>Wed, 10 Feb 2010 05:18:35 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[Futurizing]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=174</guid>
		<description><![CDATA[This article is about why I think something better than Facebook could save the world. Save the world? you&#8217;re asking. What do you mean save the world? I mean it could be the key to making society work, and not just in the puppy dogs and fairy tale way. Everything from government to philanthropies to [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p><a href="http://flightschool.acylt.com/wp-content/uploads/2010/02/facebook-doyou.jpg"><img src="http://flightschool.acylt.com/wp-content/uploads/2010/02/facebook-doyou-300x223.jpg" alt="" title="facebook-doyou" width="300" height="223" class="alignleft size-medium wp-image-199" /></a>This article is about why I think something better than Facebook could save the world.  Save the world? you&#8217;re asking.  What do you mean save the world?  I mean it could be the key to making society work, and not just in the puppy dogs and fairy tale way.  Everything from government to philanthropies to getting through the current depression to rebuilding the American Dream.  You think that&#8217;s a bit ambitious?  We&#8217;ll see.</p>
<p>Social networks are on fire.  Investors still love them while they don&#8217;t seem to love much right now, people can&#8217;t seem to get enough, and even jobs are being centered around how well people use them.</p>
<p>They&#8217;re also relatively young.  That means they&#8217;re still maturing, as anyone with a Facebook account would be well aware of.  It seems that Facebook makes a significant change to the site every other month.  That in turn tells me that there&#8217;s still plenty of room for someone to do it better.</p>
<p>Google is banking on that (if you want a to know the way the &#8216;wind is blowing&#8217; in technology, watching what Google is interested in is a good idea).  After being snubbed by Facebook when they decided to do their searching through Bing (<a href="http://www.tgdaily.com/integration/48322-yet-another-bada-bing-microsoft-search-gets-facebook" target="_blank">More info here</a>), as well as possibly losing the default browser search position with Apple in a fascinating case where Apple and Microsoft may team up (<a target="_blank" href="http://isedb.com/20100120-2951.php">More on that here</a>), Google has to act fast or it will start losing ground.</p>
<p>Its solution is to make Gmail more &#8220;social&#8221;.  If they succeed, not only will they retain their coveted spot atop the search engine market (no one could touch their search accuracy with as much information as they would have on everyone), but they could also make significant inroads into the multi-billion valued social space.</p>
<p>The problem is they&#8217;ve tried this before and haven&#8217;t had much success (<a href="http://brainstormtech.blogs.fortune.cnn.com/2010/02/09/googles-poor-social-score/?section=magazines_fortune" target="_blank">More on their social troubles, Orkut for one, here</a>).  To me it&#8217;s interesting that as smart and forward looking a company as Google is having trouble here.  These are the guys that made search profitable.  They built Android preaching that handheld computing would become THE major player in human computer interaction (which is dead on, cars are being built that integrate with the iPhone, and the time isn&#8217;t far off when other devices will be controlled by them too.  Computer phones are in place to be the key, wireless technology that control all the others and are taking the mobile handset market by storm).</p>
<p>So what are they doing wrong?  Or more pointedly, what is the future of social networking?  Will it always be micro-blogging and wallposts?  Does Facebook have the model right or is there something missing there?</p>
<p>Clearly I think something is missing because the President on Twitter hasn&#8217;t done much to save the world.  Up until now the focus is on bringing people to their computers and then bringing people together.  </p>
<p>Basically we&#8217;ve made another way to keep in touch 24/7 and organize the process.  At first the big fear in the news was that this would keep people from socializing in real life and all of our interactions would be reduced to electronic ones.  Recent research suggests otherwise.  It also found that most social network interactions were with people that were already friends outside of Facebook.</p>
<p>In other words it&#8217;s a tool that reinforces our already made connections in a virtual world.  That&#8217;s great for helping us maintain structure and contact but that&#8217;s only part of what it means to be a social human being.  What would it be like if we made it the other way around?  What if instead of bringing us to computers, computers brought us to each other?  What if it made it easier for us to meet each other and create group interaction?  If it gave us tools to MEET people too, wouldn&#8217;t that be huge?</p>
<p>That&#8217;s not interesting, you say, there&#8217;s already a lot of this going on.  Sure, there are dating sites make bank giving people tests and then helping them arrange meetings, but the drawback is that people see them as dating sites.  Not much of a chance you&#8217;d go there to find people to play ball with.  So where do you go for that sort of thing?  The idea of meeting someone on Facebook and initiating a basketball game sounds like a terrible idea, at least to me.  It doesn&#8217;t provide a situation where something like that would be socially acceptable.</p>
<p>Yes, you say, but there are sites like <a href="http://meetup.com" target="_blank">Meetup.com</a> which are made specifically to get people together for activities and they&#8217;re gaining traction.  That&#8217;s true.  When I moved last fall I wanted to play football but hadn&#8217;t met anyone in my new neighborhood.  All I had to do was go online, find a group, and I was playing the next Sunday morning.  People expected strangers to show up because of the nature of the event so they were very friendly, and it was a great way to ease me in to my new location.  All in all it was a great experience, but it still felt fragmented.  Meetup was just one more site to keep up with (and who are we kidding, even though lots of us have lots of accounts we only really use the one or two we like best.  The others just fade into the background).</p>
<p>Now we&#8217;re finally getting to the point of this article.  If someone could bring together the maintenance of previously developed social networks and join them with the ability to easily meet people and encourage social events, they could have a seriously disruptive place in social networking.  If the focus was on the human interaction and not the virtual world in-between, I think people would adopt it.  Especially if it made the meeting fun.  If it created a scenario where not only was it <em>easy</em> to meet people, it was also <em>encouraged</em>, people would eat that up!  I mean how many updates have you seen on Facebook about mafia wars?  And that&#8217;s some trite game.  If people were getting points for hosting parties, events, games, etc. how many more of those would we see?</p>
<p>How does that save the world?  It doesn&#8217;t sound like rocket science right?  It doesn&#8217;t even sound much different than what we have.  </p>
<p>Here&#8217;s how.  I&#8217;m a philosopher first (that was my original degree), and I believe that there are few things that would be better for the human experience than creating an environment that fostered social connection.  Robert Putnam conducted a study with a few other professors on what made governments successful.  They had a fascinating case in Italy where the same structure was set up in different regions, but some were very successful while others failed.  Some societies thrived while others self destructed. </p>
<p>When it came down to it what was the main difference?  Was it that some regions had better leaders?  Less people disposed to crime?  Probably not (as a philosopher I can&#8217;t definitively say &#8216;no&#8217; no matter how much I want to).  It turned out that one of the best indicators for whether a region would be successful or not was how many back yard barbecues and book clubs there were (ie how socially connected the people were).  Communities that brought people together were the ones that cultivated successful societies (if you want to read more, the paper can be found <a href="http://www.jstor.org/pss/1956011" target="_blank">here</a>).</p>
<p>If a social network could be put together that created the game, making it so people were encouraged to meet and get together, I think we&#8217;d see significant effects in society as a whole.  For anyone that&#8217;s read the Tipping Point, this could be what&#8217;s needed for society to &#8216;tip&#8217; towards the kind of involvement that existed when America was founded.  We&#8217;ve used technology for so many advances up until this point, it&#8217;s about time we used it to augment something as powerful as social collaboration.  The possibilities are limitless (yes, that was supposed to sound inspiring).  I think it It would be a case where even Heidegger would have to agree that technology, for once, was helping people get in touch with what it means to be human instead of getting in the way.  </p>
<p>This was the foundational argument for the idea.  I&#8217;ll be posting more details in coming weeks to show how this could become a reality, and to show how I think it could create a whole new job market.</p>
<div class="shr-publisher-174"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/futurizing/social-networks/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Augmented Football</title>
		<link>http://flightschool.acylt.com/futurizing/augmented-football/</link>
		<comments>http://flightschool.acylt.com/futurizing/augmented-football/#comments</comments>
		<pubDate>Wed, 10 Feb 2010 19:32:31 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[Futurizing]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=186</guid>
		<description><![CDATA[The Super Bowl got me thinking again about how much I&#8217;d like to coach. This idea really came from spygate, when Bill Belichick had cameras spying on the other teams playcalling, but at that time I thought, what if you had the next best thing? What if you took every call a coach made in [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>The Super Bowl got me thinking again about how much I&#8217;d like to coach.  This idea really came from spygate, when Bill Belichick had cameras spying on the other teams playcalling, but at that time I thought, what if you had the next best thing?  What if you took every call a coach made in every situation and then did some data mining on it.  Wouldn&#8217;t it be easy to pick out trends and predict they&#8217;re playcalling?  And wouldn&#8217;t it make it easier to avoid being predictable yourself?</p>
<p>This has the added benefit of not being illegal.  It&#8217;d just be smart.</p>
<p>So I&#8217;ve had the longstanding goal of generating the data and then analyzing to be able to do that sort of thing.  Of course I&#8217;d have to pull some crazy sales job to get a coach to let me advise on something like that, but if it worked I&#8217;d be head coach in no time!  And that would be one more human computer interaction to add to the booth replays, helmet communications, etc.</p>
<div class="shr-publisher-186"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/futurizing/augmented-football/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting Psychology Up To Speed</title>
		<link>http://flightschool.acylt.com/futurizing/getting-psychology-up-to-speed/</link>
		<comments>http://flightschool.acylt.com/futurizing/getting-psychology-up-to-speed/#comments</comments>
		<pubDate>Wed, 17 Feb 2010 21:27:17 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[Futurizing]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=188</guid>
		<description><![CDATA[Psychology is behind. Philosophically and scientifically, but that&#8217;s not the point of this article. The point of this, is that they&#8217;re behind technologically and they could really use a push. Anyone that&#8217;s been to a mental health hospital quickly sees a trend. Most people have been there more than once. They were committed two years [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p><a href="http://flightschool.acylt.com/wp-content/uploads/2010/02/psych.jpg"><img class="alignleft size-medium wp-image-190" title="Psychology" src="http://flightschool.acylt.com/wp-content/uploads/2010/02/psych-234x300.jpg" alt="" width="234" height="300" /></a>Psychology is behind.  Philosophically and scientifically, but that&#8217;s not the point of this article.  The point of this, is that they&#8217;re behind technologically and they could really use a push.</p>
<p>Anyone that&#8217;s been to a mental health hospital quickly sees a trend.  Most people have been there more than once.  They were committed two years ago, one year ago, six months ago, etc, for the same problem.  Why do they keep going back?  It&#8217;s not that they like the hospital.</p>
<p>It&#8217;s because as soon as they get out of the hospital, or leave their therapists, they go back to life as usual.  They go back to their friends.  If you&#8217;re a recovering heroin addict and you go back to hanging out with heroin addicts, chances are you&#8217;ll relapse.  If you&#8217;ve come out of a deep depression but go back to people who continually tell you how pathetic you are, chances are you&#8217;ll drop again.</p>
<p>What they need is a way to find new, healthy, social connections.  They need something like the &#8216;better than Facebook&#8217; that could save the world I talked about before.  The good news is this technology would not be difficult to create.</p>
<p>All it would take is a social networking site where people began by filling out in-depth personality profiles.  This wouldn&#8217;t be hard to get, people fill those kinds of profiles out all the time because they love to see what the test has to say about them.  If you made sure they had their friends do it too, and had their friends also fill out the profile, you could begin to find out what kind of people they get along with.  I don&#8217;t think it&#8217;s too farfetched to think that you could find an algorithm that could predict friendships.</p>
<p>The network could start with volunteers.  They would make sure to include their interests or hobbies.  Maybe it&#8217;s having bbq&#8217;s, going rock climbing, fishing or seeing plays.  These volunteers would know that they were volunteering to be the gateway for people who have struggled to re-enter normal life.</p>
<p>As a biproduct the volunteers would get their friends on it too (to get the data necessary to predict friendships).  All of a sudden there would be a strong network of healthy people with designated entry points.  From there it would just be a matter of matching people who are trying to change their lives with the right entry point.</p>
<p>All of a sudden these people would have people they&#8217;re likely to make friends with, who are healthy, and activities that would also be healthy.  Instead of getting out of the Hospital to go right back into their old lives, they&#8217;d have a jump start to creating healthy habits.  The gateway people probably wouldn&#8217;t even have to try that hard to integrate their assigned friends.</p>
<p>Technology could bridge the gap between the walls we all put up that make making new friends so difficult in the first place.  This would work not because it would help those patients, but because as soon as healthy people started seeing how easy it is to make friends through recommendations they would be all about it.  The missing factor from current social networks would be filled here.</p>
<div class="shr-publisher-188"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/futurizing/getting-psychology-up-to-speed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GeoTunes</title>
		<link>http://flightschool.acylt.com/futurizing/geotunes/</link>
		<comments>http://flightschool.acylt.com/futurizing/geotunes/#comments</comments>
		<pubDate>Wed, 03 Mar 2010 01:59:48 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[Futurizing]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=205</guid>
		<description><![CDATA[Satellite radio, normal radio, internet radio, iPod, location aware phones, playlists, social media, and adventure. What do all these things have in common? If you answered anything other than geoTunes you might be right but you didn&#8217;t read my mind. If you answered geoTunes I&#8217;m sure you got it from the title so again, you [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p><a href="http://flightschool.acylt.com/wp-content/uploads/2010/03/musicman_2.jpg"><img class="size-medium wp-image-207 alignright" title="musicman_2" src="http://flightschool.acylt.com/wp-content/uploads/2010/03/musicman_2-300x86.jpg" alt="" width="300" height="86" /></a>Satellite radio, normal radio, internet radio, iPod, location aware phones, playlists, social media, and adventure.  What do all these things have in common?  If you answered anything other than geoTunes you might be right but you didn&#8217;t read my mind.  If you answered geoTunes I&#8217;m sure you got it from the title so again, you didn&#8217;t read my mind.</p>
<p>Imagine not listening to what labels are pushing but actually being able to hear the pulse of the people all around.  Imagine going through cities and hearing music recommended and voted on by people.  Imagine being able to share thoughts about certain landmarks that anyone could listen to, just by standing where you did.  That&#8217;s the idea behind geoTunes.  It&#8217;s being able to paint the world around you with music and sound.  It&#8217;s being able to walk into a library and hear study music; to walk into a gym and hear workout music.</p>
<p>As people use the geoTunes software the songs they listen to will be tagged to the location they are.  That way when you&#8217;re listening to your favorite music, it&#8217;s learning where you listen to which kinds.  If you decide not to listen to your playlists one day you could then switch over to the geoTune generated list.  Now you&#8217;ll be able to hear what other people are listening to around you.</p>
<p>A possible problem with that is that there are lots of people with lots of different tastes all in the same vicinity.  Mixing them all together would create a cacophony of sound and that doesn&#8217;t sound like something that would attract the user base we&#8217;re looking for.  Instead as the music was tagged it would be sorted based on genre.  That way each location would have &#8216;stations&#8217;.</p>
<p>Each location would have a primary station.  That would be the most popular genre for the area.  If you wanted to understand your city better, this would be the one to listen to.  Moving from old neighborhoods to young neighborhoods, from the suburbs to the city would give a fascinating blend of the areas subculture.</p>
<p>Likewise some people just like music that sucks.  You wouldn&#8217;t want that to come up all of the time in general listening.  So each song would give the user the ability to like or dislike it, and the playlist generating algorithm would serve up higher ranked songs more often while not letting them completely drown out the less known/understood songs (like what happens on radio stations these days).  That algorithm would factor in the number of people tagging specific songs as well as personal preferences which would be kept out of the global listening sphere.</p>
<p>If you like a song enough you have the ability to save it to your personal playlist.  That way you can listen to it again even if you&#8217;re not in the location where you first heard it.  That allows you to aggregate songs you like and &#8216;take them with you&#8217;.</p>
<p>That&#8217;s how music would be separated and easily managed and listened to.  It would also take care of song ranking.  I believe it would also make music listening viral.  Local musicians would create a fan base which would make their music rise to the top for their area.  All of a sudden they would have a cities worth of listeners who would start letting people know about the music.  Other people coming in on business, etc, would hear the local songs, save them to their playlists and take them home to start the sound there.  Suddenly musicians don&#8217;t need big labels to keep them going.  It takes the internet music revolution to a whole new level.</p>
<p>Another important part of this would be geotagging sound.  Say you&#8217;re visiting Egypt and you&#8217;re walking through the temple at Luxor.  You want to know what a guided tour but you don&#8217;t really trust the onslaught of locals.  All you have to do is turn on the sound station for this area and you start hearing what people have recorded in the different parts of the temple.  Say professors have visited this site, recorded their insights and geotagged them.  Other users found them interesting and voted them up.  The nonsense tagged there was voted down and isn&#8217;t played anymore.  You get a nice, location guided sound tour and you don&#8217;t even need a guide.</p>
<p>The same goes for cities, war sites, etc.  Sound could be played over the top of music, so you could have both on if you want to discover the area around you.  That way not only do you get the music, you get users input overlayed on top of that whenever you happen upon such a location.</p>
<p>That takes me to the &#8216;how this would be funded&#8217; part.  Businesses would have a new way to lure people in if they could do location based advertising.  Say you&#8217;re by a McDonalds.  An advertisement would come up to come down the street and get a snack.  Local companies could do advertising too, and since it would be very specific it wouldn&#8217;t have to cost much.  At the same time because this kind of advertising would be all over and because it would be highly targeted it should convert more and should bring in enough different buyers to support a music listening network.  The advertising would only come up when traveling from place to place, and an algorithm would make sure that they weren&#8217;t served up too frequently as to become disruptive.</p>
<p>This is some of my vision for what geoTunes is going to look like.  I think it&#8217;s an exciting idea.</p>
<div class="shr-publisher-205"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/futurizing/geotunes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What Good is Technology Anyway</title>
		<link>http://flightschool.acylt.com/futurizing/what-good-is-technology-anyway/</link>
		<comments>http://flightschool.acylt.com/futurizing/what-good-is-technology-anyway/#comments</comments>
		<pubDate>Thu, 04 Mar 2010 07:30:47 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[Futurizing]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=211</guid>
		<description><![CDATA[Growing up my dad used to tell me how lucky I was not to be growing up in the dark ages (this was when I used every stick I found as a sword).  He, like most people, talked about how great technology is in its own terms.  The iPhone is amazing because it lets us [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p><a href="http://flightschool.acylt.com/wp-content/uploads/2010/03/tech.jpg"><img class="alignleft size-medium wp-image-215" title="tech" src="http://flightschool.acylt.com/wp-content/uploads/2010/03/tech-300x199.jpg" alt="" width="300" height="199" /></a>Growing up my dad used to tell me how lucky I was not to be growing up in the dark ages (this was when I used every stick I found as a sword).  He, like most people, talked about how great technology is in its own terms.  The iPhone is amazing because it lets us interact in ways we&#8217;ve never been able to.  The internet is incredible because we have more information available to us than ever before.  Fridges change the way we live because we can store perishable food.  Cars let us go farther and faster than we&#8217;ve ever been able to before.  Yes, technology in its own terms is incredible.  And I, like anyone, get caught up in the fray.  In that excitement it seems almost ridiculous to ask, but is technology really good?  That&#8217;s a given, right?  The only people that wouldn&#8217;t think so would be disconnected philosophers completely detached from reality, <em>right</em>?</p>
<p>This is where I say no, I don&#8217;t think it&#8217;s a given that technology is good and I don&#8217;t think that&#8217;s a far-fetched question to ask.  I could site some philosophers (Heidegger for one) that said the same thing but then we&#8217;d be right back to the -detached from reality- thing.  Instead I&#8217;ll go with a more practical approach.  Some people just live in a way that gives them meaning and happiness but that&#8217;s not everyone.  If that isn&#8217;t me, I would like to be able to figure out why and fix it, wouldn&#8217;t you?  In order to fix it I&#8217;d have to ask the right question, and I&#8217;m proposing that question is: &#8216;what makes a good life as a human being?&#8217;  To answer that question, technology has to be considered.</p>
<p>Technology permeates so much of life as a human being these days that it becomes important to know if it&#8217;s possibly getting in the way of the good life.  If it is, then it would be important to know what parts of it get in the way and what parts of it possibly enhance our ability to live the good life.  That way we could maximize the positive and minimize the negative.</p>
<p>We already know that technology isn&#8217;t the great answer to the good life because people had good lives long before technology.  In fact much of the research I&#8217;ve looked at makes it seem like people that are worried about where the next meal is coming from tend to be happier just from the mere fact that happiness doesn&#8217;t cross their mind, they&#8217;re too busy with the task at hand.  If that doesn&#8217;t qualify for happy or meaningful in your book then I have another example.</p>
<p>I&#8217;m attracted to third world countries maybe partly because of the happy, meaningful lives I&#8217;ve come across in them.  I spent two years in Brazil and Argentina, a month in Guatemala and a couple in Egypt and surrounding countries.  I&#8217;ve been to Russia, Europe, and everywhere I go I try to live like the locals.  I take local transportation, I eat where the locals eat (which often ends in terrible diarrhea, I&#8217;m sure you wanted to know that), I sleep where the locals sleep.  On arriving in a new city one of my favorite things to do is find a local family that could use money and offer to help in return for a room.  I&#8217;ve seen a lot of the culture that way, and like I said, the third world technology deprived countries have lots of people who seem very happy and fulfilled to me.</p>
<p>Why are they happy and fulfilled?  My answer is that they have meaningful, healthy relationships.  It has lead me to believe that fundamentally human beings are social creatures, and in order to have happy and fulfilled lives, we need to embrace that.  Part of what&#8217;s sad to me about technology is that we forget our place in the social web and try to solve problems through chemicals or otherwise that used to be solved by falling back on these strong social ties.</p>
<p>Technology has the tendency to get in the way of our relationships.  We&#8217;re immediately accessible as a resource to so many people that we would never want to see after work.  Because of that we give up our time and attention to those people more and more and we nurture our meaningful relationships less and less.  While it was easy for our evolving ancestors to create relationships with people they hunted with (co-workers) and have those relationships become multi dimensional, now it becomes more difficult.  We have way too many surface relationships pulling at us.</p>
<p>For fear of people walking away from this thinking I&#8217;m anti technology, I&#8217;d like to be clear at this point and say that I&#8217;m not.  I&#8217;m very pro technology.  But in order to understand what makes me pro, I think it&#8217;s important to understand what makes me against it.  That way everything I say from here on can be framed in the context of, if it&#8217;s getting in the way of meaningful relationships and life as a social being then it&#8217;s bad.</p>
<p>So what is there to be pro about?  We have ways to create relationships and develop them like never before.  Improved communication and travel insures that.  Technology enables us to do work in new ways that also enable relationships.  As a web developer I have time to spend with people I care about because as long as I get the project done on time, it doesn&#8217;t matter when I do it.  Likewise I have freedom to travel and learn about the global human family because of the same things.  Even though that doesn&#8217;t qualify as a meaningful relationship in exactly the same terms I framed earlier I think that it does create a different sort of relationship that is meaningful and lasting with humanity.  My travels were some of the happiest times of my life.</p>
<p>Looking at technology from this perspective opens up a whole new way of creating technology.  If we looked to enhance our happiness and meaning it would give direction to technology that I don&#8217;t think exists right now.  And while we can all enjoy the benefits of technology by having self control and learning how to filter out the happiness/meaning depriving noise that we&#8217;re bombarded with everyday, it would be nice if it wasn&#8217;t so hard.  Maybe that would reduce the number of Americans on anti-depressants too.</p>
<div class="shr-publisher-211"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/futurizing/what-good-is-technology-anyway/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Rise of the Social-Geography</title>
		<link>http://flightschool.acylt.com/futurizing/the-rise-of-the-social/</link>
		<comments>http://flightschool.acylt.com/futurizing/the-rise-of-the-social/#comments</comments>
		<pubDate>Thu, 25 Mar 2010 23:05:32 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[Futurizing]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=222</guid>
		<description><![CDATA[Social gaming has taken the market by storm.  All of a sudden there are games making millions of dollars that hardly cost anything to create.  Academics are looking at this closely, working on predicting what is next.  Below is a video talking about that very idea, so take a look and then you&#8217;ll have a [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>Social gaming has taken the market by storm.  All of a sudden there are games making millions of dollars that hardly cost anything to create.  Academics are looking at this closely, working on predicting what is next.  Below is a video talking about that very idea, so take a look and then you&#8217;ll have a context for what I say after it.</p>
<p><object classId="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="480" height="418" id="VideoPlayerLg44277"><param name="movie" value="http://g4tv.com/lv3/44277" /><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="true" /><embed src="http://g4tv.com/lv3/44277" type="application/x-shockwave-flash" name="VideoPlayer" width="480" height="382" allowScriptAccess="always" allowFullScreen="true" /></object>
<div style="margin:0;text-align:center;width:480px;font-family:Arial,sans-serif;font-size:12px;color:#FF9B00;"><a href="http://g4tv.com/games/xbox-360/index" style="color:#FF9B00;" target="_blank">Xbox 360 Games</a> &#8211; <a href="http://g4tv.com/e32010" style="color:#FF9B00;" target="_blank">E3 2010</a> &#8211; <a href="http://g4tv.com/games/ps3/61899/guitar-hero-5/index" style="color:#FF9B00;" target="_blank">Guitar Hero 5</a></div>
<p>Philosophers make a big deal of people being able to connect with their world.  Psychologists make a big deal of being able to connect with humanity.  I think anything that enables those two goals while helping people to think about things in a positive or novel light is bound to be successful.</p>
<p>That&#8217;s why I think location based gaming and technology is going to be huge.  Anyone paying any attention to tech news will have seen countless <a href="http://latimesblogs.latimes.com/technology/2010/03/foursquare-sxsw.html" target="_blank">articles on FourSquare, MyTown, GoWalla, and others (sorry others)</a> and the buzz they made at SXSW (for all non-nerd readers that&#8217;s a tech conference in Austin, Texas).  People are jumping on the bandwagon and this is only the beginning.</p>
<p>Why?  Because they have a new way of connecting with people.  It happens as they connect to their world, and they&#8217;re seeing discovery in a new light.  That&#8217;s why this is only the first wave.  It&#8217;s why <a href="http://www.gisdevelopment.net/application/miscellaneous/Geotagging-Geoblogging-Geo-broadacsting-Dynamic-Applications-of-Neogeography.htm" target="_blank">neogeography</a> is here to stay.</p>
<p>Whoever figures out the best way to harness this technology in the ways I mentioned above will have lots of success.  That is why I&#8217;m currently working on GeoTunes-The Underground.</p>
<p>This technology will allow fans and bands to interact in an entirely new way.  Instead of being pushed music by labels and radio stations, users will be able to share it in communities which will create a viral phenomena.  No more sitting at computers to find new music, it will be pushed to mobile devices (which have now reached <a href="http://www.themoneytimes.com/featured/20100325/91-americans-use-cell-phones-ctia-reveals-id-10105276.html" target="_blank">over 90% market penetration</a>.  Yes, Google was right to put their money on mobile computing).  Now it will have the chance to spread across the nation on its own, and it will upend the music industry as we know it.</p>
<p>These ideas will reshape experience with technology.  Originally scholars saw the internet as the great leveler.  The disruptor of geography.  Now all of a sudden there is a new movement towards enhanced geography.  Neogeography.  And it&#8217;ll be huge.</p>
<div class="shr-publisher-222"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/futurizing/the-rise-of-the-social/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Aardvark is Geniousness</title>
		<link>http://flightschool.acylt.com/futurizing/aardvark-is-geniousness/</link>
		<comments>http://flightschool.acylt.com/futurizing/aardvark-is-geniousness/#comments</comments>
		<pubDate>Fri, 09 Apr 2010 06:52:40 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[Futurizing]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=228</guid>
		<description><![CDATA[Aardvark is a fifty million dollar idea, at least that&#8217;s what Google thought when they bought the company. It takes search to a new level, incorporating social networks to find answers from people instead of document vectors and page ranks finding information from machines. It moves search from just library look-up to a village-style, ask [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p><a href="http://flightschool.acylt.com/wp-content/uploads/2010/04/Aardvark-logo-JPG.jpg"><img src="http://flightschool.acylt.com/wp-content/uploads/2010/04/Aardvark-logo-JPG-300x175.jpg" alt="" title="Aardvark logo JPG" width="300" height="175" class="alignright size-medium wp-image-229" /></a>Aardvark is a fifty million dollar idea, at least that&#8217;s what Google thought when they bought the company.  It takes search to a new level, incorporating social networks to find answers from people instead of document vectors and page ranks finding information from machines.  It moves search from just library look-up to a village-style, ask your neighbor, experience.  This in turn allows people to relate through computers in an entirely new way, and it&#8217;s able to do that because it has applied data mining in a new, novel way.</p>
<p>Data mining has been used with social networks before.  A lot of research centers around the social graphs of Facebook and other networks, but as far as I know, none of the previous research has done what Aardvark does.</p>
<p>First of all Aardvark uses information it gathers about people to classify them as data generators.  That may not seem profound at first blush but it is subtly brilliant!  This is a successful implementation of the idea that behavior can be predicted and harnessed.</p>
<p>It is done by first collecting data about users.  By asking which topics they are experts in and then asking their friends to confirm, a lot of great data is generated.  Combine that with crawls of Facebook, blogs they write, and other online content and you have a solid base of raw data describing a user.  However in this raw form it&#8217;s not very useful; it needs to be processed.</p>
<p>Using mathematical voodoo, the data is arranged into topics.  Each user gets topics associated with them that are either directly, or inderectly derived from the raw data.  This data is then used as a training set for predicting what information a user can generate.</p>
<p>Bayes theorem and probability theory drive these predictions; each user has probabilities assigned for how well suited they are to respond to certain topics.  Once they are categorized it&#8217;s just a matter of searching when a query comes in to find the best set of experts on a subject.</p>
<p>Other elements combine with this to optimize response (such as matching people based on how well they know each other and how similar they are).  Together it combines to an experience that for many people is exciting and very useful, especially since questions can be asked (in natural language) for things like advice, that is more difficult to get from Google.</p>
<p>Another interesting, if not quite so ground-breaking, idea in this paper is query classification.  When a query comes, decision trees are used to decide whether the information is obscene, or spam, or a waste of time for people to answer (yes, some people ask things like &#8220;what time is it?&#8221;).  If it makes it through those filters, the question is classified as location specific or not and then is sent out to users based on how well they match.</p>
<p>This is a key element of the social search because if the quality of questions people are asked to answer is poor, they probably won&#8217;t continue using the service and they won&#8217;t recommend it to their friends.  Aardvark&#8217;s effectiveness centers around having a user base large enough to answer queries, so it is imperative to keep the query quality high.</p>
<p>Aardvark also uses association rules to figure out when users are more likely to answer queries.  It does this based on when the user passes on a question, when they&#8217;re not online or don&#8217;t answer for some other reason.  The more the user participates in the service, the better Aardvark gets at predicting the best time to ask as well as acceptable frequency of questions.</p>
<p>The novel applications of data mining are what have made it explode in popularity.  It will be fascinating to see how Google integrates it with its search in its growing war with Bing and now Apple in advertising and search.</p>
<p>As far as improving Aardvark goes, in its current form it is a great product.  It is easy to use and very effective at what it does.  It would be interesting to see it grow into something more.</p>
<p>It is surprising that Facebook hasn&#8217;t used any similar ideas to start generating profits to match its popularity.  It sits on the richest data set available, it has no excuse not to be successful.</p>
<p>One possible application of these ideas in social computing is to mine the data to find people who are the hubs of their social circles.  By identifying commonalities between them and all of their friends, individuals could be picked out who would be optimal targets for advertisers.  They would be the most probable individuals to convince their friends to buy something, and advertisers would pay a lot to get that information.</p>
<p>Of course allowing advertisers to contact these people would have to be handled correctly, which is not in the scope of this paper, but that is one application of similar ideas here that would could be extremely lucrative.</p>
<p>Another application of these algorithms could be similar to that of dating sites.  A central part of optimizing query response is making sure that the people who will get in touch have similar social patterns.  If this was expanded into a social networking site, it would facilitate communication and interaction in an entirely new way.  Instead of the static, Facebook-like recommendations of friends suddenly people would have ways to &#8216;break the ice&#8217; and create new friendships.</p>
<p>All of these ideas are central to the revolution that is occurring online as people learn to live in this new age of technology.  The technological revolution is still so recent in terms of human history that I don&#8217;t think many people see the scope of the change we will undergo as a species.  It is breathtaking to consider!</p>
<div class="shr-publisher-228"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/futurizing/aardvark-is-geniousness/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Lazy Spider</title>
		<link>http://flightschool.acylt.com/futurizing/the-lazy-spider/</link>
		<comments>http://flightschool.acylt.com/futurizing/the-lazy-spider/#comments</comments>
		<pubDate>Wed, 12 May 2010 21:19:44 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[Futurizing]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=233</guid>
		<description><![CDATA[Facebook has begun to spider out from its main function as a social network to include a social organization of the entire web. If users visit a site while logged in to their facebook profiles, they can &#8216;like&#8217; the site and see how many of their friends liked it too. This level of feedback on [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p><a href="http://flightschool.acylt.com/wp-content/uploads/2010/05/spider_facebook.jpg"><img src="http://flightschool.acylt.com/wp-content/uploads/2010/05/spider_facebook.jpg" alt="" title="spider_facebook" width="220" height="160" class="alignleft size-full wp-image-236" /></a>Facebook has begun to spider out from its main function as a <a href="http://knowledge.wharton.upenn.edu/article.cfm?articleid=2482" target="_blank">social network to include a social organization of the entire web</a>.  If users visit a site while logged in to their facebook profiles, they can &#8216;like&#8217; the site and see how many of their friends liked it too.</p>
<p>This level of feedback on webpages is unprecedented and unparalleled.  Facebook has already surpassed Google&#8217;s usage numbers in sheer quantity, but now they are gathering information that could allow them to be major competitors in search.  By indexing these sites and their likes, they have a new way of creating pagerank that Google doesn&#8217;t have access to.  They also have much more information to what people like, which should allow them to better target advertisements.</p>
<p>It&#8217;s not unreasonable to consider that in the near future sites could be allowed to be aware of which users are visiting their site in order to better target content for those users.  This would create an ultra-personalized web, but would create many privacy issues that could cause significant problems.</p>
<p>Already people are complaining about privacy issues with the like buttons alone, so only time will tell how far Facebook can take this.  Given their <a href="http://knowledge.wharton.upenn.edu/article.cfm?articleid=2482" target="_blank"> history with privacy issues</a> they will probably push the limit as far as they can.</p>
<p>Privacy aside, this is a fascinating new way of organizing the web.  It is essentially a social indexing tool, as opposed to IR style indexing that Google employs.  With Facebook&#8217;s record of innovation it is exciting to see where they will take this.</p>
<p>The web isn&#8217;t the only thing they are making more social.  They are also expanding their reach to music, through their <a href="http://blog.pandora.com/pandora/archives/2007/08/pandora_now_on.html" target="_blank">partnership with Pandora</a>.  People who allow Facebook to integrate with Pandora can see music their friends are listening to.  This lets people to spread music in a radio social way which hasn&#8217;t been available until now.</p>
<p>What areas will Facebook spread to next?  The social paradigm for content consumption is powerful and I believe it is the future of the web.  Whether Facebook drives that future or some other company does depends on how well they apply the paradigm.</p>
<div class="shr-publisher-233"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/futurizing/the-lazy-spider/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iPhone Prototype and What It Means</title>
		<link>http://flightschool.acylt.com/futurizing/iphone-prototype-and-what-it-means/</link>
		<comments>http://flightschool.acylt.com/futurizing/iphone-prototype-and-what-it-means/#comments</comments>
		<pubDate>Wed, 12 May 2010 21:51:21 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[Futurizing]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=240</guid>
		<description><![CDATA[Until now all the hype about the new iPhone has been over how it has been purchased illegally and leaked. No one has talked about one part of it which will revolutionize the phone industry again. When Gizmodo reviewed the new iPhone, they mentioned something new that has never been on successful phones before. A [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>Until now all the hype about the new iPhone has been over how it has been <a href="http://www.newuniversity.org/2010/05/opinion/the-iphone-leak-meets-free-speech/" target="_blank">purchased illegally</a> and leaked.  No one has talked about one part of it which will revolutionize the phone industry <em>again</em>.</p>
<p>When <a href="http://gizmodo.com/5520164/this-is-apples-next-iphone" target="_blank">Gizmodo reviewed the new iPhone</a>, they mentioned something new that has never been on successful phones before.  A front facing camera.  Why do I think this is such a big deal?  Because every sci-fi movie I&#8217;ve watched since I was a kid, people have had video phones.  Skype and other technologies have been hugely successful with video chats, but that always has required computers in the past.</p>
<p>Now we finally have phones which support internet connections AND have front facing cameras.  Skype already has an app for the iPhone.  Creating a video call app would be child&#8217;s play.  Now they have the hardware to support it.  I believe that when the new iPhone goes on sale and proceeds to sell at the same blistering pace its predecessors have, people will begin making video phone calls far more than they do now.</p>
<p>Android will do what it does best, follow suit.  New handsets with front facing cameras will become commonplace, and video calling will rapidly become ubiquitous.  I would be very surprised if Google Voice and other internet implementations of phone numbers and connections wouldn&#8217;t start supporting audio calls, text messages, AND video calls.</p>
<p>With phone numbers finally supporting video calls, the transformation that has begun with Skype and webcams will be complete.  The communications industry is in for some major changes in the near future.  They&#8217;d better start getting serous about upping their support for internet connections because video calls could run heavy.</p>
<div class="shr-publisher-240"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/futurizing/iphone-prototype-and-what-it-means/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Converging Technology</title>
		<link>http://flightschool.acylt.com/futurizing/converging-technology/</link>
		<comments>http://flightschool.acylt.com/futurizing/converging-technology/#comments</comments>
		<pubDate>Wed, 12 May 2010 22:09:44 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[Futurizing]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=242</guid>
		<description><![CDATA[As smartphones become smarter, they are emerging more and more as the hub for computer interactions. Google got into smartphones in the first place because they recognized the central role it would play in the near future. The beginning of that is showing with cars and their ability to sync with phones. Google is currently [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>As smartphones become smarter, they are emerging more and more as the hub for computer interactions.  Google got into smartphones in the first place because they recognized the central role it would play in the near future.  The beginning of that is showing with cars and their ability to sync with phones.</p>
<p>Google is currently in talks with GM to get the android operating systems <a href="http://www.tgdaily.com/hardware-features/49743-report-gm-eyes-android-for-in-vehicle-telematics" target="_blank">installed in vehicles</a>.  This would allow users to start their cars remotely, unlock them via phone, and would give strong GPS navigation.  This is only the beginning.  The first cars to be able to output performance stats to graphical displays on smarthphones, such as fuel levels and oil cleanliness etc, will be hugely successful.</p>
<p>Apple, Google and Microsoft&#8217;s most recent phone software has been created with desktop variants.  As these platforms mature the mobile platform will act as the portable computer, leaving heavy computing to home computers, navigational computing to car computers, home systems computing to home sensory computers, and work computing to the computer at work.  Interfacing with each, it will specialize in information and applications people want with them all the time.  Soon smartphones will become more important than the home computer.</p>
<div class="shr-publisher-242"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/futurizing/converging-technology/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introduction</title>
		<link>http://flightschool.acylt.com/web_101/introduction/</link>
		<comments>http://flightschool.acylt.com/web_101/introduction/#comments</comments>
		<pubDate>Sun, 29 Nov 2009 20:51:39 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[Web101]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=3</guid>
		<description><![CDATA[There are great tutorials for creating web pages all over the web, so why would you do this one?  I mean it&#8217;s longer than most, and I don&#8217;t even really get into design details in photoshop very much.  Sounds bad right?  Maybe if this weren&#8217;t awesome!  Yes, I&#8217;m presumptuously slapping awesome on this like a [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>There are great tutorials for creating web pages all over the web, so why would you do this one?  I mean it&#8217;s longer than most, and I don&#8217;t even really get into design details in photoshop very much.  Sounds bad right?  Maybe if this weren&#8217;t awesome!  Yes, I&#8217;m presumptuously slapping awesome on this like a badge.  Why, you may ask.  Because this document outlines best practices for creating web pages in Photoshop so they can then be cut up and coded for the web and it follows the latest trends in web design.  Put this together with visual tutorials and you&#8217;ll be very educated in current web design.</p>
<h2>Who is this for?</h2>
<p>Aspiring designers who want to design and code their website.  This will take you through from start to getting ready for publishing online; the next will step you through the actual coding and publishing.</p>
<h2>How?</h2>
<p>We&#8217;ll design a portfolio and similar sites.  The principles work for everything but I&#8217;m targetting this specific group (so hopefully you have some work you&#8217;d like to put up online).</p>
<h2>First Things First</h2>
<p>We start with the Home Page.  I&#8217;m sure you&#8217;ve noticed good websites have the same header and footer for all their pages (the same looking menu that stays in the same place the whole time, etc).  That gives the site a unified feel and makes it easier for you during the design process because you can keep using the same header and footer for all the pages.</p>
<p>It also makes the Home Page design the most important part of designing a website because that&#8217;s when you come up with the feel of the entire thing.  So you&#8217;ll spend more time on the Home Page than you will on the subpages.</p>
<p>So below first you&#8217;ll find a quick run through of good design principles for web pages.  Then you&#8217;ll find a section on the technical details for designing your page.  That includes how big it should be, what fonts to use, etc etc.  The last section in this chapter has step by step instructions for setting up the Photoshop document so you can get designing.</p>
<div class="shr-publisher-3"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/web_101/introduction/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Good Web Design Principles</title>
		<link>http://flightschool.acylt.com/web_101/good-web-design-principles/</link>
		<comments>http://flightschool.acylt.com/web_101/good-web-design-principles/#comments</comments>
		<pubDate>Sun, 29 Nov 2009 20:59:09 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[Web101]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=5</guid>
		<description><![CDATA[Titles: I&#8217;ve put this first because it&#8217;s probably the most important. People don&#8217;t want to have to sort through all the information on your website. They want to know what they&#8217;ll be reading about before they read it. That means that you should have a very strong title structure so people can scan to find [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><h2>Titles:</h2>
<p>I&#8217;ve put this first because it&#8217;s probably the most important.  People don&#8217;t want to have to sort through all the information on your website.  They want to know what they&#8217;ll be reading about before they read it.  That means that you should have a very strong title structure so people can scan to find what they&#8217;re looking for.</p>
<p>If you have a paragraph about yourself on your About Me page, give it a title like &#8216;A Little About Myself&#8217;.  If you have a welcome paragraph on your home page, title it something like &#8216;Welcome to My Site&#8217; (but more interesting of course).  I&#8217;m sure you&#8217;re getting the picture, but if not I&#8217;ll revisit this later.</p>
<h2>Color Scheme:</h2>
<p>Color scheme is key to coming up with a good website.  The trend right now is to use up to three colors, with the rest of the site designed in greyscale (though I&#8217;ve seen sites pull off more colors than that).  A good tool to help you come up with good schemes can be found at: <a title="Color Scheme Designer" href="http://colorschemedesigner.com/" target="_blank">http://colorschemedesigner.com/</a>.  It lets you choose how many colors you want in your color scheme, and then the primary color to build the scheme from.</p>
<p>No matter what colors you use, you will usually use shades of grey for text and other content (for example grey text on a white background) so you don&#8217;t give people color overload.</p>
<h3>Don&#8217;t:</h3>
<ol>
<li>Don&#8217;t use black text on a white background.  Use grey text instead, it&#8217;s easier on the eyes.</li>
<li>Don&#8217;t use complimentary colors as foreground and background (like red text on a green background).  Also colors like bright red on black don&#8217;t look good.  The general rule here is if you wouldn&#8217;t read a book in those colors, people probably wont read your website in them.</li>
</ol>
<h2>General Layout:</h2>
<p>Your job is to guide the user to the most important parts of the website.  The logo is generally in the top left because, since we read top to bottom left to right, that&#8217;s the first place most people look.  After that you&#8217;ll want to take the reader to some text, maybe a catchy image, with the navigation being secondary but very clear.</p>
<p>You can do that through (this list comes from a great article at <a title="Principles for Good Web Design" href="http://psd.tutsplus.com/tutorials/designing-tutorials/9-essential-principles-for-good-web-design" target="_blank">http://psd.tutsplus.com/tutorials/designing-tutorials/9-essential-principles-for-good-web-design</a>):</p>
<ol>
<li>Position — Where something is on a page clearly influences in what order the user sees it.</li>
<li>Color — Using bold and subtle colors is a simple way to tell your user where to look.</li>
<li>Contrast — Being different makes things stand out, while being the same makes them secondary.</li>
<li>Size — Big takes precedence over little (unless everything is big, in which case little might stand out thanks to Contrast)</li>
<li>Design Elements — if there is a gigantic arrow pointing at something, guess where the user will look?</li>
</ol>
<p>You can get more great information from: <a title="Elements of Great Design" href="http://psd.tutsplus.com/designing-tutorials/elements-of-great-web-design-the-polish/" target="_blank">http://psd.tutsplus.com/designing-tutorials/elements-of-great-web-design-the-polish/</a>.</p>
<h2>Etc.</h2>
<p>Other regular design principles apply.  Try not to use too many fonts; if you use different fonts, make they&#8217;re very different (one&#8217;s serif and the other&#8217;s sans-serif).  Etc. etc.</p>
<p>If you&#8217;re having trouble coming up with a logo, here are some great articles:</p>
<ol>
<li><a title="Logo Design Process" href="http://www.webdesignerwall.com/tutorials/dache-logo-design-process/" target="_blank">http://www.webdesignerwall.com/tutorials/dache-logo-design-process/</a></li>
<li><a title="Logo Design" href="http://www.smashingmagazine.com/2009/04/30/60-beautiful-logo-design-tutorials-and-resources/" target="_blank">http://www.smashingmagazine.com/2009/04/30/60-beautiful-logo-design-tutorials-and-resources/</a></li>
<li><a title="Logo Design Trends" href="http://justcreativedesign.com/2009/01/07/logo-design-trends-2009/" target="_blank">http://justcreativedesign.com/2009/01/07/logo-design-trends-2009/</a></li>
</ol>
<p>If you&#8217;re having trouble coming up with general ideas, here are some helpful articles/sites:
<ol>
<li><a title="Design Was Here" href="http://designwashere.com/" target="_blank">http://designwashere.com/</a> (great resources and tutorials)</li>
<li><a title="Ideas for Themes" href="http://psdthemes.com/" target="_blank">http://psdthemes.com/</a> (fantastic resource for getting ideas on good themes).</li>
<li><a title="Web Design Trends" href="http://www.smashingmagazine.com/2009/01/14/web-design-trends-for-2009/" target="_blank">http://www.smashingmagazine.com/2009/01/14/web-design-trends-for-2009/</a> (Some of these are advanced techniques you won&#8217;t use, but there are a lot of good ideas here too).</li>
<li><a title="Collection of Well Designed Sites" href="http://bestwebgallery.com/" target="_blank">http://bestwebgallery.com/</a> (great collections of good sites)</li>
<li><a title="Collection of Well Designed Sites" href="http://cssremix.com/" target="_blank">http://cssremix.com/</a> (also a good collection)</li>
<li><a title="Collection of Well Designed Sites" href="http://www.bestcssgallery.com/" target="_blank">http://www.bestcssgallery.com/</a> (also a good collection)</li>
</ol>
<div class="shr-publisher-5"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/web_101/good-web-design-principles/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Technical Details for Web Design</title>
		<link>http://flightschool.acylt.com/web_101/technical-details-for-web-design/</link>
		<comments>http://flightschool.acylt.com/web_101/technical-details-for-web-design/#comments</comments>
		<pubDate>Sun, 29 Nov 2009 21:23:04 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[Web101]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=11</guid>
		<description><![CDATA[When designing for web there are a few technical details to keep in mind so that your web site can be developed effectively. Size: History: For a long time the standard has been 800 * 600, since many people had monitors with this resolution. Over the last few years the majority of monitors in the [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>When designing for web there are a few technical details to keep in mind so that your web site can be developed effectively.</p>
<h2>Size:</h2>
<h3>History:</h3>
<p>For a long time the standard has been 800 * 600, since many people had monitors with this resolution.  Over the last few years the majority of monitors in the most developed countries have changed to 1024 * 768 or above (for statistics visit: http://www.w3schools.com/browsers/browsers_display.asp, however note the disclaimer on the statistics).  In countries where computers are harder to come by many users may still be using 800 * 600.  It is also possible the numbers are higher here too.</p>
<p>Because of that you&#8217;ll find that most of the best developers online either develop their width at 800 or 960 px.  900 pixels is a good compromise, making it so users with 800&#8242;s don&#8217;t miss much, and so those with higher resolution don&#8217;t feel like the site is small.</p>
<h3>Recommendation:</h3>
<p>When using Photoshop to create new web designs, do so with 900 * 600 in mind.  To do that it is wise to open a document 1100 * 800 so you can have 100 pixels of padding on each side to get an idea of what your page will look like outside of the content.</p>
<p>Put guides 100px in on either side so you know how big the content area is you&#8217;ll be working with. (if you&#8217;re not sure what I&#8217;m talking about look below at the steps, I have screen shots).</p>
<h2>Font:</h2>
<h3>Web Standard:</h3>
<p>Not everyone has the same fonts that you do.  In fact there are only a few fonts that are standard on most machines.  Some examples are Arial, Verdana, Georgia, Times New Roman, and Garamond.  For a complete list see: <a title="Web Standard Fonts" href="http://www.ampsoft.net/webdesign-l/WindowsMacFonts.html" target="_blank">http://www.ampsoft.net/webdesign-l/WindowsMacFonts.html.</a></p>
<p>When you are making your website, you want the majority of the content to be in one of these fonts.  If you use other fonts, you have to use a process where you cut pictures of them out individually to put in place that will be described later.  That is time consuming and you can&#8217;t update it easily, so get used to using web standard fonts.</p>
<p>Times when it is appropriate to use a non web-standard fonts:</p>
<ol>
<li>In your Logo</li>
<li>For the font of your main menu</li>
<li>For the font of main headings or titles that are short and not used very often.</li>
</ol>
<p>Times when it is NOT appropriate to use non web-standard fonts:</p>
<ol>
<li>Body text (like the paragraph about you on your About Me page)</li>
<li>Footer menu and copyright information.</li>
</ol>
<h2>Layer Grouping</h2>
<p><div id="attachment_15" class="wp-caption alignright" style="width: 152px"><img src="http://flightschool.acylt.com/wp-content/uploads/2009/11/layers1.jpg" alt="Example Layer Grouping" title="layers" width="142" height="270" class="size-full wp-image-15" /><p class="wp-caption-text">Example Layer Grouping</p></div>Lots of times Web Development companies keep designers and coders separate.  If that&#8217;s your case, that means someone else is going to have to find their way around your PSD (photoshop document).  So, to help them (and yourself if you put this project down for a month or two), you need to organize your layers.</p>
<p>You do that by selecting similar layers (in the example to the right it&#8217;s all the menu options), and grouping them by pushing ⌘ + G or by going into the Layer menu and choosing Group Layers.</p>
<p>If you&#8217;ve grouped your layers right they&#8217;ll look like the example does.  There&#8217;s a Main Menu group, which has menu options Specialties, Portfolio, Contact, Pricing, and Home.  In the Specialties folder you find the text, its formatting, and a layer for the hover over state (called Specialties Hover-it&#8217;s highlited).</p>
<h2>Background:</h2>
<p>Background is essential and you should always design with it in mind.  That&#8217;s why we make the document 100px larger than it has to be on each side.  It helps focus on  your page looks like in a browser that is bigger than your photoshop design.</p>
<p>Ask yourself, what will this look like if someone looks at it with a monitor bigger than what I&#8217;ve got here.  Will it suddenly cut off?  Or will it repeat nicely?</p>
<h3>Repeating Backgrounds:</h3>
<p>Many backgrounds use gradients.  If you decide to use a gradient it&#8217;s best to make it horizontal or vertical.  That&#8217;s because when we code websites we use techniques to repeat images either in the horizontal or vertical directions.  I&#8217;ll explain that later, but what you should take away from that is if your background can&#8217;t be repeated horizontally or vertically you&#8217;ll have to cut out the entire thing, and that could result in big files sizes (which is BAD for websites).</p>
<div class="shr-publisher-11"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/web_101/technical-details-for-web-design/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Implementation</title>
		<link>http://flightschool.acylt.com/web_101/implementation/</link>
		<comments>http://flightschool.acylt.com/web_101/implementation/#comments</comments>
		<pubDate>Sun, 29 Nov 2009 21:38:30 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[Web101]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=18</guid>
		<description><![CDATA[Start with your home page: This section has step by step instructions on how to get your Home Page started. Once you have that polished the subpages will be easy. Step by step instructions: In Photoshop open a new document (pressing ⌘ + N, or going to new in the File menu), and at the [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><h2>Start with your home page:</h2>
<p>This section has step by step instructions on how to get your Home Page started.  Once you have that polished the subpages will be easy.</p>
<h2>Step by step instructions:</h2>
<ol>
<li>In Photoshop open a new document (pressing ⌘ + N, or going to new in the File menu), and at the opening screen create a document that is 1100 pixels wide and 800 pixels tall.  For resolution choose 72 ppi (this is a web page so the resolution doesn&#8217;t have to be very high).  It should look like this:
<div id="attachment_19" class="wp-caption aligncenter" style="width: 367px"><img class="size-full wp-image-19 " title="setup" src="http://flightschool.acylt.com/wp-content/uploads/2009/11/setup.jpg" alt="Example Setup Page" width="357" height="238" /><p class="wp-caption-text">Example Setup Page</p></div></li>
<li>Make rulers visible by clicking Rulers in the View menu (or pressing ⌘ + R); make sure they are in pixels (if not right clicking on them will allow you to change them).  Then click in the ruler area and drag out guides for the size of your page (as in the image below).  Notice the guides frame the web page.
<p><div id="attachment_20" class="wp-caption aligncenter" style="width: 624px"><img class="size-large wp-image-20 " title="guides" src="http://flightschool.acylt.com/wp-content/uploads/2009/11/guides-1024x725.jpg" alt="Example Guides" width="614" height="435" /><p class="wp-caption-text">Example Guides</p></div></li>
<li>Layout your page.  In this class we&#8217;ll be using a standard portfolio layout.  Make sure that you keep the Header area separate from the content area and the footer area.  Each should fit in their own box, like the example below:
<p><div id="attachment_21" class="wp-caption aligncenter" style="width: 410px"><img class="size-full wp-image-21" title="Home Page Template" src="http://flightschool.acylt.com/wp-content/uploads/2009/11/Home-Page-Template.jpg" alt="Example Home Page Breakdown" width="400" height="291" /><p class="wp-caption-text">Example Home Page Breakdown</p></div>
<p>An example of a good portfolio site following this layout can be found at <a title="Toggle's website" href="http://www.toggle.uk.com/">http://www.toggle.uk.com/</a>.  In this case they don&#8217;t have to worry about what&#8217;s off the page because it&#8217;s just white all around the design.</p>
<p><div id="attachment_22" class="wp-caption aligncenter" style="width: 584px"><img class="size-full wp-image-22 " title="example_portfolio" src="http://flightschool.acylt.com/wp-content/uploads/2009/11/example_portfolio.jpg" alt="Great Portfolio Example" width="574" height="427" /><p class="wp-caption-text">Great Portfolio Example</p></div></li>
<li>If you&#8217;d like you can plan for part of your content to have flash elements (flash is what plays video and animation online) that you will be able to create in the third class.  But have a placeholder image or text that will be there until you take the flash class.</li>
<li>Start designing!</li>
</ol>
<div class="shr-publisher-18"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/web_101/implementation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sub Page Design</title>
		<link>http://flightschool.acylt.com/web_101/sub-page-design/</link>
		<comments>http://flightschool.acylt.com/web_101/sub-page-design/#comments</comments>
		<pubDate>Sun, 29 Nov 2009 21:43:55 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[Web101]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=27</guid>
		<description><![CDATA[Introduction Once you&#8217;ve finished with your home page, you&#8217;ll be ready to start on your sub pages.  They&#8217;ll be quite a bit easier, and this is why: good web pages keep the same header (logo and menu) and footer on all of their pages.  It gives the site continuity.  The only thing that really changes [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><h2>Introduction</h2>
<p>Once you&#8217;ve finished with your home page, you&#8217;ll be ready to start on your sub pages.  They&#8217;ll be quite a bit easier, and this is why: good web pages keep the same header (logo and menu) and footer on all of their pages.  It gives the site continuity.  The only thing that really changes in most cases is just which menu option is highlited (for example, if you&#8217;re on the portfolio page, the portfolio option in the main menu would be highlited).</p>
<p>So the hardest part of the site is out of the way (phew!).  But you&#8217;ve still got a lot of important work to do.</p>
<h3>Photoshop Tip:</h3>
<p>If you&#8217;re wondering what the best way is to do these subpages in photoshop, I prefer making groups (folders) for the header and footer.  They should stay the same on all your pages so you won&#8217;t really touch them for subpages.  I usually have separate folders inbetween for the content of the pages (for example a folder named Home, Portfolio, Contact, etc).</p>
<p>I also use layer comps to organize the different views (if you look under the Window menu option in Photoshop you&#8217;ll find an option for Layer Comp).  At this point the specifics of how to do this is outside the scope of this document, but it would be worth your time to do a few searches online.</p>
<h2>Sub Pages</h2>
<p>Since this is a tutorial on how to create a simple portfolio, we&#8217;re going to have three subpages: Portfolio, About Me, and Contact.  Over the next few pages I&#8217;ll be covering each one.</p>
<div class="shr-publisher-27"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/web_101/sub-page-design/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Portfolio Page</title>
		<link>http://flightschool.acylt.com/web_101/portfolio-page/</link>
		<comments>http://flightschool.acylt.com/web_101/portfolio-page/#comments</comments>
		<pubDate>Sun, 29 Nov 2009 21:56:30 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[Web101]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=29</guid>
		<description><![CDATA[In the portfolio section the easiest way to do it is just to include a bunch of thumbnails of your work. Here are a few example from some designers that I like. Example 1-http://www.spoongraphics.co.uk/portfolio.html Example 2-http://www.qualityxhtml.com/examples.php Example 3-http://www.darrenhoyt.com/ Example 4-http://www.kevadamson.com/portfolio/freelance-graphic-design Take Aways As you can see, none of them included their entire pieces in their [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>In the portfolio section the easiest way to do it is just to include a bunch of thumbnails of your work.  Here are a few example from some designers that I like.</p>
<h3>Example 1-<a href="http://www.spoongraphics.co.uk/portfolio.html" title="Spoon Graphics Portfolio" target="_blank">http://www.spoongraphics.co.uk/portfolio.html</a></h3>
<div id="attachment_30" class="wp-caption aligncenter" style="width: 899px"><img src="http://flightschool.acylt.com/wp-content/uploads/2009/11/spoon.jpg" alt="Example Portfolio" title="spoon" width="889" height="570" class="size-full wp-image-30" /><p class="wp-caption-text">Example Portfolio</p></div>
<h3>Example 2-<a href="http://www.qualityxhtml.com/examples.php" title="Quality xhtml examples" target="_blank">http://www.qualityxhtml.com/examples.php</a></h3>
<div id="attachment_31" class="wp-caption aligncenter" style="width: 632px"><img src="http://flightschool.acylt.com/wp-content/uploads/2009/11/portfolio.jpg" alt="Example Portfolio" title="portfolio" width="622" height="488" class="size-full wp-image-31" /><p class="wp-caption-text">Example Portfolio</p></div>
<h3>Example 3-<a href="http://www.darrenhoyt.com/" title="Darren Hoyt example" target="_blank">http://www.darrenhoyt.com/</a></h3>
<div id="attachment_32" class="wp-caption aligncenter" style="width: 915px"><img src="http://flightschool.acylt.com/wp-content/uploads/2009/11/d.jpg" alt="Portfolio Example" title="Darren Portfolio" width="905" height="734" class="size-full wp-image-32" /><p class="wp-caption-text">Portfolio Example</p></div>
<h3>Example 4-<a href="http://www.kevadamson.com/portfolio/freelance-graphic-design" title="Kev Adamson Example" target="_blank">http://www.kevadamson.com/portfolio/freelance-graphic-design</a></h3>
<div id="attachment_33" class="wp-caption aligncenter" style="width: 458px"><img src="http://flightschool.acylt.com/wp-content/uploads/2009/11/other.jpg" alt="Example Portfolio" title="Example Portfolio" width="448" height="387" class="size-full wp-image-33" /><p class="wp-caption-text">Example Portfolio</p></div>
<h2>Take Aways</h2>
<p>As you can see, none of them included their entire pieces in their portfolio.  So don&#8217;t just slap on an entire portfolio piece.  Find an artistic way to present it (by zooming in and only showing an interesting part of it -example 2- or by turning it sideways like example 3).</p>
<p>Going along with that notice that every portfolio preview piece is the same size.  That might seem obvious but you&#8217;d be surprised at how often people make their pieces different sizes.</p>
<p>Also each one of them has used some sort of border to separate their portfolio piece from the page.  Example 1 probably has the most noticeable borders; example 2 and example 3 both have white borders, and example 4 has what look like hand drawn borders.</p>
<p>So in a nutshell:</p>
<ol>
<li>Present portfolio pieces artistically (zoom in or turn them sideways or something).</li>
<li>Make each piece the same size.</li>
<li>Use borders to separate the pieces from the page.</li>
</ol>
<h2>Other Ideas</h2>
<p>After that the rest is just details.  You can put a description by your piece if you&#8217;d like (like example 2 did).  You could also put some text on the page describing your portfolio like example 3 did, but you&#8217;ll be just fine leaving the pieces to speak for themselves if you&#8217;d like to.</p>
<p>Since the scope of this document is just a simple portfolio we won&#8217;t talk about presenting each portfolio piece.  Our method will be to open the full piece by itself in a new window when someone clicks on the thumbnail.</p>
<p>So if you want any sort of explanation make sure to include it on the Portfolio page.</p>
<div class="shr-publisher-29"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/web_101/portfolio-page/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>About Me Page</title>
		<link>http://flightschool.acylt.com/web_101/about-me-page/</link>
		<comments>http://flightschool.acylt.com/web_101/about-me-page/#comments</comments>
		<pubDate>Sun, 29 Nov 2009 22:05:20 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[Web101]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=42</guid>
		<description><![CDATA[About Me Page: There are a few ways to do About Me pages. I prefer to use it as a Resume and I usually name the page that instead of About Me. Even going that route you can still include a paragraph about yourself on the right if you&#8217;d like or combine the two, giving [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><h2>About Me Page:</h2>
<p>There are a few ways to do About Me pages.  I prefer to use it as a Resume and I usually name the page that instead of About Me.  Even going that route you can still include a paragraph about yourself on the right if you&#8217;d like or combine the two, giving you the best of both.  Here are a few examples from good designers:</p>
<h3>Example 1-<a href="http://milesdowsett.com/index.php/about" title="Example About Page" target="_blank">http://milesdowsett.com/index.php/about</a><br />
<div id="attachment_43" class="wp-caption aligncenter" style="width: 810px"><img src="http://flightschool.acylt.com/wp-content/uploads/2009/11/about_m.jpg" alt="About Me Page" title="about_m" width="800" height="528" class="size-full wp-image-43" /><p class="wp-caption-text">About Me Page</p></div></p>
<h3>Example 2-<a href="http://www.branded07.com/about-me/" title="Example About Page" target="_blank">http://www.branded07.com/about-me/</a><br />
<div id="attachment_44" class="wp-caption aligncenter" style="width: 810px"><img src="http://flightschool.acylt.com/wp-content/uploads/2009/11/about_b.jpg" alt="About Me Page" title="about_b" width="800" height="488" class="size-full wp-image-44" /><p class="wp-caption-text">About Me Page</p></div></p>
<h3>Example 3-<a href="http://www.dgundermann.com/resume/" title="Example About Page" target="_blank">http://www.dgundermann.com/resume/</a><br />
<div id="attachment_45" class="wp-caption aligncenter" style="width: 711px"><img src="http://flightschool.acylt.com/wp-content/uploads/2009/11/resume.jpg" alt="About Me Page, Resume Example" title="resume" width="701" height="512" class="size-full wp-image-45" /><p class="wp-caption-text">About Me Page, Resume Example</p></div></p>
<h2>Take Aways</h2>
<p>Notice that two of the three had pictures of themselves on that page.  You almost always want to do that because it builds since people can put a face to the name—that personal touch can go a long way.  Especially if you hope to get clients that don&#8217;t live close enough to meet face to face.</p>
<p>The only one that didn&#8217;t do it was example 3.  He&#8217;s catering towards clients that would need a security clearnance, so maybe he can get away with it but even in his case I think he&#8217;d be better off with his picture.</p>
<p>Also notice that example 1 is pureley about Miles Dowsett, example 2 is a hybrid of an &#8216;about me&#8217; paragraph and a resume, and example 3 is a pure resume.  You have a lot of flexibility here, any one of the three would work just fine.  But whatever you write, make sure that it centers around you as a designer.</p>
<p>Each one of the pages has clear structure, with titles in bold, or different colors, to set them apart and make it easy to navigate quickly.</p>
<p>So in a nutshell:</p>
<ol>
<li>Include a picture of yourself on this page.</li>
<li>Write a little about yourself as a designer, a resume, or a hybrid of the two.</li>
<li>Have clear structure (with titles etc).</li>
</ol>
<div class="shr-publisher-42"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/web_101/about-me-page/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Contact Page</title>
		<link>http://flightschool.acylt.com/web_101/contact-page/</link>
		<comments>http://flightschool.acylt.com/web_101/contact-page/#comments</comments>
		<pubDate>Sun, 29 Nov 2009 22:11:56 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[Web101]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=48</guid>
		<description><![CDATA[The contact page is pretty simple. Here are some examples from sites I like: Example 1-http://www.villagecreative.com/contact/ Example 2-http://eankadesign.com/contact/ Example 3-http://www.usdigital.co.uk/getintouch.php Take Aways In two of these examples they had forms. This is an effective, easy way to get people to get in touch with you. People are more likely to do things that are easy, [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>The contact page is pretty simple.  Here are some examples from sites I like:</p>
<h3>Example 1-<a href="http://www.villagecreative.com/contact/" title="Example Contact Page" target="_blank">http://www.villagecreative.com/contact/</a><br />
<div id="attachment_49" class="wp-caption aligncenter" style="width: 810px"><img src="http://flightschool.acylt.com/wp-content/uploads/2009/11/contact_o.jpg" alt="Example Contact Page" title="contact_o" width="800" height="318" class="size-full wp-image-49" /><p class="wp-caption-text">Example Contact Page</p></div></p>
<h3>Example 2-<a href="http://eankadesign.com/contact/" title="Example Contact Page" target="_blank">http://eankadesign.com/contact/</a><br />
<div id="attachment_50" class="wp-caption aligncenter" style="width: 621px"><img src="http://flightschool.acylt.com/wp-content/uploads/2009/11/contact.jpg" alt="Example Contact Page" title="contact" width="611" height="557" class="size-full wp-image-50" /><p class="wp-caption-text">Example Contact Page</p></div></p>
<h3>Example 3-<a href="http://www.usdigital.co.uk/getintouch.php" title="Example Contact Page" target="_blank">http://www.usdigital.co.uk/getintouch.php</a><br />
<div id="attachment_51" class="wp-caption aligncenter" style="width: 801px"><img src="http://flightschool.acylt.com/wp-content/uploads/2009/11/contact_3.jpg" alt="Example Contact Page" title="contact_3" width="791" height="284" class="size-full wp-image-51" /><p class="wp-caption-text">Example Contact Page</p></div></p>
<h2>Take Aways</h2>
<p>In two of these examples they had forms.  This is an effective, easy way to get people to get in touch with you.  People are more likely to do things that are easy, clear, and convenient.  Making them call you, or send you an email like the last example adds one more step that you can lose customers on.</p>
<p>With that said, just having your contact information works fine too if that&#8217;s what you want.  Usually both is best.</p>
<p>Also notice that each one of them has a small paragraph telling people why they&#8217;d be contacting them.  It seems obvious, but you&#8217;d be surprised how many people won&#8217;t fill out a contact form without being told what it&#8217;s for (even if your paragraph says it&#8217;s for just about anything, like example 1&#8242;s &#8216;just say hi&#8217; statement).</p>
<p>For our purposes your design should only have a name, email, and message box.  When we code the site that&#8217;s what the script allows right now.</p>
<p>In a nutshell:</p>
<ol>
<li>Forms are effective, a simple name, email, and message will do.</li>
<li>Include other contact information too.</li>
<li>Include a paragraph telling them to get in touch.</li>
</ol>
<h2>Conclusion</h2>
<p>Those are a few examples of how to do your subpages.  If you click on the links you can see them in all their glory, and if you&#8217;d like to try to find more examples, you&#8217;ll see I found a lot of these on <a href="http://deliciouscss.com" title="Delicious CSS" target="_blank">http://deliciouscss.com</a> as well as <a href="http://bestwebgallery.com/" title="Best Web Gallery" target="_blank">http://bestwebgallery.com/</a>, and they have more great examples (like <a href="http://www.brightcreative.com/" title="Bright Creative" target="_blank">http://www.brightcreative.com/</a> for example).</p>
<div class="shr-publisher-48"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/web_101/contact-page/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cutting Web Pages Out (Slicing) &#8211; Introduction</title>
		<link>http://flightschool.acylt.com/web_101/cutting-web-pages-out-slicing-introduction/</link>
		<comments>http://flightschool.acylt.com/web_101/cutting-web-pages-out-slicing-introduction/#comments</comments>
		<pubDate>Fri, 04 Dec 2009 20:49:27 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[Web101]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=59</guid>
		<description><![CDATA[In the early days of the internet it wasn&#8217;t visual at all. Web sites were super boring with normal fonts and hardly any graphical elements. Since then things have changed quite a bit. Now when you surf the web you find vibrant sites with visual navigation, nice backgrounds, and all that jazz. That&#8217;s because now [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>In the early days of the internet it wasn&#8217;t visual at all.  Web sites were super boring with normal fonts and hardly any graphical elements.</p>
<p>Since then things have changed quite a bit.  Now when you surf the web you find vibrant sites with visual navigation, nice backgrounds, and all that jazz.  That&#8217;s because now we have more power to code sites.</p>
<p>They work basically like a puzzle.  You start with your design, cut it into peices, and then put it back together online with code.  It&#8217;s a little different than a puzzle because you don&#8217;t have to cut out everything.  Code can make things look right in a lot of cases, and basically fill in the gaps.  So this chapter will start by teaching you basic ideas of code, followed by what NOT to cut out, then what TO cut out, and then HOW to cut things out.</p>
<p>One more thing before we get into that.  If you&#8217;ve ever had to wait for a web page to load, you know how important it is to make it so that they load fast.  The way you do that is you keep file sizes small.  Keep that in mind as you read this chapter; I&#8217;ll bring it up during relevant parts.</p>
<div class="shr-publisher-59"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/web_101/cutting-web-pages-out-slicing-introduction/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Code Basics for Web Designers</title>
		<link>http://flightschool.acylt.com/web_101/code-basics-for-web-designers/</link>
		<comments>http://flightschool.acylt.com/web_101/code-basics-for-web-designers/#comments</comments>
		<pubDate>Fri, 04 Dec 2009 20:56:17 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[Web101]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=61</guid>
		<description><![CDATA[If you&#8217;re wondering why we&#8217;re cutting things out already without knowing how to code, it&#8217;s because this is a good introduction to code from a design perspective, and will help you when you actually get into coding. That being said here&#8217;s a quick idea of what you can do with code. Layers You can do [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>If you&#8217;re wondering why we&#8217;re cutting things out already without knowing how to code, it&#8217;s because this is a good introduction to code from a design perspective, and will help you when you actually get into coding.  That being said here&#8217;s a quick idea of what you can do with code.</p>
<h2>Layers</h2>
<p>You can do basically what you do in photoshop and stack images on top of each other.  That way you can make a solid background color and then put the content on top.</p>
<h2>Fonts</h2>
<p>Earlier I introduced the idea of web standard fonts.  The reason we use web standard fonts is because browsers get the fonts they use from people&#8217;s computers.  That means that you have to use fonts that EVERYONE has, or people won&#8217;t be able to see your pages the way you&#8217;ve designed them.  Remember most people aren&#8217;t designers, and don&#8217;t have any more fonts installed than what came with the computer.</p>
<p>So if you designed most of your content with web standard fonts, like I suggested, code can do that.  You don&#8217;t have to cut that out as a jpg or a gif.  So go ahead and go into your PSD and turn off the layers that are web standard font (by clicking the eye next to them).  They were useful to help you design things but you won&#8217;t need them when you actually code the site.  If you&#8217;ve forgotten what fonts are web standard, this site can help you: <a href="http://www.ampsoft.net/webdesign-l/WindowsMacFonts.html" target="_blank" title="Web Standard Fonts">http://www.ampsoft.net/webdesign-l/WindowsMacFonts.html</a>. </p>
<h2>Solid Colors</h2>
<p>Code can do solid colors too for fonts or even backgrounds.  If you use it to make a background color though, it can only do it in square shapes.  For example, if you have a header made up of a solid color and the color goes off the page on each side and has a straight border on the bottom, you won&#8217;t have to cut it out at all because you can code that.  However if it has a curvy side, you can still do the main area with code, but you&#8217;d have to cut out the curvy edge.</p>
<p>Here&#8217;s an example:</p>
<h3>Example 1- <a href="http://simpleslice.com" target="_blank" title="SimpleSlice">http://simpleslice.com</a></h3>
<div id="attachment_62" class="wp-caption aligncenter" style="width: 810px"><img src="http://flightschool.acylt.com/wp-content/uploads/2009/12/simpleslice.jpg" alt="Example box structure" title="SimpleSlice" width="800" height="382" class="size-full wp-image-62" /><p class="wp-caption-text">Example box structure</p></div>
<p>In this example the footer is made of a solid color that fits in a square shape.  Code can make that.</p>
<p>Like I said before, code allows for layering so even if you can&#8217;t see part of the square shape if you can tell it&#8217;s square behind things, that counts.  Above the gradient goes on to the left and right and fits in a square shape, even though it has the content box over the top of it.</p>
<h2>Repeating Images</h2>
<p>Some things, like gradients, repeat over and over again.  Again, in Example 1 above you&#8217;ll notice there is a gradient going behind the content.  That gradient can be done with code by repeating a thin pixel slice over and over next to itself like this:</p>
<h3>Example 2</h3>
<div id="attachment_63" class="wp-caption aligncenter" style="width: 310px"><img src="http://flightschool.acylt.com/wp-content/uploads/2009/12/repeating-300x165.jpg" alt="How background repeating works" title="repeating" width="300" height="165" class="size-medium wp-image-63" /><p class="wp-caption-text">How background repeating works</p></div>
<p>The example above shows how code does repeating in the x direction (horizontally).  It can also do that in the y direction (vertically), so if you have a gradient repeating down the page you can do that the same way by cutting out a thin slice.  When code puts things together like this you can&#8217;t even tell, it looks like a solid image.</p>
<p>The reason you&#8217;d want to do this is because it keeps file sizes small.  If you only save a tiny slice of something (1 pixel across), it is MUCH smaller than saving an entire background.</p>
<h3>Wrap up</h3>
<p>Now that you&#8217;ve got some idea of how code works, the next section will talk about the basics of web based images.</p>
<div class="shr-publisher-61"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/web_101/code-basics-for-web-designers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Image Basics for Web Developers</title>
		<link>http://flightschool.acylt.com/web_101/image-basics-for-web-developers/</link>
		<comments>http://flightschool.acylt.com/web_101/image-basics-for-web-developers/#comments</comments>
		<pubDate>Fri, 04 Dec 2009 21:03:38 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[Web101]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=65</guid>
		<description><![CDATA[In order to understand how to cut out the images, you need to understand the evolution of images on the internet. Images on the Internet You have three ways you can save images for the internet: JPG, GIF and PNG. Here&#8217;s a mini history lesson. GIF&#8217;s were patented by Unisys in the 80&#8242;s and people [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>In order to understand how to cut out the images, you need to understand the evolution of images on the internet.</p>
<h2>Images on the Internet</h2>
<p>You have three ways you can save images for the internet: JPG, GIF and PNG.  Here&#8217;s a mini history lesson.  GIF&#8217;s were patented by Unisys in the 80&#8242;s and people were afraid that they&#8217;d have to start paying to use the format (programs like Photoshop had to until 2006).  So they came up with a free version, the PNG, to replace it.  Well, other than software makers no one else had to pay for the GIF, so it kept going strong which leaves us all three today.</p>
<h3>JPG Pros and Cons</h3>
<p>JPG&#8217;s are great for images and keeping their file sizes small.  They support 16 million colors so if you&#8217;re saving a complex graphic or an image for the web, this is the way to go.  The drawback of using JPG&#8217;s is that they use compression to get rid of things we can&#8217;t detect with our eye.  That means that you lose some quality in your picture that you can&#8217;t get back, so if you use this format to compress your picture, keep your original.</p>
<h3>GIF Pros and Cons</h3>
<p>GIF&#8217;s are great for icons and things with not very many colors.  They only support 256 colors, which is plenty for web, and if there are only a few colors in what you&#8217;re saving the file size will be much smaller than what the JPG would be.  They offer lossless compression so you lose quality by having less colors instead of getting rid of information like the JPG does.</p>
<p>GIF&#8217;s also support simple animation and simple transparency (honestly if you want animation that bad Flash is usually a better way to go).  However transparency only works for one color, so unless the background is a solid color with no designs this transparency doesn&#8217;t work very well.</p>
<h3>PNG Pros and Cons</h3>
<p>PNG&#8217;s are amazing for alpha transparency.  The 24-bit, interlaced transparent PNG&#8217;s go seamlessly on any background.  Their compression is also just a touch better than GIFs.  So you&#8217;d think they&#8217;d be better than GIFs (since GIFs only allow transparency with one color), but there are a couple of problems.</p>
<p>First of all in order for PNG transparency to work in Internet Explorer 6, you have to do a lot of extra work, otherwise things won&#8217;t look so good (or you can do like I did here and just tell people that Internet Explorer 6 is no good and they should get a better browser like <a href="http://www.google.com/chrome" target="_blank" title="Google Chrome Download">Google Chrome</a> or <a href="http://www.mozilla.com/firefox/" target="_blank" title="Firefox Download">Firefox</a>.  If you didn&#8217;t notice that then you&#8217;re probably not using IE 6, it only shows up to people using it).  Also PNGs have Gamma support, which should be a good thing but sometimes throws off your color in Internet Explorer (by the way, Internet Explorer is the worst thing that ever happened to the internet.  If you use it please, please change now.  Use Firefox or Chrome or Safari or Opera or ANYTHING but Internet Explorer).  So if that happens to you you&#8217;ll have to go through a process to strip the Gamma out for it to look okay, which could be more trouble than it&#8217;s worth.</p>
<h3>Summary</h3>
<p>So.  To put it simply:</p>
<ol>
<li>Use whichever format gives you the smallest file size with the best quality.</li>
<li>Usually JPG&#8217;s are best for pictures and complex graphics.</li>
<li>Usually GIF&#8217;s are best for images with few colors, like lines or logos.</li>
<li>PNG&#8217;s are best for transparency but getting them to work in some browsers can be difficult, so I usually use PNGs as a last resort (which is sad, they&#8217;re so great).</li>
</ol>
<div class="shr-publisher-65"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/web_101/image-basics-for-web-developers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>To Cut or Not To Cut</title>
		<link>http://flightschool.acylt.com/web_101/to-cut-or-not-to-cut/</link>
		<comments>http://flightschool.acylt.com/web_101/to-cut-or-not-to-cut/#comments</comments>
		<pubDate>Fri, 04 Dec 2009 21:06:36 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[Web101]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=67</guid>
		<description><![CDATA[What NOT to Cut A lot of this section comes from last section. Since code file sizes are much smaller than picture file sizes, you want to do as much with code as you can. That way your page will load faster since the files are smaller, and people will like you more&#8230; I mean [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><h2>What NOT to Cut</h2>
<p>A lot of this section comes from last section.  Since code file sizes are much smaller than picture file sizes, you want to do as much with code as you can.  That way your page will load faster since the files are smaller, and people will like you more&#8230; I mean who wants to wait for a page to load?</p>
<h3>Web Standard Fonts</h3>
<p>I&#8217;ve already mentioned this but if you have paragraphs written in web standard fonts, go ahead and click the eye next to those layers in Photoshop because you won&#8217;t need to be cutting them out.  The only time you would cut these out is if you gave it a drop shadow, outer glow, or some other effect directly on the text.  If it has a cool background you turn off the text and cut out the background by itself.</p>
<h3>Solid Colors</h3>
<p>Since you can make solid colors with code, don&#8217;t cut them out.</p>
<h3>Entire Gradients</h3>
<p>Cut out a thin slice instead, like I mentioned above.  That keeps file sizes small.</p>
<h2>What TO Cut Out</h2>
<p>That leaves pretty much everything else.  So why are you reading this part you might ask?  Because I have one important point to make.</p>
<p>When you&#8217;re cutting out everything else, you should do it so you can stack things like layers.  So cut your logo out separate from your header.  Cut your images out separate from your background, etc etc.</p>
<div class="shr-publisher-67"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/web_101/to-cut-or-not-to-cut/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Cut/Slice from Photoshop</title>
		<link>http://flightschool.acylt.com/web_101/how-to-cutslice-from-photoshop/</link>
		<comments>http://flightschool.acylt.com/web_101/how-to-cutslice-from-photoshop/#comments</comments>
		<pubDate>Fri, 04 Dec 2009 21:18:27 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[Web101]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=71</guid>
		<description><![CDATA[That leaves (drum roll&#8230;) the most important part. HOW? There are two basic techniques: copying and slicing. I use copying the majority of the time, but sometimes it&#8217;s good to use slicing. I&#8217;ll cover both in the next few sections, but before you actually do that you have to get ready to save the images. [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>That leaves (drum roll&#8230;) the most important part.  HOW?</p>
<p>There are two basic techniques: copying and slicing.  I use copying the majority of the time, but sometimes it&#8217;s good to use slicing.  I&#8217;ll cover both in the next few sections, but before you actually do that you have to get ready to save the images.</p>
<h2>Set Up</h2>
<p>If you haven&#8217;t already, create a folder for your web page.  Inside that folder make a folder named &#8216;images&#8217; (lower case i).  That&#8217;s where you&#8217;ll be saving your images.  Since you&#8217;ll be saving them for the web you need to write file names a certain way so coding will be easier (which is why I said to name images with a lower case i).</p>
<p>Each file you save should be all lower case, and if you want a space you should do it with an underscore just_like_this.  So an example jpg name would be &#8216;my_saved_image.jpg&#8217;.</p>
<p>Ok now that&#8217;s out of the way, so roll up your sleeves, lets get to work!  We&#8217;ll be working with examples from <a href="http://acylt.com" target="_blank" title="Acylt Web Design">http://acylt.com</a> in this next section.</p>
<div class="shr-publisher-71"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/web_101/how-to-cutslice-from-photoshop/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Copy Method for Cutting Pages From Photoshop</title>
		<link>http://flightschool.acylt.com/web_101/copy-method-for-cutting-pages-from-photoshop/</link>
		<comments>http://flightschool.acylt.com/web_101/copy-method-for-cutting-pages-from-photoshop/#comments</comments>
		<pubDate>Fri, 04 Dec 2009 21:34:12 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[Web101]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=75</guid>
		<description><![CDATA[For this technique there are three basic steps: Target the Image. Isolate it. Save it for web. Target the Image First you need to target the image. In order to do that you have to decide whether you&#8217;ll be using transparency or not. If you are, you need to turn off the background in Photoshop [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>For this technique there are three basic steps:</p>
<ol>
<li>Target the Image.</li>
<li>Isolate it.</li>
<li>Save it for web.</li>
</ol>
<h2>Target the Image</h2>
<p>First you need to target the image.  In order to do that you have to decide whether you&#8217;ll be using transparency or not.  If you are, you need to turn off the background in Photoshop (by clicking the eye), so there are only transparent pixels behind what you&#8217;re targeting.  If not, you leave the background on.</p>
<p>Here is the example I mentioned before:</p>
<h3>Example 1: <a title="Acylt Web Design" href="http://acylt.com" target="_blank">acylt.com</a></h3>
<div id="attachment_87" class="wp-caption alignnone" style="width: 670px"><img class="size-full wp-image-87" title="acylt" src="http://flightschool.acylt.com/wp-content/uploads/2009/12/web_acylt.jpg" alt="Example" width="660" height="386" /><p class="wp-caption-text">Example</p></div>
<p>In this example, if I wanted to line the logo up perfectly with the background then I could cut the logo out as a JPG or a GIF (and just make sure it joins seamlessly with the sky).  Instead I&#8217;ll cut it out as a PNG so it will work over whatever background I want.</p>
<p>So to target the image, I turn off the background layers.  It looks like this:</p>
<h2>Example 2:</h2>
<div id="attachment_90" class="wp-caption alignnone" style="width: 670px"><img class="size-full wp-image-90" title="No Background" src="http://flightschool.acylt.com/wp-content/uploads/2009/12/web_nb.jpg" alt="Hide the Background" width="660" height="387" /><p class="wp-caption-text">Hide the Background</p></div>
<p>Then I use the Marquee tool (pushing M on the keyboard or selecting the dotted square on the toolbar), click so the marching ants are around the image, like so:</p>
<div id="attachment_79" class="wp-caption alignnone" style="width: 280px"><img class="size-full wp-image-79 " title="dotted" src="http://flightschool.acylt.com/wp-content/uploads/2009/12/dotted.jpg" alt="Marquee Selection" width="270" height="194" /><p class="wp-caption-text">Marquee Selection</p></div>
<h2>Isolate the Image</h2>
<p>Push ⌘ + Shift + C or go into the Edit menu and choose Copy Merged.  The reason we do copy merged instead of just copy, is copy only gets the layer that you&#8217;re on.  So if I&#8217;m on the &#8216;web design&#8217; text layer when I copy the selection above, it won&#8217;t copy the ship.  If I push copy merged it will copy everything there, because it will get all the layers.</p>
<div id="attachment_78" class="wp-caption alignright" style="width: 310px"><img class="size-medium wp-image-78" title="newdoc" src="http://flightschool.acylt.com/wp-content/uploads/2009/12/newdoc-300x167.jpg" alt="New Document" width="300" height="167" /><p class="wp-caption-text">New Document</p></div>
<p>Next I open a new document pushing  ⌘ + N or going into File and choosing New.  If I&#8217;ve done copy merged right, the box that comes up (like the example on the right) will give me options that will fit what I&#8217;ve just copied perfectly, so just push enter.  Don&#8217;t even worry about what the settings are.</p>
<p>It will automatically give your image a background, so turn it off like in the example below, and now that you&#8217;ve got your image targeted and isolated (in a document of its own, its own size), you&#8217;re ready to save for web.</p>
<p><img class="size-full wp-image-80 alignnone" title="turn-off-bg" src="http://flightschool.acylt.com/wp-content/uploads/2009/12/turn-off-bg.jpg" alt="turn-off-bg" width="435" height="163" /></p>
<h2>Save for Web</h2>
<p>To save for web either push ⌘ + Shift + Option + S or go into File and choose Save for Web &amp; Devices.</p>
<p>You&#8217;ll get a dialogue box with lots of options.  Here I have an example of saving a JPG, a GIF, and a PNG.  I&#8217;ve labeled the options you should pay attention to:</p>
<h2>Example 1:</h2>
<h2>
<div id="attachment_91" class="wp-caption alignnone" style="width: 670px"><img class="size-full wp-image-91" title="Example JPG" src="http://flightschool.acylt.com/wp-content/uploads/2009/12/web_JPG.jpg" alt="Example Saving with JPGs" width="660" height="464" /><p class="wp-caption-text">Example Saving with JPGs</p></div></h2>
<h2>Example 2:</h2>
<h2>
<p><div id="attachment_92" class="wp-caption alignnone" style="width: 670px"><img class="size-full wp-image-92" title="Example Gif" src="http://flightschool.acylt.com/wp-content/uploads/2009/12/web_gif1.jpg" alt="Example Saving with GIFs" width="660" height="465" /><p class="wp-caption-text">Example Saving with GIFs</p></div></h2>
<h2>Example 3:</h2>
<p><div id="attachment_93" class="wp-caption alignnone" style="width: 670px"><img class="size-full wp-image-93" title="Example PNG" src="http://flightschool.acylt.com/wp-content/uploads/2009/12/web_png.jpg" alt="Example Saving with PNG" width="660" height="456" /><p class="wp-caption-text">Example Saving with PNG</p></div>
<p>The first example was a JPG, so it didn&#8217;t have transparency and wouldn&#8217;t work.  The second, a GIF, was smaller than the JPG (9.561K vs 11.57K), but because it can only be transparent with one color it would look very bad on a backdrop of stars.</p>
<p>The third option, PNG-24, is the biggest file size but the only one with the transparency that we need.  So we have to go with that.</p>
<h2>IMPORTANT!</h2>
<p>When you save for web, remember remember remember to save the names of your images all lower case and with_underscores_for_spaces.</p>
<div class="shr-publisher-75"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/web_101/copy-method-for-cutting-pages-from-photoshop/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Slicing Method for Web Sites in Photoshop</title>
		<link>http://flightschool.acylt.com/web_101/slicing-method-for-web-sites-in-photoshop/</link>
		<comments>http://flightschool.acylt.com/web_101/slicing-method-for-web-sites-in-photoshop/#comments</comments>
		<pubDate>Fri, 04 Dec 2009 22:01:13 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[Web101]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=95</guid>
		<description><![CDATA[Slicing is similar to copying but uses the slice tool. I only use it when I want things I&#8217;m cutting out to be the same height and line up right next to each other. For example, the acylt example we&#8217;ve been using, if I want to cut the menu out as JPGs instead of PNGs, [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>Slicing is similar to copying but uses the slice tool.  I only use it when I want things I&#8217;m cutting out to be the same height and line up right next to each other.</p>
<p>For example, the acylt example we&#8217;ve been using, if I want to cut the menu out as JPGs instead of PNGs, I have to make sure that everything&#8217;s exactly the right size so it all matches with the background.  In that case I&#8217;d use the slice tool.</p>
<p>To do that choose it by pushing C (if it&#8217;s the first option), or clicking on the crop tool and holding so you can choose the slice tool underneath.</p>
<p>Once you&#8217;ve got the tool, select the entire menu like this:</p>
<div id="attachment_96" class="wp-caption alignnone" style="width: 666px"><img src="http://flightschool.acylt.com/wp-content/uploads/2009/12/slices.jpg" alt="Slice Tool Menu Selected" title="slices" width="656" height="278" class="size-full wp-image-96" /><p class="wp-caption-text">Slice Tool Menu Selected</p></div>
<p>For this to work you want each menu option cut out separately, so you have to divide the slice.  This is easy, just right click (or control click) inside the orange slice above.  You&#8217;ll get a menu that looks like this:</p>
<div id="attachment_97" class="wp-caption alignnone" style="width: 511px"><img src="http://flightschool.acylt.com/wp-content/uploads/2009/12/divide_slice.jpg" alt="How to Divide a Slice" title="Divide Slice" width="501" height="233" class="size-full wp-image-97" /><p class="wp-caption-text">How to Divide a Slice</p></div>
<p>Next choose how many pieces.  In this case there are five menu options and they needed to be divided vertically so I chose:</p>
<div id="attachment_98" class="wp-caption alignnone" style="width: 512px"><img src="http://flightschool.acylt.com/wp-content/uploads/2009/12/divide_options.jpg" alt="Divide Option Dialogue Box" title="Divide Vertically" width="502" height="322" class="size-full wp-image-98" /><p class="wp-caption-text">Divide Option Dialogue Box</p></div>
<p>Then resize the slices so they fit your menu (or whatever you&#8217;re slicing) and Save for Web.  </p>
<p>You&#8217;ll get a box similar to the one we&#8217;ve seen before but with slices now instead of just a preview of what you&#8217;re saving.  It&#8217;ll look like this:</p>
<div id="attachment_99" class="wp-caption alignnone" style="width: 670px"><img src="http://flightschool.acylt.com/wp-content/uploads/2009/12/web_slice_save_options.jpg" alt="Web Slice Save Options" title="Web Slice Save Options" width="660" height="461" class="size-full wp-image-99" /><p class="wp-caption-text">Web Slice Save Options</p></div>
<p>Shift click on each one of your slices in the middle so they all have orange around them and are darker colors, like in the image above.  Then choose the way you want to save them (I chose JPG because it was the smallest filesize and still looked great).</p>
<p>When it asks you what to save, make sure to choose &#8216;Selected Slices&#8217; like I did below, or it will save a lot of extra files you don&#8217;t want.</p>
<div id="attachment_100" class="wp-caption alignnone" style="width: 670px"><img src="http://flightschool.acylt.com/wp-content/uploads/2009/12/web_only-save-selected.jpg" alt="Save ONLY Selected" title="Save ONLY Selected" width="660" height="546" class="size-full wp-image-100" /><p class="wp-caption-text">Save ONLY Selected</p></div>
<p>It will automatically make a folder and put all the saved slices in it, so just drag those into your images folder and you&#8217;ll be good to go!</p>
<p>And there you have it: copying and slicing.</p>
<h2>Summary</h2>
<p>Remember use copy most of the time, and slice only when you have to cut multiple things out so that they&#8217;re the same height.</p>
<div class="shr-publisher-95"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/web_101/slicing-method-for-web-sites-in-photoshop/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Last Details</title>
		<link>http://flightschool.acylt.com/web_101/last-details/</link>
		<comments>http://flightschool.acylt.com/web_101/last-details/#comments</comments>
		<pubDate>Fri, 04 Dec 2009 22:02:25 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[Web101]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=102</guid>
		<description><![CDATA[Now that you know how to cut things out here are a few more details that will hopefully clarify things a little bit. Cutting Out Menus The reason we cut these out separately is so we can make our hover overs work. If your menu doesn&#8217;t have hover over states you should go back and [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>Now that you know how to cut things out here are a few more details that will hopefully clarify things a little bit.</p>
<h2>Cutting Out Menus</h2>
<p>The reason we cut these out separately is so we can make our hover overs work.  If your menu doesn&#8217;t have hover over states you should go back and put some in.  </p>
<p>When you&#8217;re cutting out your menu you cut out one version of your menu in the normal state, and then one in the hover over state.  They should be the same height and width.  If you want to be really fancy you can put them both on one image, with the hover over above the normal state but that&#8217;s not necessary.</p>
<h2>Conclusion</h2>
<p>Now you&#8217;ve got the tools you need to be able to cut out a website.  I haven&#8217;t included all of the possible scenarios, so if you&#8217;re confused at all just do your best and get ready to code.  You&#8217;ll probably have to re-cut out some things while you&#8217;re coding, but this will have helped you quite a bit so that it&#8217;s easier to do once you&#8217;re coding.</p>
<div class="shr-publisher-102"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/web_101/last-details/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTML Introduction</title>
		<link>http://flightschool.acylt.com/web_101/html-introduction/</link>
		<comments>http://flightschool.acylt.com/web_101/html-introduction/#comments</comments>
		<pubDate>Wed, 23 Dec 2009 03:52:14 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[Web101]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=105</guid>
		<description><![CDATA[Introduction What is this for? This is for the daunting task of coding a portfolio-style website from scratch. It builds on a tutorial for creating that page in Photoshop; if you haven&#8217;t done that yet you should. If you have, then even if you&#8217;ve never seen code before in your life, this is for you. [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><h2>Introduction</h2>
<h2></h2>
<h3>What is this for?</h3>
<p>This is for the daunting task of coding a portfolio-style website from scratch.  It builds on a tutorial for creating that page in Photoshop; if you haven&#8217;t done that yet you should.  If you have, then even if you&#8217;ve never seen code before in your life, this is for you.  The basic format of the website will be:<br />
<a href="http://flightschool.acylt.com/wp-content/uploads/2009/12/Home-Page-Template.jpg"><img class="size-full wp-image-107 alignleft" title="Home Page" src="http://flightschool.acylt.com/wp-content/uploads/2009/12/Home-Page-Template.jpg" alt="Example Home Page" width="400" height="291" /></a></p>
<p>This specific example is of a home page, but the point is that you should have a header area with a logo and main menu, a content area that is the same width and has content, and a footer with a footer menu and a copyright notice.  If your design looks different (for example if you have your main menu down the left side of the content) then you can still use this, you&#8217;ll just have to be creative to make it work.  I won&#8217;t explain how to do that sort of thing explicitly.</p>
<p>You can add more information but just keep in mind that the only part of the site that should change from page to page is the content area.  The header and footer should be reusable.</p>
<h3>W3Schools.com</h3>
<p>This is not meant to be used alone, in fact it will rely heavily on w3Schools.com.  This just fills in the gaps that w3schools doesn&#8217;t.  They&#8217;re great about teaching the details of web design, but they don&#8217;t put it all together very well.</p>
<p>This will put everything together, but that means that you&#8217;ll have to have an iternet connection to use this because you&#8217;ll be going to w3schools quite a bit.</p>
<h3>HTML5</h3>
<p>This is rather bad timing to be writing this document, because HTML 5 is starting to gain momentum.  Eventually it will take over, but for now it&#8217;s still being developed and isn&#8217;t fully supported, and the HTML 4 here provides the groundwork for easy learning later.</p>
<p>One of the main purposes of this is to teach you how to find answers online for how to do this sort of thing.  I learned web design from resources online.  Everything you need is there, it&#8217;s just a matter of training yourself to find it, and knowing the best ways to find it.</p>
<h3>Dreamweaver?</h3>
<p>To write HTML you need a text editor.  In case you were wondering, yes we will be doing this in dreamweaver.  However the way that this is written you could do this in anything (including the most simple text editors—however word isn&#8217;t very good because it adds code).<br />
<a href="http://flightschool.acylt.com/wp-content/uploads/2009/12/code_web.jpg"><img class="alignright size-full wp-image-108" title="code view" src="http://flightschool.acylt.com/wp-content/uploads/2009/12/code_web.jpg" alt="code view" width="200" height="106" /></a><br />
Dreamweaver is great, but most companies don&#8217;t want to pay the license fee to Adobe.  Instead they use free editors, like Eclipse, Notepad ++, etc.  So when we code it will always be in CODE mode (highliting code like the example on the right), and always be taught as if we didn&#8217;t get all the help from Dreamweaver (partially because dreamweaver can make a mess of your code if you&#8217;re using all of its helps).</p>
<div class="shr-publisher-105"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/web_101/html-introduction/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTML Basics</title>
		<link>http://flightschool.acylt.com/web_101/html-basics/</link>
		<comments>http://flightschool.acylt.com/web_101/html-basics/#comments</comments>
		<pubDate>Wed, 23 Dec 2009 03:57:41 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[Web101]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=111</guid>
		<description><![CDATA[Beautiful, now we&#8217;re ready to get started. If you didn&#8217;t notice the title of this chapter I&#8217;ll write it again, this is all about HTML. Are you ready? Here are the basic ideas. My First Heading Browsers don&#8217;t just automatically know what you want your page to look like. They need to know what kind [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>Beautiful, now we&#8217;re ready to get started.  If you didn&#8217;t notice the title of this chapter I&#8217;ll write it again, this is all about HTML.</p>
<p>Are you ready?  Here are the basic ideas.</p>
<h3>My First Heading</h3>
<p>Browsers don&#8217;t just automatically know what you want your page to look like.  They need to know what kind of HTML you&#8217;re using, and what you want to show and how.  This is done by marking up documents with what I call &#8216;alligators&#8217; (which are really greater and less than signs &lt; &gt;).</p>
<p>Anything between the alligators- &lt;, &gt; -is meant for the browser to read.  Since it&#8217;s marking up the document for the browser, it&#8217;s called a markup language.</p>
<p>For a browser to show a big &#8216;My First Heading&#8217;, it would need something like this:</p>
<p>&lt;html&gt;<br />
&lt;body&gt;<br />
&lt;h1&gt;My First Heading&lt;/h1&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</p>
<p>The browser sees this code and knows first that it&#8217;s html (&lt;html&gt;), then that you want to display content (&lt;body&gt;) then that the content is the title &#8216;My First Heading&#8217; (&lt;h1&gt;).  To understand better how this works, go to <a href="http://w3schools.com/html/html_intro.asp" target="_blank">http://w3schools.com/html/html_intro.asp</a>.</p>
<p>You&#8217;ll see a <a href="http://flightschool.acylt.com/wp-content/uploads/2009/12/tryitbtn.gif"><img class="size-full wp-image-112 alignnone" title="tryitbtn" src="http://flightschool.acylt.com/wp-content/uploads/2009/12/tryitbtn.gif" alt="" width="90" height="20" /></a> button.  Go ahead and click on that and try putting in your own code.</p>
<p>Also try out <a href="http://w3schools.com/html/html_primary.asp" target="_blank">http://w3schools.com/html/html_primary.asp</a>.  That has a few basic tags and will get you more familiar with what HTML looks like.</p>
<p>Once you&#8217;ve read about tags come back here.</p>
<div class="shr-publisher-111"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/web_101/html-basics/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TAG Basics</title>
		<link>http://flightschool.acylt.com/web_101/tag-basics/</link>
		<comments>http://flightschool.acylt.com/web_101/tag-basics/#comments</comments>
		<pubDate>Wed, 23 Dec 2009 04:18:48 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[Web101]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=120</guid>
		<description><![CDATA[Tags &#38; Elements If you went to the w3schools link above you&#8217;ll know that tags almost always come in pairs.  An &#60;h1&#62; tag needs to have a closing &#60;/h1&#62; tag.   The entire thing (&#60;h1&#62;The text inside&#60;/h1&#62;) is an element. The code on each side of the element content describes it (in this case everything between [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><h3>Tags &amp; Elements</h3>
<p>If you went to the w3schools link above you&#8217;ll know that tags almost always come in pairs.  An &lt;h1&gt; tag needs to have a closing &lt;/h1&gt; tag.   The entire thing (&lt;h1&gt;The text inside&lt;/h1&gt;) is an <strong>element.</strong> The code on each side of the element content describes it (in this case everything between the h1 tags the browser would recognize as a heading or title because that&#8217;s what the tags tell the browser).</p>
<p>There are a few tags that are <strong>self closing</strong>.  Those tags look like this: &lt;img &#8230;. /&gt;.  Notice that in the tag the &#8216;/&#8217; is right before the last alligator, indicating that the tag doesn&#8217;t need another one to close it.</p>
<h3>KEY TAGS</h3>
<p>If you&#8217;ve looked over the list of HTML tags, you may be feeling a bit overwhelmed.  There are quite a few!  Luckily only a few of them are used most of the time.  Here is the list of tags you need to know, and where you can find more information about them:</p>
<h4>Headings (titles):</h4>
<p>&lt;h1&gt;&lt;/h1&gt;&#8230; &lt;h6&gt;&lt;/h6&gt;</p>
<p>These tags are used for titles.  So if you have <strong>titles</strong> and <strong>subtitles</strong> on your webpage, you would use these tags.  It is also common practice to use these for the <strong>logo</strong>.</p>
<p><a href="http://w3schools.com/html/html_headings.asp">http://w3schools.com/html/html_headings.asp</a></p>
<h4>Paragraphs:</h4>
<p>&lt;p&gt;&lt;/p&gt;</p>
<p>It should be pretty obvious that these tags are for <strong>paragraphs</strong>.  Pretty much any content other than titles would fall between &lt;p&gt; tags.</p>
<p><a href="http://w3schools.com/html/html_paragraphs.asp">http://w3schools.com/html/html_paragraphs.asp</a></p>
<h4>Anchor (Link):</h4>
<p>&lt;a &#8230;&gt;&lt;/a&gt;</p>
<p>These tags are for <strong>links</strong> and make the text clickable.</p>
<p><a href="http://w3schools.com/html/html_links.asp">http://w3schools.com/html/html_links.asp</a></p>
<h4>Image:</h4>
<p>&lt;img &#8230;/&gt;</p>
<p>These tags allow you to put in <strong>images</strong> in your document.  We&#8217;ll get more into this later, but you should use this for images on the page, not background images (like the content background, etc).  We&#8217;ll put background images on differently.</p>
<p><a href="http://w3schools.com/html/html_images.asp">http://w3schools.com/html/html_images.asp</a></p>
<h4>Table:</h4>
<p>&lt;table&gt;</p>
<p>&lt;tr&gt;(table row)</p>
<p>&lt;td&gt;(table data)&lt;/td&gt;</p>
<p>&lt;/tr&gt;</p>
<p>&lt;/table&gt;</p>
<p>Tables used to be used for layout and are rarely used for that anymore.  One common use for <strong>tables</strong> would be the form on the contact page (it helps line everything up).  Other than that tables should usually be avoided.</p>
<p><a href="http://w3schools.com/html/html_tables.asp">http://w3schools.com/html/html_tables.asp</a></p>
<h4>List:</h4>
<p>&lt;ul&gt;(unordered list)</p>
<p>&lt;li&gt;(list item)&lt;/li&gt;</p>
<p>&lt;/ul&gt;</p>
<p>This creates <strong>lists</strong> with bullets next to them.  If you wanted numbers instead you would put &lt;ol&gt; (ordered list) in place of &lt;ul&gt;.  However one of the most common uses of lists is to make <strong>menus</strong>.  So the main menu would be an unordered list.</p>
<p><a href="http://www.w3schools.com/html/html_lists.asp">http://www.w3schools.com/html/html_lists.asp</a></p>
<h4>Forms:</h4>
<p>&lt;form&gt;</p>
<p>&lt;input &#8230;/&gt; (place where people can input stuff)</p>
<p>&lt;textarea&gt;&lt;/textarea&gt; (area where people can write longer messages)</p>
<p>&lt;/form&gt;</p>
<p>These are used to <strong>get information</strong> from people online.  They allow people to input data and click submit.</p>
<p><a href="http://w3schools.com/html/html_forms.asp">http://w3schools.com/html/html_forms.asp</a></p>
<h4>Divisions:</h4>
<p>&lt;div&gt;&lt;/div&gt;</p>
<p>You will probably use div&#8217;s more than any other tag, they are <strong>how we create layout.</strong> They <strong>group things</strong> together and are very versatile.  You can put pretty much anything inside of them.</p>
<p><a href="http://www.w3schools.com/tags/tag_DIV.asp">http://www.w3schools.com/tags/tag_DIV.asp</a></p>
<h4>Spans:</h4>
<p>&lt;span&gt;&lt;/span&gt;</p>
<p>Spans are like divs, but for <strong>inline content</strong>.  So while div&#8217;s are used for big layout, spans would be used to <strong>change</strong> the color of a little <strong>text</strong>, or make text bold, italicized, or anything else like that.</p>
<h3>Separate Style from Markup</h3>
<p>You may have noticed there are html tags for making things bold, italic, etc.  The reason we&#8217;d use spans instead is because best practice is to <strong>separate all styling</strong> <strong>from</strong> <strong>html</strong> <strong>markup</strong>, and spans let us do the styling with CSS (Cascading Stylesheets, we&#8217;ll discuss those at length in the next chapter)</p>
<p><a href="http://www.w3schools.com/tags/tag_span.asp" target="_blank">http://www.w3schools.com/tags/tag_span.asp</a></p>
<p>That&#8217;s it!  That may feel like quite a few tags, but it&#8217;s really not that bad.  Once you&#8217;ve mastered these tags you&#8217;ll know your way around 95% of all websites.  Now that you know some of the tags we&#8217;re going to cover how to use them.</p>
<div class="shr-publisher-120"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/web_101/tag-basics/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nesting</title>
		<link>http://flightschool.acylt.com/web_101/nesting/</link>
		<comments>http://flightschool.acylt.com/web_101/nesting/#comments</comments>
		<pubDate>Wed, 23 Dec 2009 04:26:48 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[Web101]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=123</guid>
		<description><![CDATA[Nesting is a very important concept.  Ever seen nesting dolls from europe?  They&#8217;re made of wood, and when you open one doll, you find another inside.  Opening the one inside you find another. The smallest doll fits inside the second smallest.  That fits inside the third smallest, and so forth until you get to the [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>Nesting is a very important concept.  Ever seen nesting dolls from europe?  They&#8217;re made of wood, and when you open one doll, you find another inside.  Opening the one inside you find another.</p>
<p><a href="http://flightschool.acylt.com/wp-content/uploads/2009/12/nesting_doll.jpg"><img class="alignnone size-full wp-image-124" title="Nesting dolls" src="http://flightschool.acylt.com/wp-content/uploads/2009/12/nesting_doll.jpg" alt="nesting dolls" width="500" height="332" /></a></p>
<p>The smallest doll fits inside the second smallest.  That fits inside the third smallest, and so forth until you get to the biggest one.  That&#8217;s how code works.</p>
<p>&lt;html&gt;</p>
<p>&lt;body&gt;</p>
<p>&lt;div&gt;</p>
<p>&lt;h1&gt;</p>
<p>This is a heading</p>
<p>&lt;/h1&gt;</p>
<p>&lt;/div&gt;</p>
<p>&lt;/body&gt;</p>
<p>&lt;/html&gt;</p>
<p>As you can see the &#8216;smallest&#8217; tag, h1, goes inside the next smallest, div, goes inside the bigger body, goes inside the biggest html.</p>
<p>Doing something like this:</p>
<p>&lt;html&gt;</p>
<p>&lt;body&gt;</p>
<p>&lt;/html&gt;</p>
<p>&lt;/body&gt;</p>
<p>Doesn&#8217;t work.  It&#8217;s like trying to put the top of the biggest doll together with the next biggest dolls bottom.  It doesn&#8217;t fit.  The browser will get confused if you do something like that.  Instead it needs to look like this:</p>
<p>&lt;html&gt;</p>
<p>&lt;body&gt;</p>
<p>&lt;/body&gt;</p>
<p>&lt;/html&gt;</p>
<p>Something like this works too:</p>
<p>&lt;html&gt;</p>
<p>&lt;head&gt;</p>
<p>&lt;/head&gt;</p>
<p>&lt;body&gt;</p>
<p>&lt;/body&gt;</p>
<p>&lt;/html&gt;</p>
<p>Both head and body are <em>nested </em> inside of html.</p>
<p>Now go to <a href="http://w3schools.com/html/html_elements.asp">http://w3schools.com/html/html_elements.asp</a> to get more information.</p>
<div class="shr-publisher-123"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/web_101/nesting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Required Attributes</title>
		<link>http://flightschool.acylt.com/web_101/required-attributes/</link>
		<comments>http://flightschool.acylt.com/web_101/required-attributes/#comments</comments>
		<pubDate>Wed, 23 Dec 2009 05:01:19 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[Web101]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=127</guid>
		<description><![CDATA[Each element can have attributes.  Basically what they do is give the browser more information about a tag.  They can tell a link where it should link to, identify a tag so it stands out from all the others, and do many other things.  However some tags require attributes.  They will be discussed here. Links: [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>Each element can have attributes.  Basically what they do is give the browser more information about a tag.  They can tell a link where it should link to, identify a tag so it stands out from all the others, and do many other things.  However some tags require attributes.  They will be discussed here.</p>
<h3>Links:</h3>
<p>The first tag that requires an attribute is the anchor tag.  Attributes always follow the tag identifier.  For example, an anchor tag isn&#8217;t just &lt;a&gt;.  It needs to tell the browser where to go when it&#8217;s clicked on.  So it uses the attribute &#8216;href&#8217;, which stands for hyperlink reference.  So a full anchor tag would look like:</p>
<p>&lt;a href=&#8217;http://w3schools.com&#8217;&gt;Link to w3schools.com&lt;/a&gt;</p>
<p>Here you would see &#8216;Link to w3schools.com&#8217; underlined.  You wouldn&#8217;t see the actuall link but when you clicked on it, it would take you to w3schools.com.</p>
<h3>Images</h3>
<p>Another attribute would be on the image tag.  You need to tell the browser where to get the image to display.  If you have your images in an &#8216;images&#8217; folder, it would look like this:</p>
<p>&lt;img src=&#8217;images/my_image.jpg&#8217; alt=&#8217;My Image&#8217; /&gt;</p>
<p>You probably noticed that one attribute gave the source (src).  The other gives the alternate (alt), just in case the browser can&#8217;t find your image, or for people who are blind.  It should be a description of your image, and if you don&#8217;t include the alt tag, your code won&#8217;t be up to standard.</p>
<h3>Forms:</h3>
<p>Form is another tag that requires some attributes.  I won&#8217;t explain these much in this document since HTML and CSS in and of themselves can&#8217;t process forms, but basically &#8216;method&#8217; tells the form how to process the information users put in, and &#8216;action&#8217; tells it what will process the information.  Here&#8217;s an example:</p>
<p>&lt;form method=&#8217;post&#8217; action=&#8217;processor.php&#8217;&gt;</p>
<p>Inputs also require an attribute so they know what type they are.  For example:</p>
<p>&lt;input type=&#8217;text&#8217;  /&gt;</p>
<p>Inputs text, while:</p>
<p>&lt;input type=&#8217;submit&#8217; /&gt;</p>
<p>Makes a submit button.</p>
<h3>Etc:</h3>
<p>For more information on the attributes needed for each tag, just go to their link in the Key Tags section above.  Each one goes into detail about the required attributes.</p>
<p>For general information about attributes, go to <a target="_blank" href="http://www.w3schools.com/html/html_attributes.asp">http://www.w3schools.com/html/html_attributes.asp</a>.</p>
<div class="shr-publisher-127"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/web_101/required-attributes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Other Attributes</title>
		<link>http://flightschool.acylt.com/web_101/other-attributes/</link>
		<comments>http://flightschool.acylt.com/web_101/other-attributes/#comments</comments>
		<pubDate>Wed, 23 Dec 2009 05:06:34 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[Web101]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=131</guid>
		<description><![CDATA[If you went to the link above, you should have seen some attributes we haven&#8217;t talked about yet.  Those are the most important attributes and I&#8217;ll explain why here.  Specifically I&#8217;m talking about title, id, and class.  Style is actually an attribute you should never use, which I will also explain here. Title: First of [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>If you went to the link above, you should have seen some attributes we haven&#8217;t talked about yet.  Those are the most important attributes and I&#8217;ll explain why here.  Specifically I&#8217;m talking about title, id, and class.  Style is actually an attribute you should never use, which I will also explain here.</p>
<h3>Title:</h3>
<p>First of all <strong>title</strong> is an important attribute.  If you put that on a tag (like &lt;p title=&#8217;My Paragraph&#8217;&gt;) then if someone hovers over that paragraph with their mouse, they&#8217;ll see &#8216;My Paragraph&#8217; written there.</p>
<p>This is useful if you want to give people tips, help them around the document, or just increase the clarity of your website.  It can go on pretty much any tag, but is most commonly put on h1-h6 tags.</p>
<p>Another benefit to <strong>title</strong> has to do with SEO (or search engine optimization).  If you haven&#8217;t heard of it, this is the process of getting your website to rank higher in search engines like google.  They see titles as helpful for getting people to navigate your site and reward you for that.</p>
<h3>Id:</h3>
<p><strong>Id</strong> is another hugely important attribute.</p>
<p>To understand it, think of a classroom with students.  The <strong>id</strong> is like a students name.  If there are more than one students with a name, it makes it very confusing when the teacher tries to get the attention of one of them.  Often the teacher will give one of them a nickname, or a way to distinguish them from the rest of the class.</p>
<p>In a similar way, you can name the tags in your HTML document so you can get their attention later when you want to tell one of them to be big and bold, and another to be a different color, and another to have a background-image, etc etc.  But remember, only give each id once per page or it will cause confusion, like it would in a class.  So, for example, if I have the id blue on my Home Page:</p>
<p>&lt;h1 id=&#8217;blue&#8217;&gt;Here is my Blue Title&lt;/h1&gt;</p>
<p>I have to make sure that for the rest of that HTML page I don&#8217;t give anything else the id=&#8217;blue&#8217;.  I can put id=&#8217;blue&#8217; on my About Me page too, since it&#8217;s a <em>different </em>page, I just can&#8217;t have it twice on a page (the Home, About Me, Portfolio and Contact pages will all be saved as separate HTML documents).  This isn&#8217;t just preference, it&#8217;s essential to keeping your code up to standards.</p>
<h3>Class:</h3>
<p>What if you have three or four things you want to be blue?  Then you would use <strong>class. </strong>Thinking about the classroom again, even though everyone has a different name, they are all part of a classroom.  So if you asked them if they were in such and such a class, they would say yes.</p>
<p>In the same way, if I want to have lots of blue things on a page, I would use <strong>class</strong> instead of id.  It would look like this:</p>
<p>&lt;h1 class=&#8217;blue&#8217;&gt;Here is a main title&lt;/h1&gt;</p>
<p>&lt;h3 class=&#8217;blue&#8217;&gt;Here is another main title&lt;/h1&gt;</p>
<p>&lt;p class=&#8217;blue&#8217;&gt;Here is another main title&lt;/p&gt;</p>
<p>Each one of those is part of the group named &#8216;blue&#8217;.  It&#8217;s also just fine to have just one member of a class, making it like id (for example if you had a class only once on one page because you knew on another page you&#8217;d want to use it more than once).  But if you&#8217;re sure you&#8217;ll only have one of something, id is much better (you should have quite a few more id&#8217;s than classes)</p>
<p>If you tried putting class=&#8217;blue&#8217; on your own HTML you might be wondering why they didn&#8217;t actually turn blue yet.  That&#8217;s because we&#8217;ve only given them a name so far.  Id and class just name tags.  Later on we&#8217;ll use those names to tell them what to look like with CSS (Cascading Style Sheets).</p>
<h3>Style:</h3>
<p>Which brings me to the attribute <strong>style</strong>.  If you&#8217;ve seen <strong>style</strong> used on tags, you&#8217;ll notice that it actually does make things look different.  For example if you have:</p>
<p>&lt;p style=&#8217;color:blue&#8217;&gt;</p>
<p>The paragraph will turn blue.  The reason you should <strong>NEVER NEVER NEVER NEVER do this </strong>is because then your styling is in your HTML and remember, we try to separate the markup (HTML) from the actual look of the site (done with CSS).</p>
<p>The basic reason is that if you have your styling in line then if you decide you really wanted all the color on your site to be orange instead of blue, you would have to change every single line where you said you wanted it blue.  If instead you did it with CSS then you would only have to change it once, and that would <em>cascade </em>down through everything and make it all the right color.  It&#8217;s <strong>much easier</strong> if you do all your styling with CSS.  I won&#8217;t explain it in any more depth here because it won&#8217;t make much sense yet but trust me, if you keep your styling and markup separate it will save you a lot of time.</p>
<div class="shr-publisher-131"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/web_101/other-attributes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tab In</title>
		<link>http://flightschool.acylt.com/web_101/tab-in/</link>
		<comments>http://flightschool.acylt.com/web_101/tab-in/#comments</comments>
		<pubDate>Wed, 23 Dec 2009 05:13:44 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[Web101]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=133</guid>
		<description><![CDATA[When you actually write your HTML, you should follow some guidelines.  They will help you A LOT. Tab In You may have noticed that when I write examples, I always tab in when I&#8217;m inside a tag.  That&#8217;s becuase it helps you to lay your code out visually.  Then you know what&#8217;s inside what, and [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>When you actually write your HTML, you should follow some guidelines.  They will help you A LOT.</p>
<h2>Tab In</h2>
<p>You may have noticed that when I write examples, I always tab in when I&#8217;m inside a tag.  That&#8217;s becuase it helps you to lay your code out visually.  Then you know what&#8217;s inside what, and you can see whether you ended a tag or not.</p>
<p>So every time you put a tag inside another, tab in.  Here&#8217;s an example of a very simple web page:</p>
<p>&lt;html&gt;</p>
<div style="padding:0 0 0 25px;">&lt;div id=&#8217;wrapper&gt;</p>
<div style="padding:0 0 0 25px;">&lt;div id=&#8217;header&#8217;&gt;</p>
<div style="padding:0 0 0 25px;">&lt;h1&gt;This is an Example Heading&lt;/h1&gt;</div>
<p>&lt;/div&gt;</p></div>
<div style="padding:0 0 0 25px;">&lt;div id=&#8217;content&#8217;&gt;</p>
<div style="padding:0 0 0 25px;">&lt;p&gt;This is an example paragraph.&lt;/p&gt;</div>
<p>&lt;/div&gt;</p></div>
<p>&lt;/div&gt;</p></div>
<p>&lt;/html&gt;</p>
<p>In the code above, it&#8217;s easy to see that everything is inside the &lt;html&gt; tags.  Everything  else is inside the wrapper.  In the wrapper you have two things, a header and content.  Inside the header is an &lt;h1&gt; with some content.  Inside the content is a &lt;p&gt; with content.  It&#8217;s all lined up, and if one of the tags were missing it would be easy to spot.  Which takes me to my next point.</p>
<div class="shr-publisher-133"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/web_101/tab-in/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Write the End Tag!</title>
		<link>http://flightschool.acylt.com/web_101/write-the-end-tag/</link>
		<comments>http://flightschool.acylt.com/web_101/write-the-end-tag/#comments</comments>
		<pubDate>Wed, 23 Dec 2009 05:18:41 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[Web101]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=139</guid>
		<description><![CDATA[Always write your end tag when you write your first tag. I&#8217;m going to write that again.  Always write your end tag when you write your first tag. If I write &#60;html&#62; I would push enter and write &#60;/html&#62; immediately.  Then I&#8217;d arrow up and write what&#8217;s inside of it.  If you do this it [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>Always <strong>write your end tag when you write your first tag. </strong>I&#8217;m going to write that again.  <strong>Always write your end tag when you write your first tag. </strong>If I write &lt;html&gt; I would push enter and write &lt;/html&gt; immediately.  Then I&#8217;d arrow up and write what&#8217;s inside of it.  If you do this it will save you all kinds of trouble in the future because you won&#8217;t forget end tags.  If you don&#8217;t you&#8217;ll have all kinds of bugs that will be hard to find.</p>
<h2>Wrapup</h2>
<p>In this chapter you&#8217;ve learned all the HTML basics you need to start coding your page.  You&#8217;ve learned about Elements, Attributes, and Nesting.  In the next chapter you&#8217;ll start to learn how to make it all start to look right with CSS.</p>
<p>Included with this are two sets of example HTML files.  The first example is for websites designed to have the backgrounds of each section (header, body and footer) go off forever in both directions, like <a href="http://milesdowsett.com/index.php" target="_blank">http://milesdowsett.com/index.php</a>.  I call that HTML Three Wrappers.  The second example is for websites designed to have the backgrounds for each section (header, body and footer) in the middle of the page, with a main background going off forever in both directions, like <a href="http://www.darrenhoyt.com/" target="_blank">http://www.darrenhoyt.com/</a> and <a href="http://www.toggle.uk.com/" target="_blank">http://www.toggle.uk.com/</a> (with toggle they don&#8217;t have a main background going on in each direction, they just have backgrounds for their header, body and footer that stay in the middle).  I call that HTML Big Wrapper.</p>
<p><strong>IMPORTANT NOTE- </strong>The contact page form will act funny until you upload it to a server.  That&#8217;s because it was written to be sent online, not from your computer.  You can still test it; you should get emails if you fill it out right with your email address.  It just won&#8217;t redirect you back to your page if you do that from your computer.</p>
<div class="shr-publisher-139"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/web_101/write-the-end-tag/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CSS!</title>
		<link>http://flightschool.acylt.com/web_101/css/</link>
		<comments>http://flightschool.acylt.com/web_101/css/#comments</comments>
		<pubDate>Wed, 23 Dec 2009 05:22:46 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[Web101]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=143</guid>
		<description><![CDATA[This chapter is a quick introduction to CSS (cascading style sheets).  As such it will just cover the basics you need to know before you can actually start styling your html.  But before we get into that, here&#8217;s a quick plug for Firefox. FIREFOX If you&#8217;re using Internet Explorer, stop now.  It is notoriously slow, [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>This chapter is a quick introduction to CSS (cascading style sheets).  As such it will just cover the basics you need to know before you can actually start styling your html.  But before we get into that, here&#8217;s a quick plug for Firefox.</p>
<h3>FIREFOX</h3>
<p>If you&#8217;re using Internet Explorer, stop now.  It is notoriously slow, buggy, and non standards compliant.  The security on it is the worst of all browsers too, especially if you have an older version.</p>
<p>Instead for all of our development here we&#8217;ll be using Firefox.  That&#8217;s because Firefox has some useful add-ons for web developers and because it is fast, safe, and very standards compliant.</p>
<p>If you like Safari, Chrome or even Opera, go ahead and use them for everything else, but for web development stick with Firefox because of its resources.</p>
<div class="shr-publisher-143"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/web_101/css/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Head and CSS</title>
		<link>http://flightschool.acylt.com/web_101/head-and-css/</link>
		<comments>http://flightschool.acylt.com/web_101/head-and-css/#comments</comments>
		<pubDate>Wed, 23 Dec 2009 05:27:07 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[Web101]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=145</guid>
		<description><![CDATA[Getting to Know the Head Part of HTML By now hopefully you&#8217;ve noticed that HTML documents are made up basically like this: &#60;html&#62; &#60;head&#62; &#60;/head&#62; &#60;body&#62; &#60;/body&#62; &#60;/html&#62; We&#8217;ve already said that if you want something to show up in the browser, you should put it inside the body tags.  Now we&#8217;re going to talk [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><h3>Getting to Know the Head Part of HTML</h3>
<p>By now hopefully you&#8217;ve noticed that HTML documents are made up basically like this:</p>
<p>&lt;html&gt;</p>
<div style="padding:0 0 0 25px;">&lt;head&gt;</p>
<p>&lt;/head&gt;</p></div>
<div style="padding:0 0 0 25px;">&lt;body&gt;</p>
<p>&lt;/body&gt;</p></div>
<p>&lt;/html&gt;</p>
<p>We&#8217;ve already said that if you want something to show up in the browser, you should put it inside the body tags.  Now we&#8217;re going to talk about the head tags.</p>
<p>The head tags are meant to contain information about the document and how it should show up, but not any of the actual text that will show up.  So, for example, in the index.html file I included (and you hopefully opened with dreamweaver at the end of the last chapter) you&#8217;ll notice at the top of each document, inside the head tags, there is a tag that looks like this:</p>
<p>&lt;title&gt;Home Page&lt;/title&gt;</p>
<p>If you go into Firefox and open that document up, you&#8217;ll notice in the top of the browser it says &#8216;Home Page&#8217; (I&#8217;ve underlined it in the example below).</p>
<p><a href="http://flightschool.acylt.com/wp-content/uploads/2009/12/title_example.jpg"><img class="alignnone size-full wp-image-146" title="title_example" src="http://flightschool.acylt.com/wp-content/uploads/2009/12/title_example.jpg" alt="" width="401" height="248" /></a></p>
<p>Notice that the title isn&#8217;t in the actually body.  Only what was written between the &lt;body&gt; tags shows up there.</p>
<div class="shr-publisher-145"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/web_101/head-and-css/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Internal/External Stylesheets</title>
		<link>http://flightschool.acylt.com/web_101/internalexternal-stylesheets/</link>
		<comments>http://flightschool.acylt.com/web_101/internalexternal-stylesheets/#comments</comments>
		<pubDate>Wed, 23 Dec 2009 05:33:53 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[Web101]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=150</guid>
		<description><![CDATA[Internal Style Sheet (CSS) The reason I bring all of this up is because that&#8217;s where we&#8217;re going to put the CSS. One way you can do that is to put in tags like this: &#60;html&#62; &#60;head&#62; &#60;style&#62; (CSS goes here) &#60;/style&#62; &#60;/head&#62; &#60;body&#62; &#60;/body&#62; &#60;/html&#62; But if we do it that way then if [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><h3>Internal Style Sheet (CSS)</h3>
<p>The reason I bring all of this up is because that&#8217;s where we&#8217;re going to put the CSS.</p>
<p>One way you can do that is to put in tags like this:</p>
<p>&lt;html&gt;</p>
<div style="padding:0 0 0 25px;">&lt;head&gt;</p>
<div style="padding:0 0 0 25px;"><strong>&lt;style&gt;</strong></p>
<div style="padding:0 0 0 25px;">(CSS goes here)</div>
<p><strong>&lt;/style&gt;</strong></div>
<p>&lt;/head&gt;</p></div>
<div style="padding:0 0 0 25px;">&lt;body&gt;</p>
<p>&lt;/body&gt;</p></div>
</div>
<p>&lt;/html&gt;</p>
<p>But if we do it that way then if we wanted to change how the main menu looked on each page, we&#8217;d have to go into the style on each page.  It would be so much better if we could just change it once, right?</p>
<h3>External Style Sheet (CSS the best way)</h3>
<p>You may have noticed in the example HTML files I gave you there&#8217;s a line like this:</p>
<p>&lt;link rel=&#8217;stylesheet&#8217; href=&#8217;style.css&#8217; type=&#8217;text/css&#8217; /&gt;</p>
<p>That line tells the browser that the CSS for the document is in its own file called style.css.  That way each page points to that one file, and if you change what the main menu looks like in that one file, it will change what it looks like on each page saving us all the time and effort of changing them one by one.</p>
<p>For more information on how that works go to <a href="http://www.w3schools.com/css/css_intro.asp" target="_blank">http://www.w3schools.com/css/css_intro.asp</a>.  Also for more information on the different Style Sheets go to <a href="http://www.w3schools.com/css/css_howto.asp" target="_blank">http://www.w3schools.com/css/css_howto.asp</a>.</p>
<div class="shr-publisher-150"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/web_101/internalexternal-stylesheets/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CSS Formatting and Selecting</title>
		<link>http://flightschool.acylt.com/web_101/css-formatting-and-selecting/</link>
		<comments>http://flightschool.acylt.com/web_101/css-formatting-and-selecting/#comments</comments>
		<pubDate>Wed, 23 Dec 2009 05:36:41 +0000</pubDate>
		<dc:creator>Ace</dc:creator>
				<category><![CDATA[Web101]]></category>

		<guid isPermaLink="false">http://flightschool.acylt.com/?p=154</guid>
		<description><![CDATA[Opening the style.css file you&#8217;ll see a the code I put there with its explanation.  If you want to look around feel free, but it will still seem pretty obscure until you read the next couple chapters.  For now you need to understand how CSS is formatted.  W3Schools explains it great here: http://www.w3schools.com/css/css_syntax.asp. As part [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>Opening the style.css file you&#8217;ll see a the code I put there with its explanation.  If you want to look around feel free, but it will still seem pretty obscure until you read the next couple chapters.  For now you need to understand how CSS is formatted.  W3Schools explains it great here: <a href="http://www.w3schools.com/css/css_syntax.asp">http://www.w3schools.com/css/css_syntax.asp</a>.</p>
<p>As part of that hopefully you noticed that we have a way in CSS to find classes and id.  Putting a period before the class name lets the code know we&#8217;re looking for a certain class ( .blue will find the class named blue, or everywhere in our HTML that we have a class=&#8217;blue&#8217;).  Putting a hash or pound sign before a name says we&#8217;re looking for a certain id ( #blue will find the id named blue, or everywhere in our HTML that we have an id=&#8217;blue&#8217;).</p>
<p>This is a <strong>very important concept</strong>, because lots of the styling we do with CSS is done by finding classes and ids in HTML and telling them how they should look.</p>
<p>You&#8217;ll notice too that you can find things by writing tag names.  For example, just having &#8216;a&#8217; written would select all of the anchor tags in the html (&lt;a href=&#8221;&gt;&lt;/a&gt;).</p>
<h3>Wrapup</h3>
<p>Now that you know where the style sheet goes and some basics of how it works, you&#8217;re ready to start making your page look like your design.  The next chapter will help you get everything the right size.</p>
<div class="shr-publisher-154"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://flightschool.acylt.com/web_101/css-formatting-and-selecting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

