<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">
  <title>mokhan.ca</title>
  <link rel="alternate" type="text/html" href="http://mokhan.ca/" />
  
  <id>http://mokhan.ca/</id>
  <updated>2012-01-25T20:57:04-07:00</updated>
  <subtitle>a journal about code and my experiments with truth, trust, and honesty</subtitle>
  <author>
    <name>mo khan</name>
    <uri>http://mokhan.ca</uri>
    <email>email@mokhan.ca</email>
  </author>
  
  <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/mokhan" /><feedburner:info uri="mokhan" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><entry>
    <title>osx</title>
    <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/mokhan/~3/QwvOm2LsJDU/osx.html" />
    <id>http://mokhan.ca/tools/2011/09/11/osx</id>
    <updated>2011-09-11T00:00:00-06:00</updated>
    <content type="html" xml:lang="en" xml:base="http://mokhan.ca/">
      &lt;p&gt;My mac book pro arrived on Monday and since then I've spent most of my time trying to figure out
some settings that I consider to be basic.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;mapping capslock to escape&lt;/li&gt;
&lt;li&gt;swap fn and ctrl&lt;/li&gt;
&lt;li&gt;keyboard shortcut to maximize a window&lt;/li&gt;
&lt;li&gt;keyboard to active/deactive fullscreen&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;mapping caps lock to escape&lt;/h2&gt;

&lt;p&gt;I can't believe how difficult this is. In ubuntu this is a simple keyboard setting, but sadly on OSX
I had to install some thirdparty software to do this. The tools i used was &lt;a href="http://pqrs.org/macosx/keyremap4macbook/extra.html"&gt;PCKeyboardHack&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;swapping fn and ctrl&lt;/h2&gt;

&lt;p&gt;I am used to having the ctrl key in the bottom left corner of the keyboard so i found it more
natural to swap the two keys. To do this i used &lt;a href="http://pqrs.org/macosx/keyremap4macbook/extra.html"&gt;KeyRemap4Macbook&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;keyboard shortcut to maximize a window&lt;/h2&gt;

&lt;p&gt;I'm currently trying this &lt;a href="http://hints.macworld.com/article.php?story=20051227001809626"&gt;script&lt;/a&gt; in
combination with quicksilver triggers and mapped to cmd+ctrl+z. So far i'm not liking this setup. I
prefer winkey + up on windows or alt + f10 on ubuntu.&lt;/p&gt;

&lt;h2&gt;keyboard shortcut to activate/dectivate fullscreen.&lt;/h2&gt;

&lt;p&gt;To do this follow the instructions &lt;a href="http://osxdaily.com/2011/08/10/full-screen-keyboard-shortcut-mac-os-x/"&gt;here&lt;/a&gt;.
Unfortunatly, the cmd + escape combination did not work for me so i opted for ctrl+cmd+f&lt;/p&gt;

&lt;h2&gt;working with screen in bash in terminal&lt;/h2&gt;

&lt;p&gt;To get screen to and bash to function properly and recognize your .rvmrc project files follow the
instructions in this &lt;a href="http://www.silassewell.com/blog/2008/02/23/os-xs-gnu-screen-proper-bash-prompt/"&gt;post&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;.bashrc&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="text"&gt;&lt;span class="lineno"&gt;1&lt;/span&gt; alias screen=&amp;#39;export SCREENPWD=$(pwd); /usr/bin/screen&amp;#39;
&lt;span class="lineno"&gt;2&lt;/span&gt; export SHELL=&amp;#39;/bin/bash -rcfile ~/.bash_profile&amp;#39;;
&lt;span class="lineno"&gt;3&lt;/span&gt; 
&lt;span class="lineno"&gt;4&lt;/span&gt; case &amp;quot;$TERM&amp;quot; in
&lt;span class="lineno"&gt;5&lt;/span&gt;     &amp;#39;screen&amp;#39;)
&lt;span class="lineno"&gt;6&lt;/span&gt;              cd $SCREENPWD
&lt;span class="lineno"&gt;7&lt;/span&gt;                       ;;
&lt;span class="lineno"&gt;8&lt;/span&gt;                       esac
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;.screenrc&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="text"&gt;&lt;span class="lineno"&gt;1&lt;/span&gt; startup_message off
&lt;span class="lineno"&gt;2&lt;/span&gt; shell -$SHELL
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;h2&gt;customizing the terminal prompt&lt;/h2&gt;

&lt;p&gt;to get your prompt to look like mine
ie.&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="text"&gt;mo@mobook ~/development/blah
$ 
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;.bashrc&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="text"&gt;export PS1=&amp;quot;\u@\h\w \n$ &amp;quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;h2&gt;installing imagemagick properly&lt;/h2&gt;

&lt;p&gt;Follow the instructions found on this &lt;a href="http://stackoverflow.com/questions/2838307/why-is-this-rmagick-call-generating-a-segmentation-fault"&gt;stackoverflow post&lt;/a&gt;&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="text"&gt;&lt;span class="lineno"&gt;1&lt;/span&gt;   brew remove imagemagick
&lt;span class="lineno"&gt;2&lt;/span&gt; 
&lt;span class="lineno"&gt;3&lt;/span&gt;   rm -rf &amp;#39;brew --cache imagemagick&amp;#39;
&lt;span class="lineno"&gt;4&lt;/span&gt; 
&lt;span class="lineno"&gt;5&lt;/span&gt;   brew install -f imagemagick --disable-openmp
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;h2&gt;how to source .bashrc by default in terminal&lt;/h2&gt;

&lt;p&gt;&lt;a href="http://linuxtomacbook.com/?p=22"&gt;read this&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;/etc/profile&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="text"&gt;&lt;span class="lineno"&gt;1&lt;/span&gt;   [ -r $HOME/.bashrc ] &amp;amp;&amp;amp; source $HOME/.bashrc
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;




    &lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/mokhan?a=QwvOm2LsJDU:tNzPWhnYyIg:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/mokhan?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/mokhan?a=QwvOm2LsJDU:tNzPWhnYyIg:zNBqN1PhYbM"&gt;&lt;img src="http://feeds.feedburner.com/~ff/mokhan?i=QwvOm2LsJDU:tNzPWhnYyIg:zNBqN1PhYbM" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/mokhan/~4/QwvOm2LsJDU" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://mokhan.ca//tools/2011/09/11/osx.html</feedburner:origLink></entry>
  
  <entry>
    <title>javascript unit testing</title>
    <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/mokhan/~3/x1Nra6_FW30/javascript-testing.html" />
    <id>http://mokhan.ca/tdd/javascript/tools/2011/07/27/javascript-testing</id>
    <updated>2011-07-27T00:00:00-06:00</updated>
    <content type="html" xml:lang="en" xml:base="http://mokhan.ca/">
      &lt;h2&gt;Top 4 picks&lt;/h2&gt;

&lt;h3&gt;jasmine&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/pivotal/jasmine"&gt;jasmine&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;h3&gt;qunit&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://docs.jquery.com/Qunit"&gt;qunit&lt;/a&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.lostechies.com/blogs/chad_myers/archive/2008/08/28/getting-started-with-jquery-qunit-for-client-side-javascript-testing.aspx"&gt;getting started&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.lostechies.com/blogs/joshuaflanagan/archive/2008/09/18/running-jquery-qunit-tests-under-continuous-integration.aspx"&gt;running tests under ci&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.lostechies.com/blogs/joshua_lockwood/archive/2009/03/11/qunit-amost-just-what-i-was-looking-for.aspx"&gt;extending assertions&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;h3&gt;screwunit&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://pivotallabs.com/users/nick/blog/articles/455-better-javascript-testing-through-screwunit"&gt;screwunit&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;#&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://elijahmanor.com/webdevdotnet/post/bdd-style-qunit-testing-aspnet-mvce28099s-jquery-validation.aspx"&gt;elijamanor&lt;/a&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/elijahmanor/jQueryUnitTestingFormValidation"&gt;source&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;h4&gt;other libs&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://visionmedia.github.com/jspec/"&gt;jspec&lt;/a&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/visionmedia/jspec"&gt;source code&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;this project is no longer supported they suggest you look at jasmine&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="http://ejohn.org/blog/fireunit/"&gt;fireunit&lt;/a&gt;

&lt;ul&gt;
&lt;li&gt;is a plugin that allows you to simple test logging and viewing within a new tab of firebug.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.jsunit.net/"&gt;jsunit&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://code.google.com/p/rhinounit/"&gt;rhinounit&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://code.google.com/p/jsspec/"&gt;jsspec&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://codeutopia.net/blog/2009/08/04/unit-testing-javascript/"&gt;jstestdriver&lt;/a&gt;

&lt;ul&gt;
&lt;li&gt;looks good but is dependent on java&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="http://developer.yahoo.com/yui/yuitest/"&gt;YUITest&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://code.google.com/p/jqunit/"&gt;jqunit&lt;/a&gt;

&lt;ul&gt;
&lt;li&gt;The jqunit project suggests that you use qunit.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;h4&gt;helpful links&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://agilepainrelief.com/notesfromatooluser/2008/11/unit-testing-in-javascript.html"&gt;unit testing in javascript&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


    &lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/mokhan?a=x1Nra6_FW30:Ue20EK1d9XA:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/mokhan?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/mokhan?a=x1Nra6_FW30:Ue20EK1d9XA:zNBqN1PhYbM"&gt;&lt;img src="http://feeds.feedburner.com/~ff/mokhan?i=x1Nra6_FW30:Ue20EK1d9XA:zNBqN1PhYbM" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/mokhan/~4/x1Nra6_FW30" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://mokhan.ca//tdd/javascript/tools/2011/07/27/javascript-testing.html</feedburner:origLink></entry>
  
  <entry>
    <title>design patterns</title>
    <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/mokhan/~3/NWuCG8uv18g/design-patterns.html" />
    <id>http://mokhan.ca/designpatterns/2011/07/09/design-patterns</id>
    <updated>2011-07-09T00:00:00-06:00</updated>
    <content type="html" xml:lang="en" xml:base="http://mokhan.ca/">
      &lt;h2&gt;Domain Logic Patterns&lt;/h2&gt;

&lt;h3&gt;Transaction Script&lt;/h3&gt;

&lt;p&gt;Organizes business logic by procedures where each procedure handles a single request from the
presentation.&lt;/p&gt;

&lt;h3&gt;Domain Model&lt;/h3&gt;

&lt;p&gt;An object model of the domain that incorporates both behavior and data&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="/books/2007/06/26/domain-models.html"&gt;domain model&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;h3&gt;Table Module&lt;/h3&gt;

&lt;p&gt;A single instance that handles the business logic for all rows in a database table or view.&lt;/p&gt;

&lt;h3&gt;Service Layer&lt;/h3&gt;

&lt;p&gt;Defines an application's boundary with a layer of services that establishes a set of available
operations and coordinates the applications response in each operation.&lt;/p&gt;

&lt;h2&gt;Data Source Architectural Patterns&lt;/h2&gt;

&lt;h3&gt;Table Data Gateway&lt;/h3&gt;

&lt;p&gt;An object that acts as a gateway to a database table. One instance handles all the rows in the
table.&lt;/p&gt;

&lt;h3&gt;Row Data Gateway&lt;/h3&gt;

&lt;p&gt;An object that acts as a gateway to a single record in a data source. There is one instance per row.&lt;/p&gt;

&lt;h3&gt;Active Record&lt;/h3&gt;

&lt;p&gt;An object that wraps a row in a database table or view, encapsulates the database access, and adds
domain logic on that data.&lt;/p&gt;

&lt;h3&gt;Data Mapper&lt;/h3&gt;

&lt;p&gt;A layer of mappers that moves data between objects and a database while keeping them independent of
each other and the mapper itself.&lt;/p&gt;

&lt;h2&gt;Object-Relational Behavioral Patterns&lt;/h2&gt;

&lt;h3&gt;Unit of Work&lt;/h3&gt;

&lt;p&gt;Maintains a list of objects affected by a business transaction and coordinates the writing out of
changes and the resolution of concurrency problems.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="/csharp/designpatterns/oop/2008/11/04/intercepting-business-transactions.html"&gt;unit of work&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;h3&gt;Identity Map&lt;/h3&gt;

&lt;p&gt;Ensures that each object gets loaded only once by keeping every loaded object in a map. Looks up
objects using the map when referring to them.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="/books/csharp/designpatterns/generics/2007/12/18/the-identity-map.html"&gt;identity map&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;h3&gt;Lazy Load&lt;/h3&gt;

&lt;p&gt;An object that doesn't contain all of the data you need but knows how to get it.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="/csharp/designpatterns/generics/oop/tools/2008/11/09/lazy-loaded-interceptors.html"&gt;lazy loaded interceptors&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;Object-Relational Structural Patterns&lt;/h2&gt;

&lt;h3&gt;Identity Field&lt;/h3&gt;

&lt;p&gt;Saves a database id field in an object to maintain identity between an in-memory object and a
database row.&lt;/p&gt;

&lt;h3&gt;Foreign Key Mapping&lt;/h3&gt;

&lt;p&gt;Maps an association between objects to a foreign key reference between tables.&lt;/p&gt;

&lt;h3&gt;Association Table Mapping&lt;/h3&gt;

&lt;p&gt;Saves an association as a table with foreign keys to the tables that are linked by the association.&lt;/p&gt;

&lt;h3&gt;Dependent Mapping&lt;/h3&gt;

&lt;p&gt;Has one class perform the database mapping for a child class.&lt;/p&gt;

&lt;h3&gt;Embedded Value&lt;/h3&gt;

&lt;p&gt;Maps an object into several fields of another objects table.&lt;/p&gt;

&lt;h3&gt;Serialized LOB&lt;/h3&gt;

&lt;p&gt;Saves a graph of objects by serializing them into a single large object (LOB), which it stores in a
database field.&lt;/p&gt;

&lt;h3&gt;Single Table Inheritance&lt;/h3&gt;

&lt;p&gt;Represents an inheritance hierarchy of classes as a single table that has columns for all the fields
of the various classes.&lt;/p&gt;

&lt;h3&gt;Class Table Inheritance&lt;/h3&gt;

&lt;p&gt;Represents an inheritance hierarchy of classes with one table for each class.&lt;/p&gt;

&lt;h3&gt;Concrete Table Inheritance&lt;/h3&gt;

&lt;p&gt;Represents an inheritance hierarchy of classes with one table per concrete class in the hierarchy.&lt;/p&gt;

&lt;h3&gt;Inheritance Mappers&lt;/h3&gt;

&lt;p&gt;A structure to organize database mappers that handle inheritance hierarchies.&lt;/p&gt;

&lt;h2&gt;Object-Relational Metadata Mapping Patterns&lt;/h2&gt;

&lt;h3&gt;Metadata Mapping&lt;/h3&gt;

&lt;p&gt;Holds details of object-relational mapping in metadata.&lt;/p&gt;

&lt;h3&gt;Query Object&lt;/h3&gt;

&lt;p&gt;An object that represents a database query.&lt;/p&gt;

&lt;h3&gt;Repository&lt;/h3&gt;

&lt;p&gt;Mediates between the domain and data mapping layers using a collection like interface for accessing
domain objects.&lt;/p&gt;

&lt;h2&gt;Web Presentation Patterns&lt;/h2&gt;

&lt;h3&gt;Model View Controller&lt;/h3&gt;

&lt;p&gt;Splits user interface interaction into three distinct roles.&lt;/p&gt;

&lt;h3&gt;Page Controller&lt;/h3&gt;

&lt;p&gt;An object that handles a request for a specific page or action on a website.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="/csharp/designpatterns/2008/02/01/controlling-pages.html"&gt;page controller&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;h3&gt;Front Controller&lt;/h3&gt;

&lt;p&gt;A controller that handles all requests for a website.&lt;/p&gt;

&lt;h3&gt;Template View&lt;/h3&gt;

&lt;p&gt;Renders information into HTML by embedding markers in an html page.&lt;/p&gt;

&lt;h3&gt;Transform View&lt;/h3&gt;

&lt;p&gt;A view that processes domain data element by element and transforms it into html.&lt;/p&gt;

&lt;h3&gt;Two Step View&lt;/h3&gt;

&lt;p&gt;Turns domain data into html in two steps. First by formatting some kind of logical page, then
rendering the logical page into html.&lt;/p&gt;

&lt;h3&gt;Application Controller&lt;/h3&gt;

&lt;p&gt;A centralized point for handling screen navigation and the flow of an application.&lt;/p&gt;

&lt;h2&gt;Distribution Patterns&lt;/h2&gt;

&lt;h3&gt;Remote Facade&lt;/h3&gt;

&lt;p&gt;Provides a coarse-grained facade on fine-grained objects to improve efficiency over a network.&lt;/p&gt;

&lt;h3&gt;Data Transfer Object&lt;/h3&gt;

&lt;p&gt;An object that carries data between processes in order to reduce the number of method calls.&lt;/p&gt;

&lt;h2&gt;Offline Concurrency Patterns&lt;/h2&gt;

&lt;h3&gt;Optimistic Offline Lock&lt;/h3&gt;

&lt;p&gt;Prevents conflicts between concurrent business transactions by detecting a conflict and rolling back
the transaction.&lt;/p&gt;

&lt;h3&gt;Pessimistic Offline Lock&lt;/h3&gt;

&lt;p&gt;Prevents conflicts between concurrent business transactions by allowing only one business
transaction at a time to access data.&lt;/p&gt;

&lt;h3&gt;Coarse-Grained Lock&lt;/h3&gt;

&lt;p&gt;Locks a set of related objects with a single lock.&lt;/p&gt;

&lt;h3&gt;Implicit Lock&lt;/h3&gt;

&lt;p&gt;Allows framework or layer supertype code to acquire offline locks.&lt;/p&gt;

&lt;h2&gt;Session State Patterns&lt;/h2&gt;

&lt;h3&gt;Client Session State&lt;/h3&gt;

&lt;p&gt;Stores session state on the client.&lt;/p&gt;

&lt;h3&gt;Server Session State&lt;/h3&gt;

&lt;p&gt;Keeps the session state on a server system in a serialized form.&lt;/p&gt;

&lt;h3&gt;Database Session State&lt;/h3&gt;

&lt;p&gt;Stores session data as committed data in the database.&lt;/p&gt;

&lt;h2&gt;Base Patterns&lt;/h2&gt;

&lt;h3&gt;Gateway&lt;/h3&gt;

&lt;p&gt;An object that encapsulates access to an external system or resource.&lt;/p&gt;

&lt;h3&gt;Mapper&lt;/h3&gt;

&lt;p&gt;An object that sets up a communication between two independent objects.&lt;/p&gt;

&lt;h3&gt;Layer Supertype&lt;/h3&gt;

&lt;p&gt;A type that acts as the supertype for all types in its layer.&lt;/p&gt;

&lt;h3&gt;Separated Interface&lt;/h3&gt;

&lt;p&gt;Defines an interface in a separate package from its implementation.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://mokhan.ca/books/csharp/tdd/2007/05/22/interface-based-programming.html"&gt;interface based programming&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;h3&gt;Registry&lt;/h3&gt;

&lt;p&gt;A well known object that other objects can use to find common objects and services.&lt;/p&gt;

&lt;h3&gt;Value Object&lt;/h3&gt;

&lt;p&gt;A small simple object, like Money or a Date Range, whose equality isn't based on identity.&lt;/p&gt;

&lt;h3&gt;Money&lt;/h3&gt;

&lt;p&gt;Represents a monetary value.&lt;/p&gt;

&lt;h3&gt;Special Case&lt;/h3&gt;

&lt;p&gt;A subclass that provides special behavior for particular cases.&lt;/p&gt;

&lt;h3&gt;Plugin&lt;/h3&gt;

&lt;p&gt;Links classes during configuration rather than compilation.&lt;/p&gt;

&lt;h3&gt;Service Stub&lt;/h3&gt;

&lt;p&gt;Removes dependencies upon problematic services during testing.&lt;/p&gt;

&lt;h3&gt;Record Set&lt;/h3&gt;

&lt;p&gt;An in-memory representation of tabular data.&lt;/p&gt;

    &lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/mokhan?a=NWuCG8uv18g:mpiJqirxcAM:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/mokhan?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/mokhan?a=NWuCG8uv18g:mpiJqirxcAM:zNBqN1PhYbM"&gt;&lt;img src="http://feeds.feedburner.com/~ff/mokhan?i=NWuCG8uv18g:mpiJqirxcAM:zNBqN1PhYbM" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/mokhan/~4/NWuCG8uv18g" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://mokhan.ca//designpatterns/2011/07/09/design-patterns.html</feedburner:origLink></entry>
  
  <entry>
    <title>ruby classes</title>
    <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/mokhan/~3/7y6LEQjbvYg/ruby-classes.html" />
    <id>http://mokhan.ca/ruby/oop/2011/06/03/ruby-classes</id>
    <updated>2011-06-03T00:00:00-06:00</updated>
    <content type="html" xml:lang="en" xml:base="http://mokhan.ca/">
      &lt;p&gt;&lt;img src="http://ws.assoc-amazon.com/widgets/q?_encoding=UTF8&amp;amp;Format=_SL160_&amp;amp;ASIN=1934356085&amp;amp;MarketPlace=US&amp;amp;ID=AsinImage&amp;amp;WS=1&amp;amp;tag=mokhthliofawa-20&amp;amp;ServiceVersion=20070822" alt="Programming Ruby 1.9" /&gt;&lt;/p&gt;

&lt;h2&gt;The basics&lt;/h2&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="ruby"&gt;&lt;span class="lineno"&gt;1&lt;/span&gt;   &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Book&lt;/span&gt;
&lt;span class="lineno"&gt;2&lt;/span&gt;     &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;initialize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;isbn&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="lineno"&gt;3&lt;/span&gt;       &lt;span class="vi"&gt;@isbn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;isbn&lt;/span&gt;
&lt;span class="lineno"&gt;4&lt;/span&gt;       &lt;span class="vi"&gt;@price&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt;
&lt;span class="lineno"&gt;5&lt;/span&gt;     &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="lineno"&gt;6&lt;/span&gt;   &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="lineno"&gt;7&lt;/span&gt; 
&lt;span class="lineno"&gt;8&lt;/span&gt;   &lt;span class="n"&gt;book&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;Book&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;new&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;isbn&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;initialize is a special method in Ruby programs. When you call Book.new to create a new object, Ruby
allocated memory to hold an uninitialized object and then calls that object's initialize method. T&lt;/p&gt;

&lt;p&gt;initialize is an objects constructor. The call to Book.new calls the Book's constructor (initialize)
and allocates a new instance of Book.&lt;/p&gt;

&lt;p&gt;@isbn in an instance field of the class. when you want to declare a instance field you must prefix
the name of the variable with the "@" sign.&lt;/p&gt;

&lt;p&gt;To customize how an object is displayed via puts or p you can override the "to_s" method.&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="ruby"&gt;&lt;span class="lineno"&gt; 1&lt;/span&gt;   &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Movie&lt;/span&gt;
&lt;span class="lineno"&gt; 2&lt;/span&gt;     &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;initialize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;studio&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;year_published&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="lineno"&gt; 3&lt;/span&gt;       &lt;span class="vi"&gt;@name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;name&lt;/span&gt;
&lt;span class="lineno"&gt; 4&lt;/span&gt;       &lt;span class="vi"&gt;@studio&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;studio&lt;/span&gt;
&lt;span class="lineno"&gt; 5&lt;/span&gt;       &lt;span class="vi"&gt;@year_published&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;year_published&lt;/span&gt;
&lt;span class="lineno"&gt; 6&lt;/span&gt;     &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="lineno"&gt; 7&lt;/span&gt;     &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;to_s&lt;/span&gt;
&lt;span class="lineno"&gt; 8&lt;/span&gt;       &lt;span class="s2"&gt;&amp;quot;Name: &lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="vi"&gt;@name&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;, Studio: &lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="vi"&gt;@studio&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;, Year: &lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="vi"&gt;@year_published&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;
&lt;span class="lineno"&gt; 9&lt;/span&gt;     &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="lineno"&gt;10&lt;/span&gt;   &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="lineno"&gt;11&lt;/span&gt; 
&lt;span class="lineno"&gt;12&lt;/span&gt;   &lt;span class="nb"&gt;p&lt;/span&gt; &lt;span class="no"&gt;Movie&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;new&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;MegaMind&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;DreamWorks&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2010&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;h2&gt;Attributes (methods)&lt;/h2&gt;

&lt;p&gt;By default instance variables are private and cannot be accessed from outside the class.
You can define &lt;strong&gt;"attributes"&lt;/strong&gt; on the class to be able to see and change the internal state of the
class. These are equivelant to properties in c#.&lt;/p&gt;

&lt;p&gt;You can define read only attribute explicitly, like this.&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="ruby"&gt;&lt;span class="lineno"&gt; 1&lt;/span&gt;   &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;VideoGame&lt;/span&gt;
&lt;span class="lineno"&gt; 2&lt;/span&gt;     &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;initialize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="lineno"&gt; 3&lt;/span&gt;       &lt;span class="vi"&gt;@name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;name&lt;/span&gt;
&lt;span class="lineno"&gt; 4&lt;/span&gt;     &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="lineno"&gt; 5&lt;/span&gt;     &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;name&lt;/span&gt;
&lt;span class="lineno"&gt; 6&lt;/span&gt;       &lt;span class="vi"&gt;@name&lt;/span&gt;
&lt;span class="lineno"&gt; 7&lt;/span&gt;     &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="lineno"&gt; 8&lt;/span&gt;   &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="lineno"&gt; 9&lt;/span&gt; 
&lt;span class="lineno"&gt;10&lt;/span&gt;   &lt;span class="n"&gt;game&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;VideoGame&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;new&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;call of duty&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="lineno"&gt;11&lt;/span&gt;   &lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="n"&gt;game&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;Ruby has a handy little shorthand to save you from having to type out your read only attributes.
It's called &lt;strong&gt;"attr_reader".&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="ruby"&gt;&lt;span class="lineno"&gt; 1&lt;/span&gt;   &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;VideoGame&lt;/span&gt;
&lt;span class="lineno"&gt; 2&lt;/span&gt; 
&lt;span class="lineno"&gt; 3&lt;/span&gt;     &lt;span class="kp"&gt;attr_reader&lt;/span&gt; &lt;span class="ss"&gt;:name&lt;/span&gt;
&lt;span class="lineno"&gt; 4&lt;/span&gt; 
&lt;span class="lineno"&gt; 5&lt;/span&gt;     &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;initialize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="lineno"&gt; 6&lt;/span&gt;       &lt;span class="vi"&gt;@name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;name&lt;/span&gt;
&lt;span class="lineno"&gt; 7&lt;/span&gt;     &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="lineno"&gt; 8&lt;/span&gt;   &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="lineno"&gt; 9&lt;/span&gt; 
&lt;span class="lineno"&gt;10&lt;/span&gt;   &lt;span class="n"&gt;game&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;VideoGame&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;new&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;call of duty&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="lineno"&gt;11&lt;/span&gt;   &lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="n"&gt;game&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;To create a method that would allow me to change the name of a video game I can
define a method named "name=".&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="ruby"&gt;&lt;span class="lineno"&gt; 1&lt;/span&gt;   &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;VideoGame&lt;/span&gt;
&lt;span class="lineno"&gt; 2&lt;/span&gt; 
&lt;span class="lineno"&gt; 3&lt;/span&gt;     &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;initialize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="lineno"&gt; 4&lt;/span&gt;       &lt;span class="vi"&gt;@name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;name&lt;/span&gt;
&lt;span class="lineno"&gt; 5&lt;/span&gt;     &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="lineno"&gt; 6&lt;/span&gt;     &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;new_name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="lineno"&gt; 7&lt;/span&gt;       &lt;span class="vi"&gt;@name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;new_name&lt;/span&gt;
&lt;span class="lineno"&gt; 8&lt;/span&gt;     &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="lineno"&gt; 9&lt;/span&gt;   &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="lineno"&gt;10&lt;/span&gt; 
&lt;span class="lineno"&gt;11&lt;/span&gt;   &lt;span class="n"&gt;game&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;VideoGame&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;new&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;call of duty&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="lineno"&gt;12&lt;/span&gt;   &lt;span class="n"&gt;game&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;GTA4&amp;quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;There's also a shorthand for having to write your own setter methods. It's called
&lt;strong&gt;attr_writer.&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="ruby"&gt;&lt;span class="lineno"&gt; 1&lt;/span&gt;   &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;VideoGame&lt;/span&gt;
&lt;span class="lineno"&gt; 2&lt;/span&gt; 
&lt;span class="lineno"&gt; 3&lt;/span&gt;     &lt;span class="kp"&gt;attr_writer&lt;/span&gt; &lt;span class="ss"&gt;:name&lt;/span&gt;
&lt;span class="lineno"&gt; 4&lt;/span&gt; 
&lt;span class="lineno"&gt; 5&lt;/span&gt;     &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;initialize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="lineno"&gt; 6&lt;/span&gt;       &lt;span class="vi"&gt;@name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;name&lt;/span&gt;
&lt;span class="lineno"&gt; 7&lt;/span&gt;     &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="lineno"&gt; 8&lt;/span&gt;   &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="lineno"&gt; 9&lt;/span&gt; 
&lt;span class="lineno"&gt;10&lt;/span&gt;   &lt;span class="n"&gt;game&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;VideoGame&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;new&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;call of duty&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="lineno"&gt;11&lt;/span&gt;   &lt;span class="n"&gt;game&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;GTA4&amp;quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;There's also a shorthand for defining a setter, and getter for your instance variable called
"attr_accessor"&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="ruby"&gt;&lt;span class="lineno"&gt; 1&lt;/span&gt;   &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;VideoGame&lt;/span&gt;
&lt;span class="lineno"&gt; 2&lt;/span&gt; 
&lt;span class="lineno"&gt; 3&lt;/span&gt;     &lt;span class="kp"&gt;attr_accessor&lt;/span&gt; &lt;span class="ss"&gt;:name&lt;/span&gt;
&lt;span class="lineno"&gt; 4&lt;/span&gt; 
&lt;span class="lineno"&gt; 5&lt;/span&gt;     &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;initialize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="lineno"&gt; 6&lt;/span&gt;       &lt;span class="vi"&gt;@name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;name&lt;/span&gt;
&lt;span class="lineno"&gt; 7&lt;/span&gt;     &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="lineno"&gt; 8&lt;/span&gt;   &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="lineno"&gt; 9&lt;/span&gt; 
&lt;span class="lineno"&gt;10&lt;/span&gt;   &lt;span class="n"&gt;game&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;VideoGame&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;new&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;call of duty&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="lineno"&gt;11&lt;/span&gt;   &lt;span class="n"&gt;game&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;GTA4&amp;quot;&lt;/span&gt;
&lt;span class="lineno"&gt;12&lt;/span&gt;   &lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="n"&gt;game&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;h2&gt;Access Control&lt;/h2&gt;

&lt;p&gt;You get 3 levels of protection:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Public methods (default): can be called by anyone.&lt;/li&gt;
&lt;li&gt;Protected methods: can be invoked by defining class and subclasses.&lt;/li&gt;
&lt;li&gt;Private methods: can only be called within the context of the current object.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;It is never possible to access another object's private methods directly, even if
the object is of the same class as the caller.&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="ruby"&gt;&lt;span class="lineno"&gt; 1&lt;/span&gt;   &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MyClass&lt;/span&gt;
&lt;span class="lineno"&gt; 2&lt;/span&gt;     &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;public_method&lt;/span&gt;
&lt;span class="lineno"&gt; 3&lt;/span&gt;     &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="lineno"&gt; 4&lt;/span&gt; 
&lt;span class="lineno"&gt; 5&lt;/span&gt;   &lt;span class="kp"&gt;protected&lt;/span&gt;
&lt;span class="lineno"&gt; 6&lt;/span&gt;     &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;protected_method&lt;/span&gt;
&lt;span class="lineno"&gt; 7&lt;/span&gt;     &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="lineno"&gt; 8&lt;/span&gt; 
&lt;span class="lineno"&gt; 9&lt;/span&gt;   &lt;span class="kp"&gt;private&lt;/span&gt;
&lt;span class="lineno"&gt;10&lt;/span&gt;     &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;private_method&lt;/span&gt;
&lt;span class="lineno"&gt;11&lt;/span&gt;     &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="lineno"&gt;12&lt;/span&gt; 
&lt;span class="lineno"&gt;13&lt;/span&gt;   &lt;span class="kp"&gt;public&lt;/span&gt; 
&lt;span class="lineno"&gt;14&lt;/span&gt;     &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;another_public_method&lt;/span&gt;
&lt;span class="lineno"&gt;15&lt;/span&gt;     &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="lineno"&gt;16&lt;/span&gt;   &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="lineno"&gt;17&lt;/span&gt;   
&lt;span class="lineno"&gt;18&lt;/span&gt; &lt;span class="c1"&gt;# or&lt;/span&gt;
&lt;span class="lineno"&gt;19&lt;/span&gt; 
&lt;span class="lineno"&gt;20&lt;/span&gt;   &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;AnotherClass&lt;/span&gt;
&lt;span class="lineno"&gt;21&lt;/span&gt;     &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;public_method&lt;/span&gt;
&lt;span class="lineno"&gt;22&lt;/span&gt;     &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="lineno"&gt;23&lt;/span&gt; 
&lt;span class="lineno"&gt;24&lt;/span&gt;     &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;protected_method&lt;/span&gt;
&lt;span class="lineno"&gt;25&lt;/span&gt;     &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="lineno"&gt;26&lt;/span&gt; 
&lt;span class="lineno"&gt;27&lt;/span&gt;     &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;private_method&lt;/span&gt;
&lt;span class="lineno"&gt;28&lt;/span&gt;     &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="lineno"&gt;29&lt;/span&gt; 
&lt;span class="lineno"&gt;30&lt;/span&gt;     &lt;span class="kp"&gt;public&lt;/span&gt;      &lt;span class="ss"&gt;:public_method&lt;/span&gt;
&lt;span class="lineno"&gt;31&lt;/span&gt;     &lt;span class="kp"&gt;protected&lt;/span&gt;   &lt;span class="ss"&gt;:protected_method&lt;/span&gt;
&lt;span class="lineno"&gt;32&lt;/span&gt;     &lt;span class="kp"&gt;private&lt;/span&gt;     &lt;span class="ss"&gt;:private_method&lt;/span&gt;
&lt;span class="lineno"&gt;33&lt;/span&gt;   &lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;h2&gt;Variables&lt;/h2&gt;

&lt;p&gt;Variables are used to keep track of objects; each variable holds a reference to an object.
A variable is simply a reference to an object.&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="ruby"&gt;&lt;span class="lineno"&gt;1&lt;/span&gt;   &lt;span class="n"&gt;movie&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;Movie&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;new&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;man on fire&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="lineno"&gt;2&lt;/span&gt;   &lt;span class="n"&gt;another_movie&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;movie&lt;/span&gt;
&lt;span class="lineno"&gt;3&lt;/span&gt;   &lt;span class="n"&gt;movie&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;Movie&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;new&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;batman&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="lineno"&gt;4&lt;/span&gt; 
&lt;span class="lineno"&gt;5&lt;/span&gt;   &lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="n"&gt;movie&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;
&lt;span class="lineno"&gt;6&lt;/span&gt;   &lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="n"&gt;another_movie&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;




    &lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/mokhan?a=7y6LEQjbvYg:ajjKJH0QIRg:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/mokhan?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/mokhan?a=7y6LEQjbvYg:ajjKJH0QIRg:zNBqN1PhYbM"&gt;&lt;img src="http://feeds.feedburner.com/~ff/mokhan?i=7y6LEQjbvYg:ajjKJH0QIRg:zNBqN1PhYbM" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/mokhan/~4/7y6LEQjbvYg" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://mokhan.ca//ruby/oop/2011/06/03/ruby-classes.html</feedburner:origLink></entry>
  
  <entry>
    <title>ruby 101</title>
    <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/mokhan/~3/mhH3OMW8bRQ/ruby.html" />
    <id>http://mokhan.ca/ruby/oop/books/2011/05/31/ruby</id>
    <updated>2011-05-31T00:00:00-06:00</updated>
    <content type="html" xml:lang="en" xml:base="http://mokhan.ca/">
      &lt;p&gt;&lt;a href="http://www.amazon.com/gp/product/1934356085/ref=as_li_ss_il?ie=UTF8&amp;tag=mokhthliofawa-20&amp;linkCode=as2&amp;camp=217145&amp;creative=399349&amp;creativeASIN=1934356085"&gt;&lt;img src="http://ws.assoc-amazon.com/widgets/q?_encoding=UTF8&amp;Format=_SL160_&amp;ASIN=1934356085&amp;MarketPlace=US&amp;ID=AsinImage&amp;WS=1&amp;tag=mokhthliofawa-20&amp;ServiceVersion=20070822" /&gt;Referenced from Programming Ruby 1.9 The Pragmatic Programmers' Guide&lt;/a&gt;&lt;img src="http://www.assoc-amazon.com/e/ir?t=&amp;l=as2&amp;o=1&amp;a=1934356085&amp;camp=217145&amp;creative=399349" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /&gt;&lt;/p&gt;

&lt;h2&gt;installing ruby&lt;/h2&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="text"&gt;  $ sudo apt-get update
  $ sudo apt-get install curl
  $ bash &amp;lt; &amp;lt;( curl -s https://rvm.beginrescueend.com/install/rvm )
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;h3&gt;Add to .bashrc&lt;/h3&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="text"&gt;source $HOME/.rvm/scripts/rvm
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;then.&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="text"&gt;  $ rvm notes # follow instructions to install missing libs
  $ sudo apt-get install build-essential bison openssl libreadline5 libreadline-dev curl git-core zliblg zliblg-dev libssl-dev vim libsqlite3-0 libsqlite3-dev sqlite3 libreadline-dev libxml2-dev git-core subversion autoconf
  $ rvm install 1.9.2
  $ rvm use 1.9.2
  $ ruby -v
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;h2&gt;documentation&lt;/h2&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="text"&gt;  $ ri GC
  $ ri GC::enable
  $ ri assoc
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;h2&gt;ruby is object-oriented&lt;/h2&gt;

&lt;h3&gt;arrays and hashes&lt;/h3&gt;

&lt;p&gt;arrays and hashes are indexed collections. both store collections of objects, accessible using a key.&lt;/p&gt;

&lt;p&gt;e.g array literal&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="ruby"&gt;&lt;span class="lineno"&gt;1&lt;/span&gt;   &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;cat&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="mi"&gt;14&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="c1"&gt;# array with three elements&lt;/span&gt;
&lt;span class="lineno"&gt;2&lt;/span&gt;   &lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;the first element is &lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;ruby has a shortcut for creating arrays of strings&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="ruby"&gt;&lt;span class="lineno"&gt;1&lt;/span&gt;   &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;ant&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;bee&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;cat&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;dog&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;elk&amp;#39;&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;
&lt;span class="lineno"&gt;2&lt;/span&gt;   &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="c1"&gt;# =&amp;gt; &amp;quot;ant&amp;quot;&lt;/span&gt;
&lt;span class="lineno"&gt;3&lt;/span&gt;   &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sx"&gt;%w[ ant bee cat dog elk ]&lt;/span&gt;
&lt;span class="lineno"&gt;4&lt;/span&gt;   &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="c1"&gt;# =&amp;gt; &amp;quot;ant&amp;quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;hashes are similar to arrays. you must supply two objects for every entry, one for the key, the other for the value.&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="ruby"&gt;&lt;span class="lineno"&gt; 1&lt;/span&gt;   &lt;span class="n"&gt;dead_rappers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="lineno"&gt; 2&lt;/span&gt;     &lt;span class="s1"&gt;&amp;#39;tupac&amp;#39;&lt;/span&gt;   &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;1996&amp;#39;&lt;/span&gt;
&lt;span class="lineno"&gt; 3&lt;/span&gt;     &lt;span class="s1"&gt;&amp;#39;biggie&amp;#39;&lt;/span&gt;   &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;1997&amp;#39;&lt;/span&gt;
&lt;span class="lineno"&gt; 4&lt;/span&gt;     &lt;span class="s1"&gt;&amp;#39;big l&amp;#39;&lt;/span&gt;   &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;1999&amp;#39;&lt;/span&gt;
&lt;span class="lineno"&gt; 5&lt;/span&gt;     &lt;span class="s1"&gt;&amp;#39;eazy e&amp;#39;&lt;/span&gt;   &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;1995&amp;#39;&lt;/span&gt;
&lt;span class="lineno"&gt; 6&lt;/span&gt;     &lt;span class="s1"&gt;&amp;#39;odb&amp;#39;&lt;/span&gt;   &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;2004&amp;#39;&lt;/span&gt;
&lt;span class="lineno"&gt; 7&lt;/span&gt;   &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="lineno"&gt; 8&lt;/span&gt; 
&lt;span class="lineno"&gt; 9&lt;/span&gt;   &lt;span class="nb"&gt;p&lt;/span&gt; &lt;span class="n"&gt;dead_rappers&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;tupac&amp;#39;&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;   &lt;span class="c1"&gt;# =&amp;gt; &amp;#39;1996&amp;#39;&lt;/span&gt;
&lt;span class="lineno"&gt;10&lt;/span&gt;   &lt;span class="nb"&gt;p&lt;/span&gt; &lt;span class="n"&gt;dead_rappers&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;biggie&amp;#39;&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;  &lt;span class="c1"&gt;# =&amp;gt; &amp;#39;1997&amp;#39;&lt;/span&gt;
&lt;span class="lineno"&gt;11&lt;/span&gt;   &lt;span class="nb"&gt;p&lt;/span&gt; &lt;span class="n"&gt;dead_rappers&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;big pun&amp;#39;&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;  &lt;span class="c1"&gt;# =&amp;gt; nil&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;a hash by default returns nil when indexed by a key it doesn't contain.
to change the default value you can specify it when creating a new hash.&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="ruby"&gt;&lt;span class="lineno"&gt;1&lt;/span&gt;   &lt;span class="n"&gt;histogram&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;Hash&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;new&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;# the default value 0&lt;/span&gt;
&lt;span class="lineno"&gt;2&lt;/span&gt;   &lt;span class="n"&gt;histogram&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;ruby&amp;#39;&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="c1"&gt;# =&amp;gt; 0&lt;/span&gt;
&lt;span class="lineno"&gt;3&lt;/span&gt;   &lt;span class="n"&gt;histogram&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;ruby&amp;#39;&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;histogram&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;ruby&amp;#39;&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="lineno"&gt;4&lt;/span&gt;   &lt;span class="n"&gt;histogram&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;ruby&amp;#39;&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="c1"&gt;# =&amp;gt; 1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;h3&gt;symbols&lt;/h3&gt;

&lt;p&gt;are simple constant names that you don't have to predeclare and that are guaranteed to be unique.
a symbol literal starts with a colon and is normally followed by some kind of name:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="ruby"&gt;&lt;span class="lineno"&gt;1&lt;/span&gt;   &lt;span class="n"&gt;walk&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;:north&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="lineno"&gt;2&lt;/span&gt;   &lt;span class="n"&gt;walk&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;:east&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;there's no need to assign some kind of value to a symbol - ruby takes care of that for you.
ruby also guarantees that no matter where it appears in your program, a particular symbol will have
the same value.&lt;/p&gt;

&lt;p&gt;e.g&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="ruby"&gt;&lt;span class="lineno"&gt;1&lt;/span&gt;   &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;walk&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;direction&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="lineno"&gt;2&lt;/span&gt;     &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;direction&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="ss"&gt;:north&lt;/span&gt;
&lt;span class="lineno"&gt;3&lt;/span&gt;       &lt;span class="c1"&gt;# ...&lt;/span&gt;
&lt;span class="lineno"&gt;4&lt;/span&gt;     &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="lineno"&gt;5&lt;/span&gt;   &lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;symbols are frequently used as keys in hashes.&lt;/p&gt;

&lt;p&gt;like this&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="ruby"&gt;&lt;span class="lineno"&gt;1&lt;/span&gt;   &lt;span class="n"&gt;dead_rappers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="lineno"&gt;2&lt;/span&gt;     &lt;span class="ss"&gt;:tupac&lt;/span&gt;    &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;1996&amp;#39;&lt;/span&gt;
&lt;span class="lineno"&gt;3&lt;/span&gt;     &lt;span class="ss"&gt;:biggie&lt;/span&gt;   &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;1997&amp;#39;&lt;/span&gt;
&lt;span class="lineno"&gt;4&lt;/span&gt;     &lt;span class="ss"&gt;:bigl&lt;/span&gt;     &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;1999&amp;#39;&lt;/span&gt;
&lt;span class="lineno"&gt;5&lt;/span&gt;     &lt;span class="ss"&gt;:eazye&lt;/span&gt;    &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;1995&amp;#39;&lt;/span&gt;
&lt;span class="lineno"&gt;6&lt;/span&gt;     &lt;span class="ss"&gt;:odb&lt;/span&gt;      &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;2004&amp;#39;&lt;/span&gt;
&lt;span class="lineno"&gt;7&lt;/span&gt;   &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="lineno"&gt;8&lt;/span&gt; 
&lt;span class="lineno"&gt;9&lt;/span&gt;   &lt;span class="n"&gt;dead_rappers&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="ss"&gt;:odb&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="c1"&gt;# =&amp;gt; &amp;#39;2004&amp;#39;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;in ruby 1.9 you can use name: value pairs to create a hash if the keys are symbols.&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="ruby"&gt;&lt;span class="lineno"&gt;1&lt;/span&gt;   &lt;span class="n"&gt;dead_rappers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="lineno"&gt;2&lt;/span&gt;     &lt;span class="n"&gt;tupac&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;    &lt;span class="s1"&gt;&amp;#39;1996&amp;#39;&lt;/span&gt;
&lt;span class="lineno"&gt;3&lt;/span&gt;     &lt;span class="n"&gt;biggie&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="s1"&gt;&amp;#39;1997&amp;#39;&lt;/span&gt;
&lt;span class="lineno"&gt;4&lt;/span&gt;     &lt;span class="n"&gt;bigl&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;     &lt;span class="s1"&gt;&amp;#39;1999&amp;#39;&lt;/span&gt;
&lt;span class="lineno"&gt;5&lt;/span&gt;     &lt;span class="n"&gt;eazye&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;    &lt;span class="s1"&gt;&amp;#39;1995&amp;#39;&lt;/span&gt;
&lt;span class="lineno"&gt;6&lt;/span&gt;     &lt;span class="n"&gt;odb&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;      &lt;span class="s1"&gt;&amp;#39;2004&amp;#39;&lt;/span&gt;
&lt;span class="lineno"&gt;7&lt;/span&gt;   &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="lineno"&gt;8&lt;/span&gt;   &lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;big l died in &lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;dead_rappers&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="ss"&gt;:bigl&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;h3&gt;control structures&lt;/h3&gt;

&lt;p&gt;the if/elseif/else structure&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="ruby"&gt;&lt;span class="lineno"&gt;1&lt;/span&gt;   &lt;span class="n"&gt;today&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;Time&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;now&lt;/span&gt;
&lt;span class="lineno"&gt;2&lt;/span&gt; 
&lt;span class="lineno"&gt;3&lt;/span&gt;   &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;today&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;saturday?&lt;/span&gt;
&lt;span class="lineno"&gt;4&lt;/span&gt;     &lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;do chores around the house&amp;quot;&lt;/span&gt;
&lt;span class="lineno"&gt;5&lt;/span&gt;   &lt;span class="k"&gt;elsif&lt;/span&gt; &lt;span class="n"&gt;today&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sunday?&lt;/span&gt;
&lt;span class="lineno"&gt;6&lt;/span&gt;     &lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;chill out&amp;quot;&lt;/span&gt;
&lt;span class="lineno"&gt;7&lt;/span&gt;   &lt;span class="k"&gt;else&lt;/span&gt;
&lt;span class="lineno"&gt;8&lt;/span&gt;     &lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;go to work&amp;quot;&lt;/span&gt;
&lt;span class="lineno"&gt;9&lt;/span&gt;   &lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;the while loop&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="ruby"&gt;&lt;span class="lineno"&gt;1&lt;/span&gt;   &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;span class="lineno"&gt;2&lt;/span&gt;   &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;
&lt;span class="lineno"&gt;3&lt;/span&gt;     &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;+=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;
&lt;span class="lineno"&gt;4&lt;/span&gt;   &lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;ruby treats nil as a false, so you can write this.&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="ruby"&gt;&lt;span class="lineno"&gt;1&lt;/span&gt;   &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;gets&lt;/span&gt;
&lt;span class="lineno"&gt;2&lt;/span&gt;     &lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;downcase&lt;/span&gt;
&lt;span class="lineno"&gt;3&lt;/span&gt;   &lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;statement modifiers are a cool shortcut if the body of an if or while statement is just a single express.&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="ruby"&gt;&lt;span class="lineno"&gt; 1&lt;/span&gt;   &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;radiation&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;3000&lt;/span&gt;
&lt;span class="lineno"&gt; 2&lt;/span&gt;     &lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;danger, will robinson&amp;quot;&lt;/span&gt;
&lt;span class="lineno"&gt; 3&lt;/span&gt;   &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="lineno"&gt; 4&lt;/span&gt; 
&lt;span class="lineno"&gt; 5&lt;/span&gt;   &lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;danger, will robinson&amp;quot;&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;radiation&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;3000&lt;/span&gt;
&lt;span class="lineno"&gt; 6&lt;/span&gt; 
&lt;span class="lineno"&gt; 7&lt;/span&gt;   &lt;span class="n"&gt;square&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;
&lt;span class="lineno"&gt; 8&lt;/span&gt;   &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;square&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;
&lt;span class="lineno"&gt; 9&lt;/span&gt;     &lt;span class="n"&gt;square&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;square&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;square&lt;/span&gt;
&lt;span class="lineno"&gt;10&lt;/span&gt;   &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="lineno"&gt;11&lt;/span&gt; 
&lt;span class="lineno"&gt;12&lt;/span&gt;   &lt;span class="n"&gt;square&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;square&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;square&lt;/span&gt; &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;square&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;h3&gt;blocks&lt;/h3&gt;

&lt;p&gt;this is a code block:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="ruby"&gt;&lt;span class="lineno"&gt;1&lt;/span&gt;   &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;hello&amp;quot;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;so is this:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="ruby"&gt;&lt;span class="lineno"&gt;1&lt;/span&gt;   &lt;span class="k"&gt;do&lt;/span&gt; 
&lt;span class="lineno"&gt;2&lt;/span&gt;     &lt;span class="n"&gt;club&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;enroll&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;person&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="lineno"&gt;3&lt;/span&gt;     &lt;span class="n"&gt;person&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;socialize&lt;/span&gt;
&lt;span class="lineno"&gt;4&lt;/span&gt;   &lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;the only thing you can do with a block is associate it with a call to a method.
you can do this by putting the start of the block at the end of the source line containing the method call.&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="ruby"&gt;&lt;span class="lineno"&gt;1&lt;/span&gt;   &lt;span class="n"&gt;greet&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;hi&amp;quot;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;the method greet is given a block.
if the method has parameters, then they appear before the block:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="ruby"&gt;&lt;span class="lineno"&gt;1&lt;/span&gt;   &lt;span class="n"&gt;verbose_greet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;mo&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;a geek&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;hi&amp;quot;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;a method can invoke the block by calling yield.&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="ruby"&gt;&lt;span class="lineno"&gt;1&lt;/span&gt;   &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;call_block&lt;/span&gt;
&lt;span class="lineno"&gt;2&lt;/span&gt;     &lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;start of method&amp;quot;&lt;/span&gt;
&lt;span class="lineno"&gt;3&lt;/span&gt;     &lt;span class="k"&gt;yield&lt;/span&gt;
&lt;span class="lineno"&gt;4&lt;/span&gt;     &lt;span class="k"&gt;yield&lt;/span&gt;
&lt;span class="lineno"&gt;5&lt;/span&gt;     &lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;end of method&amp;quot;&lt;/span&gt;
&lt;span class="lineno"&gt;6&lt;/span&gt;   &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="lineno"&gt;7&lt;/span&gt; 
&lt;span class="lineno"&gt;8&lt;/span&gt;   &lt;span class="n"&gt;call_block&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;in the block&amp;quot;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;




&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="text"&gt;  output:
  start of method
  in the block
  in the block
  end of method
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;you can also pass arguments to the block. within the block you need to list the names of the
parameters to receive these arguments between vertical bars.&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="ruby"&gt;&lt;span class="lineno"&gt;1&lt;/span&gt;   &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;who_says_what&lt;/span&gt;
&lt;span class="lineno"&gt;2&lt;/span&gt;     &lt;span class="k"&gt;yield&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;mo&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;hello&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="lineno"&gt;3&lt;/span&gt;     &lt;span class="k"&gt;yield&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;morilla&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;yo&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="lineno"&gt;4&lt;/span&gt;   &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="lineno"&gt;5&lt;/span&gt; 
&lt;span class="lineno"&gt;6&lt;/span&gt;   &lt;span class="n"&gt;who_says_what&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;person&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;phrase&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;person&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; says &lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;phrase&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;code blocks are used throughout the ruby library to implement iterators, which are methods that
return successive elements from some kind of collection, such as an array:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="ruby"&gt;&lt;span class="lineno"&gt;1&lt;/span&gt;   &lt;span class="n"&gt;animals&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sx"&gt;%w( ant bee cat dog elk )&lt;/span&gt;
&lt;span class="lineno"&gt;2&lt;/span&gt;   &lt;span class="n"&gt;animals&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;each&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;animal&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nb"&gt;puts&lt;/span&gt; &lt;span class="n"&gt;animal&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="lineno"&gt;3&lt;/span&gt;   &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;cat&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;dog&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;horse&amp;#39;&lt;/span&gt; &lt;span class="o"&gt;].&lt;/span&gt;&lt;span class="n"&gt;each&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="nb"&gt;name&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nb"&gt;print&lt;/span&gt; &lt;span class="nb"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot; &amp;quot;&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="lineno"&gt;4&lt;/span&gt;   &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;times&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nb"&gt;print&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;*&amp;quot;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="lineno"&gt;5&lt;/span&gt;   &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;upto&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nb"&gt;print&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="lineno"&gt;6&lt;/span&gt;   &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;a&amp;#39;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;.&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;e&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;each&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;char&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nb"&gt;print&lt;/span&gt; &lt;span class="n"&gt;char&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;




    &lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/mokhan?a=mhH3OMW8bRQ:fzdVhjfw2R8:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/mokhan?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/mokhan?a=mhH3OMW8bRQ:fzdVhjfw2R8:zNBqN1PhYbM"&gt;&lt;img src="http://feeds.feedburner.com/~ff/mokhan?i=mhH3OMW8bRQ:fzdVhjfw2R8:zNBqN1PhYbM" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/mokhan/~4/mhH3OMW8bRQ" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://mokhan.ca//ruby/oop/books/2011/05/31/ruby.html</feedburner:origLink></entry>
  
  <entry>
    <title>financial boot camp week three</title>
    <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/mokhan/~3/RZc6JPwoe1c/financial-boot-camp-week-three.html" />
    <id>http://mokhan.ca/money/2011/02/15/financial-boot-camp-week-three</id>
    <updated>2011-02-15T00:00:00-07:00</updated>
    <content type="html" xml:lang="en" xml:base="http://mokhan.ca/">
      &lt;h2&gt;Step 3: legally minimize your taxes&lt;/h2&gt;

&lt;p&gt;In week three of the Kustom Design &lt;a href="http://kustomdesign.ca/kd-educational/boot-camps.html#bootcamp"&gt;Level 1 Financial boot camp&lt;/a&gt; we covered the CRA, taxes, and tax reduction strategies.&lt;/p&gt;

&lt;p&gt;Below are my notes from the class.&lt;/p&gt;

&lt;h2&gt;The Authority Hierarchy&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;The Supreme Court of Canada&lt;/li&gt;
&lt;li&gt;Tax Court of Canada&lt;/li&gt;
&lt;li&gt;Canada Revenue Agency (formerly 'Revenue Canada', formerly Canada Customs and Revenue Agency (CCRA))&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;The CRA is a corporation, and their main line of business is collections or as they call it "to
administer tax". They are effectively a collection agency. In Alberta, they only adminster personal
income tax not corporate.&lt;/p&gt;

&lt;h3&gt;The Tax Court of Canada&lt;/h3&gt;

&lt;p&gt;The tax court of Canada is a specialized court of law whose jusisdiction extends to several Acts of
parliament, and most notable the Income Tax Act, the Excise Tax Act, and several provisions of the
Employment Insurance Act.&lt;/p&gt;

&lt;p&gt;This is a superior court to which individuals and companies may appeal to settle disagreements with
the Canada Revenue Agency on matters of income tax, GST and employment insurance.&lt;/p&gt;

&lt;h3&gt;The Supreme Court of Canada&lt;/h3&gt;

&lt;p&gt;The Supreme Court of Canada is Canada's final court of appeal, the last judicial resort for all
litigants, whether individuals or governements.&lt;/p&gt;

&lt;h3&gt;The Canada Revenue Agency&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;CRA loses many cases that are appealed to the Supreme Court of Canada.&lt;/li&gt;
&lt;li&gt;The Supreme Court of Canada over the years have repeatedly said to the CRA:

&lt;blockquote&gt;&lt;p&gt;Taxpayers have the right to structure their affairs in a way that minimizes taxes.&lt;/p&gt;&lt;/blockquote&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;Never ever give the CRA originals of anything! They have a history of accidentally losing documents.&lt;/p&gt;

&lt;h4&gt;Dealing with the CRA&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Don't ever take what an agent says on the phone as fact, get it in writing.&lt;/li&gt;
&lt;li&gt;Go to the rulings department to get it in writing.&lt;/li&gt;
&lt;li&gt;object if you don't agree. (appeal)&lt;/li&gt;
&lt;li&gt;make applications to the fairness and Tax Ombudsman.&lt;/li&gt;
&lt;li&gt;you have 90 days to object to an assessment (the blue paper in your taxes)&lt;/li&gt;
&lt;li&gt;stay in honour with them.&lt;/li&gt;
&lt;/ul&gt;


&lt;h4&gt;Disclaimer&lt;/h4&gt;

&lt;blockquote&gt;&lt;p&gt;... nor is it responsible for the accuracy, reliability or currency of the information contained
on our Web site and supplied by external sources.&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="http://www.cra-arc.gc.ca/ntcs/dsclmr-eng.html"&gt;CRA Disclaimer&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;Understanding Tax Brackets&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;15% on the first $40,970.00 of taxable income.&lt;/li&gt;
&lt;li&gt;22% on the next $40,971.00 of taxable income. ($40,970.00 to $81,941.00)&lt;/li&gt;
&lt;li&gt;26% on the next $45,080.00 of taxable income. ($81,941.00 to $127,021.00)&lt;/li&gt;
&lt;li&gt;29% of taxable income over $127,021.00.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;Provincial tax rate for Alberta is a flat 10% on taxable income.&lt;/p&gt;

    &lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/mokhan?a=RZc6JPwoe1c:S0bX5nRJWR8:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/mokhan?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/mokhan?a=RZc6JPwoe1c:S0bX5nRJWR8:zNBqN1PhYbM"&gt;&lt;img src="http://feeds.feedburner.com/~ff/mokhan?i=RZc6JPwoe1c:S0bX5nRJWR8:zNBqN1PhYbM" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/mokhan/~4/RZc6JPwoe1c" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://mokhan.ca//money/2011/02/15/financial-boot-camp-week-three.html</feedburner:origLink></entry>
  
  <entry>
    <title>Financial Boot Camp - Week Two</title>
    <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/mokhan/~3/3patsoRQ9Dg/financial-boot-camp-week-two.html" />
    <id>http://mokhan.ca/money/2011/02/08/financial-boot-camp-week-two</id>
    <updated>2011-02-08T00:00:00-07:00</updated>
    <content type="html" xml:lang="en" xml:base="http://mokhan.ca/">
      &lt;p&gt;In week two of the Kustom Design &lt;a href="http://kustomdesign.ca/kd-educational/boot-camps.html#bootcamp"&gt;Level 1 Financial boot camp&lt;/a&gt; we covered budgeting, good debt vs. bad debt,
and we discussed some advice that is now obsolete.&lt;/p&gt;

&lt;p&gt;Below are my notes from the class.&lt;/p&gt;

&lt;h2&gt;Financial Calculator:&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;N = Time/Periods&lt;/li&gt;
&lt;li&gt;I/Y = Interest/Year&lt;/li&gt;
&lt;li&gt;PV = Present Value&lt;/li&gt;
&lt;li&gt;PMT = Payment (negative value)&lt;/li&gt;
&lt;li&gt;FV = Future Value&lt;/li&gt;
&lt;li&gt;COMP = Compute&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;E.G. How many years if you could only contribute $400 monthly?
FV = 700000
PV = 0
I = 6%
PMT = -$400
N = 38.05 (38 years 1 month or 457 months)&lt;/p&gt;

&lt;h2&gt;Top 3 Credit Bureau's:&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Equifax&lt;/li&gt;
&lt;li&gt;TransUnion&lt;/li&gt;
&lt;li&gt;Northern Credit&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;Steps to fix your credit report&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;deal directly with the company.&lt;/li&gt;
&lt;li&gt;order investigation by equifax.&lt;/li&gt;
&lt;li&gt;make a note on your credit report.&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;Always pull your own score before you go to borrow (soft check).&lt;/p&gt;

&lt;p&gt;RBC credit alert notifies you when something happens to your credit score or report.&lt;/p&gt;

&lt;h2&gt;Improving Your Credit Score&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;remains on your credit report for six years.&lt;/li&gt;
&lt;li&gt;a hard check can knock 10-20 points off your score.&lt;/li&gt;
&lt;li&gt;can fall over night.&lt;/li&gt;
&lt;li&gt;good credit will save you money.

&lt;ul&gt;
&lt;li&gt;lower interest on mortgages/loans.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;650 bottom line for most lenders.&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;5 Main Ares Used in Calculating Your Credit Score&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Your payment history&lt;/li&gt;
&lt;li&gt;Amounts you owe&lt;/li&gt;
&lt;li&gt;Length of your credit history&lt;/li&gt;
&lt;li&gt;Types of credit used.&lt;/li&gt;
&lt;li&gt;Your new credit&lt;/li&gt;
&lt;/ol&gt;


&lt;h2&gt;Top 5 Ways to Improve Your Credit Score&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Pay all bills on time.&lt;/li&gt;
&lt;li&gt;Keep revolving credit balances low.&lt;/li&gt;
&lt;li&gt;Limit your credit.&lt;/li&gt;
&lt;li&gt;Be focused when you go for credit.&lt;/li&gt;
&lt;li&gt;Manage your credit responsibly and regularly.&lt;/li&gt;
&lt;/ul&gt;


&lt;blockquote&gt;&lt;p&gt;Some agreements allow lenders to check your credit when they want.&lt;/p&gt;

&lt;p&gt;Brokers are good, they check your credit once then shop it around for you.&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;If you have a good score you can negotiate a lower rate with your lender.
If your write them a letter, then it is documented.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open Circle (ever expanding)&lt;/li&gt;
&lt;li&gt;Closed Circle (fixed)&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;The Closed Circle&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Obligations&lt;/li&gt;
&lt;li&gt;Necessities&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Wants&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Issue a tracking system.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;Total of expenditures.&lt;/li&gt;
&lt;li&gt;Capture sources of income.&lt;/li&gt;
&lt;li&gt;Determine material wants.&lt;/li&gt;
&lt;li&gt;Determine between Obligations, Necessities or Wants.&lt;/li&gt;
&lt;li&gt;Prepare the closed circle.&lt;/li&gt;
&lt;li&gt;Compare income and expenses.&lt;/li&gt;
&lt;/ul&gt;


&lt;h3&gt;notes&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;you are much more likely to get something if you write it out.&lt;/li&gt;
&lt;li&gt;split and list wants.&lt;/li&gt;
&lt;/ul&gt;


&lt;blockquote&gt;&lt;p&gt;Calculate your expenses first.&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;Only take what you need from your business, nothing more.&lt;/p&gt;

&lt;blockquote&gt;&lt;p&gt;When you take good care of what you have been given, you will receive more to take care of!&lt;/p&gt;&lt;/blockquote&gt;

&lt;h2&gt;Overflow&lt;/h2&gt;

&lt;p&gt;Overflow can be used for:
* eliminating bad debt.
* planned giving.
* investing.
* other agreed upon items that help you achieve your goals.&lt;/p&gt;

&lt;h2&gt;What about cash flow?&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;not all funds come when you think they are coming.&lt;/li&gt;
&lt;li&gt;use your cash flow wisely and don't go over your budget.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;2 ways to increase cash flow:
* more cash flow coming in
* less expenses going out&lt;/p&gt;

&lt;blockquote&gt;&lt;p&gt;incoming cash flow can be active or passive.&lt;/p&gt;&lt;/blockquote&gt;

&lt;h2&gt;Step 2: Eliminate Bad Debt&lt;/h2&gt;

&lt;p&gt;Good Debt:
* Has asset attached.
* Is tax deductible.
* leverage used to invest. (rental property)&lt;/p&gt;

&lt;p&gt;Bad Debt:
* Consumer (credit cards)
* Non Deductible (Mortgage)
* High Interest&lt;/p&gt;

&lt;h3&gt;Example:&lt;/h3&gt;

&lt;p&gt;You owe $10,000.00 on your credit cards with an average interest rate of 20%.
The standard minimum payment for $10,000.00 is $250.00.
If that is all you pay each month, it will be 37 years and more than $19,000.00
in interest charges before your balance is paid off.&lt;/p&gt;

&lt;h3&gt;What if you have more than one credit card to pay off?&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;List outstanding credit card balances.&lt;/li&gt;
&lt;li&gt;Divide each balance by the minimum payment required.&lt;/li&gt;
&lt;li&gt;Do this for all of your credit cards.&lt;/li&gt;
&lt;li&gt;List them in order of payments from lowest to highest.&lt;/li&gt;
&lt;li&gt;Apply your extra $10.00 a day to the one with the least amount of payments.&lt;/li&gt;
&lt;/ol&gt;


&lt;h4&gt;Example&lt;/h4&gt;

&lt;h5&gt;Mastercard&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;balance of $3000 @ 19.99%&lt;/li&gt;
&lt;li&gt;Minimum payment of $300.00&lt;/li&gt;
&lt;/ul&gt;


&lt;h5&gt;Visa&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;balance at $4000.00 @ 17.99%&lt;/li&gt;
&lt;li&gt;minimum payment of $450.00&lt;/li&gt;
&lt;/ul&gt;


&lt;h5&gt;Calculation:&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;MC $3000.00/$300.00 = 10&lt;/li&gt;
&lt;li&gt;Visa $4000.00/$450.00 = 9&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;Pay off your Visa first, then your mastercard.&lt;/p&gt;

&lt;h2&gt;Eliminating Bad Debt&lt;/h2&gt;

&lt;h3&gt;Don't be a slave to interest&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;all credit card interest.&lt;/li&gt;
&lt;li&gt;high interest loans, notes and credit lines.&lt;/li&gt;
&lt;li&gt;non deductible loans, notes and credit lines.&lt;/li&gt;
&lt;li&gt;all non deductible mortgages.&lt;/li&gt;
&lt;li&gt;family debt with no repayment structure.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;Bad Debt elimination strategies
* refinancing at lower interest rates
* consolidation
* depositing paychecks to line of credit.
* smith maneuver&lt;/p&gt;

&lt;h2&gt;What We Were Taught&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Work hard and you'll get job security.&lt;/li&gt;
&lt;li&gt;The company pension plan will take care of you.&lt;/li&gt;
&lt;li&gt;Canada pension plan will take care of you.&lt;/li&gt;
&lt;li&gt;save money&lt;/li&gt;
&lt;li&gt;get out of debt&lt;/li&gt;
&lt;li&gt;invest for the long term.&lt;/li&gt;
&lt;li&gt;diversify your investments.&lt;/li&gt;
&lt;li&gt;turn your money over to an expert - someone you can trust.&lt;/li&gt;
&lt;li&gt;you need to have money to make money.&lt;/li&gt;
&lt;li&gt;to good to be true? it probably is.&lt;/li&gt;
&lt;/ul&gt;


&lt;h3&gt;Why working hard is obsolete advice&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;income tax was first imposed in Canada in 1917 on both individuals and corporations, collected primarily by the federal government.&lt;/li&gt;
&lt;li&gt;Canada has a graduated tax system, as do most provinces. (Alberta does not 10%)&lt;/li&gt;
&lt;li&gt;tax rate can exceed 50% annually in many provinces:

&lt;ul&gt;
&lt;li&gt;federal and provincial surtaxes&lt;/li&gt;
&lt;li&gt;provincial health premium taxes&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;other mandatory government premiums (not officially taxes)

&lt;ul&gt;
&lt;li&gt;CPP&lt;/li&gt;
&lt;li&gt;EI&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;effective tax rate of close to 60%

&lt;ul&gt;
&lt;li&gt;top tax rate at &lt;a href="http://www.cra-arc.gc.ca/tx/ndvdls/fq/txrts-eng.html"&gt;$128, 800 (2011)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;the government has the right to get paid its taxes at the same time as employees.&lt;/li&gt;
&lt;li&gt;business owners are allowed to pay their expenses before they pay their taxes.

&lt;ul&gt;
&lt;li&gt;this massive loophole is one of the reasons that the rich get richer.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;blockquote&gt;&lt;p&gt;Therefore, the harder you work as an employee the more you pay in taxes.&lt;/p&gt;&lt;/blockquote&gt;

&lt;h2&gt;The RRSP&lt;/h2&gt;

&lt;p&gt;Positives:
* tax deductions
* long term growth for future income
* forced savings program&lt;/p&gt;

&lt;p&gt;Negatives:
* eventually taxed
* limit on amount
* no collateral advantage
* investment restrictions
* age and income restrictions
* government control
* interest on load not deductible
* liquidity
* cannot claim losses
* no tax savings on capital gains or dividends&lt;/p&gt;

&lt;h3&gt;notes&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;interest on loans are tax deductible for other investments but not for RRSP's&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;Why "Save Money" is obsolete advice&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;after the U.S. went off the gold standard, a dollar saved was no longer a dollar earned.&lt;/li&gt;
&lt;li&gt;Prior to 2000, in fear of Y2K the government of the U.S. printed billions of dollars to keep the economy afloat.&lt;/li&gt;
&lt;li&gt;9/11, Iraq War and Bailouts the US printed massive amounts of money again.&lt;/li&gt;
&lt;li&gt;at the same time China entered the World Trade Organization and became the biggest creditor in the world and the U.S. became the biggest debtor.&lt;/li&gt;
&lt;li&gt;As our economy floats on the U.S. dollar, the Canadian dollar will continue to be devalued.&lt;/li&gt;
&lt;li&gt;The core Consumer Price Index determines the rate of inflation, but it is missing fruit,
vegetables, gasoline, fuel oil, natural gas, mortgage interest, intercity transportation, tabacco
products as well as the effect of changes in indirect taxes on the remaining components.&lt;/li&gt;
&lt;li&gt;In spite of house prices doubling, and tripling... and oil going from $10.00 a barrel to $90.00 a
barrel, the economists say there is no real inflation. That's because economists watch the CPI, not
the price of assets.&lt;/li&gt;
&lt;li&gt;The bank can leverage your dollars to the tune of 20 to 1.&lt;/li&gt;
&lt;li&gt;The savers lose because the value of their dollar goes down, and the bank has created 20 more
dollars from their 1 dollar.&lt;/li&gt;
&lt;/ul&gt;


&lt;h3&gt;Notes&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The more currency they inject, the less it is worth. (supply and demand)&lt;/li&gt;
&lt;li&gt;Buy GOLD!&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;Why "Get Out of Debt" is Obsolete Advice&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Good debt is money leveraged to make more money such as the real estate investment.

&lt;ul&gt;
&lt;li&gt;This is debt that someone else pays for you.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Bad debt is consumer debt; money spent on consumable items.

&lt;ul&gt;
&lt;li&gt;This is debt that you pay for.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;The majority of people think that all debt is bad because they have not been trained to use debt properly.&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;Why "Invest for the Long Term" is Obsolete Advice&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;All mutual funds require fees regardless of whether you earn money or lose money.&lt;/li&gt;
&lt;li&gt;Canadians pay much more for the same services than Americans do.&lt;/li&gt;
&lt;li&gt;It is possible to receive higher rates of return by making your money work for you. It doesn't
make sense to simple hand over your money - to complete strangers - and expect to receive a return
at some point in the future.&lt;/li&gt;
&lt;li&gt;You have to be willing to invest in your financial education so that you can see the potential in
any oppurtunity.&lt;/li&gt;
&lt;/ul&gt;


&lt;blockquote&gt;&lt;p&gt;"Rule number one is don't lose money" - Warren Buffet
"Rule number two is always remember rule number one." - Warren Buffet
"Diversification is required when investors do not know what they are doing." - Warren Buffet&lt;/p&gt;&lt;/blockquote&gt;

&lt;h2&gt;Why "Diversify" is Obsolete Advice&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Diversification is like going to the racetrack and betting on all the horses; you may not lose much money, but you also won't make much money.&lt;/li&gt;
&lt;li&gt;Many financial advisors recommend diversification because they don't have the ability to pick the winner.. so they play it safe and recommend that you "bet on all the horses".&lt;/li&gt;
&lt;li&gt;There are three basic asset classes:

&lt;ul&gt;
&lt;li&gt;Paper Assets: promissary notes, bonds etc.&lt;/li&gt;
&lt;li&gt;Real Estate: raw land or buildings&lt;/li&gt;
&lt;li&gt;Businesses: publicly held or private&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;The five biggest markets to invest in are:
* The Stock Market
* The Bond Market
* The Real Estate Market
* The Currency Market
* The Commodities Market&lt;/p&gt;

&lt;h2&gt;The Smith Manoeuvre&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Get a re-advanceable mortgage&lt;/li&gt;
&lt;li&gt;Liquidate non-registered assets (like stocks held outside of an RRSP) into cash.&lt;/li&gt;
&lt;li&gt;Use this cash as a down payment on your mortgage.&lt;/li&gt;
&lt;li&gt;Make mortgage payments like normal.&lt;/li&gt;
&lt;li&gt;Re-borrow $1 for every $1 of mortgage principle you pay each month.&lt;/li&gt;
&lt;li&gt;Invest that borrowed money at a higher rate of return than the loan interest you pay.&lt;/li&gt;
&lt;li&gt;Deduct your investment loan interest and use the tax savings to pre-pay your mortgage.&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;Repeat steps 3-7 until your mortage is paid off!&lt;/p&gt;

&lt;blockquote&gt;&lt;p&gt;This one is a little confusing, because now you have an extra interest payment to make against the
line of credit portion of the re-advanceable mortgage. I've read that you're supposed to capitalize
the interest by borrowing from your line of credit to pay the interest payment on your line of
credit. This sounds very risky! - mo&lt;/p&gt;&lt;/blockquote&gt;

&lt;h3&gt;links&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.smithman.net/"&gt;smithman&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.milliondollarjourney.com/the-smith-manoeuvre-a-wealth-strategy-part-1.htm"&gt;million dollar journey&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.canadiancapitalist.com/the-smith-manoeuvre-debate/"&gt;canadian capitalist&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;&lt;audio controls&gt;
  &lt;source src="http://mokhan.ca/downloads/TheCreatureFromJekyllIsland.mp3" /&gt;
&lt;/audio&gt;&lt;/p&gt;

    &lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/mokhan?a=3patsoRQ9Dg:B64r3FswJD4:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/mokhan?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/mokhan?a=3patsoRQ9Dg:B64r3FswJD4:zNBqN1PhYbM"&gt;&lt;img src="http://feeds.feedburner.com/~ff/mokhan?i=3patsoRQ9Dg:B64r3FswJD4:zNBqN1PhYbM" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/mokhan/~4/3patsoRQ9Dg" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://mokhan.ca//money/2011/02/08/financial-boot-camp-week-two.html</feedburner:origLink></entry>
  
  <entry>
    <title>freenx</title>
    <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/mokhan/~3/BCrrbnLLJhs/freenx.html" />
    <id>http://mokhan.ca/tools/2011/02/03/freenx</id>
    <updated>2011-02-03T00:00:00-07:00</updated>
    <content type="html" xml:lang="en" xml:base="http://mokhan.ca/">
      &lt;p&gt;freenx is like remote desktop (mstsc.exe). The way it works is you have to run a NX server on the
box that you want to remote in to. You then use a NX Client to remote in to the box.&lt;/p&gt;

&lt;p&gt;There's a great &lt;a href="https://help.ubuntu.com/community/FreeNX"&gt;Community Doc page&lt;/a&gt; for getting up and running on Ubuntu.&lt;/p&gt;

&lt;p&gt;If you don't already have &lt;a href="http://mokhan.ca/tools/2011/01/12/ssh.html"&gt;SSH&lt;/a&gt; set up, you will probably want to get that up and running first.&lt;/p&gt;

&lt;p&gt;Below is a short version of what I ran to get up and running on 10.10.&lt;/p&gt;

&lt;h2&gt;Install Server&lt;/h2&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="text"&gt;  $ sudo add-apt-repository ppa:freenx-team
  $ sudo sed -i &amp;#39;s/maverick/lucid/g&amp;#39; /etc/apt/sources.list.d/freenx-team-ppa-maverick.list
  $ sudo apt-get update
  $ sudo apt-get install freenx
  $ cd ~/Downloads
  $ wget https://bugs.launchpad.net/freenx-server/+bug/576359/+attachment/1378450/+files/nxsetup.tar.gz
  $ tar -xvf nxsetup.tar.gz
  $ sudo cp nxsetup /usr/lib/nx/nxsetup
  $ sudo /usr/lib/nx/nxsetup --install
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;h2&gt;Install Client&lt;/h2&gt;

&lt;p&gt;There seems to be several NXClients available but I chose to try the NoMachine client which can be downloaded from &lt;a href="http://www.nomachine.com/select-package-client.php"&gt;here.&lt;/a&gt;&lt;/p&gt;

    &lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/mokhan?a=BCrrbnLLJhs:N6vLPoA6fGQ:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/mokhan?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/mokhan?a=BCrrbnLLJhs:N6vLPoA6fGQ:zNBqN1PhYbM"&gt;&lt;img src="http://feeds.feedburner.com/~ff/mokhan?i=BCrrbnLLJhs:N6vLPoA6fGQ:zNBqN1PhYbM" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/mokhan/~4/BCrrbnLLJhs" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://mokhan.ca//tools/2011/02/03/freenx.html</feedburner:origLink></entry>
  
  <entry>
    <title>financial boot camp - week 1</title>
    <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/mokhan/~3/uZ_f1aC2eIk/financial-boot-camp-week-one.html" />
    <id>http://mokhan.ca/money/2011/01/28/financial-boot-camp-week-one</id>
    <updated>2011-01-28T00:00:00-07:00</updated>
    <content type="html" xml:lang="en" xml:base="http://mokhan.ca/">
      &lt;p&gt;Earlier this week I attended the first of seven classes of Kustom Design's
&lt;a href="http://kustomdesign.ca/kd-educational/boot-camps.html#bootcamp"&gt;Level 1 financial boot camp&lt;/a&gt;.&lt;/p&gt;

&lt;blockquote&gt;&lt;p&gt;paraphrased: "Accumulate assets that are valuable whether or not the financial system crashes." - Mike&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;The class is taught by Michael E. Lepitre. Mike is super passionate about money, and it shows when he's
teaching.&lt;/p&gt;

&lt;blockquote&gt;&lt;p&gt;Financial freedom: Where you do not have to work for money. Instead money works for you providing
plenty to fulfill your purpose, enjoy life and allow your wealth to grow for future generations and
charity.&lt;/p&gt;&lt;/blockquote&gt;

&lt;h2&gt;The 5 Steps&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Develop a closed circle budget.&lt;/li&gt;
&lt;li&gt;Eliminate bad debt (consumer &amp;amp; mortgage).&lt;/li&gt;
&lt;li&gt;Legally Minimize Taxes.&lt;/li&gt;
&lt;li&gt;Wealth accumulation &amp;amp; increase passive cash flow.&lt;/li&gt;
&lt;li&gt;Wealth preservation.&lt;/li&gt;
&lt;/ol&gt;


&lt;h2&gt;Today's educational system focuses on:&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;academic education: ability to read, write and compute.&lt;/li&gt;
&lt;li&gt;Professional education: learning a trade to earn money, to get a job.&lt;/li&gt;
&lt;li&gt;NOT financial education: learning how to make money work for you.&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;Classes of Investors&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Non-investor (the poor)

&lt;ul&gt;
&lt;li&gt;consume everything they earn.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Active Investors

&lt;ul&gt;
&lt;li&gt;these people are entrepreneurs.&lt;/li&gt;
&lt;li&gt;They invest first in becoming financial experts.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Passive Investors (the middle class)

&lt;ul&gt;
&lt;li&gt;believes in good education, a high paying job, home ownership and saving for retirement through a pension.&lt;/li&gt;
&lt;li&gt;Turns their money over to financial experts to invest.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;h3&gt;Key Differences&lt;/h3&gt;

&lt;h4&gt;Passive Investors&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;no control&lt;/li&gt;
&lt;li&gt;higher risks&lt;/li&gt;
&lt;li&gt;banks will not lend money to them&lt;/li&gt;
&lt;li&gt;higher taxes&lt;/li&gt;
&lt;li&gt;worries about market crash&lt;/li&gt;
&lt;li&gt;low returns&lt;/li&gt;
&lt;li&gt;plan can run out of money&lt;/li&gt;
&lt;li&gt;may never retire&lt;/li&gt;
&lt;/ul&gt;


&lt;h4&gt;Active Investors&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;has control&lt;/li&gt;
&lt;li&gt;lower risks&lt;/li&gt;
&lt;li&gt;use bank's money (OPM)&lt;/li&gt;
&lt;li&gt;uses insurance&lt;/li&gt;
&lt;li&gt;may pay zero taxes&lt;/li&gt;
&lt;li&gt;welcomes market crash&lt;/li&gt;
&lt;li&gt;high returns&lt;/li&gt;
&lt;li&gt;plan provides for generations&lt;/li&gt;
&lt;li&gt;may retire early (choice)&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;Cash Flow Quadrants&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;E Employee - You have a job&lt;/li&gt;
&lt;li&gt;S Self Employed - You own a job&lt;/li&gt;
&lt;li&gt;B Business Owner - You own a system &amp;amp; people work for you&lt;/li&gt;
&lt;li&gt;I Investor - Money works for you.&lt;/li&gt;
&lt;/ul&gt;


&lt;h3&gt;Employee&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;earns income, works for money, has a job.&lt;/li&gt;
&lt;li&gt;Believes the harder you work, the more money you make.&lt;/li&gt;
&lt;li&gt;Believes more money will solve their financial problems.&lt;/li&gt;
&lt;li&gt;Searches for a safe secure job with good pay and excellent benefits.&lt;/li&gt;
&lt;li&gt;Believes the level of formal education relates directly to receiving a higher income.&lt;/li&gt;
&lt;li&gt;Taxes are their number one expense.&lt;/li&gt;
&lt;li&gt;Invests in RRSPs and mutual funds.&lt;/li&gt;
&lt;/ul&gt;


&lt;h3&gt;Self Employed&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;hardest working people on the planet.&lt;/li&gt;
&lt;li&gt;Usually wear all the hats.&lt;/li&gt;
&lt;li&gt;90% fail after 5 years.&lt;/li&gt;
&lt;li&gt;Work harder and longer than most employees and bring their work home with them.&lt;/li&gt;
&lt;li&gt;Like to "be their own boss" and do it themselves.&lt;/li&gt;
&lt;li&gt;Seek to be in control and resist delegating.&lt;/li&gt;
&lt;/ul&gt;


&lt;h3&gt;Business Owner&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;surround themselves with smart people from all four quadrants&lt;/li&gt;
&lt;li&gt;learn technical skills:

&lt;ul&gt;
&lt;li&gt;reading financial statements&lt;/li&gt;
&lt;li&gt;marketing&lt;/li&gt;
&lt;li&gt;sales&lt;/li&gt;
&lt;li&gt;accounting&lt;/li&gt;
&lt;li&gt;management&lt;/li&gt;
&lt;li&gt;how to lead people&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;pay very little in taxes&lt;/li&gt;
&lt;li&gt;protected by using corporations and trusts.&lt;/li&gt;
&lt;/ul&gt;


&lt;h3&gt;Investor&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;knows that you must invest to be wealthy&lt;/li&gt;
&lt;li&gt;have money working for them&lt;/li&gt;
&lt;li&gt;do not invest in RRSPs&lt;/li&gt;
&lt;li&gt;main focus on ROI (return on investment) and cash flow&lt;/li&gt;
&lt;li&gt;pay the least amount of taxes&lt;/li&gt;
&lt;li&gt;invest utilizing corporations and trusts&lt;/li&gt;
&lt;/ul&gt;


&lt;h4&gt;investment income&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;interest income: taxed very high&lt;/li&gt;
&lt;li&gt;capital gains income: taxed at 50%

&lt;ul&gt;
&lt;li&gt;if you buy one share at $10. Then watch it go up to $20, and sell it you will be taxed on the $10 increase at 50%.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;dividend income: most tax advantageous&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;There are people who become wealthy in each quadrant and sometimes derive income from different
sources.&lt;/p&gt;

&lt;h2&gt;History of Money&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Before money, the barter system was used.&lt;/li&gt;
&lt;li&gt;Silver, gold and other metals were the first forms of the monetary system.&lt;/li&gt;
&lt;li&gt;Gold became the standard of currency banking.&lt;/li&gt;
&lt;li&gt;The fiat money system has been tested for 2000 years (never with any long term success due to debt.)&lt;/li&gt;
&lt;li&gt;The separation process of gold from paper money began in 1933.&lt;/li&gt;
&lt;li&gt;In 1971, Richard Nixon took the US off of the quasi-gold standard.&lt;/li&gt;
&lt;li&gt;Savers become losers because they were now saving a currency instead of saving money.&lt;/li&gt;
&lt;li&gt;The problem with saving a currency is that a currency is designed to go down in value.&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;Wake Up Call&lt;/h2&gt;

&lt;p&gt;Banks make a tonne of money off of our money.
E.G.
If I deposit $100,000.00 in to the bank and I receive an interest rate of 3%. I can expect to make
about $3000.00 in a year.&lt;/p&gt;

&lt;p&gt;The bank could then lend out $100,000.00 at a rate of 6% and make $6000.00.&lt;/p&gt;

&lt;p&gt;So far the bank has lost $3000.00 but gained $6000.00, so that would be about a 100% return for
them.&lt;/p&gt;

&lt;p&gt;Apparently, banks can actually lend out 20 times that original $100,000.00 I put in. Which means
that bank can lend out $2,000,000.00 at 6% and get a return of $120,000.00 in a year. It costs the
bank $3000.00 and earns them $120,000.00. This sounds crazy!&lt;/p&gt;

&lt;p&gt;It's called &lt;a href="http://en.wikipedia.org/wiki/Fractional-reserve_banking"&gt;fractional reserve banking&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next, up it's time to visit the Finance section of the &lt;a href="http://www.khanacademy.org/"&gt;Khan Academy&lt;/a&gt;.&lt;/p&gt;

    &lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/mokhan?a=uZ_f1aC2eIk:sDPxCwEOfzo:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/mokhan?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/mokhan?a=uZ_f1aC2eIk:sDPxCwEOfzo:zNBqN1PhYbM"&gt;&lt;img src="http://feeds.feedburner.com/~ff/mokhan?i=uZ_f1aC2eIk:sDPxCwEOfzo:zNBqN1PhYbM" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/mokhan/~4/uZ_f1aC2eIk" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://mokhan.ca//money/2011/01/28/financial-boot-camp-week-one.html</feedburner:origLink></entry>
  
  <entry>
    <title>wget</title>
    <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/mokhan/~3/j6pHZ4JqSZI/wget.html" />
    <id>http://mokhan.ca/tools/2011/01/27/wget</id>
    <updated>2011-01-27T00:00:00-07:00</updated>
    <content type="html" xml:lang="en" xml:base="http://mokhan.ca/">
      &lt;p&gt;How do you replace a deprecated application that was built on top of Microsoft Content Management
System (MCMS) 2002?&lt;/p&gt;

&lt;p&gt;You could recursively download the entire website and serve it up as static html pages.
This is where you use a tool like wget.&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="text"&gt;  $ sudo apt-get install wget
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;or download the wget package via cygwin.&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;code class="text"&gt;  $ wget -r -p http://mokhan.ca/
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;


&lt;p&gt;And there you have it. You now have a local copy of the target website.&lt;/p&gt;

&lt;p&gt;If you notice that some content wasn't pulled down, that should have been, it's likely because the
site has a robots.txt file at root that disallows certain urls.&lt;/p&gt;

&lt;h2&gt;links&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.linuxjournal.com/content/downloading-entire-web-site-wget"&gt;linux journal&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://linuxreviews.org/quicktips/wget/"&gt;linux reviews&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


    &lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/mokhan?a=j6pHZ4JqSZI:62IMlVxmE44:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/mokhan?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/mokhan?a=j6pHZ4JqSZI:62IMlVxmE44:zNBqN1PhYbM"&gt;&lt;img src="http://feeds.feedburner.com/~ff/mokhan?i=j6pHZ4JqSZI:62IMlVxmE44:zNBqN1PhYbM" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/mokhan/~4/j6pHZ4JqSZI" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://mokhan.ca//tools/2011/01/27/wget.html</feedburner:origLink></entry>
  
</feed>

