<?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>Calvin Froedge</title>
	<atom:link href="http://www.calvinfroedge.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.calvinfroedge.com</link>
	<description>Stuff I think about and do</description>
	<lastBuildDate>Mon, 20 Feb 2012 06:15:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Ikigai by Sebastian Marshall &#8211; A Review</title>
		<link>http://www.calvinfroedge.com/ikigai-by-sebastian-marshall-a-review/</link>
		<comments>http://www.calvinfroedge.com/ikigai-by-sebastian-marshall-a-review/#comments</comments>
		<pubDate>Sun, 19 Feb 2012 18:13:17 +0000</pubDate>
		<dc:creator>Calvin Froedge</dc:creator>
				<category><![CDATA[Books]]></category>
		<category><![CDATA[Goals]]></category>
		<category><![CDATA[Health]]></category>
		<category><![CDATA[Philosophy]]></category>
		<category><![CDATA[Self Improvement]]></category>

		<guid isPermaLink="false">http://www.calvinfroedge.com/?p=232</guid>
		<description><![CDATA[I just finished up the book Ikigai (or rather, ordered collection of essays, email fragments and blog posts) by a guy named Sebastian Marshall.  Ikigai translates to &#8220;Reason for Living,&#8221; and Sebastian does a good job of putting together a case for what type of reasons one should live their life, and provides a general framework [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.amazon.com/gp/product/B006M9T8NI/ref=as_li_qf_sp_asin_tl?ie=UTF8&amp;tag=calvinfrcom-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=B006M9T8NI" target="_blank"><img class="alignleft" title="Ikigai" src="http://www.sebastianmarshall.com/wp-content/uploads/2012/01/ikigai-preview.png" alt="" width="300" height="250" /></a></p>
<p>I just finished up the book Ikigai (or rather, ordered collection of essays, email fragments and blog posts) by a guy named <a href="http://www.sebastianmarshall.com">Sebastian Marshall</a>.  Ikigai translates to &#8220;Reason for Living,&#8221; and Sebastian does a good job of putting together a case for what type of reasons one should live their life, and provides a general framework for doing it effectively.  The book constantly reminded me of work I&#8217;ve read by the Stoics (ie Marcus Aurelius, Cicero, and Epictetus).  I wouldn&#8217;t go so far as to put Sebastian&#8217;s work on an equal footing with Marcus Aurelius&#8217;<em> Meditations</em>, but it is good.</p>
<p>The book covers a lot of ground for being a short read.  I finished in a week of  reading one hour per day.  Among the topics discussed:</p>
<p>- Why it pays to study history.  He includes tons of historical examples of figures who made both strategic strokes of genius and blunders.</p>
<p>- Managing your life.  The importance of tracking things.  Sebastian contends that what gets measured gets  managed, so if you want to stop a bad habit or create a good one  you need to start by tracking how much you do it.</p>
<p>- The importance of constant learning and self enrichment.  Why you should pursue <em>all</em> of your interests (yet carefully schedule that pursuit, thus eliminating all but the most important).</p>
<p>- Settings goals and getting things done.</p>
<p>- Self control and self discipline.  How to build them.</p>
<p>- The low value of temporary happiness and the high value of producing great work.</p>
<p>- Why the &#8220;All you have to do is find your passion!&#8221; stuff is mostly bullshit &#8211; sure you can&#8217;t hate what you do but no one who achieves anything does it without doing things that are hard.  For example, I don&#8217;t enjoy every line of code I write, nor am I *always* enthused about studying new programming techniques.</p>
<p>The book is by no means perfect.  There are many sentence fragments, a few misspelled / cut off words, etc.  It was not proofed well.  It is not polished, and as something of an English language snob, at times it annoyed the hell out of me.  However, it is a great read.  It&#8217;s inspiring, funny, and you&#8217;ll definitely learn something.  At times I found myself saying &#8220;HELL YES&#8221; and pumping my fist.  I <em>rarely</em> do that while I&#8217;m reading.</p>
<p>If I had to produce one paragraph that aptly described Sebastian&#8217;s message, it would be this:</p>
<p>&#8220;You&#8217;re going to DIE some day.  Don&#8217;t waste your life  mucking around in mediocrity.  Don&#8217;t  compare yourself to peers in your own generation &#8211; compare yourself to the greatest in history.  Put yourself at the bottom of THAT mountain and start climbing.  On your journey upwards, take care of your body, constantly feed your mind, and be a Johnny Appleseed.  Help others when you can, and do not grant that help begrudgingly.  What are you waiting for, go out and <em>start doing things</em>.&#8221;</p>
<p><strong><a href="http://www.amazon.com/gp/product/B006M9T8NI/ref=as_li_qf_sp_asin_tl?ie=UTF8&amp;tag=calvinfrcom-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=B006M9T8NI">Check out reviews on Amazon</a></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.calvinfroedge.com/ikigai-by-sebastian-marshall-a-review/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>A !Quick Lesson in Operators</title>
		<link>http://www.calvinfroedge.com/a-not-quick-lesson-in-operators/</link>
		<comments>http://www.calvinfroedge.com/a-not-quick-lesson-in-operators/#comments</comments>
		<pubDate>Sun, 19 Feb 2012 10:51:44 +0000</pubDate>
		<dc:creator>Calvin Froedge</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.calvinfroedge.com/?p=220</guid>
		<description><![CDATA[Operators are one of the core components of any programming language. Knowing how they are classified and how they can be used is extremely important. This post might teach you some new operators. Since the samples are pulled from multiple languages, you may even learn something cool about a new language. Enjoy, and please point [...]]]></description>
			<content:encoded><![CDATA[<p>Operators are one of the core components of any programming language.  Knowing how they are classified and how they can be used is extremely important.  This post might teach you some new operators.  Since the samples are pulled from multiple languages, you may even learn something cool about a new language.  Enjoy, and please point out any mistakes. </p>
<p><strong>Arithmetic operators</strong></p>
<p>Ok, lets roll through these as fast as we can.  You know these, right?</p>
<p>+ for addition<br />
- for subtraction<br />
* for multiplication<br />
/ for division<br />
% for modulo (remainder after two numbers have been divided)</p>
<p>You can use each of these operators to work with numeric data types (examples in C &#8211; int, float, and double are all numeric data types):</p>
<pre class="cplusplus">//Addition
int x = 2 + 2; //4
int x = 2.0 + 2; //4;
float x = 2.0 + 2; //4.000000

//Subtraction
int x = 2 - 2; //0;
double x = 2.0 - 42; //-40

//Multiplication
int x = 2 * 2; //4

//Division
int x = 3 / 2; //1
double x = 3.0 / 2; //1.5
double x = 3 / 2; //1.000000 &lt;- Be careful with these!

//Modulo
int x = 5 % 4; //1
double x = 3.0 % 2; //Won't compile, actual sanity check here!</pre>
<p><strong>Relational (also called comparison) operators</strong></p>
<p>These operators are used to compare values.  In all languages they can compare numeric types.  In most languages they can compare strings and characters as well as simple datatypes (such as enums).  In some languages they can compare more complex data types such as vectors, arrays, and objects.</p>
<p>&gt;= greater than or equal to<br />
&gt; greater than<br />
&lt;&gt; not equal to (less than OR greater than)<br />
&lt;= less than or equal to<br />
&lt; less than<br />
!= not equal to<br />
== equal to<br />
=== equal and same type (PHP)</p>
<p>Python:</p>
<pre class="python">3 &gt;= 4 #False
4 &gt; 3 #True
"test" &lt;&gt; "test" #False
"apple" != "orange" #True
"3" == "3" #True</pre>
<p>PHP:</p>
<pre class="php">$arr = array();
$arr2 = array();
var_dump($arr == $arr2); // bool(true)

$obj = new StdClass;
$obj2 = new StdClass;
$obj-&gt;apple = 'test';
var_dump($obj == $obj2); //bool(false)

var_dump(3 === "3") //bool(false)</pre>
<p><strong>Logical operators</strong></p>
<p>&amp;&amp; and<br />
|| or<br />
! not</p>
<p><strong>Increment and decrement operators</strong></p>
<p>Pretty simple, like the arithmetic operators&#8230;</p>
<p>++var //Increment, equal to var + 1<br />
&#8211;var //Decrement, equal to var &#8211; 1<br />
+= //Add one number to another<br />
-= //Subtract one number to another</p>
<pre class="javascript">var i = 1;
++i; //2
--i; //1
i += 1; //2
i -= 1; //1</pre>
<p><strong>Assignment operators</strong></p>
<p>= //Assign a value<br />
+= //Compact assignment, addition, equal to x = x + y<br />
-= //Compact assignment, subtraction, equal to x = x &#8211; y<br />
*= //Compact assignment, multiplication, equal to x = x * y<br />
/= //Compact assignment, division, equal to x = x / y<br />
%= //Compact assignment, modulo, equal to x = x % y</p>
<p><strong>Bitwise operators</strong></p>
<p>&amp; //True if any is true.  Evaluates to last statement (meaning all conditions are checked).<br />
| //True if either is true.<br />
^ //True if only one is true.<br />
&lt;&lt; and &gt;&gt; // Left shift / right shift operators.  Perform shifts at binary level.</p>
<p>Note that &amp; and &amp;&amp; are different in that &amp;&amp; &#8220;short circuits&#8221; if one of the conditions it&#8217;s evaluating or false.  Consider the following example:</p>
<pre class="cplusplus">
#include "stdio.h"

int printSomething()
{
	printf("%s", "Something");
	return 1;
}

int main()
{
	int x = 3, y = 2;

	int a = (x > y &#038; y > 5 &#038; printSomething()); //"Something" is printed

	int b = (x > y &#038;&#038; y > 5 &#038;&#038; printSomething()); //"Something" is not printed.  &#038;&#038; operator short circuits and after y > 5 evaluates to false conditions stop being evaluated.

	printf("Example 1: %d \n \n", a);

	printf("Example 2: %d \n \n", b);

	return 0;
}
</pre>
<p>The | operator is the same as the &#038;, but does OR comparisons.</p>
<p>The ^ operator evaluates whether or not ONLY ONE of the conditions is true:</p>
<pre class="cplusplus">
#include "stdio.h"

int main()
{
	int x = 1, y = 2, z = 3;

	if(y > z ^ x > y ^ x > 0) printf("%s \n \n", "True!"); //Only one condition is true, statement evaluates to boolean true

	if(z > y ^ x > 0) printf("%s \n \n", "Also True!"); //Both conditions are true.  Statement evaluates to boolean false and "Also True!" is not printed

	return 0;
}
</pre>
<p>Shift operators work at the binary level.  Easy way to raise any multiple of 2 to the nth power:</p>
<pre class="cplusplus">
#include "stdio.h"

int main()
{
	int x, z, y = 2, a = 3, r;

	x = y << 2;  //Binary operation.  Bits are shifted two places to the left (001 becomes 100).  This evalutes to 8

	printf("%d \n \n", x);

	z = a << 2;  //Binary operation.  a starts as 011 and bits are shifted two spaces to the left.  a becomes 1100 (12)

	printf("%d \n \n", z);

	r = z >> 2;  //Binary operation.  r shifts z to spaces right.  r is 3.

	printf("%d \n \n", r);
}
</pre>
<p><strong>Ternary</strong></p>
<p>Seeing this freaked me out when I first started programming, but it&#8217;s actually really easy.</p>
<pre class="cplusplus">
#include "stdio.h"

int main()
{
	int x = 1, y = 2, a;

	a = (x > y) ? x : y; //IF x > y, a = x, ELSE, a = y

	printf("%d \n \n", a); //a is equal to y
}
</pre>
<p><strong>Other operator uses (strings, arrays, objects, etc.)</strong></p>
<p>. //Dot notation for concatenating strings, not to be confused with dot notation like calling a method in ruby or python<br />
+ //Used for concatenating strings.  In some languages more complex data types can be joined.<br />
+= //Add one string to another<br />
.= //Concatenate strings<br />
&amp;= //Reference assignment</p>
<p>PHP</p>
<pre class="php">$string = 'test';
$stringtwo = 'test2';
$concat = $string . '  ' . $stringtwo; // "test test2"

$concatTwo = '';
$concatTwo .= $string;
$concatTwo .= $stringtwo; //test test2

$ref &amp;= $string; //"test"</pre>
<p>JavaScript</p>
<pre class="javascript">var myString = 'test';
var mySecondString = 'test2';

var concat = myString + mySecondString; //value is testtest2</pre>
<p>Python uses the same concept:</p>
<pre class="python">test = "test"
maybe = "tester"

test + maybe # 'testtester'</pre>
<p>In PHP associative arrays can be joined with the + operator.  It&#8217;s not a good idea to add arrays with numeric keys because only one value will be retained:</p>
<pre class="php">$one = array('test');
$two = array('test2');

$three = $one + $two; //$three is now array('test');

$four = array('test' =&gt; 'tester');
$five = array('tester=&gt; 'tester2');

$six = $one + $two; //$six is array('test' =&gt; 'tester', 'tester' =&gt; 'tester2');</pre>
<p>At least in the languages I know a bit about, the -. *, % and / operators cannot be used on any non-integer types.</p>
<p>That&#8217;s all I got.  Hope you learned something!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.calvinfroedge.com/a-not-quick-lesson-in-operators/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The difference between a function-like macro and a function in C, C++</title>
		<link>http://www.calvinfroedge.com/the-difference-between-a-function-like-macro-and-a-function-in-c-cplusplus/</link>
		<comments>http://www.calvinfroedge.com/the-difference-between-a-function-like-macro-and-a-function-in-c-cplusplus/#comments</comments>
		<pubDate>Fri, 17 Feb 2012 06:44:37 +0000</pubDate>
		<dc:creator>Calvin Froedge</dc:creator>
				<category><![CDATA[C Programming Language]]></category>
		<category><![CDATA[C++]]></category>

		<guid isPermaLink="false">http://www.calvinfroedge.com/?p=207</guid>
		<description><![CDATA[I&#8217;ve been working my way through some of the open courseware computer science materials that MIT hosts. The past few nights, I&#8217;ve been reviewing the &#8220;Practical Programming in C&#8221; lecture notes and assignments. For the most part, the first few assignments were really easy for me &#8211; few new concepts. One bit that tripped me [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been working my way through some of the open courseware computer science materials that MIT hosts.  The past few nights, I&#8217;ve been reviewing the &#8220;Practical Programming in C&#8221; lecture notes and assignments.  For the most part, the first few assignments were really easy for me &#8211; few new concepts.</p>
<p>One bit that tripped me up were what looked like functions, but were actually macros (I later learned these are called macro-like functions).</p>
<p>Now, I know C is an ancient language and I&#8217;m sure this has been discussed thousands of times (or more) &#8211; but I still think it warrants a blog post.  So here is a macro-like function:</p>
<pre class="c">
#define squaredM(x) x*x
</pre>
<p>And here is a function:</p>
<pre class="c">
double squaredF(double x)
{
    return x*x;
}
</pre>
<p>Here is what looks like the same code calling functions that do the same things:<br />
double ans = 18.0 / squaredM(2+1);<br />
double ans = 18.0 / squaredF(2+1);</p>
<p>You might assume that both pieces of code would be handled the same way.  And you&#8217;d be wrong.  I did not assume that both pieces of code would be handled the same way, but I also made an incorrect assumption how a function-like macro worked (I did not already know).  The key difference is that a function-like macro is pre-processed and <em>then</em> compiled, while the function is compiled.  In plain english, that means that when you compile the program, the preprocessor essentially creates a new piece of code, with the macro substituted in, and then compiles:</p>
<p>double ans = 18.0 / 2+1*2+1;</p>
<p>Order of operations tells us that division / multiplication, left to right, should happen first.  So you actually end up with 9 + 2 + 1.</p>
<p>In the second example, using a function, 2+1 is already a float of 3.0 when it is received by squaredF.  This may not ever be useful to you, but I thought it was cool and wanted to share it.</p>
<p>References:<br />
<a href="http://en.wikipedia.org/wiki/C_preprocessor">Wikipedia (C Preprocessor) </a><br />
<a href="http://publib.boulder.ibm.com/infocenter/comphelp/v7v91/index.jsp?topic=%2Fcom.ibm.vacpp7a.doc%2Flanguage%2Fref%2Fclrc09cpxmac.htm">IBM AIX Compilers Reference</a><br />
<a href="http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-087-practical-programming-in-c-january-iap-2010/assignments/MIT6_087IAP10_assn01_sol.pdf">MIT Open Courseware Answers</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.calvinfroedge.com/the-difference-between-a-function-like-macro-and-a-function-in-c-cplusplus/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How Well Do You Understand &#8220;Static&#8221; Variables?</title>
		<link>http://www.calvinfroedge.com/how-well-do-you-understand-static-variables/</link>
		<comments>http://www.calvinfroedge.com/how-well-do-you-understand-static-variables/#comments</comments>
		<pubDate>Thu, 16 Feb 2012 19:29:39 +0000</pubDate>
		<dc:creator>Calvin Froedge</dc:creator>
				<category><![CDATA[Abstract]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software Design]]></category>

		<guid isPermaLink="false">http://www.calvinfroedge.com/?p=200</guid>
		<description><![CDATA[Today I realized that I did not completely understand the &#8220;static&#8221; keyword as it applies to variables, which is used in many programming languages. If you weren&#8217;t aware of the full breadth of how the static keyword alters a variable, this post should be a mind blower. So, let&#8217;s start simple. Take the following example [...]]]></description>
			<content:encoded><![CDATA[<p>Today I realized that I did not completely understand the &#8220;static&#8221; keyword as it applies to variables, which is used in many programming languages.  If you weren&#8217;t aware of the full breadth of how the static keyword alters a variable, this post should be a mind blower.</p>
<p>So, let&#8217;s start simple.  Take the following example (it&#8217;s in PHP, but you will find EXACTLY the same behavior in ANY language that uses the static keyword on variables &#8211; the concept itself is inherited from C):</p>
<pre class="php">
function test(){
	$test = 0;
	$test += 1;
	return $test;
}

echo test(); //1
echo test(); //1
echo test(); //1
</pre>
<p>What&#8217;s expected, right?  Ok, now throw a static in front of the declaration for $test</p>
<pre class="php">
function test(){
	static $test = 0;
	$test += 1;
	return $test;
}

echo test(); //1
echo test(); //2
echo test(); //3
</pre>
<p>Trippy, right?  When a variable is declared static, it&#8217;s stored in the program&#8217;s memory for the duration of the program&#8217;s runtime (translate for web devs: from the point the static var is created till the request has finished and the page is loaded).  In this case, $test is only available within the scope of the test() function, so it isn&#8217;t global, but within the scope which it was declared &#8211; it persists until the program ends.</p>
<p>Ok, now let&#8217;s look at how the same idea applies to classes:</p>
<pre class="php">
class StaticTest {

	public static $test;

	public function __construct()
	{
		self::$test = 'hello';
	}

	public static function getTest()
	{
		return self::$test;
	}

	public static function setTest()
	{
		self::$test = 'test';
	}

	public function __destruct()
	{
		echo "StaticTest class is dead \n";
	}
}

class Tester {
	public function __construct()
	{
		new StaticTest();
	}

	public function __destruct()
	{
		echo "Tester class is dead \n";
	}
}

new Tester();

echo StaticTest::$test . "\n \n";
</pre>
<p>The previous example may remind you of the Singleton pattern.  The important distinction to be made is that in this example, no instance of StaticTest exists when StaticTest::$test is called at the end of the program.  StaticTest is instantiated by Tester, sets a static variable, and then dies.  Tester is instantiated, and then dies.  The <em>static member</em> of StaticTest itself lives on, and is still available, regardless of whether the class instance which created it is alive or not.  Singletons are different because proper Singletons store their static properties privately.  Thus, if the Singleton was killed (which, I&#8217;ll grant you, presents it&#8217;s own set of challenges), it&#8217;s members would no longer be accessible, even though <em>they do still exist in memory</em>.</p>
<p>To sum up, a public, static property of a class is generally equivalent to a global property, and thus violates encapsulation.  Thus, their implementation within a class interface should be carefully considered.  A static variable within a function persists within it&#8217;s own scope for the duration of the program&#8217;s runtime.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.calvinfroedge.com/how-well-do-you-understand-static-variables/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Quick Introduction to the Observer Pattern</title>
		<link>http://www.calvinfroedge.com/quick-introduction-to-the-observer-pattern/</link>
		<comments>http://www.calvinfroedge.com/quick-introduction-to-the-observer-pattern/#comments</comments>
		<pubDate>Thu, 16 Feb 2012 06:23:26 +0000</pubDate>
		<dc:creator>Calvin Froedge</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software Design]]></category>

		<guid isPermaLink="false">http://www.calvinfroedge.com/?p=193</guid>
		<description><![CDATA[A continuation in my self-assigned crash course in design patterns, I&#8217;ve been learning more about the observer pattern recently. It&#8217;s a cool pattern, and I&#8217;m hoping I can convince some of you that it&#8217;s worth learning more about. I only have time for a quick post, and hopefully I can get in the major points [...]]]></description>
			<content:encoded><![CDATA[<p>A continuation in my self-assigned crash course in design patterns, I&#8217;ve been learning more about the observer pattern recently.  It&#8217;s a cool pattern, and I&#8217;m hoping I can convince some of you that it&#8217;s worth learning more about.  I only have time for a quick post, and hopefully I can get in the major points &#8211; but I WILL follow up on this with some example implementations.</p>
<p><strong>High Level Overview</strong></p>
<p>The observer pattern does exactly what it sounds like it should do &#8211; it allows one class to observe the changes made in another.  Essentially, you have a class or set of classes (the subject), that inherit an abstract interface which will dictate the methods that they must implement in order to provide updates to their observer(s).  The subjects don&#8217;t actually do the talking to their observers directly; there is always a layer of abstraction to ensure the subjects and observers are decoupled.</p>
<p>Coming from a web programming background, it may not be immediately apparent why the observer pattern is especially useful.  This is because (in my opinion) web programs (with some exceptions) tend to have a very short runtime (meaning their execution starts when you load a page and concludes when the page finishes loading).  So, even though we use the observer pattern in web programming (MVC springs to mind), I don&#8217;t think it&#8217;s <em>usefulness and role</em> are as readily apparent as in other contexts.  In programs which are &#8220;on&#8221; until they are intentionally shut down (ie programs that run on an event loop, main loop, etc.), the importance of this pattern is much more obvious.</p>
<p><strong>Here are some real world examples:</strong></p>
<p>- The observer pattern forms the basis for how many GUI frameworks operate.  It was first introduced in the SmallTalk language, which had an extremely strong influence on Apple and the evolution of their Objective C language.   Many of the programs you use every day implement the observer pattern.  Qt framework (c++), a GUI framework developed by Nokia, implements the observer pattern for Signal and Slot events &#8211; ie so your program knows when a button is pushed and can hook that update to the appropriate class / method.  Java likewise implements a very similar signals / slots mechanism.<br />
- Your web browser implements the observer pattern.  You know that thing the DOM?  Event listeners?  onSomething(doThis)?  Yea.<br />
- Your cell phone implements the observer pattern.  Your phone is always sitting there&#8230;waiting&#8230;just waiting for the network to tell it there is an inbound call.</p>
<p>&#8230;There are tons of other real world examples.  At it&#8217;s core, the observer pattern is just a standardized way of separating cause and effect to reduce dependencies within a system.  I hope this has been a decent beginner&#8217;s introduction!</p>
<p><strong>Resources (best I&#8217;ve found)</strong></p>
<p>Source Making: <a href="http://sourcemaking.com/design_patterns/observer">http://sourcemaking.com/design_patterns/observer</a><br />
IBM Research: <a href="http://www.research.ibm.com/designpatterns/example.htm">http://www.research.ibm.com/designpatterns/example.htm</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.calvinfroedge.com/quick-introduction-to-the-observer-pattern/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Understanding Singletons</title>
		<link>http://www.calvinfroedge.com/understanding-singletons/</link>
		<comments>http://www.calvinfroedge.com/understanding-singletons/#comments</comments>
		<pubDate>Wed, 08 Feb 2012 02:35:09 +0000</pubDate>
		<dc:creator>Calvin Froedge</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.calvinfroedge.com/?p=170</guid>
		<description><![CDATA[Why ANOTHER article about Singletons? If you search for &#8216;Singleton&#8217; in Google or StackOverflow you get a bajillion and a half results.  That makes sense, because it&#8217;s one of the most commonly implemented design patterns in the history of software.  Some reasons for the popularity of the Singleton are: A.  It makes more intuitive sense [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Why ANOTHER article about Singletons?</strong></p>
<p>If you search for &#8216;Singleton&#8217; in Google or StackOverflow you get a bajillion and a half results.  That makes sense, because it&#8217;s one of the most commonly implemented design patterns in the history of software.  Some reasons for the popularity of the Singleton are:</p>
<p>A.  It makes more intuitive sense to store things you want global access to in well-defined groupings, instead of having a bunch of globally namespaced functions, constants and variables you need to keep track of (read more about <a href="http://en.wikipedia.org/wiki/Namespace_(computer_science)">namespacing</a> here).</p>
<p>B.  They are incredibly easy to implement.</p>
<p>Stick with me, by the end of this post you&#8217;ll have a much better understanding of the Singleton, and links to some other great reference materials.</p>
<p><strong>So what are Singletons, exactly?</strong></p>
<p>As you may know, computer science inherits a great many ideas from mathematics, and if you want to become a better programmer &#8211; and hope to someday call yourself a computer <em>scientist</em>, you must understand the mathematical foundations on which computer science has been built.  Fortunately, most of the concepts are pretty easy, including the Singleton.</p>
<p>A Singleton, as defined mathematically, is a set (a set could be similarly described as an array, linked list, vector, etc.) which has a <a href="http://en.wikipedia.org/wiki/Cardinality">cardinality</a> of 1, meaning it only contains a single <a href="http://en.wikipedia.org/wiki/Tuple">tuple</a>, and that it cannot be subject to injective functions.  In plain English, this means that a set is only a Singleton if it:</p>
<p>A.  Only has one root level element.</p>
<p>B.  Has no siblings.</p>
<p>C.  Can not be cloned.</p>
<p>If it does not meet these requirements, it is not a Singleton.</p>
<p>As programmers, we commonly associate Singletons with single class instances (single objects), but they could also be other data types as well.  For example, some languages, such as Delphi, C# and Charm++, allow for read-only arrays, while C++ allows you to declare arrays and vectors as constant.  I&#8217;m sure there are many other examples.  I believe (though someone may correct me on this) &#8211; that those would also qualify as Singletons using the mathematical definition &#8211; provided they meet the aforementioned requirements.</p>
<p><strong>Common uses of Singletons</strong></p>
<p>Singletons are usually used by programmers when they want a class instance that is truly global &#8211; meaning that various classes and functions can perform operations on the instance, and see the changes the others make, without the need to pass a reference to that class around.</p>
<p>A. Logging: As opposed to procedural functions in the global namespace, &#8220;Logger&#8221; classes are commonly implemented as Singletons.</p>
<p>B.  Truly global classes: For example, keeping state.  Session and authentication management come to mind.</p>
<p>C.  Database instances: Singletons can in some cases reduce memory usage in your application because a single connection point to the database is established; a new instance is not created each time a query is made.</p>
<p>I&#8217;d love to hear some of the ways which you have implemented Singletons with satisfaction.</p>
<p><strong>Criticisms</strong></p>
<p>But what is a pattern if not also a suspected anti-pattern?  Singletons, despite their heavy usage, certainly have a fair amount of haters out there.  Some of these criticisms are simply FUD (fear, uncertainty and doubt) being passed from programmer to programmer like gonnorhea in a co-ed dorm; however, some are valid, and certainly need to be factored into design decisions.</p>
<p>A.  It&#8217;s hard to destroy a Singleton, and mishandling can cause very subtle and perhaps disastrous results.  Say, for example, that you want your program to destruct (shut down) in a very specific way.  You can&#8217;t really have a class destruct the Singleton, because hey, if the only class that can MAKE a Singleton is the Singleton itself, why should another class be able to destroy it?  And what happens if the class that destroys it kills it before another class, also dependent on the Singleton, can use data it depends on?  This rules out having other classes destroy Singletons.  So how about self destruction?  Well, depending on the language, compiler, and other variables, you may not have any control over what order objects are destroyed in.  When you only have one Singleton, this probably won&#8217;t cause an issue, but if you have many Singletons, each of which may depend on the data of the other, you may create the same problem faced in the previous example &#8211; you have dangling references to things that don&#8217;t exist anymore.  Not good!</p>
<p>This barely scratches the surface of this topic, for more I&#8217;d check out <a href="http://www.research.ibm.com/designpatterns/pubs/ph-jun96.txt">this article</a> by John Vlissides, one of the original &#8220;Gang of Four&#8221; members, who spent most of his career as a researcher at IBM.</p>
<p>B.  Singletons can make testing, reuse and debugging painful.  Remember, since there is only one instance of a Singleton, if one class makes a change to a Singleton member &#8211; all other classes that use that data are now using that updated value.  Misko Hevery has written an amusing post on this topic <a href="http://misko.hevery.com/2008/08/17/singletons-are-pathological-liars/">here</a> titled &#8220;Singletons are Pathological Liars.&#8221;</p>
<p>C.  Inheritance.  By definition, singletons cannot be used as base classes (ie child Extends Singleton).  However, some languages (such as C#) which support nested types.  Check out <a href="http://msmvps.com/blogs/jon_skeet/archive/2006/01/20/singleton-inheritance.aspx">this post</a> by John Skeet, a prominent C# developer and the author of &#8220;C# In Depth&#8221;, for more info on that.</p>
<p><strong>Singletons and multithreading</strong></p>
<p>Threads are spawned within the process created when a programming runs.  Multithreading allows a program to essentially &#8220;splinter off&#8221; and go in multiple directions simultaneously.   Concurrency problems occur when these threads are accessing shared resources and happen to collide.  One of the most intriguing bits I&#8217;ve read about Singletons was <a href="http://www.oaklib.org/docs/oak/singleton.html">written by Vishal Kochhar</a>.  He explains why the standard approach to Singletons is not threadsafe, and how <a href="http://en.wikipedia.org/wiki/Mutual_exclusion">mutual exclusion</a> (a concept introduced by the late <a href="http://en.wikipedia.org/wiki/Edsger_W._Dijkstra">Edsger Djikstra</a>, the Dutch computer scientist  who also gave us the modern pathfinding algorithm) can be implemented in C++ classes to ensure thread safety.  The article delves into many cool things &#8211; and I highly suggest you check it out.</p>
<p>Most scripting languages tell you that you need not worry about thread safety &#8211; that the language designers have ensured it &#8211; but if I was working on code that depended on thread safety, and was using Singletons, I&#8217;d probably double check.  You need not worry about this in languages that do not use threads (such as JavaScript, unless you are using <a href="https://developer.mozilla.org/En/Using_web_workers">Web Workers  &#8211; which DO in fact spawn threads</a>).</p>
<p><strong>Implementation in three languages</strong></p>
<p>I implemented a Singleton class in 3 languages for fun and learning.</p>
<p>C++</p>
<pre class="cplusplus">
#include &lt;iostream&gt;
#include &lt;thread.h&gt;

using namespace std;

class Singleton
{
	public:
		static int val_;
		static Singleton* instance() {
			if( val_ == 0 ) {
				//lock_mutex();
				if(p_instance == 0)
					new Singleton;
				//unlock_mutex();
				//MEMORY_BARRIER();
				val_ = 1;
				return p_instance;
			}
			else {
				return p_instance;
			}
		}

		void setMember(string&#038; newState) {
			m_member = newState;
		}

		string getMember() {
			return m_member;
		}

	private:
		Singleton(){}

		static Singleton* p_instance;

		string m_member;
};

Singleton* Singleton::p_instance = 0;

int main()
{
	string newState = "active";
	Singleton::instance()->setMember(newState);
	cout << "Member has been set to:" << Singleton::instance()->getMember() << "\n";
	return 0;
}
</pre>
<p>Please note that the ideas for mutual exclusion were taken from <a href="http://www.oaklib.org/docs/oak/singleton.html">the article written by Vishal Kochhar</a>, which I have referenced.</p>
<p>JavaScript</p>
<pre class="javascript">
var Singleton = (function()
{
	var instance = false;

	/*
	* Because this is in a closure, it cannot be accessed
	*/
	var member = 'test';

	function Constructor(){

		this.getMember = function(){
			return member;
		}

		this.setMember = function(v){
			member = v;
		}

	}

	/*
	* This is what's actually returned by the closure
	*/
	return new function(){

		this.getInstance = function() {	

			/*
			* Private member functions are accessible once the constructor has been called
			*/
			if(instance == false){
				instance = new Constructor();
				instance.constructor = null;
			}

			return instance;
		}

	}

}
)();

//print(Singleton.getInstance().getRand());
Singleton.getInstance().setMember('whatuppppp');

print(Singleton.getInstance().getMember());
</pre>
<p>Please note that this JavaScript implementation is almost certainly not a "real" singleton - it can be copied and passed around.</p>
<p>PHP</p>
<pre class="php">

//Shows how a singleton can be used to keep state for the duration of a request
class Singleton
{
	private static $instance = 0;

	private static $member = null;

	/*
	 * Private constructor prevents object initialization ith new keyword
	*/
	private function __construct(){}

	/*
	 * Creates an instance - accesed statically since constructor is private
	*/
	public static function instance(){
		if(self::$instance)
		{
			return self::$instance;
		}

		//Return a new instance if one does not exist
		return new Singleton;
	}

	public function setMember($v){
		self::$member = $v;
	}

	public function getMember(){
		return self::$member;
	}

	/*
	 * Prevents cloning (ie copying the instance or using the clone keyword)
	*/
	public function __clone(){
		trigger_error('Singleton instance cannot be cloned.', E_USER_ERROR);
	}

	/*
	 * Prevents Unserializing of Object
	*/
	public function __wakeup(){
		trigger_error('Singleton instance cannot be unserialized.', E_USER_ERROR);
	}
}

class A
{
	public function __construct(){
		Singleton::instance()->setMember('active');
	}

	public function __toString(){
		return Singleton::instance()->getMember();
	}
}

class B
{
	public function __construct(){
	}

	public function __toString(){
		return Singleton::instance()->getMember();
	}
}

//Class A sets the member's value to 'active'
$a = new A;
echo "Member after being set by class A: $a \n \n";

//Class B simply returns the member value set by class A
$b = new B;
echo "Member after being returned by class B: $b \n \n";
</pre>
<p><strong>Conclusion</strong></p>
<p>Singletons are a popular pattern with both benefits and challenges associated with them.  If you want to make use of this powerful pattern, ignore anyone who treats them as artifacts in a religious war and focus on understanding what they are, why and how they can be used.</p>
<p><strong>Disclaimer</strong></p>
<p>This post is essentially self-assigned homework.  I've written it to increase my own understanding of Singletons, their uses, limitations and theoretical underpinnings.  I hope this has helped you, but also hope you verify any assumptions I may have made, and point out any mistakes.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.calvinfroedge.com/understanding-singletons/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Add support for dbase in php 5.3.8</title>
		<link>http://www.calvinfroedge.com/add-support-for-dbase-in-php-5-3-8/</link>
		<comments>http://www.calvinfroedge.com/add-support-for-dbase-in-php-5-3-8/#comments</comments>
		<pubDate>Wed, 14 Dec 2011 14:04:58 +0000</pubDate>
		<dc:creator>Calvin Froedge</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.calvinfroedge.com/?p=159</guid>
		<description><![CDATA[PHP&#8217;s dbase extension allows you to work with .dbf files in PHP. After php 5.2, you can no longer compile php with dbase support, so here&#8217;s how you can add it to your php installation: 1. Download dbase: http://pecl.php.net/get/dbase 2. Extract and cd into. 3. sudo phpize 4. sudo ./configure &#038;&#038; sudo make &#038;&#038; sudo [...]]]></description>
			<content:encoded><![CDATA[<p>PHP&#8217;s dbase extension allows you to work with .dbf files in PHP.  After php 5.2, you can no longer compile php with dbase support, so here&#8217;s how you can add it to your php installation:</p>
<p>1.  Download dbase: http://pecl.php.net/get/dbase</p>
<p>2.  Extract and cd into.  </p>
<p>3.  sudo phpize</p>
<p>4.  sudo ./configure &#038;&#038; sudo make &#038;&#038; sudo make install</p>
<p>5.  Add extension=dbase.so to your php config and restart apache.</p>
<p>Done!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.calvinfroedge.com/add-support-for-dbase-in-php-5-3-8/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tackling the Linux Network for Small Business – Part 2 – Hardware and Topology</title>
		<link>http://www.calvinfroedge.com/tackling-the-linux-network-for-small-business-%e2%80%93-part-2-%e2%80%93-hardware-and-topology/</link>
		<comments>http://www.calvinfroedge.com/tackling-the-linux-network-for-small-business-%e2%80%93-part-2-%e2%80%93-hardware-and-topology/#comments</comments>
		<pubDate>Fri, 02 Dec 2011 07:11:32 +0000</pubDate>
		<dc:creator>Calvin Froedge</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Networking]]></category>

		<guid isPermaLink="false">http://www.calvinfroedge.com/?p=154</guid>
		<description><![CDATA[Believe it or not, this is the easy part. There aren&#8217;t that many physical components that make up a small business network, and acquiring all of them should be both easy and fast. First, let&#8217;s start with a diagram (click to enlarge), and we&#8217;ll drill into each piece in more detail. So, basically your internet [...]]]></description>
			<content:encoded><![CDATA[<p>Believe it or not, this is the easy part.  There aren&#8217;t that many physical components that make up a small business network, and acquiring all of them should be both easy and fast.  First, let&#8217;s start with a diagram (click to enlarge), and we&#8217;ll drill into each piece in more detail.</p>
<p><a href="http://www.calvinfroedge.com/wp-content/uploads/2011/12/network_topology.png"><img src="http://www.calvinfroedge.com/wp-content/uploads/2011/12/network_topology.png" alt="small business linux network" title="network_topology" width="1152" height="733" class="alignleft size-full wp-image-155" /></a></p>
<p>So, basically your internet service provider (ISP) is going to give you a public IP address so that you can connect to the internet.  Typically, an ISP will only assign you one IP.  The internet is essentially just one huge network, and having an IP allows you to be in that network. </p>
<h3>Yea, dude, you&#8217;re gonna need a firewall</h3>
<p>Go to whatismyip.com and get your IP address.  Copy and paste that IP address into your browser and see what you get.  If you&#8217;re using a standard router, or are directly connected to the internet and are running a web host on your computer, you&#8217;ll see either your router&#8217;s login page or whatever content your computer publishes on port 80.  The ramifications of your computer / server having an IP on the internet are that <strong>other computers can see you, just like you can see them</strong>.  All those websites out there are just other computers (or clusters of computers).</p>
<p>A firewall is a device (either physical or virtual) that protects your computer / server from outside intrusion by filtering out what connections can be established.  At the simplest level, this is done by opening and closing ports, and by deciding which IP ranges you will allow connections from.  A good firewall setup will typically only allow connections on the ports that seem to have a good reason for being open.  Some examples:</p>
<ul>
<li>Port 80 allows HTTP connections.  This is how you browse the web</li>
<li>Port 443 allows HTTPS connections.  This is how you checkout securely in a website payment process</li>
<li>Ports 22 and 21 allow for SSH and FTP, respectively, two ways of interacting with other computers (the former being total access, the second being file server access)</li>
</ul>
<p>There are thousands of ports on a computer, many of them for unique processes you&#8217;ve never even heard of, some of them ready for you to assign a purpose to them.  All of these ports give attackers MANY doorways to enter your network.  Best practice is to only allow connection on the ports you need.  Ports 80, 443, 22 and 21 would be pretty standard.</p>
<p>If you aren&#8217;t running a firewall &#8211; you are wide open.  Once I get your IP address (and I could do that by scraping IPs from forums, or hell, even using nmap to try certain ranges and see who I can ping), if you aren&#8217;t running SOME type of firewall, I can own your bases.  So make sure you include one in your network.</p>
<h3>What your server does</h3>
<p>Your server is probably the most important piece of your network.  Beside the fact that it will be running all kind of software that your users need, it performs some very important functions just in keeping the network online.  For example, your server can:</p>
<ul>
<li>Assign IP addresses to other machines on the network</li>
<li>Share an internet connection and speed up your internet by circumventing your ISP&#8217;s DNS</li>
<li>Provide an authentication mechanism for other machines on the network to use</li>
<li>Facilitate cross-platform file and printer sharing</li>
<li>Provide shared software to use across the network</li>
</ul>
<h3>Building your server</h3>
<p>The great thing about Linux, derived from UNIX, is that it can run and perform fairly well on just about any hardware (<a href="http://www.kernelthread.com/publications/gbaunix/">you can even run UNIX on a gameboy, though I don&#8217;t recommend it here = )</a>).  You&#8217;ll be building what essentially boils down to a computer.  Here&#8217;s what you&#8217;ll need:</p>
<ul>
<li>A motherboard</li>
<li>A processor, heatsink and fan (the heatsink and fan that come with processors usually suck)</li>
<li>RAM</li>
<li>A hard drive</li>
<li>A motherboard</li>
<li>At least 2 ethernet devices</li>
<li>A case (housing) for all of this to sit in)</li>
</ul>
<p>Once you get all the gear, assembly is pretty easy, and is <a href="http://www.youtube.com/watch?v=pKesSrGp2Eg">well documented elsewhere</a>.  The main thing to ensure is that everything is compatible with everything else.  For example, your motherboard will support a specific chipset, so you need to choose either a motherboard or a processor and then getting a matching component.  RAM types supported and the size of your hard drive (the physical dimensions, ie 3.5 inch or 2.5 inch) can vary too, so just make sure everything matches up.</p>
<p>Don&#8217;t feel like you need a CD drive to install the OS.  You can easily <a href="https://help.ubuntu.com/community/Installation/FromUSBStick">load your OS from a USB drive</a> or <a href="https://help.ubuntu.com/community/Installation/Netboot">from the network</a>.</p>
<h3>Keep a backup!</h3>
<p>Obviously, your server is your network&#8217;s lynchpin &#8211; and if it goes down it is really bad news&#8230;so make sure you have a backup.  Lightning, hacking, or random hardware failure &#8211; you have to be prepared for it all.</p>
<p>I recommend building a secondary, much cheaper machine that you can quickly replace the more powerful version with if you absolutely have to.  You&#8217;ll want to keep a daily backup of your main server so you can easily load the image onto your backup system.</p>
<h3>The 802.1x switch</h3>
<p>I didn&#8217;t know about this either, and when I asked about RADIUS server on ServerFault, I got flogged by experienced server admins for not knowing.  802.1x is a protocol developed specifically for handling network authentication.  You can read a <a href="http://www.interlinknetworks.com/whitepapers/Intro_802_1X_for_Wireless_LAN.htm">really good 802.1x overview here</a>.</p>
<p>Unfortunately, not all networking devices support 802.1x, so you need to get one that does support it.  Managed 802.1x switches start at a few hundred dollars and can get really expensive.  I bought a ZyXel GS2200-24 and am really happy with it so far.</p>
<p>You&#8217;ll need to read your switch&#8217;s manual as it relates to creating LANs, enabling AAA / radius (802.1x), and port authentication just to get a basic setup rolling, but it should be too tough.</p>
<h3>The patch panel</h3>
<p>This is just a way to keep from looking at a nasty nest of jumbled wires going into your switch.  Basically, you wire cables directly to the back of your patch panel (instead of using an RJ45 and plugging them in).  Then, you run a short cable (under 6 inches) from the patch panel to the switch, and you label each port on the patch panel.  This makes it really easy to keep track of where each wire goes, and to enable easier termination and troubleshooting.</p>
<p>This does mean a lot of extra wiring work, but it should be worth it.</p>
<h3>802.1x Wi-Fi</h3>
<p>With 802.1x enabled Wi-Fi, you&#8217;ll be super secure as long as you don&#8217;t transmit passwords in clear text.  Get a wireless router which supports 802.1x and deploy where you need a signal.</p>
<h3>The LAN</h3>
<p>All the other machines that will connect to your networked components.  Depending on the size and complexity of your network, you could have other servers, patch panels and switches at other points in your network.  Imagine that this part can be very simple (just a few computers) or very complex (many switches, many wireless access points, and other servers which perform various functions).</p>
<h3>Summary</h3>
<p>I hope this gives you a good introduction to the physical components of the small business network I&#8217;ll be walking you through.  Please feel free to ask me any questions you might have!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.calvinfroedge.com/tackling-the-linux-network-for-small-business-%e2%80%93-part-2-%e2%80%93-hardware-and-topology/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tackling the Linux Network for Small Business &#8211; Part 1 &#8211; Goals &amp; Overview</title>
		<link>http://www.calvinfroedge.com/tackling-the-linux-network-for-small-business-part-1-goals-overview/</link>
		<comments>http://www.calvinfroedge.com/tackling-the-linux-network-for-small-business-part-1-goals-overview/#comments</comments>
		<pubDate>Thu, 01 Dec 2011 05:22:39 +0000</pubDate>
		<dc:creator>Calvin Froedge</dc:creator>
				<category><![CDATA[Networking]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.calvinfroedge.com/?p=143</guid>
		<description><![CDATA[I&#8217;ve been working on a Linux driven network for my family&#8217;s small business, Froedge Machine. It&#8217;s been an awesome, engrossing experience so far working on this &#8211; and the farther I delve the more I realize just how approachable this type of project is. I&#8217;m far along enough in the project now that I can [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been working on a Linux driven network for my family&#8217;s small business, <a href="http://www.froedge.com">Froedge Machine</a>.  It&#8217;s been an awesome, engrossing experience so far working on this &#8211; and the farther I delve the more I realize just how approachable this type of project is.  I&#8217;m far along enough in the project now that I can see the light at the end of the tunnel and am confident enough to start teaching others how to do this &#8211; because it&#8217;s really, really, insanely cool.  So without further delay, here were my goals in approaching the project:</p>
<p>- User authentication required across the network<br />
- Proxy / captive portal<br />
- Varying permissions / workgroups<br />
- Software running in an intranet &#8211; not on the cloud (everything from accounting to project management, to timecard entry, to security systems), and accessible via VPN and in some cases web services<br />
- Automated backups, storage and system updates</p>
<p>The first thing I did was hire another network admin to just come in and talk to me for a few hours.  He was more of a hardware focused guy, which was fine, because I had no idea on even basic things &#8211; like the difference between a switch and a hub (basically that a hub &#8220;floods&#8221; traffic while a switch routes it intelligently <a href="http://www.duxcw.com/faq/network/hubsw.htm">more detail</a>), or <a href="http://www.youtube.com/watch?v=0S6cjJS5y1I">how to put an RJ45 on a Cat5e cable</a>.  I spent some time checking out <a href="http://www.ratemynetworkdiagram.com/index2.php">Rate My Network Diagram</a> to see some examples of large and small networks, and the physical and virtual components that compose them.</p>
<p>On the software side, I knew I wanted to run Ubuntu Server as our central server, despite the advice of many seasoned network admins on ServerFault who advised &#8220;Just use windows server, man, it&#8217;s a rock, and everything will just work (as a disclaimer, my experience with Microsoft products is it usually <em>does</em> just work, however klunkily).&#8221;  </p>
<p>My rational for going with Ubuntu was:</p>
<ul>
<li>I already knew Ubuntu fairly well, as I&#8217;d been running it for web servers (and doing all the configuration myself) for a couple of years.</li>
<li>Open source means <strong>I can make it do whatever I want</strong></li>
<li>In the future, clients will be increasingly cross platform (ie I don&#8217;t think we&#8217;ll be running all PCs in 10 years &#8211; several people are using Ipads at work, a few run Linux at home, I use a macbook, and a lot of machines and devices that we could plug into the network run on Unix)</li>
<li>Ubuntu is crazily well supported.</li>
<li>Did I say <strong>I can make it do whatever I want it to?</strong></li>
<li>The internet (the biggest network I know of) runs on UNIX</li>
</ul>
<p>Since choosing a platform and defining some goals, I&#8217;ve accomplished quite a bit.  So far I:<br />
1.  Ordered / assembled of my hardware<br />
2.  Got Ubuntu Server running on the machine<br />
3.  Configured my managed switch<br />
4.  Set up a DHCP server<br />
5.  Configured 802.1x authentication via RADIUS and got it working on Mac, Linux &#038; Windows clients<br />
6.  Got internet connection sharing working<br />
7.  Set up a DNS cache / server</p>
<p>I&#8217;ve got a lot left to tackle, but I&#8217;m encouraged by the progress I&#8217;ve made so far.  One of the toughest parts about this project has been the lack of information that brings all of the pieces together in context, yet also drills into detail on the implementation.  I&#8217;d like to dedicate some time to writing a series of posts which drill into each piece of this project &#8211; hardware, networking and software.  Hopefully, it will save some time for someone else out there who wants to tackle this kind of project.</p>
<p>The first post will be about hardware &#8211; illustrating the physical pieces that go into a computing network and the pieces that they play, and providing some recommendations on what you can get started with.  Stay tuned!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.calvinfroedge.com/tackling-the-linux-network-for-small-business-part-1-goals-overview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PCI Compliance Step 5 &#8211; Adding Automated Virus Scanning to Your Ubuntu Server</title>
		<link>http://www.calvinfroedge.com/pci-compliance-step-5-adding-automated-virus-scanning-to-your-ubuntu-server/</link>
		<comments>http://www.calvinfroedge.com/pci-compliance-step-5-adding-automated-virus-scanning-to-your-ubuntu-server/#comments</comments>
		<pubDate>Tue, 01 Nov 2011 22:11:33 +0000</pubDate>
		<dc:creator>Calvin Froedge</dc:creator>
				<category><![CDATA[PCI Compliance]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.calvinfroedge.com/?p=141</guid>
		<description><![CDATA[Number 5 of the 12 PCI compliance steps in the SAQ D is to &#8220;Use and regularly update anti-virus software or programs.&#8221; We all know that this *really* isn&#8217;t needed &#8211; but it&#8217;s in the PCI compliance requirements &#8211; so here&#8217;s an easy way to do it. Install ClamAV: sudo apt-get install clamav And then [...]]]></description>
			<content:encoded><![CDATA[<p>Number 5 of the 12 PCI compliance steps in the SAQ D is to &#8220;Use and regularly update anti-virus software or programs.&#8221;  We all know that this *really* isn&#8217;t needed &#8211; but it&#8217;s in the PCI compliance requirements &#8211; so here&#8217;s an easy way to do it.</p>
<p>Install ClamAV:</p>
<p>sudo apt-get install clamav</p>
<p>And then create a simple bash script that will run clam and send you an email with a summary of the scan:</p>
<p>#! /bin/bash<br />
sudo clamscan -i -r / | sendmail calvinfroedge@gmail.com</p>
<p>The -i flag tells clam you only want to know which files are infected (if any), the -r is to recurse into directories.  The pipe then sendmail is to put the output from the clamscan into an email and send it to you.</p>
<p>I&#8217;m using SendGrid as my email provider, and it&#8217;s easy as hell to integrate with Postfix.  Here&#8217;s how: </p>
<p><a href="http://docs.sendgrid.com/documentation/get-started/integrate/examples/postfix/">http://docs.sendgrid.com/documentation/get-started/integrate/examples/postfix/</a></p>
<p>Finally, schedule this to happen each day (or whatever).  Put this in your contab (sudo crontab -e):</p>
<p>01 04 * * * /bin/viruscheck</p>
<p>And that&#8217;s it!  You&#8217;ve just fulfilled step 5 of PCI compliance = )</p>
]]></content:encoded>
			<wfw:commentRss>http://www.calvinfroedge.com/pci-compliance-step-5-adding-automated-virus-scanning-to-your-ubuntu-server/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

