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

<channel>
	<title>Code. Design. Explore.</title>
	<atom:link href="http://www.janisb.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.janisb.com/blog</link>
	<description>The World Through the Eyes of John Brennan</description>
	<pubDate>Sun, 29 Jun 2008 00:22:30 +0000</pubDate>
	<generator>http://wordpress.org/?v=</generator>
	<language>en</language>
			<item>
		<title>Velocity Conf - My takeaways</title>
		<link>http://www.janisb.com/blog/2008/06/velocity-conf-my-takeaways/</link>
		<comments>http://www.janisb.com/blog/2008/06/velocity-conf-my-takeaways/#comments</comments>
		<pubDate>Thu, 26 Jun 2008 07:04:22 +0000</pubDate>
		<dc:creator>John Brennan</dc:creator>
		
		<category><![CDATA[Code]]></category>

		<category><![CDATA[Velocity08]]></category>

		<category><![CDATA[VelocityConf08]]></category>

		<guid isPermaLink="false">http://www.janisb.com/blog/?p=88</guid>
		<description><![CDATA[San Francisco was great!  I got to take part in a great conference, network with other people facing similar challenges and catch up with some of my old friends in the area.
It&#8217;s amazing how many people are doing &#8220;startups&#8221; in that area.  I put startups in quotes though because a startup isn&#8217;t anything [...]<script type="text/javascript">SHARETHIS.addEntry({ title: "Velocity Conf - My takeaways", url: "http://www.janisb.com/blog/2008/06/velocity-conf-my-takeaways/" });</script>]]></description>
			<content:encoded><![CDATA[<p>San Francisco was great!  I got to take part in a great conference, network with other people facing similar challenges and catch up with some of my old friends in the area.</p>
<p>It&#8217;s amazing how many people are doing &#8220;startups&#8221; in that area.  I put startups in quotes though because a startup isn&#8217;t anything less than a great idea that hasn&#8217;t been fully executed yet.  Second, I should clarify &#8220;amazing&#8221; too.  Obviously Silicon Valley is the mecca for high-tech startups in the world, but you don&#8217;t actually realize what that means until you start to talk to people there.  Here in San Diego I can count the number of people I know working on startups on one hand.  Ok, maybe 2 hands if you count people wanting to get involved, but haven&#8217;t made that first step yet.</p>
<p>While I was catching up with Sameer and Shirin over dinner they were telling me how the majority of their friends (aside from working at Google) work in startups.</p>
<p>That said, here&#8217;s a summary of what I got from the Velocity conference.  I had a great time and <a href="http://en.oreilly.com/velocity2008/public/schedule/speaker/1669">Steve Souders</a> and the O&#8217;Reilly team really did a great job putting this together.  My only suggestion for next time would be to show some more real examples.  For example, I know that in order to scale you need to shard, partition and replicate the databases.  You need to profile and test, then profile and test again.  Maybe I was looking for more of a workshop, but it was very informative and I hope you return next year!</p>
<p><span id="more-88"></span></p>
<p>Here&#8217;s what I got&#8230;</p>
<h2>Performance Overview and Tools</h2>
<ul>
<li>Plan for perf from day 1</li>
<li>Set expectations ahead of time
<ul>
<li>why do users of World of Warcraft accept downtime each week (and pay for the service), but users of Friendster/twitter don&#8217;t?  Expectations.</li>
</ul>
</li>
<li>Even after you solved YOUR performance problems, ads become the root of the problem!
<ul>
<li>Artur has a <a href="http://www.google.com/notebook/public/15466807879718028470/BDQqRIwoQ65Gisasj#SDR24IgoQr6X2sqsj">cool hack</a> to overwrite document.write to get around this problem</li>
</ul>
</li>
<li>Measure the right things
<ul>
<li>No cache scenario is really important</li>
</ul>
</li>
<li>When optimizing perf you can&#8217;t just look at the mean average, you have to look at the median, percentile, and outliers too.</li>
<li>Automated testing and profiling needs to be part of the process!</li>
<li>keep historical records of how features perform</li>
<li>consider keeping some (small amount of) profiling code in production</li>
<li>Tools
<ul>
<li><a href="http://kite.keynote.com/">Kite</a>
<ul>
<li>Real-time testing from multiple locations</li>
<li>Interactively test perf from desktop, last mile, and cloud</li>
<li>available in Aug</li>
</ul>
</li>
<li><a href="http://code.google.com/p/jiffy-web/">Jiffy</a>
<ul>
<li>measure individual pieces of page rendering (script load, AJAX execution, page load, etc.) on every client</li>
<li>report those measurements and other metadata to a web server</li>
<li>aggregate web server logs into a database</li>
<li>generate reports</li>
<li>has Firebug plugin</li>
</ul>
</li>
<li><a href="http://research.microsoft.com/projects/doloto/">Doloto</a>
<ul>
<li>analyzes application workloads and automatically performs code splitting</li>
<li>code gets processed and only necessary initialization code gets transfers right away</li>
<li>the rest of the code is replaced by short stubs and transferred lazily in the background</li>
</ul>
</li>
<li><a href="http://cloudstatus.com:8000">CloudStatus</a>
<ul>
<li>Provide service to monitor uptime and availability for AWS, Google appengine, etc</li>
</ul>
</li>
<li><a href="http://www.fiddler2.com/fiddler2/">Fiddler</a> (profiling tool)
<ul>
<li>Written by my old mentor from Microsoft!</li>
<li>measure request size, page wgt</li>
<li>analyze caching, compression, page composition</li>
<li>simulate low-speed/high-latency connections</li>
<li>breakpoint debugging</li>
<li>traffic modification</li>
<li><a href="http://www.fiddler2.com/fiddler/Perf/">perf test walkthrough</a></li>
</ul>
</li>
<li>AOL PageTest
<ul>
<li>Online version: <a href="http://www.webpagetest.org/">http://www.webpagetest.org</a></li>
<li><a href="http://pagetest.wiki.sourceforge.net/">http://pagetest.wiki.sourceforge.net/</a></li>
</ul>
</li>
</ul>
</li>
</ul>
<h2>Optimizing Page Load Times</h2>
<ul>
<li>Apache changes
<ul>
<li>use gzip, far future expires and etag</li>
<li>Don&#8217;t use advanced compression (run time cost)</li>
</ul>
</li>
<li>Javascript changes
<ul>
<li>reduce DOM elements</li>
<li><a href="http://ajaxpatterns.org/On-Demand_Javascript">lazy load components</a></li>
<li>use GET unless you need POST</li>
<li>use JSON instead of XML (don&#8217;t want to walk the XML tree!)</li>
<li>minify with YUI compressor + HTTP compression</li>
<li>use jQuery</li>
</ul>
</li>
<li>Content changes
<ul>
<li><a href="http://www.julienlecomte.net/blog/2007/09/16/">minify JS+CSS as part of build process</a></li>
<li>render most of content on server side (instead of using JS+DOM for example)</li>
<li>fewer serialized actions</li>
<li>eliminated DNS lookup</li>
<li>move your contents closer to your customers (use a CDN)</li>
</ul>
</li>
<li>Trim cookies
<ul>
<li>moving them away from your root domain and root path &#8220;/&#8221; bc those will be sent with EVERY page request</li>
<li>compress cookies (heads) not just bodies</li>
<li>grouping multiple smaller files into fewer bigger ones (image clustering)</li>
<li>eliminating them by moving your static content to a different domain</li>
<li>trim down the # of requests and redirects (round trips)</li>
</ul>
</li>
<li>Work on improving perceived performance
<ul>
<li>cheat when you can by updating UI then do the work</li>
</ul>
</li>
<li>Unique tricks
<ul>
<li>After page load, download external CSS and JS for upcoming page views</li>
</ul>
</li>
<li>See my <a href="http://www.google.com/notebook/public/15466807879718028470/BDQqRIwoQ65Gisasj#SDUThIgoQmu3_uqsj">notes on Julien Lecomte&#8217;s High Performance Ajax</a> for more great tips</li>
</ul>
<h2>Optimizing Images</h2>
<ul>
<li>Choose PNG over GIF
<ul>
<li>avg savings of 20%</li>
</ul>
</li>
<li>Crushing PNGs
<ul>
<li>most image programs DO NOT optimize</li>
<li>cmdline tools:
<ul>
<li><a href="http://pmt.sourceforge.net/pngcrush">pngcrush</a></li>
<li>pngrewrite</li>
<li>optipng</li>
<li>pngout</li>
</ul>
</li>
<li>avg savings of 16%</li>
</ul>
</li>
<li>strip needless JPEG metadata</li>
<li>reducing their color palettes
<ul>
<li>convert truecolor PNG to palette PNG (PNG8)</li>
</ul>
<ul>
<li>PNG8 has 256 colors, truecolor has millions</li>
</ul>
</li>
<li>far future expires (harder than it seems)</li>
<li>combine images
<ul>
<li>use sprites</li>
</ul>
</li>
</ul>
<h2>Scaling</h2>
<ul>
<li>Use <a href="http://www.danga.com/memcached/">Memcached<br />
</a></p>
<ul>
<li>high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load.  Handles the majority of your reads.  It&#8217;s practically a requirement, but not a substitute for bad design!</li>
</ul>
</li>
<li>Use a CDN
<ul>
<li><a href="http://www.pantherexpress.net/">Panther</a> - cheap and good (recommended by someone from <a href="http://www.stardoll.com">stardoll.com</a>)</li>
<li>Akamai - expensive, but top of the line</li>
</ul>
</li>
<li>Increase cache hits (with edge caching)
<ul>
<li>doesn&#8217;t like <a href="http://www.squid-cache.org/">squid</a></li>
<li>loves <a href="http://varnish.projects.linpro.no/">varnish</a>
<ul>
<li>a bit unstable</li>
<li>segfaults under load (running trunk)</li>
</ul>
</li>
</ul>
</li>
<li>Database scaling options
<ul>
<li>Vertical partitioning - splits table columns into separate tables or even splitting of tables into separate databases.  You can use a view to read the data again, but can&#8217;t insert/delete from a view.  <strong>Speaker was against this approach.</strong></li>
<li>Replication
<ul>
<li>most apps are read intensive, which is handled by memcached</li>
<li>does not help to scale writes (bc all slaves in a master-slave setup must get written)</li>
</ul>
</li>
<li>Sharding
<ul>
<li>&#8220;only&#8221; solution for large scale apps</li>
<li>can be hard to implement if not designed for&#8230;needs planning</li>
<li>want most queries to be run on same shard
<ul>
<li>good: sharding blogs by user_id</li>
<li>bad: sharding by country_id (large portion can come from same country)</li>
</ul>
</li>
<li>techniques
<ul>
<li>fixed hash sharding</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li>DB scaling tips
<ul>
<li>if you have problems bc foreign key obj, look if db offers cluster indexes.  will cut down on disk seeks.</li>
<li>app should be unaware of partition strategy. app should ask where a user lives and go get it</li>
<li>you start with a normalized db, but you need to denormalize when you start scaling</li>
<li>have triggers that hit processing nodes to figure out how to build a new row to add to db as denormalized data</li>
<li>if you are a brand new startup don&#8217;t worry about partitioning, sharding</li>
<li>better to launch to all then have a private beta and hope those users are still interested in 6 months</li>
<li>good to think about how you <em><strong>could</strong></em> use sharding down the road</li>
</ul>
<ul>
<li>
<ul>
<li>
<ul>
<li>
<ul>
<li>even IDs on A, odd on B</li>
</ul>
</li>
<li>data dictionary
<ul>
<li>user 25 has data on server D</li>
<li>dict can become bottleneck</li>
</ul>
</li>
<li>mixed hashing</li>
</ul>
</li>
<li><a href="http://www.hivedb.com/">HiveDB</a></li>
<li><a href="http://www.hscale.org/">HSCALE</a></li>
</ul>
</li>
</ul>
</li>
</ul>
<h2>Operations</h2>
<ul>
<li>Think about how your architecture will scale when design it, but don&#8217;t shard or partition until you have to.  You&#8217;re bottlenecks might not be what you think.
<ul>
<li>LinkedIn underestimated the number of events/messages that would occur in the system.  To scale they had to denormalize and duplicate that event for each user it was sent to.</li>
<li>SmugMug didn&#8217;t realize they would get 1000s of comments on a single photo, so they needed to re-architecture how they handle comments.</li>
<li>SmugMug was logging all people that were viewing the photos, but after a huge traffic burst the site crumbled.  They had to adjust how they were logging (I didn&#8217;t pick up how).</li>
</ul>
</li>
<li>The Cloud
<ul>
<li>There needs to be an MVC framework for the backend, much like the MVC frameworks that exist today for the frontend (RoR, CakePHP, Pylons)</li>
<li>Data centers are unsustainable in their current form.  Energy costs will double in next 5 yrs.  We need Active power management.  Basically, when you leave the room, turn off the light.  Which means power down servers that you don&#8217;t need.  Virtualize.</li>
<li>You beat complexity by automating it</li>
</ul>
</li>
<li>Cloud computing services
<ul>
<li><a href="http://www.rightscale.com">RightScale</a> - leverages AWS EC2</li>
<li>AWS</li>
<li>b-hive</li>
<li>joyent</li>
<li>gogrid</li>
<li>Verio</li>
<li>EngineYard</li>
<li>3tera</li>
<li>sun <a href="http://powerofnetwork.com/">powerofnetwork.com</a></li>
</ul>
<ul>
<li><a href="http://eucalyptus.cs.ucsb.edu/">Eucalyptus</a> (open-source)
<ul>
<li>open-source software infrastructure for implementing cloud computing on clusters</li>
<li>compatible with EC2</li>
<li>wants to be the common denominator</li>
<li>doesn&#8217;t focus on the scalability</li>
</ul>
</li>
</ul>
</li>
</ul>
<h2>Tuning Recommendations</h2>
<ul>
<li><a href="http://www.danga.com/memcached/">Memcached</a>
<ul>
<li>network
<ul>
<li>ensure network processing is distributed across CPUs</li>
<li>bind memcached to CPUs not processing interrupts</li>
</ul>
</li>
<li>run memcached 1.2.5 with 4 threads (default)</li>
<li>use in 64-bit mode for a large cache size</li>
<li>run in multi-threaded mode</li>
</ul>
</li>
<li>MySQL
<ul>
<li>5.1 has several perf improvements over 5.0</li>
<li>joins over sub-queries</li>
<li>use limits</li>
<li>innodb</li>
<li>avoid too frequent FS flushes
<ul>
<li>innodb_flush_log_at_trx_commit = 2</li>
</ul>
</li>
<li><strong>separate read/write databases</strong></li>
<li>avoids trashing query cache</li>
</ul>
</li>
<li>Apache
<ul>
<li>network stack: tune TCP time-wait if handling lots of conn</li>
<li>do not load modules that you do not need (in httpd.conf)</li>
<li>tune ListenBacklog(8192), ServerLimit(2048), MaxClients(2048)</li>
</ul>
</li>
<li>PHP
<ul>
<li>turn off <em>safe_mode</em> if you don&#8217;t need it
<ul>
<li>safe_mode = off</li>
</ul>
</li>
<li>increase <em>realpath_cache_size</em> if you have lots of files
<ul>
<li>realpath_cache_size = 128K</li>
</ul>
</li>
<li>use <a href="http://xcache.lighttpd.net/wiki/Introduction">xcache </a>(stability problems? &#8230; participant in audience said he uses it in large scale and works great) or <a href="http://pecl.php.net/apc">APC</a></li>
</ul>
</li>
</ul>
<h2>Miscellaneous</h2>
<p>I was at the IE8 session and they spoke about a few new object enhancements.</p>
<ul>
<li>XDomainRequest - cross domain communication w/o server-side proxy</li>
<li>Improved XMLHTTPRequest obj now with timeout attribute</li>
</ul>
<p><a href="http://sharethis.com/item?&wp=2.5&amp;publisher=5be9cfee-1ca7-4df9-a04a-c2fbf8266feb&amp;title=Velocity+Conf+-+My+takeaways&amp;url=http%3A%2F%2Fwww.janisb.com%2Fblog%2F2008%2F06%2Fvelocity-conf-my-takeaways%2F">ShareThis</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.janisb.com/blog/2008/06/velocity-conf-my-takeaways/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Velocity Conf Day 1</title>
		<link>http://www.janisb.com/blog/2008/06/velocity-conf-day-1/</link>
		<comments>http://www.janisb.com/blog/2008/06/velocity-conf-day-1/#comments</comments>
		<pubDate>Tue, 24 Jun 2008 01:07:10 +0000</pubDate>
		<dc:creator>John Brennan</dc:creator>
		
		<category><![CDATA[Code]]></category>

		<category><![CDATA[Interesting]]></category>

		<category><![CDATA[Tips]]></category>

		<category><![CDATA[Velocity08]]></category>

		<category><![CDATA[VelocityConf08]]></category>

		<guid isPermaLink="false">http://www.janisb.com/blog/?p=87</guid>
		<description><![CDATA[I&#8217;m currently attending the O&#8217;Reilly Conference, Velocity Web Performance and Operations.  It&#8217;s the first of its kind, focusing on building web applications that scale.  My focus for the conference is to build on top of what I already know and dive deeper into performance best practice, database tuning, achieving more with less, launching [...]<script type="text/javascript">SHARETHIS.addEntry({ title: "Velocity Conf Day 1", url: "http://www.janisb.com/blog/2008/06/velocity-conf-day-1/" });</script>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m currently attending the O&#8217;Reilly Conference, <a href="http://en.oreilly.com/velocity2008/public/content/home">Velocity Web Performance and Operations</a>.  It&#8217;s the first of its kind, focusing on building web applications that scale.  My focus for the conference is to build on top of what I already know and dive deeper into performance best practice, database tuning, achieving more with less, launching in the cloud, and performance/profiling tools to track these trends.</p>
<p>My notes will be available live <a href="http://www.google.com/notebook/public/15466807879718028470/BDQqRIwoQ65Gisasj">here</a>:</p>
<p><a href="http://www.google.com/notebook/public/15466807879718028470/BDQqRIwoQ65Gisasj"></a><em>Feel free to leave your comments if their are specific questions you want asked.<br />
</em></p>
<p><a href="http://sharethis.com/item?&wp=2.5&amp;publisher=5be9cfee-1ca7-4df9-a04a-c2fbf8266feb&amp;title=Velocity+Conf+Day+1&amp;url=http%3A%2F%2Fwww.janisb.com%2Fblog%2F2008%2F06%2Fvelocity-conf-day-1%2F">ShareThis</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.janisb.com/blog/2008/06/velocity-conf-day-1/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Give and you shall receive</title>
		<link>http://www.janisb.com/blog/2008/05/give-and-you-shall-receive/</link>
		<comments>http://www.janisb.com/blog/2008/05/give-and-you-shall-receive/#comments</comments>
		<pubDate>Thu, 29 May 2008 05:59:30 +0000</pubDate>
		<dc:creator>John Brennan</dc:creator>
		
		<category><![CDATA[Middle East]]></category>

		<category><![CDATA[Travel]]></category>

		<category><![CDATA[israel]]></category>

		<guid isPermaLink="false">http://www.janisb.com/blog/?p=79</guid>
		<description><![CDATA[Judaism&#8217;s spiritual side
I had envisioned Israel being a completely adventuresome journey.  At work I was asked if I was going for spiritual reasons to which I quickly replied, &#8220;No.&#8221;  Of course if that were true I wouldn&#8217;t be writing this piece, would I?
I, like most children born into a Jewish family, went through [...]<script type="text/javascript">SHARETHIS.addEntry({ title: "Give and you shall receive", url: "http://www.janisb.com/blog/2008/05/give-and-you-shall-receive/" });</script>]]></description>
			<content:encoded><![CDATA[<h2>Judaism&#8217;s spiritual side</h2>
<p>I had envisioned Israel being a completely adventuresome journey.  At work I was asked if I was going for spiritual reasons to which I quickly replied, &#8220;No.&#8221;  Of course if that were true I wouldn&#8217;t be writing this piece, would I?</p>
<p>I, like most children born into a Jewish family, went through Sunday and Hebrew school.  Hebrew school was actually on Wednesdays after regular classroom study where my education continued, but now <em>in</em> Hebrew.  We were taught a majority of the stories from the Torah, and without a doubt all the popular ones.  One thing missing from that though was the spiritual side of Judaism.  If such a thing exists that is.</p>
<p>Before this trip I didn&#8217;t know there was a spiritual component to Judaism.  I thought Judaism = Tanakh (Torah) just as Christianity = Bible (e.g. Tanakh+New Testament).  In the last year or so I have been exploring other cultures as well as religions.  I wanted to pursue an inner peace, and explore a more spiritual understanding of the world.  The journey started with Buddhism.  Unfortunately with the chaos of life, work, and pursuing my own business I did not yet have the time to get below a general understanding of the teachings of Buddhism.</p>
<p><img class="alignnone size-full wp-image-81" title="Kabbalah, Tzfat, Israel" src="http://www.janisb.com/blog/wp-content/uploads/2008/06/big_100_0168.jpg" alt="Avraham teaching us about Kabbalah, Tzfat, Israel" width="320" height="240" /><br />
<em>Avraham teaching us about Kabbalah, Tzfat, Israel</em></p>
<p><span id="more-79"></span>Now I find myself in Tzfat, Israel.  Starring back at me was Avraham.  Avraham is a spiritual man.  He began talking about the teachings of Kabbalah.  That&#8217;s right, Kabbalah.  The supposed religion of Madonna and several other A-list celebrities.  It&#8217;s not my place to question their beliefs, but that is probably the first thing most people think of when they hear the term.  I did myself!  Actually, Kabbalah was not traditionally taught until after one masters the teachings of the Torah.  Only then, usually around age 40, does that person begin to learn the inner meaning of the Torah, known as the <a href="http://en.wikipedia.org/wiki/Kabbalah">kabbalah</a>.</p>
<p><img class="alignnone size-full wp-image-82" title="Kabbalah, Tzfat, Israel" src="http://www.janisb.com/blog/wp-content/uploads/2008/06/big_100_0172.jpg" alt="A meditational map of the 100 sounds of the Shofar, Tzfat, Israel" width="320" height="240" /><br />
<em>A meditational map of the 100 sounds of the Shofar, Tzfat, Israel</em></p>
<p>Avraham is an artist, a religious artist if you will.  He showed us several pieces of his work, but one  in particular seemed to resonant with me.  He calls it <em>Tashuv-Hey</em> or in Hebrew, תשובה.  This painting represents balance, sort of like the ying and yang.  The bottom ה is associated with the desire to receive, the place of conditional love.  The upper ה is associated with the desire to give, the place of unconditional love.  The Kabbalah explains that through the transformation of the lower ה within ourselves, that is the self-love, to the place of the upper ה, the love of all things, that we become united with infinite goodness.</p>
<p>This image can be viewed two different ways.  Similar to the glass being half full or half empty, do you see a single letter at the top or a white background with a cutout of a letter?</p>
<p><img class="alignnone size-medium wp-image-84" style="border: 1px solid black;" title="body-and-soul-one" src="http://www.janisb.com/blog/wp-content/uploads/2008/06/body-and-soul-one-202x300.gif" alt="" width="202" height="300" /><br />
<em>The transformation of self-love to a love of all these brings infinite goodness</em></p>
<p>Imagine for a second that the upper ה, the greater love, is nearly complete, but missing that last piece.  Once you have reached that unconditional love, the bottom ה (white letter on the black background) will float up and fill in the black ה at the top.  The image is now transformed into a single white rectangle and a single black rectangle.  This represents infinite goodness.  Can you see it?<a href="http://www.amazon.com/Jewish-Meditation-Practical-Aryeh-Kaplan/dp/0805210377"></a></p>
<p>If you want to learn more about Kabbalah, Avraham recommended that you start with a book called <a href="http://www.amazon.com/Jewish-Meditation-Practical-Aryeh-Kaplan/dp/0805210377">Jewish Mediation</a>.</p>
<h2 style="clear: both; padding-top: 1em;">Israel in all her beauty</h2>
<p>We took the bus up the coast of Israel.  We had the Mediterranean Sea over our left shoulder, but I struggled to keep my eyes open.  Not because the views weren&#8217;t spectacular&#8230;because they were!  The problem is that I don&#8217;t think I&#8217;ve slept yet.  The first night it was my mistake to not shut the blinds, so we were up at the crack of dawn.  Even if we had remembered to shut the blinds, those damn roosters would&#8217;ve woken us up just moments later.  At least it wasn&#8217;t just me that had my eyes closed, but failed to drift away.  Both my roommates, Shaun and Mike, experienced the same problem.  Good thing our wake up call of 6am didn&#8217;t arrive too soon!</p>
<p><img class="alignnone size-full wp-image-83" title="Haifa" src="http://www.janisb.com/blog/wp-content/uploads/2008/06/p1000861.jpg" alt="" width="320" height="182" /><br />
<em>Baha&#8217;i Gardens in Haifa, Israel</em></p>
<p>Sorry for the tangent.  So yes, Israel is quite beautiful.  The two towns we got to experience were Haifa and Akko.  Both these towns lie about 24 km (~15 miles) from the border of Lebanon.  It&#8217;s hard to believe that in 2006 bombs from Lebanon rained down from the skies on both of these towns.  Even more unbelievable is that many of the people living here chose to remain in their homes and go about business as usual.  Did you change your habits after what happened on September 11th?  I remember a lot of people canceled flights and postponed travel plans.  Actually, I was probably one of about twenty people that went to high school the next day.  We had a school of 1400.</p>
<p><img class="alignnone size-full wp-image-80" title="Retirement.  Akko, Israel" src="http://www.janisb.com/blog/wp-content/uploads/2008/06/p1000871.jpg" alt="Retirement.  Akko, Israel" width="320" height="240" /><br />
<em>Retirement.  Akko, Israel</em></p>
<h2 style="clear: both; padding-top: 1em;">We slept in a Kibbutz!</h2>
<p>A kibbutz, for those unfamiliar with the term, is a planned residential community based on socialistic principals.  In a traditional kibbutz you own nothing and share everything.  They began as utopian communities, but are becoming increasing privatized.  One of the ideals I really like about these communities are the environments they create for children.  I had the priviliage of growing up with my brother (what&#8217;s up Scotty!), but for those that were only children, a kibbutz gave you twenty children to play with and call family.</p>
<p>Ok, that&#8217;s all for tonight.  Gnight.</p>
<p><a href="http://sharethis.com/item?&wp=2.5&amp;publisher=5be9cfee-1ca7-4df9-a04a-c2fbf8266feb&amp;title=Give+and+you+shall+receive&amp;url=http%3A%2F%2Fwww.janisb.com%2Fblog%2F2008%2F05%2Fgive-and-you-shall-receive%2F">ShareThis</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.janisb.com/blog/2008/05/give-and-you-shall-receive/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Walls divide us all</title>
		<link>http://www.janisb.com/blog/2008/05/walls-divide-us-all/</link>
		<comments>http://www.janisb.com/blog/2008/05/walls-divide-us-all/#comments</comments>
		<pubDate>Wed, 28 May 2008 06:05:24 +0000</pubDate>
		<dc:creator>John Brennan</dc:creator>
		
		<category><![CDATA[Middle East]]></category>

		<category><![CDATA[Travel]]></category>

		<category><![CDATA[israel]]></category>

		<guid isPermaLink="false">http://www.janisb.com/blog/?p=67</guid>
		<description><![CDATA[I honestly don&#8217;t even know where to begin. Throughout this trip I took notes of my thoughts and experiences so that this moment would be easy. Since I was not able to write on this blog during the trip I am forced to back date my posts. I shouldn&#8217;t say forced.  I wanted to [...]<script type="text/javascript">SHARETHIS.addEntry({ title: "Walls divide us all", url: "http://www.janisb.com/blog/2008/05/walls-divide-us-all/" });</script>]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;">I honestly don&#8217;t even know where to begin. Throughout this trip I took notes of my thoughts and experiences so that this moment would be easy. Since I was not able to write on this blog during the trip I am forced to back date my posts. I shouldn&#8217;t say forced.  I wanted to know when things occurred in time, and since I kept a journal while I was there, this shouldn&#8217;t be <em>that </em>hard. What is difficult is that I have all these emotions running wild in my head and it&#8217;s rather hard to tame.</p>
<p style="text-align: left;">But let&#8217;s try&#8230;</p>
<p style="text-align: left;">
<h2>Background</h2>
<p style="text-align: left;">I will start with a little background. I went on a <a href="http://www.birthrightisrael.com">Taglit-Birthright Israel</a> trip. This is a free trip given to young people ages 18-26 to experience Israel. The trip is paid for by Jewish charities and the people of Israel. I arrived with 2 friends, Dana and Jess (pictured below). But I left with so much more than that. Memories, a greater sense of Israel&#8217;s current situation, a love for their people, and 50 new friends.</p>
<p style="text-align: left;"><img class="alignnone size-full wp-image-70" title="p1000788" src="http://www.janisb.com/blog/wp-content/uploads/2008/06/p1000788.jpg" alt="" width="320" height="240" /></p>
<p style="text-align: left;">
<h2>First Thoughts</h2>
<p style="text-align: left;">We arrived at Ben Gurion Airport in the evening. After a long 11 hour flight without sleep I was definitely ready to get some shut eye. You might be thinking, &#8220;11 hours&#8230; that should be plenty of time.&#8221; While it was always cool to sit in the back of the bus, quite the opposite is true of airplanes. The fact that I was also in the perfect position to actually feel my right eye get drawn into the bathroom with each suctioning flush of the toilet only exacerbated the situation.</p>
<p style="text-align: left;">Like many people, whenever I get into a new country it doesn&#8217;t actually hit me when I get off the plane. Instead, it is a specific moment at the start of the trip where this revelation usually occurs. For me it was seeing words in Hebrew/Arabic. If these languages were romance languages it might be different, but because their character sets are so different from ours the feeling of being totally out of my element became a reality. The sign below being one of them.</p>
<p style="text-align: left;"><img class="alignnone size-full wp-image-68" src="http://www.janisb.com/blog/wp-content/uploads/2008/06/p1000780.jpg" alt="" width="320" height="230" /></p>
<p style="text-align: left;"><span id="more-67"></span></p>
<p style="text-align: left;">
<p style="text-align: left;">
<p style="text-align: left;">We took a chartered bus from the airport near Tel Aviv to Jerusalem. The first thing that amazed me was their use of solar power. It seemed like every home had a white bucket on the roof (which I am told is some sort of solar power generator). Wikipedia actually says that Israel is the <a href="http://en.wikipedia.org/wiki/Israel#Geography_and_climate">leading nation in solar energy per capita</a>.  Interesting.</p>
<p style="text-align: left;"><img class="alignnone size-full wp-image-69" src="http://www.janisb.com/blog/wp-content/uploads/2008/06/p1000785.jpg" alt="Those white buckets on the roofs are powering the homes -- solar energy!" width="320" height="240" /></p>
<p style="text-align: left;">
<p style="text-align: left;">The other amazement was how similar Israel reminds me of Southern California. Tel Aviv, Haifa and Akko (which I get to later) are all directly on the water. They have volleyball courts and sandy beaches like San Diego or Hermosa Beach. Drive a couple miles east and you&#8217;ll get to drier land, which again, resembles San Diego/SoCal. I&#8217;d say the only differences at this point are that California doesn&#8217;t have anything close to the Negev Desert and Israel is much smaller than that of California. In fact, Israel is closer to the size of New Jersey.</p>
<p style="text-align: left;">I might as well show you a map of Israel so you can visualize it.  The route we took during the trip is in red.</p>
<p style="text-align: left;"><img class="aligncenter size-full wp-image-77" title="israel-map" src="http://www.janisb.com/blog/wp-content/uploads/2008/06/israel-map.gif" alt="" width="300" height="650" /></p>
<p style="text-align: left;">According to the map, we drove right through the West Bank!  Fortunately, that is not true.  I was surprised to find that a lot of the maps online have the West Bank as this big bubble.  In actuality this is not the case.  True, most of the towns and villages in that bubble do in fact belong to Palestinians/Fatah, but there are some towns that are still controlled by Israel&#8217;s government.  So it would only make sense that the maps we were given in Israel had much more detail about exactly what was and wasn&#8217;t under Palestinian control.  Of course, if I were to obtain a map in say, Lebanon, Israel wouldn&#8217;t even be on the map!  But that&#8217;s another story.</p>
<h2>An interesting bunch</h2>
<p>The <a href="http://en.wikipedia.org/wiki/Druze">Druze</a> are a religious group of Jewish converts from Islam.  The majority of Druze are found in Lebanon, Syria and Israel.  These people are both fascinating and friendly.  We had dinner our second night in the Druze village of Osafia.  It was a traditional meal of hummus, bread, eggplant (my favorite!), beans, and chicken.</p>
<p><img class="alignnone size-full wp-image-78" title="big_100_0112" src="http://www.janisb.com/blog/wp-content/uploads/2008/06/big_100_0112.jpg" alt="" width="320" height="240" /><br />
<em>Having dinner with people from a Druze village<br />
</em></p>
<p>The beliefs of their culture fascinate me.  They take part in a now closed religion, meaning you cannot be accepted into their faith.  Moreover, if you marry outside of the religion you are banished from your village or community. Even with these rules in place, love doesn&#8217;t always act pragmatically.  People have been known to marry outside the religion knowing full well the consequences.  The Druze are aware of this problem, but at this point don&#8217;t feel they can do anything about its inevitability.  One day soon they will be the last practicing Druze.</p>
<p>A scary truth of these people is that some migrated from Lebanon pre-Lebanon war of 2006.  This put family against family and friends against friends.   I can&#8217;t begin to imagine what they must have went through. I don&#8217;t even know how to convey my feelings right now&#8230;</p>
<h2>Divided in all directions</h2>
<p>My first encounter with division was when I heard about the agreements the Israeli government has with several groups in Israel.  Israel is home to Israelis, Arab Muslims, Druze, Bedouins and <a href="http://en.wikipedia.org/wiki/Hasidic_Judaism">Hasidic Jews</a>, not to mention a variety of other minority groups.  The reason I call out Hasidic Jews is because I couldn&#8217;t believe they actually got the government to agree to never having to pay taxes again.  (Btw, they are also not required to serve in the army.)</p>
<p>I had been in Israel for less than 24 hours and I could already see the subtle clashes between the different groups.  Israeli men are required to serve 3 years in the military (and women required to serve 2 years) with the majority serving between the transition of high school and college.   Hasidic Jews, however, do not serve because it is against their religion.  I&#8217;m not sure if it&#8217;s their interpretation of the Torah or additional texts that they follow though.  My thoughts are that if their neighbors aren&#8217;t fighting for them then what?  Is there a point where they have to put down the religious scripture that they have followed all their lives for survival or do they fold their cards and hope they lived their life to the fullest?</p>
<p>We were also able to meet a group of Bedouins during my time in Israel.  <a href="http://en.wikipedia.org/wiki/Bedouins">Bedouins</a> are a nomadic group often found living in the Negev, Sinai, and Arabian Deserts.  It only took a short while before I learned of the tensions between the Bedouins and  other groups living in Israel.  Apparently the government pays families a monthly stipend for each child they have.  Both the Bedouins and Hasidic Jews typically have twice (or three times) as many children as a typical Israeli family.  The fact that many Bedouins live on tax-free land complicates the situation even more.</p>
<p><img class="alignnone size-full wp-image-72" title="p1000796" src="http://www.janisb.com/blog/wp-content/uploads/2008/06/p1000796.jpg" alt="" width="320" height="240" /><br />
<em>The West Bank is just behind those 26 ft high concrete walls</em></p>
<p>While there seems to be a clear mental divide between people for reasons of country service and money, nothing screams division like a physical wall.  When you put the name <strong>West Bank</strong> to the name it only exemplifies its purpose.  I have learned a lot about both the West Bank and the Gaza Strip, but it deserves its own post at the very least (which I will be writing in the coming week).  For now I will say that the wall is itself a very controversial undertaking.  Supporter say that the barrier is necessary to protect Israelis from Palestinian attacks.   This point is justified as it helped reduce terrorist attacks by 97%.   Opponents, however, claim that the wall is an attempt to divide land before an official agreement is reached.  While not as quantitative, it also makes sense imho.  More on this topic later&#8230;</p>
<p style="text-align: left;"><img class="alignnone size-full wp-image-71" title="p1000793" src="http://www.janisb.com/blog/wp-content/uploads/2008/06/p1000793.jpg" alt="" width="320" height="240" /><br />
<em>The Dome of the Rock, which happens to be real gold.<br />
80 kilograms of it (funded by King Hussein of Jordan).</em></p>
<p>After starring in awe of this great wall I glanced left to find one of the best known landmarks in Jerusalem &#8212; the Dome of the Rock.  The Dome of the Rock lies in the center of the <a href="http://en.wikipedia.org/wiki/Temple_Mount">Temple Mount</a>.  The significance of this structure has roots in both Islam and Judaism.  Muslims believe that this marks the spot where Muhammad ascended to God in heaven.  There he consulted with Moses before coming back to Earth for a journey from <a href="http://en.wikipedia.org/wiki/Mecca">Mecca</a> back to the Dome of the Rock.</p>
<p>In Judaism it is believed that this was the place where God tested Abraham by asking him to sacrifice his son Isaac.  This was also believed to be the rock where the Ark of the Covenant was placed in the <a href="http://en.wikipedia.org/wiki/First_Temple">First Temple</a>.</p>
<p>Unfortunately I wasn&#8217;t allowed inside the Temple Mount.  Until just recently there was a ban barring all Jews and Christians from entering the Temple Mount.  Now there are specific hours in place where non-Muslims may enter the structure, but entrance to the Dome itself is still forbidden to non-Muslims.  At first this did not make sense because it was under the control of the Israeli government.  Our guide instructed us that the Israeli government actually gives full control of this site to the Muslim Council.</p>
<p>It is so difficult to comprehend a restriction like this.  Sure, society in America has these types of restrictions all over the place, but we&#8217;ve grown up with it.  We have yacht clubs and members-only golf courses, but you need to have money.  There are clubs that require your name to be printed on the guest list, but you can get on if you know someone.  Barring someone because of religion seems like it&#8217;s on a different level.  Essentially you were born with a lifetime ban from a certain geographical location.  What gives someone the right to own that piece of land?</p>
<p><img class="alignnone size-full wp-image-76" title="p1000855" src="http://www.janisb.com/blog/wp-content/uploads/2008/06/p1000855.jpg" alt="" width="320" height="240" /><br />
<em>I hope they are praying for peace.  Western Wall, Jerusalem.</em></p>
<p>The last 2 physical divisions I witnessed today are of the Western Wall and Jerusalem itself.  The <a href="http://en.wikipedia.org/wiki/Old_City_%28Jerusalem%29">Old City</a>, an area located within modern day Jerusalam, is divided into 4 quarters.  The names are politically correct and include the Armenian, Jewish, Christian and Muslim Quarters.</p>
<p>While the Western Wall has the least dangerous division imho, laughing in front of your wife may cause you to wind up sleeping on the couch tonight.</p>
<p style="text-align: left;"><img class="alignnone size-full wp-image-73" title="p1000836" src="http://www.janisb.com/blog/wp-content/uploads/2008/06/p1000836.jpg" alt="" width="320" height="240" /><br />
<em>Western Wall, Jerusalem</em></p>
<p style="text-align: left;">Looking at the picture there seems to be a clear division splitting the praying area into two unequal pieces at about 75/25.  To the left are the men.  To the right &#8212; women.  Men and women are required by religious law to pray separately.  What&#8217;s worse, while the women are forced to congregate in a group in over 100ºF heat, the men can choose to pray to the far left in an air conditioned area inside the walls shaded from the sun.</p>
<p style="text-align: left;"><img class="alignnone size-full wp-image-75" title="p1000845" src="http://www.janisb.com/blog/wp-content/uploads/2008/06/p1000845.jpg" alt="" width="320" height="240" /><br />
<em>Myself jamming a prayer I wrote on a piece of paper into the cracks of the wall.  (It&#8217;s a tradition) </em></p>
<p><a href="http://sharethis.com/item?&wp=2.5&amp;publisher=5be9cfee-1ca7-4df9-a04a-c2fbf8266feb&amp;title=Walls+divide+us+all&amp;url=http%3A%2F%2Fwww.janisb.com%2Fblog%2F2008%2F05%2Fwalls-divide-us-all%2F">ShareThis</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.janisb.com/blog/2008/05/walls-divide-us-all/feed/</wfw:commentRss>
		</item>
		<item>
		<title>My trip to the middle east</title>
		<link>http://www.janisb.com/blog/2008/05/my-trip-to-the-middle-east/</link>
		<comments>http://www.janisb.com/blog/2008/05/my-trip-to-the-middle-east/#comments</comments>
		<pubDate>Sun, 25 May 2008 19:22:44 +0000</pubDate>
		<dc:creator>John Brennan</dc:creator>
		
		<category><![CDATA[Middle East]]></category>

		<category><![CDATA[Travel]]></category>

		<category><![CDATA[israel]]></category>

		<guid isPermaLink="false">http://www.janisb.com/blog/?p=64</guid>
		<description><![CDATA[I&#8217;m not sure what to expect.  Actually, when I really think about it, this is the first time that I will be traveling without any expectations.  Before heading to Europe, I had several pictures of what it would be like before I got there.  Whether from movies, pictures, or just my imagination, [...]<script type="text/javascript">SHARETHIS.addEntry({ title: "My trip to the middle east", url: "http://www.janisb.com/blog/2008/05/my-trip-to-the-middle-east/" });</script>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m not sure what to expect.  Actually, when I really think about it, this is the first time that I will be traveling without any expectations.  Before <a href="http://www.janisb.com/blog/2006/07/backpacking-europe-5-countries-18-days/" >heading to Europe</a>, I had several pictures of what it would be like before I got there.  Whether from movies, pictures, or just my imagination, I knew what the streets of Paris would look like.  I knew what the canals of Venice looked like.  And I surely knew what Greece would look like.  Even when I <a href="http://www.janisb.com/blog/2007/03/jungles-of-borneo-and-summiting-mt-kinabalu/" >Jungles of Borneo and summiting Mt. Kinabalu</a> last year, I had a good idea of what to expect.</p>
<p>In my opinion it&#8217;s a good idea not to know exactly what you are getting into.  That&#8217;s part of the fun.  But I do like to have a little background before getting on the plane.</p>
<p>That said&#8230; I&#8217;m going to Israel!  I will be getting on the plane tonight without expectations.  More to come&#8230;</p>
<p><span id="more-64"></span></p>
<p>Here&#8217;s the tentative itinerary:</p>
<p><strong>Monday, May 26 2008 - Jerusalem</strong><br />
Shalom and welcome home to Israel!<br />
Arrive at Ben Gurion Airport<br />
Opening Session with Shlomo (Momo) Lifshitz, President of Oranim Educational Initiatives<br />
Group opening session</p>
<p>Neve Ilan<br />
+972-2-533-9339</p>
<p><strong>Tuesday, May 27 2008 - Haifa</strong><br />
View Armon Hanatziv<br />
Visit King David&#8217;s tomb<br />
Enter the Old City and explore the Jewish Quarter and the Southern Wall Excavations<br />
Visit the Western Wall<br />
Head north<br />
Visit the Druze village of Ossafia and enjoy a traditional meal</p>
<p>Mount Carmel Hotel<br />
+972-4-838-1414</p>
<p><strong>Wednesday, May 28 2008</strong><br />
View the Baha&#8217;i Gardens in Haifa<br />
Visit the ancient city of Akko<br />
Visit &#8220;Or Tora&#8221; synagogue<br />
Explore Zfat the city of Mystical Judaism (Kabbalah).<br />
View the narrow alleyways lined with ancient synagogues and artists&#8217; galleries</p>
<p>Kibbutz Shomrat<br />
+972-4-985-4897</p>
<p><strong>Thursday, May 29 2008</strong><br />
Holocaust seminar<br />
Enjoy the view from Gadot Kayak in the Jordan River<br />
Enjoy a night under a million stars on the banks of the Jordan River</p>
<p>Jordan Park<br />
+972-4-692-1078</p>
<p><strong>Friday, May 30 2008 - Tiberius</strong><br />
View deep into Syria from atop Mt. Bental<br />
Hike to one of the sources of the Jordan River<br />
Visit &#8220;Kinneret&#8221; cemetery<br />
Tour Tiberius Boardwalk<br />
Welcome the Shabbat at the hotel Group session and activity</p>
<p>Astoria Hotel<br />
+972-4-672-2351</p>
<p><strong>Saturday, May 31 2008 - Tiberius</strong><br />
Enjoy beach time in the Kinneret Group session and activity<br />
Enjoy some free time at the hotel pool<br />
Time for family and friends at the hotel Havdallah<br />
Enjoy some free time on the Boardwalk<br />
A night out</p>
<p>Astoria Hotel<br />
+972-4-672-2351</p>
<p><strong>Sunday, June 1 2008 - Jerusalem</strong><br />
Explore the ancient city of Beit She&#8217;an<br />
Head to Tel Aviv<br />
Israeli soldiers join the group<br />
(Soldiers meet at Tel Aviv at 11:30 A.M. To co-ordinate your pick up please contact the tour guide two days before you join the trip)<br />
Visit Independence Hall<br />
Tour Old Jaffa and Neve Tzedek<br />
Mega Event</p>
<p>Neve Ilan<br />
+972-2-533-9339</p>
<p><strong>Monday, June 2 2008</strong><br />
Visit Mt. Herzl<br />
Enjoy lunch and a chance to swim (float) in the Dead Sea<br />
Hike a trail in the Big Crater<br />
Enjoy a Camel Trek<br />
Enjoy a Bedouin Hafla (feast) and a World Music Festival</p>
<p>Mamshit<br />
+972-8-943-6882</p>
<p><strong>Tuesday, June 3 2008 - Eilat</strong><br />
Ascend Massada<br />
Swim in the blue waters of the Red Sea<br />
Enjoy some free time on the Boardwalk<br />
Party at Eilat&#8217;s popular club Unplugged</p>
<p>Briza Hotel<br />
+972-8-638-8888</p>
<p><strong>Friday, June 4 2008 - Jerusalem</strong><br />
Visit Ben Gurion’s gravesite and learn about his legacy at Kibbutz Sde Boker<br />
Closing session with Shlomo (Momo) Lifshitz, President of Oranim Educational Initiatives<br />
&#8220;What&#8217;s Next?&#8221; – A Session with Oranim alumni<br />
Group closing session</p>
<p>Ma&#8217;ale Ha&#8217;hamish<br />
+972-2-533-1331</p>
<p><strong>Saturday, June 5 2008 - Home</strong><br />
Israeli Soldiers leave the group<br />
Leave for Ben Gurion Airport back to NYC</p>
<p><a href="http://sharethis.com/item?&wp=2.5&amp;publisher=5be9cfee-1ca7-4df9-a04a-c2fbf8266feb&amp;title=My+trip+to+the+middle+east&amp;url=http%3A%2F%2Fwww.janisb.com%2Fblog%2F2008%2F05%2Fmy-trip-to-the-middle-east%2F">ShareThis</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.janisb.com/blog/2008/05/my-trip-to-the-middle-east/feed/</wfw:commentRss>
		</item>
		<item>
		<title>The company is healthy, but is the stock overpriced?</title>
		<link>http://www.janisb.com/blog/2008/05/the-company-is-healthy-but-is-the-stock-overpriced/</link>
		<comments>http://www.janisb.com/blog/2008/05/the-company-is-healthy-but-is-the-stock-overpriced/#comments</comments>
		<pubDate>Thu, 15 May 2008 17:33:37 +0000</pubDate>
		<dc:creator>John Brennan</dc:creator>
		
		<category><![CDATA[Investing]]></category>

		<guid isPermaLink="false">http://www.janisb.com/blog/?p=54</guid>
		<description><![CDATA[In the last investment post I wrote a checklist to stock investing.  I described how I do my homework to see if there are growth prospects for a particular stock in the future.  Once the answer to that question is yes, the next thing I look at is the current stock price.

Although a [...]<script type="text/javascript">SHARETHIS.addEntry({ title: "The company is healthy, but is the stock overpriced?", url: "http://www.janisb.com/blog/2008/05/the-company-is-healthy-but-is-the-stock-overpriced/" });</script>]]></description>
			<content:encoded><![CDATA[<p>In the last investment post I wrote a <a href="/blog/2008/04/a-checklist-to-stock-investing/">checklist to stock investing</a>.  I described how I do my homework to see if there are growth prospects for a particular stock in the future.  Once the answer to that question is yes, the next thing I look at is the current stock price.</p>

<p>Although a company may have solid performance, there stock may be overvalued and might be expected to fall again.  Just as there are methods to evaluate a company, so are there methods to evaluate when to buy.  After all, the price you are paying ultimately determines the rate of return that you’ll be earning.</p>

<span id="more-54"></span>

<h2>Calculate the intrinsic value</h2>

<p>To find our sweet spot price, called the intrinsic value, we will need some numbers.  I can’t stress this enough, if you have bad numbers you’ll get bad results.  Garbage in, garbage out.</p>

<p>That said I will tell you where to find each of the numbers you’ll need.  It is important to understand that there are several ways of calculating intrinsic value.  I am showing you the most common method using discounted earnings, but you could do similar calculations with discounted cash flow or discounted dividends.</p>

<p>I wrote a quick calculator to handle all the math for you, but if you want to peek under the hood, all formulas were taken from <a href="http://www.stock-investment-made-easy.com/calculate-intrinsic-value.html">How to Calculate Intrinsic Value for Stock Investing the Warren Buffet Way</a>.</p>

<p><strong>EPS on TTM</strong><br />
You can use <a href="http://finance.yahoo.com/q/ks?s=AAPL">Yahoo!’s Diluted EPS (ttm)</a> or a normalized EPS for MRFY (which I have with Scottrade).</p>

<p><strong>EPS growth rate</strong><br />
This figure is an estimate of what you expect the EPS to grow to after X years.  There are many answers to this and each will give you a slightly different end result.  Usually I’ll plug a few in and average my results.  I will tend to use <a href="http://finance.yahoo.com/q/ae?s=AAPL">Yahoo!’s Next 5 Years growth estimate</a>, but you can also take an average of the <a href="http://moneycentral.msn.com/investor/invsub/results/statemnt.aspx?Symbol=AAPL&amp;lstStatement=10YearSummary&amp;stmtView=Ann">EPS for the past 10 years</a> or use the past 5 years.  You can also listen for a prediction from the CEO of the growth rate of the business.  I would tend to use the lower of these numbers.  After all, we don’t want a best case, unrealistic number.  And who knows the business better than the CEO?</p>

<p><strong>Expected PE</strong><br />
Similar to the EPS growth rate, this will be an estimate.  I will usually take the LESSER of the average of the <a href="http://moneycentral.msn.com/investor/invsub/results/compare.asp?Page=TenYearSummary&amp;Symbol=AAPL">PE for the past 5 years</a> or twice the EPS growth rate.</p>

<p><strong>Expected ROI</strong><br />
This is simply you minimum acceptable rate of return.  For me, I don’t want to settle for anything less than 15%.</p>

<!-- CALCULATOR TO FOLLOW -->

<script type="text/javascript" src="/blog/wp-content/uploads/2008/05/investing-calculateiv.js"></script>

<style type="text/css" media="all">
<!-- 
form#iv_form fieldset { width : 25em; padding : 0.5em 1em; }
form#iv_form label, form#iv_form input {display: block;width: 70px;float: left;margin-bottom: 10px;}
form#iv_form label {text-align: right;width: 205px;padding-right: 20px;}
form#iv_form input.submit { margin-left : 15em;}
form#iv_form br {clear: left;}
form#iv_form #result {clear:both;}
form#iv_form #result .good {color:#109DD0; font-size: 120%;}
#result .bad {color:#CC0000; font-size: 120%;}
 -->
</style>
 

<form id="iv_form" name="iv_form" method="post" action="" onsubmit="calculateIV(this); return false;">
 <fieldset>
    <legend>Intrinsic Value Calculator</legend>
    <label>Years to hold stock:</label><input name="years" value="5" onchange="document.getElementById('eps_years').innerHTML = this.value; document.getElementById('eps_years_plus_one').innerHTML = parseInt(this.value)+1;" type="text"><br/>
    <label>Current share price:</label><input name="curr_price" value="182.59" type="text"><br/>
    <label><span title="Earnings per share">EPS</span> on <span title="Trailing Twelve Months">TTM</span>:</label><input name="eps" value="4.85" type="text"><br/>
    <label>EPS growth rate<br />for next <span id="eps_years">5</span> years:</label><input name="eps_grate" value="22.5" type="text"><br/>
    <label>Expected PE at year <span id="eps_years_plus_one">6</span>:</label><input name="future_pe" value="45" type="text"><br/>
    <label>Expected ROI:</label><input name="expected_roi" value="15" type="text"><br/>
	<input value="Calculate" class="submit" type="submit">
	<div id="result"></div>
 </fieldset>
</form>

<!-- /END CALCULATOR -->

<h2>Look at analysts’ predictions</h2>
<p>I also like to look at what the analysts’ opinions are for the stock.  Again, I use <a href="http://finance.yahoo.com/q/ao?s=AAPL">Yahoo! Finance</a> for this.  There predictions better be higher than the current price or what’s the point?</p>

<h2>Feedback?</h2>
<p>I am a fairly new investor, so if there are other ways to slice the data that you think are important please post them here.  I’m interested to hear how others do their due diligence.</p>

<p><a href="http://sharethis.com/item?&wp=2.5&amp;publisher=5be9cfee-1ca7-4df9-a04a-c2fbf8266feb&amp;title=The+company+is+healthy%2C+but+is+the+stock+overpriced%3F&amp;url=http%3A%2F%2Fwww.janisb.com%2Fblog%2F2008%2F05%2Fthe-company-is-healthy-but-is-the-stock-overpriced%2F">ShareThis</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.janisb.com/blog/2008/05/the-company-is-healthy-but-is-the-stock-overpriced/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Bringing the world together through the power of film</title>
		<link>http://www.janisb.com/blog/2008/05/bringing-the-world-together-through-the-power-of-film/</link>
		<comments>http://www.janisb.com/blog/2008/05/bringing-the-world-together-through-the-power-of-film/#comments</comments>
		<pubDate>Sun, 11 May 2008 00:38:52 +0000</pubDate>
		<dc:creator>John Brennan</dc:creator>
		
		<category><![CDATA[Interesting]]></category>

		<guid isPermaLink="false">http://www.janisb.com/blog/?p=62</guid>
		<description><![CDATA[I was deeply touched by the talk from Jehane Noujaim, a filmmaker and winner of the 2006  TED Prize, who created a documentary about Al Jazeera&#8217;s coverage of the Iraq war.  It is interesting to see, first hand, the perspectives of those on the other side of the fence.
For so long I have [...]<script type="text/javascript">SHARETHIS.addEntry({ title: "Bringing the world together through the power of film", url: "http://www.janisb.com/blog/2008/05/bringing-the-world-together-through-the-power-of-film/" });</script>]]></description>
			<content:encoded><![CDATA[<p>I was deeply touched by the talk from Jehane Noujaim, a filmmaker and winner of the 2006  TED Prize, who created a documentary about Al Jazeera&#8217;s coverage of the Iraq war.  It is interesting to see, first hand, the perspectives of those on the other side of the fence.</p>
<p>For so long I have watched mainstream media and [unfortunately] it was not until I read <a href="http://www.threecupsoftea.com">3 Cups of Tea</a>, did I truly see how much knowledge I was missing.  To read the account of one man on the ground in northern Pakistan, before the tradegies of 9/11, tell readers what he saw.  It was astonishing to see how different the perspectives were.  On one hand you have mainstream media using the word WMD (Weapons of Mass Destruction) more than the word &#8220;The&#8221;!  And from Greg Mortenson&#8217;s perspective the issue stems from the lack of education.  PBS actually did a special on how mainstream media become the White House&#8217;s second voice in a special titled, <a href="http://www.pbs.org/moyers/journal/btw/watch.html">Buying the War</a>.</p>
<p>So here is Jehane Noujaim&#8217;s wish: to bring the world together for one day a year through the power of film.  That day was today &#8212; May 10, 2008 &#8212; <a href="http://www.pangeaday.org/">Pangea Day</a>.  A day where we think of this world as <strong>one body of mass</strong>, <strong>one mind with many cultures</strong>, <strong>one people living in this world to leave better than we came</strong>, <strong>one family helping each other and bridging the inequalities of the world</strong>.</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="320" height="285" id="VE_Player" align="middle"><param name="movie" value="http://static.videoegg.com/ted/flash/loader.swf"><PARAM NAME="FlashVars" VALUE="bgColor=FFFFFF&#038;file=http://static.videoegg.com/ted/movies/JEHANENOUJAIM_high.flv&#038;autoPlay=false&#038;fullscreenURL=http://static.videoegg.com/ted/flash/fullscreen.html&#038;forcePlay=false&#038;logo=&#038;allowFullscreen=true"><param name="quality" value="high"><param name="allowScriptAccess" value="always"><param name="bgcolor" value="#FFFFFF"><param name="scale" value="noscale"><param name="wmode" value="window"><embed src="http://static.videoegg.com/ted/flash/loader.swf" FlashVars="bgColor=FFFFFF&#038;file=http://static.videoegg.com/ted/movies/JEHANENOUJAIM_high.flv&#038;autoPlay=false&#038;fullscreenURL=http://static.videoegg.com/ted/flash/fullscreen.html&#038;forcePlay=false&#038;logo=&#038;allowFullscreen=true" quality="high" allowScriptAccess="always" bgcolor="#FFFFFF" scale="noscale" wmode="window" width="320" height="285" name="VE_Player" align="middle" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></object></p>
<p><a href="http://sharethis.com/item?&wp=2.5&amp;publisher=5be9cfee-1ca7-4df9-a04a-c2fbf8266feb&amp;title=Bringing+the+world+together+through+the+power+of+film&amp;url=http%3A%2F%2Fwww.janisb.com%2Fblog%2F2008%2F05%2Fbringing-the-world-together-through-the-power-of-film%2F">ShareThis</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.janisb.com/blog/2008/05/bringing-the-world-together-through-the-power-of-film/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Pangea Day &#8212; May 10, 2008 &#8212; Inspiring social change</title>
		<link>http://www.janisb.com/blog/2008/05/pangea-day-may-10-2008-inspiring-social-change/</link>
		<comments>http://www.janisb.com/blog/2008/05/pangea-day-may-10-2008-inspiring-social-change/#comments</comments>
		<pubDate>Sat, 10 May 2008 17:41:47 +0000</pubDate>
		<dc:creator>John Brennan</dc:creator>
		
		<category><![CDATA[Interesting]]></category>

		<guid isPermaLink="false">http://www.janisb.com/blog/?p=63</guid>
		<description><![CDATA[From Pangea Day, May 10, 2008:
Pangea Day was a celebration of the power of film. It featured films that were funny, sad, gorgeous, stark – and powerful. Voices that had never been heard before. Things many had never seen. Scenes from worlds few had visited. A cross-section of our amazing, complicated, noisy, beautiful world.
Besides four [...]<script type="text/javascript">SHARETHIS.addEntry({ title: "Pangea Day &#8212; May 10, 2008 &#8212; Inspiring social change", url: "http://www.janisb.com/blog/2008/05/pangea-day-may-10-2008-inspiring-social-change/" });</script>]]></description>
			<content:encoded><![CDATA[<p><strong>From <a href="http://www.pangeaday.org/">Pangea Day</a>, May 10, 2008:</strong></p>
<blockquote><p>Pangea Day was a celebration of the power of film. It featured films that were funny, sad, gorgeous, stark – and powerful. Voices that had never been heard before. Things many had never seen. Scenes from worlds few had visited. A cross-section of our amazing, complicated, noisy, beautiful world.</p>
<p>Besides four hours of pure entertainment, Pangea Day offered a view into other lives. After Pangea Day – after having experienced life inside so many other heads – we hope that many were moved to action. To become involved in pressing issues. To share their own video and photos. To join discussions that might move the world just a little bit further toward understanding.</p>
<p>The films in this program were chosen by Pangea Day&#8217;s panel from more than 2,000 submissions and a long roster of curated suggestions. Together, these films moved us, frightened us, made us laugh and smile, and helped us feel closer to the world.</p></blockquote>
<p><a href="http://www.pangeaday.org/">Find out more</a>&#8230;</p>
<p><a href="http://sharethis.com/item?&wp=2.5&amp;publisher=5be9cfee-1ca7-4df9-a04a-c2fbf8266feb&amp;title=Pangea+Day+%26%238212%3B+May+10%2C+2008+%26%238212%3B+Inspiring+social+change&amp;url=http%3A%2F%2Fwww.janisb.com%2Fblog%2F2008%2F05%2Fpangea-day-may-10-2008-inspiring-social-change%2F">ShareThis</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.janisb.com/blog/2008/05/pangea-day-may-10-2008-inspiring-social-change/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Avoid annoying session timeouts with an AJAX heartbeat</title>
		<link>http://www.janisb.com/blog/2008/05/avoid-annoying-session-timeouts-with-an-ajax-heartbeat/</link>
		<comments>http://www.janisb.com/blog/2008/05/avoid-annoying-session-timeouts-with-an-ajax-heartbeat/#comments</comments>
		<pubDate>Fri, 09 May 2008 01:52:33 +0000</pubDate>
		<dc:creator>John Brennan</dc:creator>
		
		<category><![CDATA[Code]]></category>

		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.janisb.com/blog/?p=61</guid>
		<description><![CDATA[Jeff Atwood made an interesting comment on his blog, Coding Horror, about how to take advantage of AJAX to send sort-of heartbeat back to the server to keep the session from expiring.  I think this is a great idea.  Getting automatically logged out is extremely annoying (unless of course it&#8217;s my bank in [...]<script type="text/javascript">SHARETHIS.addEntry({ title: "Avoid annoying session timeouts with an AJAX heartbeat", url: "http://www.janisb.com/blog/2008/05/avoid-annoying-session-timeouts-with-an-ajax-heartbeat/" });</script>]]></description>
			<content:encoded><![CDATA[<p>Jeff Atwood made an interesting comment on his blog, <a href="http://www.codinghorror.com/blog/archives/001100.html">Coding Horror</a>, about how to take advantage of AJAX to send sort-of heartbeat back to the server to keep the session from expiring.  I think this is a great idea.  Getting automatically logged out is extremely annoying (unless of course it&#8217;s my bank in which case I&#8217;m appreciative).</p>
<p>From his post:</p>
<blockquote><p>As a user, I can say pretty unequivocally that session expiration sucks. Is it really so unreasonable to start doing something in your web browser, walk away for an hour &#8212; maybe even for a few hours &#8212; then come back and expect things to just work?</p>
<p>As programmers, I think we can do better. It is possible. I am inundated with session timeout messages every day from a variety of sources, but I&#8217;ve never once seen a session expiration message from gmail, for example. Here&#8217;s what I suggest:</p>
<p>Create a background JavaScript process in the browser that sends regular heartbeats to the server. Regenerate a new cookie with timed expiration, say, every 5 or 10 minutes.</p>
<p><a href="http://www.codinghorror.com/blog/archives/001100.html">Continue reading &#8216;Your Session Has Timed Out&#8217;&#8230;</a></p></blockquote>
<p><a href="http://sharethis.com/item?&wp=2.5&amp;publisher=5be9cfee-1ca7-4df9-a04a-c2fbf8266feb&amp;title=Avoid+annoying+session+timeouts+with+an+AJAX+heartbeat&amp;url=http%3A%2F%2Fwww.janisb.com%2Fblog%2F2008%2F05%2Favoid-annoying-session-timeouts-with-an-ajax-heartbeat%2F">ShareThis</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.janisb.com/blog/2008/05/avoid-annoying-session-timeouts-with-an-ajax-heartbeat/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Zero to 60 with Pylons… in just minutes (Part 3)</title>
		<link>http://www.janisb.com/blog/2008/05/zero-to-60-with-pylons-in-just-minutes-part-3/</link>
		<comments>http://www.janisb.com/blog/2008/05/zero-to-60-with-pylons-in-just-minutes-part-3/#comments</comments>
		<pubDate>Tue, 06 May 2008 01:56:26 +0000</pubDate>
		<dc:creator>John Brennan</dc:creator>
		
		<category><![CDATA[Code]]></category>

		<category><![CDATA[Pylons]]></category>

		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.janisb.com/blog/?p=44</guid>
		<description><![CDATA[The Presentation
Without presentation a web page is just text.  In the early days of building web sites styles and colors were mixed with JavaScript and large animated gifs.  Yes, during those days they were referred to as &#8220;web sites,&#8221; no one called them &#8220;web apps&#8221; yet.  And to be frank, with all [...]<script type="text/javascript">SHARETHIS.addEntry({ title: "Zero to 60 with Pylons… in just minutes (Part 3)", url: "http://www.janisb.com/blog/2008/05/zero-to-60-with-pylons-in-just-minutes-part-3/" });</script>]]></description>
			<content:encoded><![CDATA[<h2>The Presentation</h2>
<p>Without presentation a web page is just text.  In the early days of building web sites styles and colors were mixed with JavaScript and large animated gifs.  Yes, during those days they were referred to as &#8220;web sites,&#8221; no one called them &#8220;web apps&#8221; yet.  And to be frank, with all that work that went into it that hurt my feelings.  Anyway, today I&#8217;m going to go beyond just showing how to get Mako working with your templates, but go as far as show you a better way to structure your templates in a Rails-like fashion.</p>
<p>I&#8217;m going to leave explain Mako to the <a href="http://www.makotemplates.org/">developers</a>, but in exchange I will give you some real examples.</p>
<p>Some of my methods are borrowed for Ruby on Rails.  I essentially have 3 parts to my presentation layer &#8212; layouts, views, and elements.</p>
<p><span id="more-44"></span></p>
<h2>Layouts, views, and elements oh my!</h2>
<p>A <strong>layout </strong>is the largest of the 3 containers and contains the page’s chrome (header, footer, sidebar) as well as all page scripts and stylesheets.</p>
<p>A <strong>view </strong>is the meat of the page. This is where all the content resides. Views are organized into folders based on their respective controller. For example,  the home controller would have a folder called home where all of its views would reside.</p>
<p>An <strong>element</strong> is a component that may be shared by multiple views. For example, the home controller may have 2 different views, say the welcome screen and a dashboard screen.  Both views might want to share pieces of the view that are the same.  These would be elements. Elements are located within a specific view folder.</p>
<p>Below is a figure of the relationship:</p>
<p><img class="alignnone size-medium wp-image-57" title="layout-view-grid" src="http://www.janisb.com/blog/wp-content/uploads/2008/05/layout-view-grid-300x253.gif" alt="Figure showing the relationship between layouts, views, and elements" width="300" height="253" /><br/></p>
<p>And here is what the file structure would look like:</p>
<p><img class="alignnone size-full wp-image-58" title="template-file-structure" src="http://www.janisb.com/blog/wp-content/uploads/2008/05/template-file-structure.gif" alt="" width="167" height="255" /><br style="clear:both"/></p>
<h2>Layout details</h2>
<p>Let&#8217;s get started by looking at the layout.  As I said before, this is the chrome of the page.  I like to keep all my external scripts (CSS and JavaScript) in 1 place though.  At first it wasn&#8217;t so straightforward with Mako, but by overwriting function definitions this is possible.</p>
<p>Here&#8217;s a bare bones default layout I have created for this project.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
</pre></td><td class="code"><pre class="html4strict"><span style="color: #009900;">&lt;%
# 
# layouts/default.mako
# The default layout to wrap the page contents.
#
%<span style="color: #000000; font-weight: bold;">&gt;</span></span>
#########################################################
#########################################################
### Begin HTML Template
###
<span style="color: #00bbdd;">&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01//EN&quot; &quot;http://www.w3.org/TR/html4/strict.dtd&quot;&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;html</span> xmlns=<span style="color: #ff0000;">&quot;http://www.w3.org/1999/xhtml&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;head&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;meta</span> <span style="color: #000066;">http-equiv</span>=<span style="color: #ff0000;">&quot;content-type&quot;</span> <span style="color: #000066;">content</span>=<span style="color: #ff0000;">&quot;text/html; charset=utf-8&quot;</span> /<span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;title&gt;</span></span>My first app<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/title&gt;</span></span>
&nbsp;
${ h.javascript_include_tag('global', builtins=True) }
${ h.stylesheet_link_tag('/css/styles.css',media='all') }
${self.additional_head_tags()}
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;script</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;text/javascript&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!--
###
### Scripts to execute once DOM is loaded
   function init() {
      ${self.additional_jscript_init()}
   }
   Event.observe(window, &quot;load&quot;, init);
&nbsp;
###
### Custom scripts for the specific page inheriting this layout
   ${self.additional_jscript()}
//--&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/script&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/head&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;body&gt;</span></span>
&nbsp;
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;wrap&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
### **********************************
### HEADER
### **********************************
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;header&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;h1&gt;</span></span>Simple Pylons Examples - My First App<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/h1&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div&gt;</span></span>
&nbsp;
### **********************************
### MAIN CONTENT
### **********************************
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;main&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
      ${ next.body() }
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div&gt;</span></span>
&nbsp;
### **********************************
### SIDEBAR
### **********************************
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;sidebar&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
      ${self.sidebar()}
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div&gt;</span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/body&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/html&gt;</span></span>
### End HTML Template
###
#########################################################
#########################################################
### Define funcs that may be inherited and overwritten in child templates
###
<span style="color: #009900;">&lt;%def <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;additional_head_tags()&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;</span>/%def&gt;</span>
<span style="color: #009900;">&lt;%def <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;additional_jscript_init()&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;</span>/%def&gt;</span>
<span style="color: #009900;">&lt;%def <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;additional_jscript()&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;</span>/%def&gt;</span>
<span style="color: #009900;">&lt;%def <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;sidebar()&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;</span>/%def&gt;</span></pre></td></tr></table></div>

<p>You might have noticed that aside from the common HTML declarations I have a few other python expressions that make function calls and look like that are pulling in additional content.  If you noticed that, you are right!</p>
<p>I have set up a simple way to get JavaScript code included when the DOM loads, the ability to load other external script files, as well as modify the sidebar.</p>
<p>For example, I&#8217;m telling Mako to take all JavaScript initialization calls and place them at line 26.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>26
</pre></td><td class="code"><pre class="python">$<span style="color: black;">&#123;</span><span style="color: #008000;">self</span>.<span style="color: black;">additional_jscript_init</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#125;</span></pre></td></tr></table></div>

<p>Towards the bottom of the page I am defining these functions, although I plan to overwrite them in the views, which I will show you next.</p>
<h2>It&#8217;s all about the View</h2>
<p>Although the layout is the chrome of the page, your view is the entry point, and the doorway from the controller out to the user.</p>
<p>An entry point in your controller would look something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="python"><span style="color: #ff7700;font-weight:bold;">return</span> render<span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;/home/list.mako&quot;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>Here we are calling the <em>list view</em> for the <em>home controller</em>.  The view will then decide what layout it should use, bring in any elements it needs, fill in any places where variables need to be filled, and send it off to the user.</p>
<p>Here is an example view of the list view:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
</pre></td><td class="code"><pre class="html4strict"><span style="color: #009900;">&lt;%inherit file=<span style="color: #ff0000;">&quot;../layouts/default.mako&quot;</span>/<span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;">&lt;%
# 
# templates/home/list.mako 
# Displays list of user names to demonstrate end-to-end
#
%<span style="color: #000000; font-weight: bold;">&gt;</span></span>
#########################################################
#########################################################
### Override inherited funcs
###
###############################
### additional_head_tags()
<span style="color: #009900;">&lt;%def <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;additional_head_tags()&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    ${parent.additional_head_tags()}
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;script</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;${h.url_for('javascript')}/example.js&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;text/javascript&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/script&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;</span>/%def&gt;</span>
###############################
### additional_jscript_init()
<span style="color: #009900;">&lt;%def <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;additional_jscript_init()&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    ${parent.additional_jscript_init()}
    modify_footer();
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;</span>/%def&gt;</span>
###############################
### sidebar()
<span style="color: #009900;">&lt;%def <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;sidebar()&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    ${parent.sidebar()}
    <span style="color: #009900;">&lt;%include file=<span style="color: #ff0000;">&quot;elements/sidebar.mako&quot;</span>/<span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;</span>/%def&gt;</span>
###
#########################################################
#########################################################
### Begin HTML Template
###
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;h2&gt;</span></span>Welcome<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/h2&gt;</span></span>
Hey, how are ya?</pre></td></tr></table></div>

<p>In line 1 we are telling the view what layout to use.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="python">&lt;%inherit <span style="color: #008000;">file</span>=<span style="color: #483d8b;">&quot;../layouts/default.mako&quot;</span>/&gt;</pre></td></tr></table></div>

<p>Starting in line 14, we are overwriting a function that we defined in our layout.  Since we don&#8217;t want to completely overwrite it thought, we make a call to the parent (the layout) first.  Here we are including an additional JavaScript file.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>14
15
16
17
</pre></td><td class="code"><pre class="html4strict"><span style="color: #009900;">&lt;%def <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;additional_head_tags()&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    ${parent.additional_head_tags()}
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;script</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;${h.url_for('javascript')}/example.js&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;text/javascript&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/script&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;</span>/%def&gt;</span></pre></td></tr></table></div>

<h2>And a sprinkle of Elements</h2>
<p>From the example above, we are including a sidebar element at line 28.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>28
</pre></td><td class="code"><pre class="html4strict"><span style="color: #009900;">&lt;%include file=<span style="color: #ff0000;">&quot;elements/sidebar.mako&quot;</span>/<span style="color: #000000; font-weight: bold;">&gt;</span></span></pre></td></tr></table></div>

<p>This allows us to share components between views and even layouts.  Elements have access to the global <strong>c</strong> variable just as the layout and views do.  As a convention I like to call out what variables need to be defined for an element to work towards the top of the file.  As such, an example should follow&#8230;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="html4strict"># 
# element/sidebar.mako 
# Sidebar element
#
# Required defined vars:
#  c.active_users - An array of active users {Users database objects}
#
%&gt;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;p&gt;</span></span>Ads<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/p&gt;</span></span>
% for user in c.active_users:
    ${ user.name }<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;br</span>/<span style="color: #000000; font-weight: bold;">&gt;</span></span>
% endfor</pre></td></tr></table></div>

<p>Here we are assuming that we have several active users that we wish to loop over.  The object would be obtained in the calling controller as follows:</p>

<div class="wp_syntax"><div class="code"><pre class="python">users = meta.<span style="color: black;">Session</span>.<span style="color: black;">query</span><span style="color: black;">&#40;</span>model.<span style="color: black;">User</span><span style="color: black;">&#41;</span>.<span style="color: black;">filter_by</span><span style="color: black;">&#40;</span>date &gt;= <span style="color: #dc143c;">time</span>.<span style="color: black;">now</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: #ff4500;">-86400</span>*<span style="color: #ff4500;">7</span><span style="color: black;">&#41;</span>
c.<span style="color: black;">active_users</span> = users</pre></div></div>

<h2>Download</h2>
<p>That concludes the 3 part series of <a href="/blog/2008/04/zero-to-60-with-pylons-in-just-minutes-part-1/">Zero to 60 with Pylons</a></p>
<p>If you wish to see the full, bare bones project in action you can <a href="/blog/wp-content/uploads/2008/05/myfirstapp.zip">download here</a>.</p>
<p><a href="http://sharethis.com/item?&wp=2.5&amp;publisher=5be9cfee-1ca7-4df9-a04a-c2fbf8266feb&amp;title=Zero+to+60+with+Pylons%E2%80%A6+in+just+minutes+%28Part+3%29&amp;url=http%3A%2F%2Fwww.janisb.com%2Fblog%2F2008%2F05%2Fzero-to-60-with-pylons-in-just-minutes-part-3%2F">ShareThis</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.janisb.com/blog/2008/05/zero-to-60-with-pylons-in-just-minutes-part-3/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
