<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>VijayKiran.com</title>
	
	<link>http://www.vijaykiran.com</link>
	<description />
	<lastBuildDate>Tue, 31 Jan 2012 23:44:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/Vijaykirancom" /><feedburner:info uri="vijaykirancom" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId>Vijaykirancom</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><item>
		<title>Web Application Development with Clojure – Part 3</title>
		<link>http://feedproxy.google.com/~r/Vijaykirancom/~3/tiZP28prIVQ/</link>
		<comments>http://www.vijaykiran.com/2012/01/31/web-application-development-with-clojure-part-3/#comments</comments>
		<pubDate>Tue, 31 Jan 2012 15:57:18 +0000</pubDate>
		<dc:creator>Vijay Kiran</dc:creator>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[beginner]]></category>
		<category><![CDATA[clojure]]></category>
		<category><![CDATA[enlive]]></category>
		<category><![CDATA[korma]]></category>
		<category><![CDATA[webapp]]></category>

		<guid isPermaLink="false">http://www.vijaykiran.com/?p=3691</guid>
		<description><![CDATA[Continuing with previous series of blog posts, in this third part we'll learn how to load some test data using clojure-yaml. After loading the test data, we'll explore how to create a simple template using enlive and render the home page for our Clog - blog. Make sure you checkout Part 1 and Part 2 as well.]]></description>
			<content:encoded><![CDATA[<p>This post is part of the Web Application Development with <a href="http://clojure.org">Clojure</a> tutorial. You might want to read the previous posts before with this post for continuitiy&#8217;s sake.</p>
<ul>
<li><a href="http://www.vijaykiran.com/2012/01/11/web-application-development-with-clojure-part-1/">Part 1: Project Setup</a></li>
<li><a href="http://www.vijaykiran.com/2012/01/17/web-application-development-with-clojure-part-2/">Part 2: Data model definition with Lobos and Korma</a></li>
<li><a href="http://www.vijaykiran.com/2012/01/18/web-application-development-with-clojure-part-3/">Part 3: Loading Fixures with <a href="https://github.com/lancepantz/clj-yaml">clj-yaml</a> and HTML Templating with <a href="https://github.com/cgrand/enlive">Enlive</a></li>
</ul>
<h2>Introduction</h2>
<p>In the <a title="Clojure Web App Development - Part 2" href="http://www.vijaykiran.com/2012/01/17/web-application-development-with-clojure-part-2/">previous part</a> of this tutorial we created a couple of tables using migrations &#8211; users table and posts table. In this part first I&#8217;ll describe how to load some test data (a.k.a &#8216;<em>fixtures</em>&#8216;) into our database tables. We&#8217;ll use YAML to define a couple of users and 3 blog posts and we&#8217;ll parse the YAML file and load the data using the clj-yaml library.</p>
<p>Also we&#8217;ll create our first template and render the blog&#8217;s home page with the sample data from the database.</p>
<h3>Source code on github</h3>
<p>The code for this series is now available on <a href="https://github.com/vijaykiran/clog">github</a> and the source code is tagged with part names. If you want to checkout the code for a specific part of this tutorial you can do so using the following command:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">git clone git://github.com/vijaykiran/clog.git
cd clog
git checkout part3</pre></div></div>

<p><h>A quick note for PostgreSQL users</h3>
<p>In the previous while creating the tables using migrations, I overlooked and made a mistake in naming the tables. If you are using PostgreSQL then the word &#8220;user&#8221; is a reserved word, so you should rename the table to users &#8211; I&#8217;ve updated the code accordingly. </p>
<h2>Loading Fixtures</h2>
<p>Fixtures are used to populate the database with some initial data. Though fixtures are mostly used for loading test data we can also use fixtures to bootstrap the content. First let us create a file called <em>fixtures.yml</em> under <em>resources</em> folder. If you don&#8217;t have a resources folder in your project, create it under the root directory so that will be at the same level as <em>src</em> folder.</p>
<p>Edit the <em>fixtures.yml</em> and add the following:</p>
<div class="asideBlock">Pay attention to the formatting of the text in a YAML file, otherwise you might get exceptions during parsing.</div>

<div class="wp_syntax"><div class="code"><pre class="yml" style="font-family:monospace;">authors:
    - id: 1
      username:     &quot;john&quot;
      password:     &quot;clojure-blogger&quot;
      email:        &quot;john@clojure-blog.org&quot;
    - id: 2
      username:     &quot;jane&quot;
      password:     &quot;clojure-blogher&quot;
      email:        &quot;jane@clojure-blog.org&quot;
&nbsp;
posts:
    - title: &quot;Hello World!&quot;
      text: &quot;&lt;em&gt;Welcome to Clog, the World's most advanced Clojure Blog Engine!&lt;/em&gt;&quot;
      status: true
      author: 1
    - title: &quot;Hello World!, again!&quot;
      text: &quot;Sayin 't 'gain! &lt;em&gt;Welcome to Clog, the World's most advanced Clojure Blog Engine!&lt;/em&gt;&quot;
      status: true
      author: 2</pre></div></div>

<div class="asideBlock>Check out <a title="Clojure Web App Development - Part 1" href="http://www.vijaykiran.com/2012/01/11/web-application-development-with-clojure-part-1/">part 1</a>, if you want to refresh your memory on how to use setup IntelliJ IDE</div>
<p>Now, fire up the Clojure REPL in IntelliJ IDE using <em>Tools -> Start Clojure Console</em>. We&#8217;ll load the <em>clj-yaml</em> library and parse the yaml file.</p>

<div class="wp_syntax"><div class="code"><pre class="clojure" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">;; load clj-yaml</span>
<span style="color: #66cc66;">&#40;</span>use 'clj<span style="color: #66cc66;">-</span>yaml<span style="color: #66cc66;">.</span>core<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span>parse<span style="color: #66cc66;">-</span>string <span style="color: #66cc66;">&#40;</span>slurp <span style="color: #ff0000;">&quot;./resources/fixtures.yml&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>If everything went well, you should see the map with keys <em>:authors</em> and <em>:posts</em> in the console as shown below:</p>

<div class="wp_syntax"><div class="code"><pre class="clojure" style="font-family:monospace;"><span style="color: #66cc66;">&#123;</span>:<span style="color: #555;">authors</span> 
  <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>:<span style="color: #555;">id</span> <span style="color: #cc66cc;">1</span>, :<span style="color: #555;">username</span> <span style="color: #ff0000;">&quot;john&quot;</span>, :<span style="color: #555;">password</span> <span style="color: #ff0000;">&quot;clojure-blogger&quot;</span>, :<span style="color: #555;">email</span> <span style="color: #ff0000;">&quot;john@clojure-blog.org&quot;</span><span style="color: #66cc66;">&#125;</span> 
   <span style="color: #66cc66;">&#123;</span>:<span style="color: #555;">id</span> <span style="color: #cc66cc;">2</span>, :<span style="color: #555;">username</span> <span style="color: #ff0000;">&quot;jane&quot;</span>, :<span style="color: #555;">password</span> <span style="color: #ff0000;">&quot;clojure-blogher&quot;</span>, :<span style="color: #555;">email</span> <span style="color: #ff0000;">&quot;jane@clojure-blog.org&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>, 
 :<span style="color: #555;">posts</span> 
  <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>:<span style="color: #555;">title</span> <span style="color: #ff0000;">&quot;Hello World!&quot;</span>, 
    :<span style="color: #555;">text</span> <span style="color: #ff0000;">&quot;&lt;i&gt;Welcome to Clog, the World's most advanced Clojure Blog Engine!&lt;/i&gt;&quot;</span>, 
    :<span style="color: #555;">status</span> true, :<span style="color: #555;">author</span> <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#125;</span> 
   <span style="color: #66cc66;">&#123;</span>:<span style="color: #555;">title</span> <span style="color: #ff0000;">&quot;Hello World!, again!&quot;</span>, 
     :<span style="color: #555;">text</span> <span style="color: #ff0000;">&quot;Sayin 't 'gain! &lt;i&gt;Welcome to Clog, the World's most advanced Clojure Blog Engine!&lt;/i&gt;&quot;</span>, 
    :<span style="color: #555;">status</span> true, :<span style="color: #555;">author</span> <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>Now to add the authors to the database all you need is the following couple of lines:</p>
<div class="asideBlock">As you can see, you don&#8217;t need to write the code in a file, compile, redeploy and refresh to modify your program. All you need is a REPL which you use to build your program bottom-up &#8211; one little function at a time.</div>

<div class="wp_syntax"><div class="code"><pre class="clojure" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">;;load korma library and models</span>
<span style="color: #66cc66;">&#40;</span>use 'korma<span style="color: #66cc66;">.</span>db 'korma<span style="color: #66cc66;">.</span>core 'clog<span style="color: #66cc66;">.</span>models<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span>insert authors <span style="color: #66cc66;">&#40;</span>values <span style="color: #66cc66;">&#40;</span>:<span style="color: #555;">users</span> <span style="color: #66cc66;">&#40;</span>parse<span style="color: #66cc66;">-</span>string <span style="color: #66cc66;">&#40;</span>slurp <span style="color: #ff0000;">&quot;./resources/fixtures.yml&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>The second line in the above code snippet reads the fixtures file using <em>slurp</em>, parses the yaml using <em>parse-string</em> which returns a map with keys <em>:users</em> and <em>:posts</em>. We use clojure&#8217;s maps-as-functions-of-keys features to get the list of users and pass them to Korma&#8217;s insert function. Once this is executed you can see the data is now inserted into the Users table.</p>
<div class="asideBlock">In a real-world-application you never use password, but instead you will  probably store some encrypted hash. I&#8217;ll leave that as an exercise to the reader (not the clojure reader!).</div>

<div class="wp_syntax"><div class="code"><pre class="clojure" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span>select authors<span style="color: #66cc66;">&#41;</span>
<span style="color: #808080; font-style: italic;">;;output</span>
<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#123;</span>:<span style="color: #555;">id</span> <span style="color: #cc66cc;">1</span>, :<span style="color: #555;">username</span> <span style="color: #ff0000;">&quot;john&quot;</span>, :<span style="color: #555;">password</span> <span style="color: #ff0000;">&quot;clojure-blogger&quot;</span>, :<span style="color: #555;">email</span> <span style="color: #ff0000;">&quot;john@clojure-blog.org&quot;</span><span style="color: #66cc66;">&#125;</span> 
 <span style="color: #66cc66;">&#123;</span>:<span style="color: #555;">id</span> <span style="color: #cc66cc;">2</span>, :<span style="color: #555;">username</span> <span style="color: #ff0000;">&quot;jane&quot;</span>, :<span style="color: #555;">password</span> <span style="color: #ff0000;">&quot;clojure-blogher&quot;</span>, :<span style="color: #555;">email</span> <span style="color: #ff0000;">&quot;jane@clojure-blog.org&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#93;</span>
<span style="color: #66cc66;">&#40;</span>select posts<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">....</span></pre></div></div>

<h2>Templates using Enlive</h2>
<p>Now that we have our sample data populated in the database, it is time to get started with our first template. Clojure has a couple of libraries that can help you with dealing with HTML viz, Hiccup and Enlive. Hiccup is a DSL for generating HTML and Enlive is a selector based templating engine. I&#8217;m a bit biased towards Enlive &#8211; since I have more freedom of styling and HTML stays HTML. So in this tutorial I&#8217;m using Enlive.</p>
<h3> Defining Home Page Template</h3>
<p>Enlive provides a macro called <em>deftemplate</em> to define template functions. The macro is defined as follows:</p>

<div class="wp_syntax"><div class="code"><pre class="clojure" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">defmacro</span> deftemplate
 <span style="color: #ff0000;">&quot;Defines a template as a function that returns a seq of strings.&quot;</span> 
 <span style="color: #66cc66;">&#91;</span>name source args <span style="color: #66cc66;">&amp;</span> forms<span style="color: #66cc66;">&#93;</span> 
  `<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">def</span> ~name <span style="color: #66cc66;">&#40;</span>template ~source ~args ~@forms<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>The forms you pass in are actually used to transform the html. I think it will be easier to understand with an example that you can follow along. First let us create the <em>home.html</em> under <em>resources</em> folder. By convention the templates are loaded from the resources directory.</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
    &lt;title&gt;Title Here&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
Clog - Home Page!
&lt;/body&gt;
&lt;/html&gt;</pre></div></div>

<p>We will place all our template definitions in <em>clog.templates</em> namespace which lives in cleverly named <em>templates.clj</em></p>

<div class="wp_syntax"><div class="code"><pre class="clojure" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">ns</span> clog<span style="color: #66cc66;">.</span>templates
  <span style="color: #66cc66;">&#40;</span>:<span style="color: #555;">use</span> <span style="color: #66cc66;">&#91;</span>net<span style="color: #66cc66;">.</span>cgrand<span style="color: #66cc66;">.</span>enlive<span style="color: #66cc66;">-</span>html<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #66cc66;">&#40;</span>deftemplate home<span style="color: #66cc66;">-</span>page <span style="color: #ff0000;">&quot;home.html&quot;</span> <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span>
  <span style="color: #66cc66;">&#91;</span>:<span style="color: #555;">title</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&#40;</span>content <span style="color: #ff0000;">&quot;Clog - the clojure blog engine!&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>In the above snippet we are using <em>deftemplate</em> macro to create a template function called <em>home-page</em> which takes the file <em>home.html</em> and transforms the file using the forms, in our case only one which is:</p>

<div class="wp_syntax"><div class="code"><pre class="clojure" style="font-family:monospace;"><span style="color: #66cc66;">&#91;</span>:<span style="color: #555;">title</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&#40;</span>content <span style="color: #ff0000;">&quot;Clog - the clojure blog engine!&quot;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>This says find out the tag :title in the home.html and replace its contents with &#8220;Clog &#8211; the clojure blog engine!&#8221;. To test this out you can load the namespace in repl and run the <em>home-page</em> function. That will print out the transformed template as shown below.</p>

<div class="wp_syntax"><div class="code"><pre class="clojure" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span>use 'clog<span style="color: #66cc66;">.</span>templates<span style="color: #66cc66;">&#41;</span>
nil
user<span style="color: #66cc66;">=&gt;</span> <span style="color: #66cc66;">&#40;</span>home<span style="color: #66cc66;">-</span>page<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;&lt;!DOCTYPE html&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #ff0000;">&quot;&lt;html&gt;&quot;</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #ff0000;">&quot;&lt;head&gt;&quot;</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>    &quot;</span> <span style="color: #ff0000;">&quot;&lt;title&gt;&quot;</span> <span style="color: #ff0000;">&quot;Clog - the clojure blog engine!&quot;</span> <span style="color: #ff0000;">&quot;&lt;/title&gt;&quot;</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #ff0000;">&quot;&lt;/head&gt;&quot;</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #ff0000;">&quot;&lt;body&gt;<span style="color: #000099; font-weight: bold;">\n</span>Clog - Home Page!<span style="color: #000099; font-weight: bold;">\n</span>&lt;/body&gt;&quot;</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #ff0000;">&quot;&lt;/html&gt;&quot;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>Now this template function can be used to generate the transformed html we need to send to the client. To connect the these views to the requests, we will use simple controller functions. These functions/handlers are then used to transform the templates using the request parameter and data from the database. For example we want our blog to respond to something like <em>http://host:port/posts/1</em> by sending out the html for the post with id 1. This logic is wrapped inside a controller function.</p>
<h3>A simple Controller</h3>
<p>We&#8217;ll put our controller functions in the <em>clog.controller</em> namespace. Here&#8217;s the initial version of the controller which has handler for the index page.</p>

<div class="wp_syntax"><div class="code"><pre class="clojure" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">ns</span> clog<span style="color: #66cc66;">.</span>controller
  <span style="color: #66cc66;">&#40;</span>:<span style="color: #555;">use</span> clog<span style="color: #66cc66;">.</span>templates
         clog<span style="color: #66cc66;">.</span>models
         ring<span style="color: #66cc66;">.</span>util<span style="color: #66cc66;">.</span>response<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">defn</span> index
  <span style="color: #ff0000;">&quot;Index page handler&quot;</span>
  <span style="color: #66cc66;">&#91;</span>req<span style="color: #66cc66;">&#93;</span>
  <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">-&gt;&gt;</span> <span style="color: #66cc66;">&#40;</span>home<span style="color: #66cc66;">-</span>page<span style="color: #66cc66;">&#41;</span> response<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #808080; font-style: italic;">;; A sexier way to write (response (home-page))</span></pre></div></div>

<p>Now to see this function in action, we need to update the routes of the application in core.clj to call clog.controller/index. Here&#8217;s the complete core.clj after the required modifications:</p>
<div class="asideBlock">Notice that <em>delegate</em> call in routes ? This is due to small gotcha in mustache route syntax. We can&#8217;t use the function directly as the handler, since we want the parameters of the handler, in our case &#8216;req&#8217; to be passed to function. So we use delegate to pass the request as the first argument.</div>

<div class="wp_syntax"><div class="code"><pre class="clojure" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">ns</span> clog<span style="color: #66cc66;">.</span>core
  <span style="color: #66cc66;">&#40;</span>:<span style="color: #555;">use</span> ring<span style="color: #66cc66;">.</span>adapter<span style="color: #66cc66;">.</span>jetty
        ring<span style="color: #66cc66;">.</span>middleware<span style="color: #66cc66;">.</span>resource
        ring<span style="color: #66cc66;">.</span>middleware<span style="color: #66cc66;">.</span>reload
        ring<span style="color: #66cc66;">.</span>util<span style="color: #66cc66;">.</span>response
        net<span style="color: #66cc66;">.</span>cgrand<span style="color: #66cc66;">.</span>moustache
        clog<span style="color: #66cc66;">.</span>controller<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">;; Routes definition</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">def</span> routes
  <span style="color: #66cc66;">&#40;</span>app
    <span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;&quot;</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&#40;</span>delegate index<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">;;; start function for starting jetty</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">defn</span> start <span style="color: #66cc66;">&#91;</span>port<span style="color: #66cc66;">&#93;</span>
  <span style="color: #66cc66;">&#40;</span>run<span style="color: #66cc66;">-</span>jetty #'routes <span style="color: #66cc66;">&#123;</span>:<span style="color: #555;">port</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">or</span> port <span style="color: #cc66cc;">8080</span><span style="color: #66cc66;">&#41;</span> :<span style="color: #555;">join</span>? false<span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">defn</span> <span style="color: #66cc66;">-</span>main <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span>
  <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">let</span> <span style="color: #66cc66;">&#91;</span>port <span style="color: #66cc66;">&#40;</span>Integer<span style="color: #66cc66;">/</span>parseInt <span style="color: #66cc66;">&#40;</span>System<span style="color: #66cc66;">/</span>getenv <span style="color: #ff0000;">&quot;PORT&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
    <span style="color: #66cc66;">&#40;</span>start port<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>Start the server as shown below, and you should see the home page with title in the window title bar &#8220;Clog &#8211; the clojure blog engine!&#8221;.</p>

<div class="wp_syntax"><div class="code"><pre class="clojure" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span>use 'clog<span style="color: #66cc66;">.</span>core<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span>start <span style="color: #cc66cc;">9000</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<h3>List of Posts</h3>
<p>The home is working, but it is rather boring and doesn&#8217;t show any real data. Let us try to show the two posts we added in the database. First we need to update the home.html to create a place holder for a post.</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
    &lt;title&gt;Title Here&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div class=&quot;post&quot;&gt;
    &lt;div class=&quot;title&quot;&gt;Title of the Post&lt;/div&gt;
    &lt;div class=&quot;content&quot;&gt;Post Content&lt;/div&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;</pre></div></div>

<p>Now let us update the template and add another transformation. In this case we want to &#8220;clone&#8221; the <em>div</em> with class <em>post</em> and replace the content of divs with classes <em>title</em> and <em>content</em>. Here&#8217;s the updated deftemplate&#8217;s code that does exactly the same. We are using clone-for macro and using the forms to transform the sub elements.</p>

<div class="wp_syntax"><div class="code"><pre class="clojure" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span>deftemplate home<span style="color: #66cc66;">-</span>page  <span style="color: #ff0000;">&quot;home.html&quot;</span> <span style="color: #66cc66;">&#91;</span>posts<span style="color: #66cc66;">&#93;</span>
  <span style="color: #66cc66;">&#91;</span>:<span style="color: #555;">title</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&#40;</span>content <span style="color: #ff0000;">&quot;Clog - the clojure blog engine!&quot;</span><span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">&#91;</span>:<span style="color: #555;">div</span><span style="color: #66cc66;">.</span>post<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&#40;</span>clone<span style="color: #66cc66;">-</span><span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#91;</span>post posts<span style="color: #66cc66;">&#93;</span>
                <span style="color: #66cc66;">&#91;</span>:<span style="color: #555;">div</span><span style="color: #66cc66;">.</span>title<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&#40;</span>content <span style="color: #66cc66;">&#40;</span>:<span style="color: #555;">title</span> post<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
                <span style="color: #66cc66;">&#91;</span>:<span style="color: #555;">div</span><span style="color: #66cc66;">.</span>content <span style="color: #66cc66;">&#40;</span>content <span style="color: #66cc66;">&#40;</span>:<span style="color: #555;">content</span> post<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>Now we need to make sure that our controller function sends the required data to the template.</p>

<div class="wp_syntax"><div class="code"><pre class="clojure" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">ns</span> clog<span style="color: #66cc66;">.</span>controller
  <span style="color: #66cc66;">&#40;</span>:<span style="color: #555;">use</span>  clog<span style="color: #66cc66;">.</span>templates
         clog<span style="color: #66cc66;">.</span>models
         ring<span style="color: #66cc66;">.</span>util<span style="color: #66cc66;">.</span>response
         korma<span style="color: #66cc66;">.</span>core<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">defn</span> index
  <span style="color: #ff0000;">&quot;Index page handler&quot;</span>
  <span style="color: #66cc66;">&#91;</span>req<span style="color: #66cc66;">&#93;</span>
  <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">-&gt;&gt;</span> <span style="color: #66cc66;">&#40;</span>select posts<span style="color: #66cc66;">&#41;</span> home<span style="color: #66cc66;">-</span>page response<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #808080; font-style: italic;">;; Equivalent to  (response (home-page (select posts))</span></pre></div></div>

<p>We are selecting all the posts using Korma select function and passing it on to home-page function. The result of the home-page template function &#8211; which is the html with posts populated is passed on to response.</p>
<p>After making these changes, you should see the list of posts in the home page.</p>
<div class="asideBlock">Don&#8217;t worry about styling of the page, we&#8217;ll add a pretty CSS in the next part of the tutorial.</div>
<p><a href="http://www.vijaykiran.com/wp-content/uploads/2012/01/posts.png" class="enlarge"><img src="http://www.vijaykiran.com/wp-content/uploads/2012/01/posts-620x442.png" alt="" title="posts" width="620" height="442" class="aligncenter size-large wp-image-3742" /></a></p>
<h3>Conclusion</h3>
<p>In this part we saw how to glue things together and get the content from database, render it in a page using templates. In the next part we&#8217;ll finish by updating the home template and adding another template to display the post. Also, in the next part we&#8217;ll start working in creating an admin area with authentication. </p>
<p>Make sure you <a href="http://vijaykiran.com/feed">subscribe</a> to the RSS feed or follow me on <a href="http://twitter.com/vijaykiran">Twitter</a> to get notified.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/ZRvferv185cg5rYYKVuty6rjVP4/0/da"><img src="http://feedads.g.doubleclick.net/~a/ZRvferv185cg5rYYKVuty6rjVP4/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/ZRvferv185cg5rYYKVuty6rjVP4/1/da"><img src="http://feedads.g.doubleclick.net/~a/ZRvferv185cg5rYYKVuty6rjVP4/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Vijaykirancom?a=tiZP28prIVQ:YwxFfZnAz6U:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Vijaykirancom?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Vijaykirancom?a=tiZP28prIVQ:YwxFfZnAz6U:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/Vijaykirancom?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Vijaykirancom?a=tiZP28prIVQ:YwxFfZnAz6U:6W8y8wAjSf4"><img src="http://feeds.feedburner.com/~ff/Vijaykirancom?d=6W8y8wAjSf4" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Vijaykirancom/~4/tiZP28prIVQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.vijaykiran.com/2012/01/31/web-application-development-with-clojure-part-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.vijaykiran.com/2012/01/31/web-application-development-with-clojure-part-3/</feedburner:origLink></item>
		<item>
		<title>Photo: Muffins with Raisins</title>
		<link>http://feedproxy.google.com/~r/Vijaykirancom/~3/TZAYzmcIJno/</link>
		<comments>http://www.vijaykiran.com/2012/01/22/photo-muffins-with-raisins/#comments</comments>
		<pubDate>Sun, 22 Jan 2012 11:23:34 +0000</pubDate>
		<dc:creator>Vijay Kiran</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.vijaykiran.com/?p=3713</guid>
		<description />
			<content:encoded><![CDATA[<p><a href="http://www.vijaykiran.com/wp-content/uploads/2012/01/20120122-122125.jpg"><img src="http://www.vijaykiran.com/wp-content/uploads/2012/01/20120122-122125.jpg" alt="20120122-122125.jpg" class="alignnone size-full" /></a></p>

<p><a href="http://feedads.g.doubleclick.net/~a/yuwypilySBDcxIBmdRtqc9ORoOU/0/da"><img src="http://feedads.g.doubleclick.net/~a/yuwypilySBDcxIBmdRtqc9ORoOU/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/yuwypilySBDcxIBmdRtqc9ORoOU/1/da"><img src="http://feedads.g.doubleclick.net/~a/yuwypilySBDcxIBmdRtqc9ORoOU/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Vijaykirancom?a=TZAYzmcIJno:CRLjpxiMM1o:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Vijaykirancom?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Vijaykirancom?a=TZAYzmcIJno:CRLjpxiMM1o:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/Vijaykirancom?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Vijaykirancom?a=TZAYzmcIJno:CRLjpxiMM1o:6W8y8wAjSf4"><img src="http://feeds.feedburner.com/~ff/Vijaykirancom?d=6W8y8wAjSf4" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Vijaykirancom/~4/TZAYzmcIJno" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.vijaykiran.com/2012/01/22/photo-muffins-with-raisins/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.vijaykiran.com/2012/01/22/photo-muffins-with-raisins/</feedburner:origLink></item>
		<item>
		<title>My super cool workplace at Lunatech</title>
		<link>http://feedproxy.google.com/~r/Vijaykirancom/~3/FX9EDAkXs2Q/</link>
		<comments>http://www.vijaykiran.com/2012/01/19/my-desk-at-lunatech/#comments</comments>
		<pubDate>Thu, 19 Jan 2012 18:02:27 +0000</pubDate>
		<dc:creator>Vijay Kiran</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[lunatech]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://www.vijaykiran.com/?p=3694</guid>
		<description><![CDATA[In my 10 years of programming career, Lunatech is probably the best company to work with. Herman Miller Aeron: Ultimate Programmer&#8217;s Chair Nerf Recon CS-6 with N-Strike Darts: For fun times. 17&#8243; Mac Book Pro with 8GB RAM, SSD running Emacs in Full Screen: Ultimate Programmer&#8217;s Computer The Joy of Clojure: The book for Ultimate [...]]]></description>
			<content:encoded><![CDATA[<p>In my 10 years of programming career, <a href="http://www.lunatech-research.com/">Lunatech</a> is probably the best company to work with.</p>
<p><a href="http://www.vijaykiran.com/wp-content/uploads/2012/01/lunatech-desk.png" class="enlarge"><img src="http://www.vijaykiran.com/wp-content/uploads/2012/01/lunatech-desk-620x464.png" alt="" title="lunatech-desk" width="620" height="464" class="alignleft size-large wp-image-3695" /></a></p>
<ol>
<li>Herman Miller Aeron: Ultimate Programmer&#8217;s Chair </li>
<li>Nerf Recon CS-6 with N-Strike Darts: For fun times.</li>
<li>17&#8243; Mac Book Pro with 8GB RAM, SSD running Emacs in Full Screen: Ultimate Programmer&#8217;s Computer</li>
<li>The Joy of Clojure: The book for Ultimate programming language</li>
<li>mStand for MBP: For enhanced ergonomics and coolness factor</li>
</ol>
<p>Not shown in the photo:</p>
<ul>
<li>Super Awesome Colleagues</li>
<li>Projects using cutting-edge tech including: Scala, Play! Framework.</li>
<li>No Managers</li>
<li>No Managers, Seriously.</li>
<li>WORK-ON-YOUR-OWN-COOL-PROJECT-EVERY-FRIDAY &#8211; Yeah, EVERY Friday.</li>
</ul>
<p>Like what you see and curious about what we do ? Come and talk to us at <a href="http://playframework.eventbrite.com/">Play!ground</a> on February 3rd at Paddy Murphy’s Irish Pub, Rotterdam.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/sNu17yp6izhPshGEEn_jbcSm_xw/0/da"><img src="http://feedads.g.doubleclick.net/~a/sNu17yp6izhPshGEEn_jbcSm_xw/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/sNu17yp6izhPshGEEn_jbcSm_xw/1/da"><img src="http://feedads.g.doubleclick.net/~a/sNu17yp6izhPshGEEn_jbcSm_xw/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Vijaykirancom?a=FX9EDAkXs2Q:Tk57zO2AAbc:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Vijaykirancom?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Vijaykirancom?a=FX9EDAkXs2Q:Tk57zO2AAbc:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/Vijaykirancom?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Vijaykirancom?a=FX9EDAkXs2Q:Tk57zO2AAbc:6W8y8wAjSf4"><img src="http://feeds.feedburner.com/~ff/Vijaykirancom?d=6W8y8wAjSf4" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Vijaykirancom/~4/FX9EDAkXs2Q" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.vijaykiran.com/2012/01/19/my-desk-at-lunatech/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		<feedburner:origLink>http://www.vijaykiran.com/2012/01/19/my-desk-at-lunatech/</feedburner:origLink></item>
		<item>
		<title>Web Application Development with Clojure – Part 2</title>
		<link>http://feedproxy.google.com/~r/Vijaykirancom/~3/PSYWiOnEVgU/</link>
		<comments>http://www.vijaykiran.com/2012/01/17/web-application-development-with-clojure-part-2/#comments</comments>
		<pubDate>Mon, 16 Jan 2012 23:00:50 +0000</pubDate>
		<dc:creator>Vijay Kiran</dc:creator>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[beginner]]></category>
		<category><![CDATA[clojure]]></category>
		<category><![CDATA[korma]]></category>
		<category><![CDATA[lobos]]></category>
		<category><![CDATA[webapp]]></category>

		<guid isPermaLink="false">http://www.vijaykiran.com/?p=3646</guid>
		<description><![CDATA[This post is part of the Web Application Development with Clojure tutorial. You may want to read the previous posts before continuing with this post. Part 1: Project Setup Part 2: Data model definition with Lobos and Korma Part 3: Loading Fixures with clj-yaml and HTML Templating with Enlive Updated: 31st January, 2012 &#8211; Renamed [...]]]></description>
			<content:encoded><![CDATA[<p>This post is part of the Web Application Development with <a href="http://clojure.org">Clojure</a> tutorial. You may want to read the previous posts before continuing with this post.</p>
<ul>
<li><a href="http://www.vijaykiran.com/2012/01/11/web-application-development-with-clojure-part-1/">Part 1: Project Setup</a></li>
<li><a href="http://www.vijaykiran.com/2012/01/17/web-application-development-with-clojure-part-2/">Part 2: Data model definition with Lobos and Korma</a></li>
<li><a href="http://www.vijaykiran.com/2012/01/18/web-application-development-with-clojure-part-3/">Part 3: Loading Fixures with <a href="https://github.com/lancepantz/clj-yaml">clj-yaml</a> and HTML Templating with <a href="https://github.com/cgrand/enlive">Enlive</a></li>
</ul>
<p><em>Updated: 31st January, 2012 &#8211; Renamed all &#8216;users&#8217; to &#8216;authors&#8217; to prevent problems with PostgreSQL</em></p>
<h2>Introduction</h2>
<p>In <a href="http://www.vijaykiran.com/2012/01/11/web-application-development-with-clojure-part-1/">part 1</a> of this series, we learnt how to setup a Clojure web application project &#8211; Clog a blogging engine. In this second part of the tutorial we will start working on the application&#8217;s database layer &#8211; setting up the schema, creating migrations and finally creating the entities for the model. This terminology should be familiar for people who already worked with other web application frameworks such as Ruby on Rails or Play! framework. If you have never used these frameworks, do not worry no knowledge of those is assumed in this tutorial.</p>
<h3>Source code on github</h3>
<p>The code for this series is now available on <a href="https://github.com/vijaykiran/clog">github</a> and the source code is tagged with part names. If you want to checkout the code for a specific part of this tutorial you can do so using the following command:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">git clone git://github.com/vijaykiran/clog.git
cd clog
git checkout part1</pre></div></div>

<h2>Database Schema Setup</h2>
<p>Normally when you want to work with a database, you will create a schema using DDL (Data Definition Language). DDL contains SQL statements like &#8220;CREATE TABLE AUTHOR …&#8221; etc. This will define the schema objects you need to store your application&#8217;s data. In this post however, I&#8217;d like to show you how you can create and manage the schema using a Clojure library called Lobos.</p>
<p>Lobos library provides a DSL (Domain Specific Language) that helps you in defining the database schema and migrations in a Database-agnostic way. By that I mean you can define your schema in Clojure and you can use Lobos to create the schema on any database e.g. PostgreSQL, MySQL or HSQL.</p>
<p>Before we begin, we need to create a database. As you might have seen in <a href="http://www.vijaykiran.com/2012/01/11/web-application-development-with-clojure-part-1/">part 1</a>&#8216;s dependency listing, for this tutorial we will use PostgreSQL as the database.</p>
<h2>Database Setup</h2>
<div class="asideBlock">If you prefer MySQL database to PostgreSQL, you can replace the dependency jar with MySQL jdbc driver. But I&#8217;ll leave it as an exercise for the reader.</div>
<p>First install PostgreSQL for your platform by downloading it from <a href="http://www.postgresql.org/download/">here</a>. Create a user with login <em>clog</em> and your choice of password. Create a database named <em>clogdb</em> and make sure that the user has permissions on the database. To perform these steps you can either use the pgAdmin GUI tool to manage the database or you can use psql command line tool. If you prefer the latter, you can use the following commands to create the database and user:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">USER</span> clog <span style="color: #993333; font-weight: bold;">WITH</span> PASSWORD <span style="color: #ff0000;">'Your_Choice_Of_Password'</span>;
&nbsp;
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">DATABASE</span> clogdb;
&nbsp;
<span style="color: #993333; font-weight: bold;">GRANT</span> <span style="color: #993333; font-weight: bold;">ALL</span> PRIVILEGES <span style="color: #993333; font-weight: bold;">ON</span> <span style="color: #993333; font-weight: bold;">DATABASE</span> clogdb <span style="color: #993333; font-weight: bold;">TO</span> clog;</pre></div></div>

<h2>Schema Creation using Lobos</h2>
<p>Before we start writing code in Clojure with Lobos, let us take a quick look at the terminology.</p>
<h3>Migrations</h3>
<p>Migrations are incremental steps that you have taken to evolve your database schema. Let me explain what a migration means with a concrete example. When you are creating the tables for our blog engine, you will create a table called <em>Posts</em> to store our blog posts. The <em>Posts</em> table might contain the following columns: <em>id</em>, <em>publishedDate</em>, <em>status</em>, <em>content</em>, <em>title</em>. To create a table with these fields you&#8217;ll use the following SQL DDL:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> posts <span style="color: #66cc66;">&#40;</span> id <span style="color: #993333; font-weight: bold;">INTEGER</span> <span style="color: #993333; font-weight: bold;">UNIQUE</span><span style="color: #66cc66;">,</span> 
                     title text <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
                     content text<span style="color: #66cc66;">,</span>
                     published_date DATETIME <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span>
                     <span style="color: #993333; font-weight: bold;">STATUS</span> text <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span><span style="color: #66cc66;">,</span> 
                     <span style="color: #993333; font-weight: bold;">CONSTRAINT</span> posts_id_key <span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span> <span style="color: #66cc66;">&#40;</span>id<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>Now at a later point of time you want to add rating to all the blog posts, that means you need to alter the schema to add a new column to the <em>Posts</em> table. This can be done using following Alter table statement.</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">ALTER</span> <span style="color: #993333; font-weight: bold;">TABLE</span> posts
      <span style="color: #993333; font-weight: bold;">ADD</span> rating <span style="color: #993333; font-weight: bold;">INTEGER</span>;</pre></div></div>

<p>In the above scenario, your database schema on the whole, has two versions or revisions. Version one that resulted when you executed the CREATE table statement and Version one when you executed the Alter table version. You can treat the two statements you used to modify the database as two <em>migrations</em>. Initially your database schema is at Version 0, once the first migration is executed, you have updated your database to version 1. After second statement, the ALTER TABLE one, is executed your database will be at version 2.</p>
<p>To &#8220;rollback&#8221; the schema you need a statement which will drop the added rating column, and another to drop the table completely which will result in database resulting in Version 0. When all these SQL statements are combined we get what we call &#8220;migrations&#8221;. Migrations help you &#8220;migrate&#8221; and &#8220;rollback&#8221; the database. Think of the migrations as a version control mechanism for your database.</p>
<p>Now that we know what migrations mean, let us see how to create the schema and migrations using <a href="http://budu.github.com/lobos/">Lobos</a>.</p>
<h3>Schema Definition using Lobos migrations</h3>
<p>We will define all the schema related operations and migrations in a Clojure namespace called migrations. First create a new directory called <em>lobos</em> under <em>src</em>. If you are using IntelliJ IDEA, then right click the <em>src</em> directory and select New &gt; Package and create a package named lobos. Inside the <em>src/lobos</em> create a file called <em>migrations.clj</em>. Add the following code to the file:</p>

<div class="wp_syntax"><div class="code"><pre class="clojure" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">ns</span> lobos<span style="color: #66cc66;">.</span>migrations
  <span style="color: #808080; font-style: italic;">;; exclude some clojure built-in symbols so we can use the lobos' symbols</span>
  <span style="color: #66cc66;">&#40;</span>:<span style="color: #555;">refer</span><span style="color: #66cc66;">-</span>clojure :<span style="color: #555;">exclude</span> <span style="color: #66cc66;">&#91;</span><span style="color: #b1b100;">alter</span> <span style="color: #b1b100;">drop</span>
                            bigint boolean char double float <span style="color: #b1b100;">time</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>
  <span style="color: #808080; font-style: italic;">;; use only defmigration macro from lobos</span>
  <span style="color: #66cc66;">&#40;</span>:<span style="color: #555;">use</span> <span style="color: #66cc66;">&#40;</span>lobos <span style="color: #66cc66;">&#91;</span>migration :<span style="color: #555;">only</span> <span style="color: #66cc66;">&#91;</span>defmigration<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span>
          core
          schema<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">;;; Defines the database for lobos migrations</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">def</span> clogdb
  <span style="color: #66cc66;">&#123;</span>:<span style="color: #555;">classname</span> <span style="color: #ff0000;">&quot;org.postgresql.Driver&quot;</span>
   :<span style="color: #555;">subprotocol</span> <span style="color: #ff0000;">&quot;postgresql&quot;</span>
   :<span style="color: #555;">subname</span> <span style="color: #ff0000;">&quot;clogdb&quot;</span>
   :<span style="color: #555;">user</span> <span style="color: #ff0000;">&quot;clog&quot;</span>
   :<span style="color: #555;">password</span> <span style="color: #ff0000;">&quot;clog&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>The code snippet above defines a namespace migration with one var <em>clogdb</em> which is a map of database connection information. You may need to change the database password with the one you used while creating the database user.</p>
<p>We create our first migration that will add the users table:</p>

<div class="wp_syntax"><div class="code"><pre class="clojure" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span>defmigration add<span style="color: #66cc66;">-</span>authors<span style="color: #66cc66;">-</span>table
  <span style="color: #808080; font-style: italic;">;; code be executed when migrating the schema &quot;up&quot; using &quot;migrate&quot;</span>
  <span style="color: #66cc66;">&#40;</span>up <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&#40;</span>create clogdb
           <span style="color: #66cc66;">&#40;</span>table :<span style="color: #555;">authors</span> <span style="color: #66cc66;">&#40;</span>integer :<span style="color: #555;">id</span> :<span style="color: #555;">primary</span><span style="color: #66cc66;">-</span>key <span style="color: #66cc66;">&#41;</span>
             <span style="color: #66cc66;">&#40;</span>varchar :<span style="color: #555;">username</span> <span style="color: #cc66cc;">100</span> :<span style="color: #555;">unique</span> <span style="color: #66cc66;">&#41;</span>
             <span style="color: #66cc66;">&#40;</span>varchar :<span style="color: #555;">password</span> <span style="color: #cc66cc;">100</span> :<span style="color: #555;">not</span><span style="color: #66cc66;">-</span>null <span style="color: #66cc66;">&#41;</span>
             <span style="color: #66cc66;">&#40;</span>varchar :<span style="color: #555;">email</span> <span style="color: #cc66cc;">255</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
  <span style="color: #808080; font-style: italic;">;; Code to be executed when migrating schema &quot;down&quot; using &quot;rollback&quot;</span>
  <span style="color: #66cc66;">&#40;</span>down <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">drop</span> <span style="color: #66cc66;">&#40;</span>table :<span style="color: #555;">authors</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>Next we define the migration that will create the posts table as shown below:</p>

<div class="wp_syntax"><div class="code"><pre class="clojure" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span>defmigration add<span style="color: #66cc66;">-</span>posts<span style="color: #66cc66;">-</span>table
  <span style="color: #66cc66;">&#40;</span>up <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&#40;</span>create clogdb
           <span style="color: #66cc66;">&#40;</span>table :<span style="color: #555;">posts</span> <span style="color: #66cc66;">&#40;</span>integer :<span style="color: #555;">id</span> :<span style="color: #555;">primary</span><span style="color: #66cc66;">-</span>key <span style="color: #66cc66;">&#41;</span>
             <span style="color: #66cc66;">&#40;</span>varchar :<span style="color: #555;">title</span> <span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span>
             <span style="color: #66cc66;">&#40;</span>text :<span style="color: #555;">content</span> <span style="color: #66cc66;">&#41;</span>
             <span style="color: #66cc66;">&#40;</span>boolean :<span style="color: #555;">status</span> <span style="color: #66cc66;">&#40;</span>default false<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
             <span style="color: #66cc66;">&#40;</span>timestamp :<span style="color: #555;">created</span> <span style="color: #66cc66;">&#40;</span>default <span style="color: #66cc66;">&#40;</span>now<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
             <span style="color: #66cc66;">&#40;</span>timestamp :<span style="color: #555;">published</span> <span style="color: #66cc66;">&#41;</span>
             <span style="color: #66cc66;">&#40;</span>integer :<span style="color: #555;">author</span> <span style="color: #66cc66;">&#91;</span>:<span style="color: #b1b100;">refer</span> :<span style="color: #555;">authors</span> :<span style="color: #555;">id</span><span style="color: #66cc66;">&#93;</span> :<span style="color: #555;">not</span><span style="color: #66cc66;">-</span>null<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">&#40;</span>down <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">drop</span> <span style="color: #66cc66;">&#40;</span>table :<span style="color: #555;">posts</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>The above code is pretty much similar to the authors table migration &#8211; a title column, text column and a couple of timestamp columns to store the created and published date and times. Also, every post belongs to an author, so we create a foreign key to the authors table using :refer. Here we are referring to the :authors table&#8217;s :id column.</p>
<p>To run the above code, start a REPL console if it isn&#8217;t already running. Type the following commands into the console:</p>

<div class="wp_syntax"><div class="code"><pre class="clojure" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span>use 'lobos<span style="color: #66cc66;">.</span>core 'lobos<span style="color: #66cc66;">.</span>connectivity 'lobos<span style="color: #66cc66;">.</span>migration 'lobos<span style="color: #66cc66;">.</span>migrations<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span>open<span style="color: #66cc66;">-</span>global clogdb<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span>migrate<span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>You should see the following output in the console:</p>
<div class="asideBlock">Don&#8217;t worry about the warnings, they are just alerting you that you are replacing some core symbol references with the lobos&#8217; symbols.</div>

<div class="wp_syntax"><div class="code"><pre class="clojure" style="font-family:monospace;">WARNING: <span style="color: #b1b100;">alter</span> already refers to: #'clojure<span style="color: #66cc66;">.</span>core<span style="color: #66cc66;">/</span><span style="color: #b1b100;">alter</span> in namespace: <span style="color: #555;">user</span>, being replaced by: #'lobos<span style="color: #66cc66;">.</span>core<span style="color: #66cc66;">/</span><span style="color: #b1b100;">alter</span>
WARNING: <span style="color: #b1b100;">drop</span> already refers to: #'clojure<span style="color: #66cc66;">.</span>core<span style="color: #66cc66;">/</span><span style="color: #b1b100;">drop</span> in namespace: <span style="color: #555;">user</span>, being replaced by: #'lobos<span style="color: #66cc66;">.</span>core<span style="color: #66cc66;">/</span><span style="color: #b1b100;">drop</span>
WARNING: <span style="color: #555;">complement</span> already refers to: #'clojure<span style="color: #66cc66;">.</span>core<span style="color: #66cc66;">/</span>complement in namespace: <span style="color: #555;">user</span>, being replaced by: #'lobos<span style="color: #66cc66;">.</span>migration<span style="color: #66cc66;">/</span>complement
nil
<span style="color: #66cc66;">&#123;</span>:<span style="color: #555;">default</span><span style="color: #66cc66;">-</span>connection <span style="color: #66cc66;">&#123;</span>:<span style="color: #555;">connection</span> #, :<span style="color: #555;">db</span><span style="color: #66cc66;">-</span>spec <span style="color: #66cc66;">&#123;</span>:<span style="color: #555;">subprotocol</span> <span style="color: #ff0000;">&quot;postgresql&quot;</span>, :<span style="color: #555;">classname</span> <span style="color: #ff0000;">&quot;org.postgresql.Driver&quot;</span>, :<span style="color: #555;">subname</span> <span style="color: #ff0000;">&quot;clogdb&quot;</span>, :<span style="color: #555;">user</span> <span style="color: #ff0000;">&quot;clog&quot;</span>, :<span style="color: #555;">password</span> <span style="color: #ff0000;">&quot;clog&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#125;</span>
add<span style="color: #66cc66;">-</span>authors<span style="color: #66cc66;">-</span>table
add<span style="color: #66cc66;">-</span>posts<span style="color: #66cc66;">-</span>table
nil</pre></div></div>

<p>To cross check what relations are created in the database, you can use psql and try the following commands:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;">clogdb<span style="color: #66cc66;">=</span># \d
\d         
             List <span style="color: #993333; font-weight: bold;">OF</span> relations              
 Schema <span style="color: #66cc66;">|</span>       Name       <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">TYPE</span>  <span style="color: #66cc66;">|</span> Owner  
<span style="color: #808080; font-style: italic;">--------+------------------+-------+------- </span>
 public <span style="color: #66cc66;">|</span> lobos_migrations <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #66cc66;">|</span> clog   
 public <span style="color: #66cc66;">|</span> posts            <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #66cc66;">|</span> clog   
 public <span style="color: #66cc66;">|</span> authors            <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #66cc66;">|</span> clog   
<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">3</span> <span style="color: #993333; font-weight: bold;">ROWS</span><span style="color: #66cc66;">&#41;</span>                                    
&nbsp;
clogdb<span style="color: #66cc66;">=</span># \d authors                                                                           
\d authors                                                                                    
             <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #ff0000;">&quot;public.authors&quot;</span>                                                           
  <span style="color: #993333; font-weight: bold;">COLUMN</span>  <span style="color: #66cc66;">|</span>          <span style="color: #993333; font-weight: bold;">TYPE</span>          <span style="color: #66cc66;">|</span> Modifiers                                              
<span style="color: #808080; font-style: italic;">----------+------------------------+-----------                                             </span>
 id       <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">INTEGER</span>                <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span>                                               
 username <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">CHARACTER</span> <span style="color: #993333; font-weight: bold;">VARYING</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">|</span>                                                        
 password <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">CHARACTER</span> <span style="color: #993333; font-weight: bold;">VARYING</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">100</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span>                                               
 email    <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">CHARACTER</span> <span style="color: #993333; font-weight: bold;">VARYING</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">255</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">|</span>                                                        
Indexes:                                                                                    
    <span style="color: #ff0000;">&quot;authors_primary_key_id&quot;</span> <span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span><span style="color: #66cc66;">,</span> btree <span style="color: #66cc66;">&#40;</span>id<span style="color: #66cc66;">&#41;</span>                                          
    <span style="color: #ff0000;">&quot;authors_unique_username&quot;</span> <span style="color: #993333; font-weight: bold;">UNIQUE</span><span style="color: #66cc66;">,</span> btree <span style="color: #66cc66;">&#40;</span>username<span style="color: #66cc66;">&#41;</span>                                        
Referenced <span style="color: #993333; font-weight: bold;">BY</span>:                                                                              
    <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #ff0000;">&quot;posts&quot;</span> <span style="color: #993333; font-weight: bold;">CONSTRAINT</span> <span style="color: #ff0000;">&quot;posts_fkey_user&quot;</span> <span style="color: #993333; font-weight: bold;">FOREIGN</span> <span style="color: #993333; font-weight: bold;">KEY</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;author&quot;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">REFERENCES</span> authors<span style="color: #66cc66;">&#40;</span>id<span style="color: #66cc66;">&#41;</span>    
&nbsp;
clogdb<span style="color: #66cc66;">=</span># \d posts                                                                           
\d posts                                                                                    
                  <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #ff0000;">&quot;public.posts&quot;</span>                                                      
  <span style="color: #993333; font-weight: bold;">COLUMN</span>   <span style="color: #66cc66;">|</span>            <span style="color: #993333; font-weight: bold;">TYPE</span>             <span style="color: #66cc66;">|</span>   Modifiers                                      
<span style="color: #808080; font-style: italic;">-----------+-----------------------------+---------------                                   </span>
 id        <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">INTEGER</span>                     <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span>                                         
 title     <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">CHARACTER</span> <span style="color: #993333; font-weight: bold;">VARYING</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">250</span><span style="color: #66cc66;">&#41;</span>      <span style="color: #66cc66;">|</span>                                                  
 content   <span style="color: #66cc66;">|</span> text                        <span style="color: #66cc66;">|</span>                                                  
 <span style="color: #993333; font-weight: bold;">STATUS</span>    <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">BOOLEAN</span>                     <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #993333; font-weight: bold;">FALSE</span>                                    
 created   <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">TIMESTAMP</span> <span style="color: #993333; font-weight: bold;">WITHOUT</span> <span style="color: #993333; font-weight: bold;">TIME</span> zone <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> now<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>                                    
 published <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">TIMESTAMP</span> <span style="color: #993333; font-weight: bold;">WITHOUT</span> <span style="color: #993333; font-weight: bold;">TIME</span> zone <span style="color: #66cc66;">|</span>                                                  
 author    <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">INTEGER</span>                     <span style="color: #66cc66;">|</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span>                                         
Indexes:                                                                                    
    <span style="color: #ff0000;">&quot;posts_primary_key_id&quot;</span> <span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span><span style="color: #66cc66;">,</span> btree <span style="color: #66cc66;">&#40;</span>id<span style="color: #66cc66;">&#41;</span>                                          
Foreign<span style="color: #66cc66;">-</span><span style="color: #993333; font-weight: bold;">KEY</span> constraints:                                                                    
    <span style="color: #ff0000;">&quot;posts_fkey_author&quot;</span> <span style="color: #993333; font-weight: bold;">FOREIGN</span> <span style="color: #993333; font-weight: bold;">KEY</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;author&quot;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">REFERENCES</span> authors<span style="color: #66cc66;">&#40;</span>id<span style="color: #66cc66;">&#41;</span></pre></div></div>

<div class="asideBlock">Every time you type <em>(rollback)</em> Lobos will try to rollback the schema down one migration using the <em>down</em> function. running <em>(migrate)</em> again will bring the schema back to latest version.</div>
<p>Lobos keeps track of which migrations are run using the lobos_migrations table. As you can see below our current lobos_migrations contains two migrations we have written and executed.</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;">clogdb<span style="color: #66cc66;">=</span># <span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold;">FROM</span> lobos_migrations;  
<span style="color: #993333; font-weight: bold;">SELECT</span> <span style="color: #66cc66;">*</span> <span style="color: #993333; font-weight: bold;">FROM</span> lobos_migrations;           
      name                                
<span style="color: #808080; font-style: italic;">-----------------                         </span>
 add<span style="color: #66cc66;">-</span>authors<span style="color: #66cc66;">-</span><span style="color: #993333; font-weight: bold;">TABLE</span>                          
 add<span style="color: #66cc66;">-</span>posts<span style="color: #66cc66;">-</span><span style="color: #993333; font-weight: bold;">TABLE</span>                          
<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">2</span> <span style="color: #993333; font-weight: bold;">ROWS</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<h3>Entity Definition</h3>
<p>After creating the database, now we&#8217;ll define our entities using the SQL library <a href="http://sqlkorma.com">Korma</a>. What is Korma ?</p>
<blockquote><p>Korma is a domain specific language for Clojure that takes the pain out of working with your favorite RDBMS. Built for speed and designed for flexibility, Korma provides a simple and intuitive interface to your data that won&#8217;t leave a bad taste in your mouth.</p></blockquote>
<p>Korma makes it easier to deal with the database. Instead of using SQL queries, you can use Clojure to access the database. To get the data from the tables, first we need to define entities using the Korma&#8217;s <em>defnentity</em> macro. First create a file called models.clj in your src/clog folder. And add the following code to the file:</p>

<div class="wp_syntax"><div class="code"><pre class="clojure" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">ns</span> clog<span style="color: #66cc66;">.</span>models
  <span style="color: #66cc66;">&#40;</span>:<span style="color: #555;">use</span> korma<span style="color: #66cc66;">.</span>db
        korma<span style="color: #66cc66;">.</span>core<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #66cc66;">&#40;</span>defdb clogdb
  <span style="color: #66cc66;">&#123;</span>:<span style="color: #555;">classname</span> <span style="color: #ff0000;">&quot;org.postgresql.Driver&quot;</span>
   :<span style="color: #555;">subprotocol</span> <span style="color: #ff0000;">&quot;postgresql&quot;</span>
   :<span style="color: #555;">subname</span> <span style="color: #ff0000;">&quot;clogdb&quot;</span>
   :<span style="color: #555;">user</span> <span style="color: #ff0000;">&quot;clog&quot;</span>
   :<span style="color: #555;">password</span> <span style="color: #ff0000;">&quot;clog&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #66cc66;">&#40;</span>defentity users<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span>defentity posts<span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>The above code defines two entities <em>authors</em> and <em>posts</em>. Let me show you how we can insert an author record into the database and select the list of authors from the database. Start Clojure REPL, if it isn&#8217;t running already. Type the following code into REPL:</p>

<div class="wp_syntax"><div class="code"><pre class="clojure" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span>use 'korma<span style="color: #66cc66;">.</span>db 'korma<span style="color: #66cc66;">.</span>core 'clog<span style="color: #66cc66;">.</span>models<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span>insert  authors <span style="color: #66cc66;">&#40;</span>values <span style="color: #66cc66;">&#123;</span>:<span style="color: #555;">id</span> <span style="color: #cc66cc;">1</span>, :<span style="color: #555;">username</span> <span style="color: #ff0000;">&quot;vijay&quot;</span>, :<span style="color: #555;">password</span> <span style="color: #ff0000;">&quot;password&quot;</span>, :<span style="color: #555;">email</span> <span style="color: #ff0000;">&quot;mail AT vijaykiran.com&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>This will insert a new record into the database. You can use the <em>select</em> function to get the list of authors from the authors table.</p>

<div class="wp_syntax"><div class="code"><pre class="clojure" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span>select authors<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#123;</span>:<span style="color: #555;">id</span> <span style="color: #cc66cc;">1</span>, :<span style="color: #555;">username</span> <span style="color: #ff0000;">&quot;vijay&quot;</span>, :<span style="color: #555;">password</span> <span style="color: #ff0000;">&quot;password&quot;</span>, :<span style="color: #555;">email</span> <span style="color: #ff0000;">&quot;mail AT vijaykiran.com&quot;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#93;</span></pre></div></div>

<h3>Source Code</h3>
<p>If you are stuck at any point and want to directly checkout the code, you can use the following commands to get the code that is tagged with part2</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">git clone git://github.com/vijaykiran/clog.git
cd clog
git checkout part2</pre></div></div>

<h2>Conclusion</h2>
<p>This concludes the part 2 of this series. In this part of the tutorial we saw how to create a simple schema using Lobos library, also we defined the entities for the tables we created using the Korma library. In the next part I&#8217;ll show you how to populate sample data into the database and we&#8217;ll create our first template to display the data in the browser.</p>
<p>Make sure you <a href="vijaykiran.com/feed/">subscribe</a> to the RSS feed or follow me on <a href="http://twitter.com/vijaykiran">Twitter</a> to get notified.</p>
<p>If you have any feedback on this article and its content, you can contact me via <a href="http://twitter.com/vijaykiran">Twitter</a>.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/XN_Odogw8Rs50Ywtm2k95aAFvRw/0/da"><img src="http://feedads.g.doubleclick.net/~a/XN_Odogw8Rs50Ywtm2k95aAFvRw/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/XN_Odogw8Rs50Ywtm2k95aAFvRw/1/da"><img src="http://feedads.g.doubleclick.net/~a/XN_Odogw8Rs50Ywtm2k95aAFvRw/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Vijaykirancom?a=PSYWiOnEVgU:SLFjO23fQfs:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Vijaykirancom?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Vijaykirancom?a=PSYWiOnEVgU:SLFjO23fQfs:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/Vijaykirancom?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Vijaykirancom?a=PSYWiOnEVgU:SLFjO23fQfs:6W8y8wAjSf4"><img src="http://feeds.feedburner.com/~ff/Vijaykirancom?d=6W8y8wAjSf4" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Vijaykirancom/~4/PSYWiOnEVgU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.vijaykiran.com/2012/01/17/web-application-development-with-clojure-part-2/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://www.vijaykiran.com/2012/01/17/web-application-development-with-clojure-part-2/</feedburner:origLink></item>
		<item>
		<title>→ The Rise of the New Groupthink</title>
		<link>http://feedproxy.google.com/~r/Vijaykirancom/~3/gmG42_vPcNE/</link>
		<comments>http://www.vijaykiran.com/2012/01/15/the-rise-of-the-new-groupthink/#comments</comments>
		<pubDate>Sun, 15 Jan 2012 08:44:19 +0000</pubDate>
		<dc:creator>Vijay Kiran</dc:creator>
				<category><![CDATA[Links]]></category>
		<category><![CDATA[groupthink]]></category>
		<category><![CDATA[productivity]]></category>
		<category><![CDATA[workplace design]]></category>

		<guid isPermaLink="false">http://www.vijaykiran.com/?p=3649</guid>
		<description><![CDATA[To harness the energy that fuels both these drives, we need to move beyond the New Groupthink and embrace a more nuanced approach to creativity and learning. Our offices should encourage casual, cafe-style interactions, but allow people to disappear into personalized, private spaces when they want to be alone. Our schools should teach children to [...]]]></description>
			<content:encoded><![CDATA[<p>To harness the energy that fuels both these drives, we need to move beyond the New Groupthink and embrace a more nuanced approach to creativity and learning. Our offices should encourage casual, cafe-style interactions, but allow people to disappear into personalized, private spaces when they want to be alone. Our schools should teach children to work with others, but also to work on their own for sustained periods of time. And we must recognize that introverts like Steve Wozniak need extra quiet and privacy to do their best work.</p>
<p>via <a href='http://www.nytimes.com/2012/01/15/opinion/sunday/the-rise-of-the-new-groupthink.html?_r=1&#038;pagewanted=all'>The Rise of the New Groupthink &#8211; NYTimes.com</a>.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/w6ZdMhWJBi3N9Z52UHDVirmciNY/0/da"><img src="http://feedads.g.doubleclick.net/~a/w6ZdMhWJBi3N9Z52UHDVirmciNY/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/w6ZdMhWJBi3N9Z52UHDVirmciNY/1/da"><img src="http://feedads.g.doubleclick.net/~a/w6ZdMhWJBi3N9Z52UHDVirmciNY/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Vijaykirancom?a=gmG42_vPcNE:drPFYxlNDDs:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Vijaykirancom?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Vijaykirancom?a=gmG42_vPcNE:drPFYxlNDDs:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/Vijaykirancom?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Vijaykirancom?a=gmG42_vPcNE:drPFYxlNDDs:6W8y8wAjSf4"><img src="http://feeds.feedburner.com/~ff/Vijaykirancom?d=6W8y8wAjSf4" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Vijaykirancom/~4/gmG42_vPcNE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.vijaykiran.com/2012/01/15/the-rise-of-the-new-groupthink/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.vijaykiran.com/2012/01/15/the-rise-of-the-new-groupthink/</feedburner:origLink></item>
		<item>
		<title>Photo: Veggies</title>
		<link>http://feedproxy.google.com/~r/Vijaykirancom/~3/5ea5ojER61I/</link>
		<comments>http://www.vijaykiran.com/2012/01/12/photo-veggies/#comments</comments>
		<pubDate>Thu, 12 Jan 2012 08:05:08 +0000</pubDate>
		<dc:creator>Vijay Kiran</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.vijaykiran.com/?p=3642</guid>
		<description />
			<content:encoded><![CDATA[<p><a href="http://www.vijaykiran.com/wp-content/uploads/2012/01/20120112-090225.jpg"><img src="http://www.vijaykiran.com/wp-content/uploads/2012/01/20120112-090225.jpg" alt="20120112-090225.jpg" class="alignnone size-full" /></a></p>

<p><a href="http://feedads.g.doubleclick.net/~a/ffyIVH_pXcI6QLFY1BXbA1-An1Q/0/da"><img src="http://feedads.g.doubleclick.net/~a/ffyIVH_pXcI6QLFY1BXbA1-An1Q/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/ffyIVH_pXcI6QLFY1BXbA1-An1Q/1/da"><img src="http://feedads.g.doubleclick.net/~a/ffyIVH_pXcI6QLFY1BXbA1-An1Q/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Vijaykirancom?a=5ea5ojER61I:nbtd0uvb6Qk:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Vijaykirancom?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Vijaykirancom?a=5ea5ojER61I:nbtd0uvb6Qk:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/Vijaykirancom?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Vijaykirancom?a=5ea5ojER61I:nbtd0uvb6Qk:6W8y8wAjSf4"><img src="http://feeds.feedburner.com/~ff/Vijaykirancom?d=6W8y8wAjSf4" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Vijaykirancom/~4/5ea5ojER61I" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.vijaykiran.com/2012/01/12/photo-veggies/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.vijaykiran.com/2012/01/12/photo-veggies/</feedburner:origLink></item>
		<item>
		<title>Web Application Development with Clojure – Part 1</title>
		<link>http://feedproxy.google.com/~r/Vijaykirancom/~3/_NDiFoSMULY/</link>
		<comments>http://www.vijaykiran.com/2012/01/11/web-application-development-with-clojure-part-1/#comments</comments>
		<pubDate>Wed, 11 Jan 2012 16:48:28 +0000</pubDate>
		<dc:creator>Vijay Kiran</dc:creator>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[clojure]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[intellij]]></category>
		<category><![CDATA[lobos]]></category>
		<category><![CDATA[webapp]]></category>

		<guid isPermaLink="false">http://www.vijaykiran.com/?p=3548</guid>
		<description><![CDATA[<a href="http://clojure.org">Clojure</a> is general-purpose compiled, dynamic, Lisp-dialect language that targets JVM (also .Net CLR and JavaScript). There are many ways you can build a Web application using Clojure. You can use a simple framework like <a href="http://webnoir.org">Noir</a> or you can pick and choose libraries you like and build your own web stack along the way. I assume that you already started learning Clojure using some tutorial or a good Clojure book.

In this blog post series I'll explain how to build a web application using Clojure. Creating a blogging engine seems to be the equivalent "hello world" for Web application development, so let us build a blog engine in Clojure: Clog.
]]></description>
			<content:encoded><![CDATA[<p>This post is part of the Web Application Development with <a href="http://clojure.org">Clojure</a> tutorial.</p>
<ul>
<li><a href="http://www.vijaykiran.com/2012/01/11/web-application-development-with-clojure-part-1/">Part 1: Project Setup</a></li>
<li><a href="http://www.vijaykiran.com/2012/01/17/web-application-development-with-clojure-part-2/">Part 2: Data model definition with Lobos and Korma</a></li>
<li><a href="http://www.vijaykiran.com/2012/01/18/web-application-development-with-clojure-part-3/">Part 3: Loading Fixures with <a href="https://github.com/lancepantz/clj-yaml">clj-yaml</a> and HTML Templating with <a href="https://github.com/cgrand/enlive">Enlive</a></li>
</ul>
<h2>Introduction</h2>
<p><a href="http://clojure.org">Clojure</a> is general-purpose compiled, dynamic, Lisp-dialect language that targets JVM (also .Net CLR and JavaScript). There are many ways you can build a Web application using Clojure. You can use a simple framework like <a href="http://webnoir.org">Noir</a> or you can pick and choose libraries you like and build your own web stack along the way. I assume that you already started learning Clojure using some tutorial or a good Clojure book.</p>
<p>In this blog post series I&#8217;ll explain how to build a web application using Clojure. Creating a blogging engine seems to be the equivalent &#8220;hello world&#8221; for Web application development, so let us build a blog engine in Clojure: Clog.</p>
<h2>Clojure Web Application Toolkit</h2>
<p>There are many fantastic libraries available for Clojure for any type of task you can imagine and superior Java Interoperability of <a href="http://clojure.org">Clojure</a> gives you seamless access to innumerable Java libraries and API that you can benefit from. To build a database backed web application you might need some standard libraries to perform HTTP Routing, Database connectivity and migrations, HTML Templates etc.</p>
<p>We&#8217;ll use the following libraries to build our web application:</p>
<ul>
<li><em><a href="http://clojure.org">Clojure</a></em> &#8211; <em>1.3.0</em> &#8211; The language.</li>
<li><em><a href="https://github.com/mmcgrana/ring">ring</a></em> &#8211; &nbsp;<em>1.0.1</em> &#8211; The HTTP Abstraction API and Middleware.</li>
<li><em><a href="https://github.com/cgrand/moustache">moustache</a></em> &nbsp;- <em>1.1.0</em> &#8211; HTTP Routes DSL</li>
<li><em><a href="http://budu.github.com/lobos/">lobos</a></em> &#8211; &nbsp;<em>1.0.0-SNAPSHOT</em> &#8211; Database Schema Manipulation and Migrations</li>
<li><em><a href="http://sqlkorma.com/">korma</a></em> &#8211; <em>0.2.1</em> &#8211; DSL for Database Connectivity and Interaction.</li>
<li><em><a href="https://github.com/cgrand/enlive">enlive</a></em> &#8211; <em>1.0.0</em> &#8211; Selector based HTML library.</li>
<li><em>postgresql</em> -&nbsp;<em>9.1-901.jdbc4</em> &#8211; PostgreSQL JDBC4 driver.</li>
<li><em><a href="https://github.com/lancepantz/clj-yaml">clj-yaml</a></em> &#8211; <em>0.3.1</em> &#8211; A snakeyaml wrapper for YAML file parsing and generation.</li>
</ul>
<div class="asideBlock">Apache Maven is more than just a &#8220;dependency management&#8221; tool. It is a &#8220;software project management and comprehension tool&#8221;. Don&#8217;t worry too much if you don&#8217;t <em>comprehend</em> what it means.</div>
<p>The above list is just for your information. You don&#8217;t need to individually download those libraries. For those of you who are familiar with Java dependency management tools like <a href="http://maven.apache.org/">Apache Maven</a> or <a href="http://ant.apache.org/ivy/">Apache Ivy</a>, Clojure ecosystem has similar build tool called&nbsp;<a href="https://github.com/technomancy/leiningen/">Leineingen</a>&nbsp;which helps you configure your project, manage dependencies etc.</p>
<blockquote><p>Leiningen is for automating Clojure projects without setting your hair on fire.Working on Clojure projects with tools designed for Java can be an exercise in frustration. With Leiningen, you just write Clojure.</p></blockquote>
<p>Using Leiningen you can configure your project settings using Clojure. Leiningen uses Apache Maven for dependency resolution. So you can add any library from a maven repository as a dependency to your Clojure project. Installing Leiningen is very straight forward, which is left as an exercise to the reader.</p>
<h2>Project Setup</h2>
<p>After you have installed leiningen you can create a project by typing the following command in your terminal (or command) window.</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">lein new clog</pre></div></div>

<p>If leiningen is installed properly you should see an output of the command similar to the following</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">→ ~$ lein new clog
Created new project in: /Users/vijaykiran/clog
Look over project.clj and start coding in clog/core.clj</pre></div></div>

<p>When you run the above command, leiningen will create a simple Clojure project named &#8220;clog&#8221; for you. If you look into the clog folder, you see there are several files and folders created. Again, if you are familiar with Apache Maven, you can see the structure is pretty similar to standard Maven project. Anyway, let us take a quick look at the generated files and folders:</p>
<ul>
<li><em>README</em> &#8211; A simple README file</li>
<li><em>project.clj</em> &#8211; The Clojure project configuration file &#8211; written in Clojure.</li>
<li><em>src</em> &#8211; Folder for your source code</li>
<li><em>test</em> &#8211; Folder for your tests</li>
<li><em>src/clog/core.clj</em> &#8211; The &#8220;core&#8221; Clojure file for your project (You can change it to whatever you want, but for simplicity, we&#8217;ll leave it as it is).</li>
</ul>
<p>Create a directory called <em>resources</em> inside the clog directory. This directory will be used to store and serve the static resources like images, CSS files etc. of our web application.</p>
<p>There are many configuration options available to set up your project via the <em>project.clj</em> file. But for now we&#8217;ll just focus on simple things like adding dependencies.</p>
<h3>Adding Dependencies</h3>
<p>If you open the <strong><em>project.clj</em></strong> file under your clog folder, you can already see that there are a couple of dependencies configured using <em>defproject</em> macro.</p>

<div class="wp_syntax"><div class="code"><pre class="clojure" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span>defproject clog <span style="color: #ff0000;">&quot;1.0.0-SNAPSHOT&quot;</span>
  :<span style="color: #555;">description</span> <span style="color: #ff0000;">&quot;FIXME: write description&quot;</span>
  :<span style="color: #555;">dependencies</span> <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#91;</span>org<span style="color: #66cc66;">.</span>clojure<span style="color: #66cc66;">/</span>clojure <span style="color: #ff0000;">&quot;1.3.0&quot;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>Let us update the file to add the required libraries (as shown above). Use your favorite editor to edit the <em>project.clj</em>, we&#8217;ll later setup an IDE for editing our source code. While we are there, we&#8217;ll also fix the version and description of the project and set them to <em>0.0.1-SNAPSHOT</em> and <em>A Clojure Blogging Engine</em>.</p>
<div class="asideBlock">This would be good time to create a version control repository and add your source code to it. If you are using git, you can see that <em>lein new</em> has already created a .gitignore file for you. So all you need to do is <em>git init</em>, <em>git add .</em> and <em>git commit -m &#8220;Clog project &#8211; init&#8221;</em> to create and initialize the git repository for your project.</div>

<div class="wp_syntax"><div class="code"><pre class="clojure" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span>defproject clog <span style="color: #ff0000;">&quot;0.0.1-SNAPSHOT&quot;</span>
  :<span style="color: #555;">description</span> <span style="color: #ff0000;">&quot;Clog: A Blog engine written in Clojure&quot;</span>
  :<span style="color: #555;">dependencies</span> <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#91;</span>org<span style="color: #66cc66;">.</span>clojure<span style="color: #66cc66;">/</span>clojure <span style="color: #ff0000;">&quot;1.3.0&quot;</span><span style="color: #66cc66;">&#93;</span>
                 <span style="color: #66cc66;">&#91;</span>ring <span style="color: #ff0000;">&quot;1.0.1&quot;</span> <span style="color: #808080; font-style: italic;">;;; Exclude the clojure, clj-stacktrace from ring dependency</span>
                   :<span style="color: #555;">exclusions</span> <span style="color: #66cc66;">&#91;</span>org<span style="color: #66cc66;">.</span>clojure<span style="color: #66cc66;">/</span>clojure
                               clj<span style="color: #66cc66;">-</span>stacktrace<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span>
                 <span style="color: #66cc66;">&#91;</span>net<span style="color: #66cc66;">.</span>cgrand<span style="color: #66cc66;">/</span>moustache <span style="color: #ff0000;">&quot;1.1.0&quot;</span><span style="color: #66cc66;">&#93;</span>
                 <span style="color: #66cc66;">&#91;</span>lobos <span style="color: #ff0000;">&quot;1.0.0-SNAPSHOT&quot;</span><span style="color: #66cc66;">&#93;</span>
                 <span style="color: #66cc66;">&#91;</span>korma <span style="color: #ff0000;">&quot;0.2.1&quot;</span><span style="color: #66cc66;">&#93;</span>
                 <span style="color: #66cc66;">&#91;</span>enlive <span style="color: #ff0000;">&quot;1.0.0&quot;</span><span style="color: #66cc66;">&#93;</span>
                 <span style="color: #66cc66;">&#91;</span>postgresql <span style="color: #ff0000;">&quot;9.1-901.jdbc4&quot;</span><span style="color: #66cc66;">&#93;</span>
                 <span style="color: #66cc66;">&#91;</span>clj<span style="color: #66cc66;">-</span>yaml <span style="color: #ff0000;">&quot;0.3.1&quot;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>After you edit the <em>project.clj</em>, run the <em>lein deps</em> command to download the required dependencies. You should see output similar to this:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">~/clog $ lein deps
...
Copying 32 files to /Users/vijaykiran/clog/lib</pre></div></div>

<p>That is all you need to do to configure and setup your project. Of course, we still need to set up the database, which we will come back to at a later stage. Next step is configure a development environment a.k.a an IDE.</p>
<h2>IDE Configuration</h2>
<p>All major IDEs (Eclipse with Couter-ClockWise plugin, IntelliJ IDEA with La Clojure plugin and Netbeans with Enclojure plugin) have Clojure support via Plugins. Many Clojure developers seem to prefer Emacs instead of using IDEs.</p>
<h3>Emacs with SLIME</h3>
<p>Emacs seems to be the favorite editor of most people in Clojure community. Emacs has several &#8220;plugins&#8221; that help with editing Clojure files. Learning &amp; using Emacs can be intimidating at first but personally I find it very rewarding experience. If you are an Emacs user you can use clojure-mode, slime, swank and paredit as your development environment. There are <a href="http://stackoverflow.com/questions/2285437/a-gentle-tutorial-to-emacs-swank-paredit-for-clojure">several</a> <a href="http://data-sorcery.org/2009/12/20/getting-started/">tutorials</a> available on how to configure Emacs for clojure development. I encourage you to check them out if you want to use Emacs as your &#8220;IDE&#8221;. I use Emacs with lein swank, clojure-mode and slime-connect. I configured emacs with emacs starter kit and other plugins, FWIW, this is how it looks:</p>
<div class="asideBlock">You can see project.clj in editor mode, Clojure REPL using slime-connection and lein swank running in Emacs&#8217;s eshell on this image. Since my Emacs configuration is based on <a href="https://github.com/overtone/live-coding-emacs">Live-Coding Emacs</a> setup, I get a nice color scheme and auto-completion.</div>
<p><a class="enlarge" href="http://www.vijaykiran.com/wp-content/uploads/2012/01/emacs-slime.png"><img class="aligncenter size-large wp-image-3601" title="emacs-slime" src="http://www.vijaykiran.com/wp-content/uploads/2012/01/emacs-slime-620x405.png" alt="" width="620" height="405" /></a></p>
<h3>IntelliJ IDEA</h3>
<p>For this tutorial I will use <a href="http://www.jetbrains.com/idea/">IntelliJ Community Edition</a> with <a href="http://plugins.intellij.net/plugin/?id=4050">La Clojure</a> and <a href="http://plugins.intellij.net/plugin/?id=5029">Leiningen</a> Plugins. After downloading the IDE make sure you install and enable the plugins.</p>
<p><a class="enlarge" href="http://www.vijaykiran.com/wp-content/uploads/2012/01/IntelliJ-Plugins.png"><img class="aligncenter size-large wp-image-3591" title="IntelliJ-Plugins" src="http://www.vijaykiran.com/wp-content/uploads/2012/01/IntelliJ-Plugins-620x521.png" alt="" width="620" height="521" /></a></p>
<p>After you have installed both plugins, select <em>Open Project ..</em> option in IntelliJ and choose the <em>project.clj</em> from <em>clog</em> folder. Leiningen plugin will detect the project.clj and open the clog project as an IntelliJ project as shown below.</p>
<p><a class="enlarge" href="http://www.vijaykiran.com/wp-content/uploads/2012/01/idea-clog-project.png"><img class="aligncenter size-large wp-image-3606" title="idea-clog-project" src="http://www.vijaykiran.com/wp-content/uploads/2012/01/idea-clog-project-620x455.png" alt="" width="620" height="455" /></a></p>
<p>Make sure that you add Clojure facet to the module, which will allow you start the Clojure console for the project. Also, add the clojure 1.3 library for project if you have another version of clojure installed globally. This will make sure that when you start the Clojure console, it will use the correct Clojure version.</p>
<h2>Startup code for Jetty Server</h2>
<p>First step in developing a web application is to startup the jetty server. We will use the ring-jetty adapter to start-up the Jetty server. Edit the <em>core.clj</em> file and add the following code to it:</p>
<div class="asideBlock">When you import other namespaces using <em>:use</em> you are actually importing all the symbols into current namespace. This might create conflicts with the symbols you define in your namespace, so it is advised that you use <em>:require</em> instead. To keep things very simple, we use <em>:use</em> here.</div>

<div class="wp_syntax"><div class="code"><pre class="clojure" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">ns</span> clog<span style="color: #66cc66;">.</span>core
  <span style="color: #66cc66;">&#40;</span>:<span style="color: #555;">use</span> ring<span style="color: #66cc66;">.</span>adapter<span style="color: #66cc66;">.</span>jetty
        ring<span style="color: #66cc66;">.</span>middleware<span style="color: #66cc66;">.</span>resource
        ring<span style="color: #66cc66;">.</span>util<span style="color: #66cc66;">.</span>response
        net<span style="color: #66cc66;">.</span>cgrand<span style="color: #66cc66;">.</span>moustache<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">;;; A simple handler to show send some response to the client.</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">defn</span> index
  <span style="color: #66cc66;">&#91;</span>req<span style="color: #66cc66;">&#93;</span>
  <span style="color: #66cc66;">&#40;</span>response <span style="color: #ff0000;">&quot;Welcome, to Clog - A Blog Engine written in Clojure&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">;; Routes definition</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">def</span> routes
  <span style="color: #66cc66;">&#40;</span>app
    <span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;&quot;</span><span style="color: #66cc66;">&#93;</span> index<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">;;; start function for starting jetty</span>
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">defn</span> start <span style="color: #66cc66;">&#91;</span>port<span style="color: #66cc66;">&#93;</span>
  <span style="color: #66cc66;">&#40;</span>run<span style="color: #66cc66;">-</span>jetty #'routes <span style="color: #66cc66;">&#123;</span>:<span style="color: #555;">port</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">or</span> port <span style="color: #cc66cc;">8080</span><span style="color: #66cc66;">&#41;</span> :<span style="color: #555;">join</span>? false<span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>Let us take a closer look on the code we added to the core.clj. First we defined the namespace <em>clog.core</em> and imported the namespaces via <em>:use</em>. Then we defined a simple function called <em>index</em> that uses the ring <em>response</em> method to send some text as response.</p>
<p>We used the moustache macro <em>app</em> to define the routes that we want to handle. In our case, we want the route that matches the url segment with parts [""] to the function <em>index</em>, which is another way saying when a client sends a request with no url segments or parameters, let the function <em>index</em> handle it.</p>
<p>Next we defined a function <em>start</em> that will help us to start a jetty server. It takes a port parameter, if it isn&#8217;t supplied, the run-jetty function from ring-jetty adapter will start the jetty server on port 8080.</p>
<div class="asideBlock">REPL is an acronym for <strong>R</strong>ead <strong>E</strong>val <strong>P</strong>rint <strong>L</strong>oop, which does what the name implies &#8211; it <em>reads</em> the code, <em>evaluates</em> it, <em>prints</em> the result and <em>loops</em> back to read step. The main difference between Clojure REPL and other languages&#8217; is during the Eval step, the code is compiled.</div>
<h3>Running the program in lein REPL</h3>
<p>You can run this program using REPL in command line. Open a terminal window, and change to the clog directory. Then type <em>lein repl</em>, which will start a new Clojure REPL with the class path setup to include our project&#8217;s libraries. In the REPL, first import the <em>clog.core</em> namespace by typing <em>use &#8216;clog.core</em>. Now you can use the <em>start</em> function to start jetty on your port of choice. Here&#8217;s the transcript of the commands and their results:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">→ ~$ cd clog
→ clog[master]/$ lein repl
REPL started; server listening on localhost port 53791
user=&amp;gt; (use 'clog.core)
nil
user=&amp;gt; (start 8888)
2012-01-11 16:10:41.640:INFO::Logging to STDERR via org.mortbay.log.StdErrLog
#
2012-01-11 16:10:41.642:INFO::jetty-6.1.25
2012-01-11 16:10:41.654:INFO::Started SocketConnector@0.0.0.0:8888
user=&amp;gt;</pre></div></div>

<p>Open a browser window and open the URL <em>http://localhost:8888</em>. You should see the message <em>Welcome, to Clog &#8211; A Blog Engine written in Clojure</em>.</p>
<h3>Running the program in IntelliJ IDE</h3>
<p>To run this program in IntelliJ, start the Clojure console by clicking on the Tools -&gt; Start Clojure Console. This will start a console in your IDE with the your module&#8217;s class path. Now type <em>(use &#8216;clog.core)</em> and <em>(start 8888)</em> in your clojure console. You should see the output as shown below:</p>
<p><a class="enlarge" href="http://www.vijaykiran.com/wp-content/uploads/2012/01/running-clog-in-ide-repl.png"><img class="alignleft size-large wp-image-3623" title="running-clog-in-ide-repl" src="http://www.vijaykiran.com/wp-content/uploads/2012/01/running-clog-in-ide-repl-620x278.png" alt="" width="620" height="278" /></a></p>
<p>You can now browse to the URL: http://localhost:8888 to see the response.</p>
<h2>Conclusion</h2>
<p>This concludes the part 1 of this series. In part 2 I&#8217;ll show you how to create the database schema and migrations using Clojure and <a href="http://budu.github.com/lobos/">lobos</a>. Make sure you <a href="http://vijaykiran.com/feed/">subscribe</a> to the RSS feed or follow me on <a href="http://twitter.com/vijaykiran">Twitter</a> to get notified.</p>
<p>If you have any feedback on this article and its content, you can contact me via <a href="http://twitter.com/vijaykiran">Twitter</a>.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/-ArXUpUfIeN_2fuLFqfW7oN64FY/0/da"><img src="http://feedads.g.doubleclick.net/~a/-ArXUpUfIeN_2fuLFqfW7oN64FY/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/-ArXUpUfIeN_2fuLFqfW7oN64FY/1/da"><img src="http://feedads.g.doubleclick.net/~a/-ArXUpUfIeN_2fuLFqfW7oN64FY/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Vijaykirancom?a=_NDiFoSMULY:PYQ-pgggUtg:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Vijaykirancom?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Vijaykirancom?a=_NDiFoSMULY:PYQ-pgggUtg:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/Vijaykirancom?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Vijaykirancom?a=_NDiFoSMULY:PYQ-pgggUtg:6W8y8wAjSf4"><img src="http://feeds.feedburner.com/~ff/Vijaykirancom?d=6W8y8wAjSf4" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Vijaykirancom/~4/_NDiFoSMULY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.vijaykiran.com/2012/01/11/web-application-development-with-clojure-part-1/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.vijaykiran.com/2012/01/11/web-application-development-with-clojure-part-1/</feedburner:origLink></item>
		<item>
		<title>The Making of “Chana Methi Matki Biryani”</title>
		<link>http://feedproxy.google.com/~r/Vijaykirancom/~3/Zr6Wyt5BTj0/</link>
		<comments>http://www.vijaykiran.com/2012/01/08/matka-chana-methi-matkibiryani/#comments</comments>
		<pubDate>Sun, 08 Jan 2012 19:42:42 +0000</pubDate>
		<dc:creator>Vijay Kiran</dc:creator>
				<category><![CDATA[Cooking]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[biryani]]></category>
		<category><![CDATA[food]]></category>

		<guid isPermaLink="false">http://www.vijaykiran.com/?p=3508</guid>
		<description><![CDATA[Sunday Dinner today is Chana Methi Matki Biryani. First an emergency Glossary so that the title makes some sense. Chana : Chickpeas Methi :Fenugreek Leaves Matki : Earthen Pot Basmati Rice: Basmati Rice The main ingredients Tomatoes &#8211; Deseeded, diced Red onion Methi Leaves Mint leaves Chana &#8211; soaked overnight and boiled Saffron &#8211; soaked [...]]]></description>
			<content:encoded><![CDATA[<p>Sunday Dinner today is <strong>Chana Methi Matki Biryani</strong>. First an emergency Glossary so that the title makes some sense.</p>
<ul>
<li>Chana : <a href="http://en.wikipedia.org/wiki/Chickpea">Chickpeas</a></li>
<li>Methi :<a href="http://en.wikipedia.org/wiki/Methi">Fenugreek Leaves</a></li>
<li>Matki : <a href="http://en.wikipedia.org/wiki/Matki_(earthen_pot)"> Earthen Pot</a></li>
<li>Basmati Rice: <a href="http://en.wikipedia.org/wiki/Basmati_rice">Basmati Rice</a></li>
</ul>
<p><a href="http://www.vijaykiran.com/wp-content/uploads/2012/01/biryani-ingredients.jpg"><img class="aligncenter  wp-image-3511" title="biryani-ingredients" src="http://www.vijaykiran.com/wp-content/uploads/2012/01/biryani-ingredients-620x463.jpg" alt="Biryani Ingredients" width="558" height="417" /></a><br />
<!-- more --><br />
<strong>The main ingredients</strong></p>
<ul>
<li>Tomatoes &#8211; Deseeded, diced</li>
<li>Red onion</li>
<li>Methi Leaves</li>
<li>Mint leaves</li>
<li>Chana &#8211; soaked overnight and boiled</li>
<li>Saffron &#8211; soaked in warm water</li>
<li>Briyani Rice &#8211; washed and soaked in warm water</li>
<li>Yogurt</li>
</ul>
<p><strong>Spices:</strong></p>
<ul>
<li>Cloves</li>
<li>Bay leaves</li>
<li>Black Cardamom</li>
<li>Cinnamon Sticks</li>
<li>Green Cardamom</li>
<li>Black Cumin Seeds</li>
<li>Raisins</li>
<li>Green Chili &#8211; Sliced vertically</li>
<li>Star Anise</li>
<li>Chopped Ginger and Garlic</li>
</ul>
<p><strong>Making the Chana &#8220;Masala&#8221;</strong><br />
Heat some ghee, add the spices (Cloves, Bay leaves, Black and green cardamom, cumin seeds and star anise). After a couple of minutes add chopped onions, chili, chopped ginger and garlic. Sauté for a 3-4 minutes. Add Chopped tomatoes. Once onion and tomato become soft add Chickpeas and Methi leaves. Keep stirring and keep cooking on medium heat.</p>
<p><a href="http://www.vijaykiran.com/wp-content/uploads/2012/01/chana.jpg"><img class="aligncenter  wp-image-3522" title="chana" src="http://www.vijaykiran.com/wp-content/uploads/2012/01/chana-620x620.jpg" alt="" width="496" height="496" /></a></p>
<p>After 4-5 minutes of cooking add yogurt and mix thoroughly. Reduce the heat and cook for a couple of more minutes. You don&#8217;t need to cook it all the way, since it will be put into the oven in a Matki.</p>
<p>Spread the chana masala as a thick layer in a Matki (Earthen Pot), and spread soaked rice on top of it as a second layer. On the rice sprinkle saffron water, a pinch of gram masala and some mint leaves. Add another layer of Chana Masala and Rice continue till you fill up the Matki.</p>
<p><a href="http://www.vijaykiran.com/wp-content/uploads/2012/01/biryani-rice-layers1.jpg"><img class="alignleft  wp-image-3527" title="biryani-rice-layers1" src="http://www.vijaykiran.com/wp-content/uploads/2012/01/biryani-rice-layers1-328x440.jpg" alt="" width="276" height="370" /></a><a href="http://www.vijaykiran.com/wp-content/uploads/2012/01/biryani-rice-layers2.jpg"><img class="alignleft  wp-image-3526" title="biryani-rice-layers2" src="http://www.vijaykiran.com/wp-content/uploads/2012/01/biryani-rice-layers2-328x440.jpg" alt="" width="276" height="370" /></a></p>
<p>Place the pot in the oven pre-heated to 200° Celsius &#8211; cook for 1.5 hours. Enjoy with Raita.</p>
<p><a href="http://www.vijaykiran.com/wp-content/uploads/2012/01/final.jpg"><img src="http://www.vijaykiran.com/wp-content/uploads/2012/01/final-620x463.jpg" alt="" title="final" width="620" height="463" class="aligncenter size-large wp-image-3543" /></a></p>

<p><a href="http://feedads.g.doubleclick.net/~a/XCfmDIjkmNOn_E_SxB-a15r-rMU/0/da"><img src="http://feedads.g.doubleclick.net/~a/XCfmDIjkmNOn_E_SxB-a15r-rMU/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/XCfmDIjkmNOn_E_SxB-a15r-rMU/1/da"><img src="http://feedads.g.doubleclick.net/~a/XCfmDIjkmNOn_E_SxB-a15r-rMU/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Vijaykirancom?a=Zr6Wyt5BTj0:e5MqDHeq-HU:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Vijaykirancom?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Vijaykirancom?a=Zr6Wyt5BTj0:e5MqDHeq-HU:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/Vijaykirancom?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Vijaykirancom?a=Zr6Wyt5BTj0:e5MqDHeq-HU:6W8y8wAjSf4"><img src="http://feeds.feedburner.com/~ff/Vijaykirancom?d=6W8y8wAjSf4" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Vijaykirancom/~4/Zr6Wyt5BTj0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.vijaykiran.com/2012/01/08/matka-chana-methi-matkibiryani/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.vijaykiran.com/2012/01/08/matka-chana-methi-matkibiryani/</feedburner:origLink></item>
		<item>
		<title>Jason Fried on Nokia Lumia 800 + WP7.5</title>
		<link>http://feedproxy.google.com/~r/Vijaykirancom/~3/cjPIzexaAag/</link>
		<comments>http://www.vijaykiran.com/2011/12/28/jason-fried-on-nokia-lumia-800-wp7-5/#comments</comments>
		<pubDate>Wed, 28 Dec 2011 19:29:04 +0000</pubDate>
		<dc:creator>Vijay Kiran</dc:creator>
				<category><![CDATA[Links]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[nokia lumia]]></category>
		<category><![CDATA[wp7]]></category>

		<guid isPermaLink="false">http://www.vijaykiran.com/?p=3481</guid>
		<description><![CDATA[I’ve been hugely impressed with the Nokia Lumia 800 running Windows Phone 7.5. I’ve had an iPhone since day one, and every model since, but I really like the new path Microsoft is cutting with WP7 so I decided to give it an extended try. It’s been a bit over a week, and so far [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>I’ve been hugely impressed with the Nokia Lumia 800 running Windows Phone 7.5. I’ve had an iPhone since day one, and every model since, but I really like the new path Microsoft is cutting with WP7 so I decided to give it an extended try. It’s been a bit over a week, and so far I don’t miss my iPhone at all. In fact, going back to the iPhone feels like going back in time. It’s rough around the edges in a few spots, but I think Microsoft is up to something good here. More on this in a future post after I’ve spent some more quality time with the phone/platform.</p></blockquote>
<p>via <a href="http://37signals.com/svn/posts/3050-some-great-stuff-ive-tried-recently">Some great stuff Ive tried recently &#8211; 37signals</a>.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/Ryjn9j0EoQHK-zTfauLWi_SeQ1k/0/da"><img src="http://feedads.g.doubleclick.net/~a/Ryjn9j0EoQHK-zTfauLWi_SeQ1k/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/Ryjn9j0EoQHK-zTfauLWi_SeQ1k/1/da"><img src="http://feedads.g.doubleclick.net/~a/Ryjn9j0EoQHK-zTfauLWi_SeQ1k/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Vijaykirancom?a=cjPIzexaAag:Vjon3-0v7WE:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Vijaykirancom?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Vijaykirancom?a=cjPIzexaAag:Vjon3-0v7WE:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/Vijaykirancom?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Vijaykirancom?a=cjPIzexaAag:Vjon3-0v7WE:6W8y8wAjSf4"><img src="http://feeds.feedburner.com/~ff/Vijaykirancom?d=6W8y8wAjSf4" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Vijaykirancom/~4/cjPIzexaAag" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.vijaykiran.com/2011/12/28/jason-fried-on-nokia-lumia-800-wp7-5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.vijaykiran.com/2011/12/28/jason-fried-on-nokia-lumia-800-wp7-5/</feedburner:origLink></item>
		<item>
		<title>Difference between 0 and ‘nothing’</title>
		<link>http://feedproxy.google.com/~r/Vijaykirancom/~3/IJAZ46c1CH8/</link>
		<comments>http://www.vijaykiran.com/2011/12/28/difference-between-0-and-nothing/#comments</comments>
		<pubDate>Wed, 28 Dec 2011 17:42:12 +0000</pubDate>
		<dc:creator>Vijay Kiran</dc:creator>
				<category><![CDATA[Philosophy]]></category>
		<category><![CDATA[0]]></category>
		<category><![CDATA[maths]]></category>
		<category><![CDATA[nothing]]></category>
		<category><![CDATA[quotes]]></category>

		<guid isPermaLink="false">http://www.vijaykiran.com/?p=3478</guid>
		<description><![CDATA[0 vs. nothing is one of those abstract distinctions that&#8217;s almost impossible to talk about directly; you more have to do it with examples. Imagine there&#8217;s a certain math class, and in this class there&#8217;s a fiendishly difficult 100-point midterm, and imagine that neither you nor I get even one point out of 100 on [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>0 vs. nothing is one of those abstract distinctions that&#8217;s almost impossible to talk about directly; you more have to do it with examples. Imagine there&#8217;s a certain math class, and in this class there&#8217;s a fiendishly difficult 100-point midterm, and imagine that neither you nor I get even one point out of 100 on this exam. Except there&#8217;s a difference: you are not in the class and didn&#8217;t even take the exam, where as I am, and did. The fact that you received 0 points on the exam is thus irrelevant — your 0 means N/A, nothing — where are my 0 is an actual zero. Or if you don&#8217;t like that one, imagine that you and I are respectively female and male, both healthy and 20—40 years of age, and we&#8217;re both at the doctor&#8217;s, and neither of us has had a menstrual period in the past ten weeks, in which case my total number of periods is nothing, whereas yours here is 0 — and significant.</p></blockquote>
<p>- From <a href="http://www.amazon.com/gp/product/0393003388/ref=as_li_ss_tl?ie=UTF8&amp;tag=vijaykicom-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0393003388">Everything and More: A Compact History of Infinity (Great Discoveries)</a><img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=vijaykicom-20&amp;l=as2&amp;o=1&amp;a=0393003388" alt="" width="1" height="1" border="0" /></p>

<p><a href="http://feedads.g.doubleclick.net/~a/INzKvHkjFlMfC_EO05FJwh2eGLE/0/da"><img src="http://feedads.g.doubleclick.net/~a/INzKvHkjFlMfC_EO05FJwh2eGLE/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/INzKvHkjFlMfC_EO05FJwh2eGLE/1/da"><img src="http://feedads.g.doubleclick.net/~a/INzKvHkjFlMfC_EO05FJwh2eGLE/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Vijaykirancom?a=IJAZ46c1CH8:f7tCkL_DMNo:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Vijaykirancom?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Vijaykirancom?a=IJAZ46c1CH8:f7tCkL_DMNo:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/Vijaykirancom?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Vijaykirancom?a=IJAZ46c1CH8:f7tCkL_DMNo:6W8y8wAjSf4"><img src="http://feeds.feedburner.com/~ff/Vijaykirancom?d=6W8y8wAjSf4" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Vijaykirancom/~4/IJAZ46c1CH8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.vijaykiran.com/2011/12/28/difference-between-0-and-nothing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.vijaykiran.com/2011/12/28/difference-between-0-and-nothing/</feedburner:origLink></item>
		<item>
		<title>Abstraction Levels in Mathematics</title>
		<link>http://feedproxy.google.com/~r/Vijaykirancom/~3/s-vEjAs3JFY/</link>
		<comments>http://www.vijaykiran.com/2011/11/29/abstraction-levels-in-mathematics/#comments</comments>
		<pubDate>Tue, 29 Nov 2011 19:21:10 +0000</pubDate>
		<dc:creator>Vijay Kiran</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[book]]></category>
		<category><![CDATA[david foster wallace]]></category>
		<category><![CDATA[math]]></category>
		<category><![CDATA[∞]]></category>

		<guid isPermaLink="false">http://www.vijaykiran.com/?p=3472</guid>
		<description><![CDATA[&#8230; consider for a moment how many levels of abstraction are involved in math itself. In arithmetic there&#8217;s the abstraction of number; and then there&#8217;s algebra, with a variable being a further-abstracted symbol for some number(s) and a function being a precise but abstract relation between domains of variables; and then of course there&#8217;s college [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>
&#8230; consider for a moment how many levels of abstraction are involved in math itself. In arithmetic there&#8217;s the abstraction of number; and then there&#8217;s algebra, with a variable being a further-abstracted symbol for some number(s) and a function being a precise but abstract relation between domains of variables; and then of course there&#8217;s college math&#8217;s derivatives and integrals of functions, and then integral equations involving unknown functions, and differential equations&#8217; families of functions, and complex functions (which are functions of functions), and definite integrals calculated as the difference between two integrals; and so on up through topology and tensor analysis and complex numbers and the complex plane and complex conjugates of matrices, etc. etc., the whole enterprise becoming such a towering baklava of abstractions and abstractions of abstractions that you pretty much have to pretend that everything you&#8217;re manipulating is an actual, tangible thing or else you get so abstracted that you can&#8217;t even sharpen your pencil, much less do any math.
</p></blockquote>
<p>- From &#8220;Everything and More &#8211; A Compact History of ∞&#8221; by David Foster Wallace</p>

<p><a href="http://feedads.g.doubleclick.net/~a/nGaBHF0eCuHDkuBqkPTjRXqaIfY/0/da"><img src="http://feedads.g.doubleclick.net/~a/nGaBHF0eCuHDkuBqkPTjRXqaIfY/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/nGaBHF0eCuHDkuBqkPTjRXqaIfY/1/da"><img src="http://feedads.g.doubleclick.net/~a/nGaBHF0eCuHDkuBqkPTjRXqaIfY/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Vijaykirancom?a=s-vEjAs3JFY:qIbKuIrrfp8:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Vijaykirancom?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Vijaykirancom?a=s-vEjAs3JFY:qIbKuIrrfp8:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/Vijaykirancom?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Vijaykirancom?a=s-vEjAs3JFY:qIbKuIrrfp8:6W8y8wAjSf4"><img src="http://feeds.feedburner.com/~ff/Vijaykirancom?d=6W8y8wAjSf4" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Vijaykirancom/~4/s-vEjAs3JFY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.vijaykiran.com/2011/11/29/abstraction-levels-in-mathematics/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.vijaykiran.com/2011/11/29/abstraction-levels-in-mathematics/</feedburner:origLink></item>
		<item>
		<title>CoffeeScript Experiments: Magic Date</title>
		<link>http://feedproxy.google.com/~r/Vijaykirancom/~3/PUpe-6P-BLA/</link>
		<comments>http://www.vijaykiran.com/2011/11/17/coffeescript-experiments-magic-date/#comments</comments>
		<pubDate>Thu, 17 Nov 2011 13:51:03 +0000</pubDate>
		<dc:creator>Vijay Kiran</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[coffeescript]]></category>

		<guid isPermaLink="false">http://www.vijaykiran.com/?p=3464</guid>
		<description><![CDATA[I started learning CoffeeScript recently and wanted to get my hands dirty. Here&#8217;s the first experiment. ########################################################################################## # Magic Date # # Author: Vijay Kiran&#60;mail@vijaykiran.com&#62; # # Allows conversion of natural date string to real date object. # e.g. tomorrow, today, 2w etc. # # # Implementation is shame-lessly based on MagicDate in Python. ########################################################################################## [...]]]></description>
			<content:encoded><![CDATA[<p>I started learning CoffeeScript recently and wanted to get my hands dirty. Here&#8217;s the first experiment. </p>
<p><span id="more-3464"></span></p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">##########################################################################################</span>
<span style="color: #808080; font-style: italic;">#                                 Magic Date</span>
<span style="color: #808080; font-style: italic;">#</span>
<span style="color: #808080; font-style: italic;"># Author: Vijay Kiran&lt;mail@vijaykiran.com&gt;</span>
<span style="color: #808080; font-style: italic;">#</span>
<span style="color: #808080; font-style: italic;"># Allows conversion of natural date string to real date object.</span>
<span style="color: #808080; font-style: italic;"># e.g. tomorrow, today, 2w etc.</span>
<span style="color: #808080; font-style: italic;">#</span>
<span style="color: #808080; font-style: italic;">#</span>
<span style="color: #808080; font-style: italic;"># Implementation is shame-lessly based on MagicDate in Python. </span>
<span style="color: #808080; font-style: italic;">##########################################################################################</span>
<span style="color: #808080; font-style: italic;">##                        Requirements/Specs                                            ##</span>
<span style="color: #808080; font-style: italic;">##                                                                                      ##</span>
<span style="color: #808080; font-style: italic;">#</span>
<span style="color: #808080; font-style: italic;"># One liner - should work like OmniFocus date field</span>
<span style="color: #808080; font-style: italic;">## </span>
<span style="color: #808080; font-style: italic;">#</span>
<span style="color: #808080; font-style: italic;"># Details:</span>
<span style="color: #808080; font-style: italic;"># • 2d, -3w, 1h, 1y1m, and so on — Relative dates and times put the date at</span>
<span style="color: #808080; font-style: italic;"># a certain amount of time from right now. Negative numbers represent times in the past.</span>
<span style="color: #808080; font-style: italic;"># </span>
<span style="color: #808080; font-style: italic;"># • 2 days, -3 weeks, 1 hour, 1 year 1 month, and so on — </span>
<span style="color: #808080; font-style: italic;"># You can use the full names of units too.</span>
<span style="color: #808080; font-style: italic;"># </span>
<span style="color: #808080; font-style: italic;"># • yesterday, tomorrow, next thursday, last month, this friday, and so on — </span>
<span style="color: #808080; font-style: italic;">#   You can refer to relative dates using common words. </span>
<span style="color: #808080; font-style: italic;">#   “This”, “next”, and “last” have specific meanings: this friday always means </span>
<span style="color: #808080; font-style: italic;">#   the Friday in this week, next friday always means </span>
<span style="color: #808080; font-style: italic;">#   the Friday in the next week, and last friday always means </span>
<span style="color: #808080; font-style: italic;">#   the Friday in last week, regardless of what day today is. </span>
<span style="color: #808080; font-style: italic;">#   Other units work in the same way.</span>
<span style="color: #808080; font-style: italic;"># </span>
<span style="color: #808080; font-style: italic;"># • september, thurs, 2019, and so on — If you enter the name of a specific time period, </span>
<span style="color: #808080; font-style: italic;">#   the date will be at its beginning. So september means September first.</span>
<span style="color: #808080; font-style: italic;"># </span>
<span style="color: #808080; font-style: italic;"># • 5/23/08 10a, 9.30.09 2:00 PM, and so on — You can use the short date format as </span>
<span style="color: #808080; font-style: italic;">#   defined in your International system preferences. </span>
<span style="color: #808080; font-style: italic;"># </span>
<span style="color: #808080; font-style: italic;"># • 2w sat, 4d @ 5p, tues 6a, aug 6 tues 5p, and so on —</span>
<span style="color: #808080; font-style: italic;">#    Mix the available formats however you like.</span>
<span style="color: #808080; font-style: italic;"># </span>
<span style="color: #808080; font-style: italic;"># • now, 9, 14:00, tom, and so on — OmniFocus makes its best guess </span>
<span style="color: #808080; font-style: italic;">#   at things like bare numbers, times, and word fragments. </span>
<span style="color: #808080; font-style: italic;">#   If you think something might work, give it a try.</span>
&nbsp;
weekdays = <span style="color: black;">&#91;</span><span style="color: #483d8b;">'monday'</span>, <span style="color: #483d8b;">'tuesday'</span>, <span style="color: #483d8b;">'wednesday'</span>, <span style="color: #483d8b;">'thursday'</span>, <span style="color: #483d8b;">'friday'</span>, <span style="color: #483d8b;">'saturday'</span>, <span style="color: #483d8b;">'sunday'</span><span style="color: black;">&#93;</span>
&nbsp;
magicDate = <span style="color: black;">&#40;</span><span style="color: #008000;">str</span><span style="color: black;">&#41;</span> -<span style="color: #66cc66;">&gt;</span>
 d = <span style="color: #dc143c;">new</span> Date
 regs = <span style="color: black;">&#91;</span>
   <span style="color: #808080; font-style: italic;"># Today</span>
   <span style="color: black;">&#91;</span> /^tod/i, Date <span style="color: black;">&#93;</span>,
   <span style="color: #808080; font-style: italic;"># Tomorrow</span>
   <span style="color: black;">&#91;</span> /^tom/i, -<span style="color: #66cc66;">&gt;</span> d.<span style="color: black;">setDate</span><span style="color: black;">&#40;</span>d.<span style="color: black;">getDate</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span> + <span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">;</span>  d <span style="color: black;">&#93;</span>,
   <span style="color: #808080; font-style: italic;"># Now</span>
   <span style="color: black;">&#91;</span> /^now/i, Date<span style="color: black;">&#93;</span>,
   <span style="color: #808080; font-style: italic;"># Yesterday</span>
   <span style="color: black;">&#91;</span> /^yes/i, -<span style="color: #66cc66;">&gt;</span> d.<span style="color: black;">setDate</span><span style="color: black;">&#40;</span>d.<span style="color: black;">getDate</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span> - <span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">;</span> d <span style="color: black;">&#93;</span>,
   <span style="color: black;">&#91;</span> /^<span style="color: black;">&#40;</span>last|next|this<span style="color: black;">&#41;</span>\s<span style="color: black;">&#40;</span>week<span style="color: black;">&#41;</span>/, 
     <span style="color: black;">&#40;</span>result<span style="color: black;">&#41;</span> -<span style="color: #66cc66;">&gt;</span>
       switch result<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span>.<span style="color: black;">toLowerCase</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
         when <span style="color: #483d8b;">&quot;last&quot;</span> then d.<span style="color: black;">setDate</span><span style="color: black;">&#40;</span>d.<span style="color: black;">getDate</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span> - <span style="color: #ff4500;">7</span><span style="color: black;">&#41;</span>
         when <span style="color: #483d8b;">&quot;this&quot;</span> then d.<span style="color: black;">setDate</span><span style="color: black;">&#40;</span>d.<span style="color: black;">getDate</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span> + <span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span>
         when <span style="color: #483d8b;">&quot;next&quot;</span> then d.<span style="color: black;">setDate</span><span style="color: black;">&#40;</span>d.<span style="color: black;">getDate</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span> + <span style="color: #ff4500;">7</span><span style="color: black;">&#41;</span>
       d
   <span style="color: black;">&#93;</span>,
    <span style="color: #808080; font-style: italic;"># &lt;last&gt; &lt;this&gt;/&lt;next&gt; &lt;weekday&gt;</span>
    <span style="color: black;">&#91;</span>
      /^<span style="color: black;">&#40;</span>last|this|next<span style="color: black;">&#41;</span>\s<span style="color: black;">&#40;</span>\S+<span style="color: black;">&#41;</span>/i,
      <span style="color: black;">&#40;</span>result<span style="color: black;">&#41;</span> -<span style="color: #66cc66;">&gt;</span>
        rel = result<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span>.<span style="color: black;">toLowerCase</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
        weekday = result<span style="color: black;">&#91;</span><span style="color: #ff4500;">2</span><span style="color: black;">&#93;</span>.<span style="color: black;">toLowerCase</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
        today = d.<span style="color: black;">getDay</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
        <span style="color: #808080; font-style: italic;"># Pick index + 1 because getDay is 1 = Monday, 2 = Tuesday and so on</span>
        index = <span style="color: black;">&#40;</span>i + <span style="color: #ff4500;">1</span> <span style="color: #ff7700;font-weight:bold;">for</span> item, i <span style="color: #ff7700;font-weight:bold;">in</span> weekdays when <span style="color: #dc143c;">new</span> RegExp<span style="color: black;">&#40;</span>weekday<span style="color: black;">&#41;</span>.<span style="color: #dc143c;">test</span><span style="color: black;">&#40;</span>item<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
&nbsp;
        switch result<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span>.<span style="color: black;">toLowerCase</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
          when <span style="color: #483d8b;">&quot;last&quot;</span> then d.<span style="color: black;">setDate</span><span style="color: black;">&#40;</span>d.<span style="color: black;">getDate</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span> - <span style="color: black;">&#40;</span>today - index + <span style="color: black;">&#40;</span><span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#40;</span>index <span style="color: #66cc66;">&lt;</span> today <span style="color: black;">&#41;</span> then <span style="color: #ff4500;">0</span> <span style="color: #ff7700;font-weight:bold;">else</span> <span style="color: #ff4500;">7</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span> <span style="color: black;">&#41;</span>
          when <span style="color: #483d8b;">&quot;this&quot;</span> then  d.<span style="color: black;">setDate</span><span style="color: black;">&#40;</span>d.<span style="color: black;">getDate</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span> + index - today<span style="color: black;">&#41;</span>
          when <span style="color: #483d8b;">&quot;next&quot;</span> then  d.<span style="color: black;">setDate</span><span style="color: black;">&#40;</span>d.<span style="color: black;">getDate</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span> + index + today - <span style="color: #ff4500;">1</span> <span style="color: black;">&#41;</span>
        d
    <span style="color: black;">&#93;</span>
   <span style="color: black;">&#93;</span>
<span style="color: #808080; font-style: italic;"># </span>
 <span style="color: #ff7700;font-weight:bold;">for</span> x <span style="color: #ff7700;font-weight:bold;">in</span> regs
     <span style="color: #dc143c;">re</span>  = x<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> 
     fn  = x<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span>
     <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #dc143c;">re</span>.<span style="color: #dc143c;">test</span> <span style="color: #008000;">str</span> then <span style="color: #ff7700;font-weight:bold;">return</span> fn<span style="color: black;">&#40;</span><span style="color: #008000;">str</span>.<span style="color: black;">match</span> <span style="color: #dc143c;">re</span><span style="color: black;">&#41;</span></pre></div></div>

<p>And here&#8217;s how you can use it:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">testStrings = <span style="color: black;">&#91;</span> <span style="color: #483d8b;">&quot;yes&quot;</span>, <span style="color: #483d8b;">&quot;yesterda&quot;</span>, <span style="color: #483d8b;">&quot;Yes&quot;</span>, <span style="color: #483d8b;">&quot;ye&quot;</span>, <span style="color: #483d8b;">&quot;-&quot;</span>
                <span style="color: #483d8b;">&quot;tod&quot;</span>, <span style="color: #483d8b;">&quot;todd&quot;</span>, <span style="color: #483d8b;">&quot;today&quot;</span>, <span style="color: #483d8b;">&quot;TodaY&quot;</span>, <span style="color: #483d8b;">&quot;-&quot;</span>
                <span style="color: #483d8b;">&quot;now&quot;</span>, <span style="color: #483d8b;">&quot;nowww&quot;</span>, <span style="color: #483d8b;">&quot;Now&quot;</span>, <span style="color: #483d8b;">&quot;ANDNOW&quot;</span>,<span style="color: #483d8b;">&quot;-&quot;</span>
                <span style="color: #483d8b;">&quot;tom&quot;</span>, <span style="color: #483d8b;">&quot;tomorrow&quot;</span>, <span style="color: #483d8b;">&quot;Tomorrow&quot;</span>, <span style="color: #483d8b;">&quot;to&quot;</span>, <span style="color: #483d8b;">&quot;-&quot;</span>  
                <span style="color: #483d8b;">&quot;last mon&quot;</span>, <span style="color: #483d8b;">&quot;last tuesday&quot;</span>, <span style="color: #483d8b;">&quot;last wed&quot;</span>, <span style="color: #483d8b;">&quot;last thurs&quot;</span>,  <span style="color: #483d8b;">&quot;last fri&quot;</span>, <span style="color: #483d8b;">&quot;last sat&quot;</span> , <span style="color: #483d8b;">&quot;LAst Sunda&quot;</span>, <span style="color: #483d8b;">&quot;-&quot;</span>
                <span style="color: #483d8b;">&quot;last week&quot;</span>, <span style="color: #483d8b;">&quot;tHIS Week&quot;</span>, <span style="color: #483d8b;">&quot;next week&quot;</span>, <span style="color: #483d8b;">&quot;-&quot;</span>
                <span style="color: #483d8b;">&quot;this mon&quot;</span>, <span style="color: #483d8b;">&quot;this tuesday&quot;</span>, <span style="color: #483d8b;">&quot;this weDNE&quot;</span>, <span style="color: #483d8b;">&quot;this thursday&quot;</span>, <span style="color: #483d8b;">&quot;THIS FRIDAY&quot;</span>, <span style="color: #483d8b;">&quot;this sat&quot;</span>, <span style="color: #483d8b;">&quot;this sun&quot;</span>, <span style="color: #483d8b;">&quot;-&quot;</span>
                <span style="color: #483d8b;">&quot;next mon&quot;</span>, <span style="color: #483d8b;">&quot;NExt tue&quot;</span>, <span style="color: #483d8b;">&quot;nex wednesday&quot;</span>, <span style="color: #483d8b;">&quot;next thursday&quot;</span>, <span style="color: #483d8b;">&quot;Next Friday&quot;</span>, <span style="color: #483d8b;">&quot;Next Satur&quot;</span>, <span style="color: #483d8b;">&quot;next sun&quot;</span>, <span style="color: #483d8b;">&quot;-&quot;</span><span style="color: black;">&#93;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">for</span> <span style="color: #008000;">str</span> <span style="color: #ff7700;font-weight:bold;">in</span> testStrings
  <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">str</span> <span style="color: #ff7700;font-weight:bold;">is</span> <span style="color: #483d8b;">&quot;-&quot;</span> 
    console.<span style="color: black;">log</span> <span style="color: #483d8b;">&quot;---------------------------------------------------&quot;</span>
  <span style="color: #ff7700;font-weight:bold;">else</span>
    console.<span style="color: black;">log</span> <span style="color: #483d8b;">&quot;#{str}           =     #{magicDate str}&quot;</span></pre></div></div>


<p><a href="http://feedads.g.doubleclick.net/~a/v6eui0IUAson59-0NZPZvHvLb8c/0/da"><img src="http://feedads.g.doubleclick.net/~a/v6eui0IUAson59-0NZPZvHvLb8c/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/v6eui0IUAson59-0NZPZvHvLb8c/1/da"><img src="http://feedads.g.doubleclick.net/~a/v6eui0IUAson59-0NZPZvHvLb8c/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Vijaykirancom?a=PUpe-6P-BLA:NeVRnTtIF_E:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Vijaykirancom?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Vijaykirancom?a=PUpe-6P-BLA:NeVRnTtIF_E:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/Vijaykirancom?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Vijaykirancom?a=PUpe-6P-BLA:NeVRnTtIF_E:6W8y8wAjSf4"><img src="http://feeds.feedburner.com/~ff/Vijaykirancom?d=6W8y8wAjSf4" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Vijaykirancom/~4/PUpe-6P-BLA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.vijaykiran.com/2011/11/17/coffeescript-experiments-magic-date/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.vijaykiran.com/2011/11/17/coffeescript-experiments-magic-date/</feedburner:origLink></item>
		<item>
		<title>Kiva 6 year anniversary celebrations in Paris</title>
		<link>http://feedproxy.google.com/~r/Vijaykirancom/~3/P_aPj1xzGN0/</link>
		<comments>http://www.vijaykiran.com/2011/10/21/kiva-6-years-paris/#comments</comments>
		<pubDate>Fri, 21 Oct 2011 19:55:44 +0000</pubDate>
		<dc:creator>Vijay Kiran</dc:creator>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[ikiva]]></category>
		<category><![CDATA[kiva]]></category>

		<guid isPermaLink="false">http://www.vijaykiran.com/?p=3441</guid>
		<description><![CDATA[Yesterday I hopped on the train for a quick trip to Paris, to join the Kiva&#8216;s 6th birthday celebrations. I had a great time meeting other Kiva supporters and the trip was totally worth the travel. Here are some photos I took at the event. Also, yesterday &#8211; the iKiva app that I built crossed [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday I hopped on the train for a quick trip to Paris, to join the <a href="http://kiva.org">Kiva</a>&#8216;s 6th birthday <a href="http://www.kiva.org/updates/kiva/2011/10/09/global-celebration-in-10-cities-in.html">celebrations</a>. I had a great time meeting other Kiva supporters and the trip was totally worth the travel. </p>
<p>Here are some photos I took at the event.</p>
<p><span id="more-3441"></span></p>

<a href='http://www.vijaykiran.com/2011/10/21/kiva-6-years-paris/kiva6-paris9/' title='Kiva6-paris9'><img width="170" height="170" src="http://www.vijaykiran.com/wp-content/uploads/2011/10/Kiva6-paris9-170x170.jpg" class="attachment-thumbnail" alt="Kiva6-paris9" title="Kiva6-paris9" /></a>
<a href='http://www.vijaykiran.com/2011/10/21/kiva-6-years-paris/kiva6-paris24/' title='Kiva6-paris24'><img width="170" height="170" src="http://www.vijaykiran.com/wp-content/uploads/2011/10/Kiva6-paris24-170x170.jpg" class="attachment-thumbnail" alt="Kiva6-paris24" title="Kiva6-paris24" /></a>
<a href='http://www.vijaykiran.com/2011/10/21/kiva-6-years-paris/kiva6-paris26/' title='Kiva6-paris26'><img width="170" height="170" src="http://www.vijaykiran.com/wp-content/uploads/2011/10/Kiva6-paris26-170x170.jpg" class="attachment-thumbnail" alt="Kiva6-paris26" title="Kiva6-paris26" /></a>
<a href='http://www.vijaykiran.com/2011/10/21/kiva-6-years-paris/kiva6-paris27/' title='Kiva6-paris27'><img width="170" height="170" src="http://www.vijaykiran.com/wp-content/uploads/2011/10/Kiva6-paris27-170x170.jpg" class="attachment-thumbnail" alt="Kiva6-paris27" title="Kiva6-paris27" /></a>
<a href='http://www.vijaykiran.com/2011/10/21/kiva-6-years-paris/kiva6-paris28/' title='Kiva6-paris28'><img width="170" height="170" src="http://www.vijaykiran.com/wp-content/uploads/2011/10/Kiva6-paris28-170x170.jpg" class="attachment-thumbnail" alt="Kiva6-paris28" title="Kiva6-paris28" /></a>
<a href='http://www.vijaykiran.com/2011/10/21/kiva-6-years-paris/kiva6-paris29/' title='Kiva6-paris29'><img width="170" height="170" src="http://www.vijaykiran.com/wp-content/uploads/2011/10/Kiva6-paris29-170x170.jpg" class="attachment-thumbnail" alt="Kiva6-paris29" title="Kiva6-paris29" /></a>
<a href='http://www.vijaykiran.com/2011/10/21/kiva-6-years-paris/kiva6-paris30/' title='Kiva6-paris30'><img width="170" height="170" src="http://www.vijaykiran.com/wp-content/uploads/2011/10/Kiva6-paris30-170x170.jpg" class="attachment-thumbnail" alt="Kiva6-paris30" title="Kiva6-paris30" /></a>
<a href='http://www.vijaykiran.com/2011/10/21/kiva-6-years-paris/kiva6-paris31/' title='Kiva6-paris31'><img width="170" height="170" src="http://www.vijaykiran.com/wp-content/uploads/2011/10/Kiva6-paris31-170x170.jpg" class="attachment-thumbnail" alt="Kiva6-paris31" title="Kiva6-paris31" /></a>
<a href='http://www.vijaykiran.com/2011/10/21/kiva-6-years-paris/kiva6-paris32/' title='Kiva6-paris32'><img width="170" height="170" src="http://www.vijaykiran.com/wp-content/uploads/2011/10/Kiva6-paris32-170x170.jpg" class="attachment-thumbnail" alt="Kiva6-paris32" title="Kiva6-paris32" /></a>

<p>Also, yesterday &#8211; the <a href="http://www.vijaykiran.com/projects/ikiva/">iKiva</a> app that I built crossed 6000 Downloads! I&#8217;m working on the next version which will be an universal app that will work on both iPad and iPhone/iPod touch. And Hopefully I&#8217;ll get enough free time to complete it in the next couple of months.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/YORu50LpGDZisXQOAlFEYkeLd2E/0/da"><img src="http://feedads.g.doubleclick.net/~a/YORu50LpGDZisXQOAlFEYkeLd2E/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/YORu50LpGDZisXQOAlFEYkeLd2E/1/da"><img src="http://feedads.g.doubleclick.net/~a/YORu50LpGDZisXQOAlFEYkeLd2E/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Vijaykirancom?a=P_aPj1xzGN0:jR-bOEJ6mac:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Vijaykirancom?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Vijaykirancom?a=P_aPj1xzGN0:jR-bOEJ6mac:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/Vijaykirancom?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Vijaykirancom?a=P_aPj1xzGN0:jR-bOEJ6mac:6W8y8wAjSf4"><img src="http://feeds.feedburner.com/~ff/Vijaykirancom?d=6W8y8wAjSf4" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Vijaykirancom/~4/P_aPj1xzGN0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.vijaykiran.com/2011/10/21/kiva-6-years-paris/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.vijaykiran.com/2011/10/21/kiva-6-years-paris/</feedburner:origLink></item>
		<item>
		<title>→ “My belly is too much swelling with jackfruit”</title>
		<link>http://feedproxy.google.com/~r/Vijaykirancom/~3/cm1geLN06mY/</link>
		<comments>http://www.vijaykiran.com/2011/10/19/my-belly-is-too-much-swelling-with-jackfruit/#comments</comments>
		<pubDate>Wed, 19 Oct 2011 15:18:46 +0000</pubDate>
		<dc:creator>Vijay Kiran</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[fun]]></category>

		<guid isPermaLink="false">http://www.vijaykiran.com/?p=3439</guid>
		<description><![CDATA[In 1909, after missing his train due to an ultimately disastrous trip to the lavatory at Ahmedpur station, an embarrassed, angry young man named Okhil Chandra Sen sent an unintentionally amusing letter of complaint to the Sahibganj divisional railway office in West Bengal. The letter proved to be an important one as, according to the [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>In 1909, after missing his train due to an ultimately disastrous trip to the lavatory at Ahmedpur station, an embarrassed, angry young man named Okhil Chandra Sen sent an unintentionally amusing letter of complaint to the Sahibganj divisional railway office in West Bengal. The letter proved to be an important one as, according to the Railway Museum in New Delhi, the subsequent investigation into the affair by the British Raj resulted in the introduction of toilets to all trains in the country; something that had been absent since the formation of Indian Railways in 1857.
</p></blockquote>
<p>via <a href="http://www.lettersofnote.com/2011/10/my-belly-is-too-much-swelling-with.html">Letters of Note: My belly is too much swelling with jackfruit</a>.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/_yW2F9yRAIaZKN9sW0tlTVp6rhU/0/da"><img src="http://feedads.g.doubleclick.net/~a/_yW2F9yRAIaZKN9sW0tlTVp6rhU/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/_yW2F9yRAIaZKN9sW0tlTVp6rhU/1/da"><img src="http://feedads.g.doubleclick.net/~a/_yW2F9yRAIaZKN9sW0tlTVp6rhU/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Vijaykirancom?a=cm1geLN06mY:zUF-likM4pU:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Vijaykirancom?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Vijaykirancom?a=cm1geLN06mY:zUF-likM4pU:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/Vijaykirancom?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Vijaykirancom?a=cm1geLN06mY:zUF-likM4pU:6W8y8wAjSf4"><img src="http://feeds.feedburner.com/~ff/Vijaykirancom?d=6W8y8wAjSf4" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Vijaykirancom/~4/cm1geLN06mY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.vijaykiran.com/2011/10/19/my-belly-is-too-much-swelling-with-jackfruit/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.vijaykiran.com/2011/10/19/my-belly-is-too-much-swelling-with-jackfruit/</feedburner:origLink></item>
		<item>
		<title>సాయమకాలమయ్యింది – గొల్లపూడి మారుతి రావు</title>
		<link>http://feedproxy.google.com/~r/Vijaykirancom/~3/Krnl4nZDgNc/</link>
		<comments>http://www.vijaykiran.com/2011/10/18/sayamkalamayyindi/#comments</comments>
		<pubDate>Tue, 18 Oct 2011 09:06:30 +0000</pubDate>
		<dc:creator>Vijay Kiran</dc:creator>
				<category><![CDATA[Telugu]]></category>
		<category><![CDATA[పుస్తకాలు]]></category>

		<guid isPermaLink="false">http://www.vijaykiran.com/?p=3431</guid>
		<description><![CDATA[సాయమకాలమయ్యింది &#8211; గొల్లపూడి మారుతి రావు నుంచి మచ్చుకి కొన్ని పేరాలు భరించరాని దుఃఖం మనిషిని ఆవరించినప్పుడు రెండు జరుగుతాయి. వేదనగల మనిషి పిచ్చివాడయినా అవుతాడు. నిర్మలమయిన అంతఃకరణ గల వ్యక్తి ఊహించని మలుపులో ఏకోన్ముఖుడవుతాడు. అంటే, దిక్కుతోచని దశలో బలమైన దిక్కువైపు మనస్సుని మళ్ళించుకుంటాడు. అది అతని కర్మపరిపాకం. సంస్కారం. అంతకన్నా కారణం మరొకటి వుండదు. అంతులేని దుఃఖంలో తాగుబోతులయినవారూ ఉన్నారు. అద్భుతమైన కావ్యాన్ని సృష్టించినవారూ ఉన్నారు. రెంటికీ ప్రాతిపదిక వేదనే. తన కడుపున పుట్టింది [...]]]></description>
			<content:encoded><![CDATA[<p>సాయమకాలమయ్యింది &#8211; గొల్లపూడి మారుతి రావు నుంచి మచ్చుకి కొన్ని పేరాలు</p>
<blockquote><p>భరించరాని దుఃఖం మనిషిని ఆవరించినప్పుడు రెండు జరుగుతాయి. వేదనగల మనిషి పిచ్చివాడయినా అవుతాడు. నిర్మలమయిన అంతఃకరణ గల వ్యక్తి ఊహించని మలుపులో ఏకోన్ముఖుడవుతాడు. అంటే, దిక్కుతోచని దశలో బలమైన దిక్కువైపు మనస్సుని మళ్ళించుకుంటాడు. అది అతని కర్మపరిపాకం. సంస్కారం. అంతకన్నా కారణం మరొకటి వుండదు. అంతులేని దుఃఖంలో తాగుబోతులయినవారూ ఉన్నారు. అద్భుతమైన కావ్యాన్ని సృష్టించినవారూ ఉన్నారు. రెంటికీ ప్రాతిపదిక వేదనే.</p></blockquote>
<blockquote><p>తన కడుపున పుట్టింది సాక్షాత్తూ విష్ణుమూర్త్తేనన్న స్పృహ తనకి ఉండరాదని కోరుకున్నాడు దశరధుడు ముందుజన్మలో. కేవలం తండ్రికి పుత్రునిమీద ఉన్న మమకారాన్ని పూర్తిగా అనుభవించాలన్నదే ఆయన లక్ష్యం. కానీ తనకు పుట్టింది భగవంతుడేనన్న జ్ఞానాన్ని కోరుకుంది కౌసల్య. అంతటి అదృష్టాన్ని మరిచిపోతే ఎలా? ఆ దివ్యానుభూతిని కోల్పోతే ఆ వరానికి విలువేముంది? అదీ ఆవిడ ఉద్దేశ్యం.</p></blockquote>
<blockquote><p>అమెరికానుంచి వచ్చే కుటుంబాల కథ &#8211;  అదొక పెద్ద ప్రహసనం. ఇలాంటి ప్రయాణాలకే ప్రత్యేకించిన పెట్టెలు కొన్ని ఉంటాయి. ఒక్కొక్క పెట్టెలో ఆరేళ్ళ వయస్సుగల పిల్లలు కాలు మడత పెట్టుకోకుండా ముగ్గురు పడుకోవచ్చును. అంత విశాలంగా, అంత భారీగా ఉంటాయి. వాటిలో ఏం ఉంటాయి? అమెరికా వెర్రిని ఇండియాలో పంచటానికి కావలసినంత సామగ్రి ఉంటుంది. వాకీటాకీలు, కీచైన్లు, రీబోక్ షూలు, రంగురంగుల టైలు, &#8216;కిక్ మీ ఎగైన్&#8217;, &#8216;ఓహో నాట్ నౌ&#8217;, &#8216;దట్సిట్&#8217; లాంటి రకరకాల నినాదాల బనీన్లు, సగం చిరుగులుపడ్డ జీన్ పాంటులు, చూయింగ్ గమ్ లు ,   ఆమెరికాల సినిమాల కేసెట్లూ, కంప్యూటర్ ఫ్లాపీలు, కెమెరా రీల్సూ, చిన్నసైజు విస్కీ సీసాలు, మార్ల్ బరో సిగరెట్టు పాకెట్లూ &#8230; మీ ఇష్టం.</p>
<p>వెళ్ళేటప్పుడు ఈ సూట్ కేసులనిండా ఏముంటాయి? కరక్కాయలు, తీనేసీసాలు, మొలతాళ్ళు, ఊరగయడబ్బాలు, షిర్దీ సాయిబాబా విబూదీ, పసుపు పొట్లాలు, మిరియాలు, లవంగాల పాకెట్లు, కంచిపట్టు చీరలు, ఎమ్మెస్ సుబ్బలక్ష్మి విష్ణు సహస్రనామాలు, ఇటీవల తెలుగు సినిమాల వీడియోలు, ఘంటసాల పాత పాటలు, పవిత్రమైన గంగాజలం &#8230; మీ ఇష్టం.</p>
<p>ఆ ఇరవై రోజుల్లో అమెరికా పైత్యాన్నంతా ఈ దేశానికి దిగుమతి చేసి, మరో మూడేళ్ళపాటు ఇండియా సంప్రదాయ సంపదని మూటగట్టుకు పట్టుకుపోతారు.
</p></blockquote>

<p><a href="http://feedads.g.doubleclick.net/~a/CBxBnj9aJ9oN2SYWXmXV3kM3f6o/0/da"><img src="http://feedads.g.doubleclick.net/~a/CBxBnj9aJ9oN2SYWXmXV3kM3f6o/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/CBxBnj9aJ9oN2SYWXmXV3kM3f6o/1/da"><img src="http://feedads.g.doubleclick.net/~a/CBxBnj9aJ9oN2SYWXmXV3kM3f6o/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Vijaykirancom?a=Krnl4nZDgNc:Wmwh6QhbdBU:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Vijaykirancom?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Vijaykirancom?a=Krnl4nZDgNc:Wmwh6QhbdBU:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/Vijaykirancom?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Vijaykirancom?a=Krnl4nZDgNc:Wmwh6QhbdBU:6W8y8wAjSf4"><img src="http://feeds.feedburner.com/~ff/Vijaykirancom?d=6W8y8wAjSf4" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Vijaykirancom/~4/Krnl4nZDgNc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.vijaykiran.com/2011/10/18/sayamkalamayyindi/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.vijaykiran.com/2011/10/18/sayamkalamayyindi/</feedburner:origLink></item>
		<item>
		<title>★ Murudeshwar, Karnataka, India</title>
		<link>http://feedproxy.google.com/~r/Vijaykirancom/~3/MmgBOCvZeyI/</link>
		<comments>http://www.vijaykiran.com/2011/10/13/murudeshwar-karnataka/#comments</comments>
		<pubDate>Thu, 13 Oct 2011 14:22:59 +0000</pubDate>
		<dc:creator>Vijay Kiran</dc:creator>
				<category><![CDATA[Photography]]></category>
		<category><![CDATA[murudeshwar]]></category>

		<guid isPermaLink="false">http://www.vijaykiran.com/?p=3426</guid>
		<description />
			<content:encoded><![CDATA[<p><a href="http://www.vijaykiran.com/wp-content/uploads/2011/10/others-1.jpg" class="enlarge"><img src="http://www.vijaykiran.com/wp-content/uploads/2011/10/others-1-620x413.jpg" alt="" title="others (1)" width="620" height="413" class="aligncenter size-large wp-image-3427" /></a></p>

<p><a href="http://feedads.g.doubleclick.net/~a/t3x_Y2J5AolmPKJI2YICoRtHcg8/0/da"><img src="http://feedads.g.doubleclick.net/~a/t3x_Y2J5AolmPKJI2YICoRtHcg8/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/t3x_Y2J5AolmPKJI2YICoRtHcg8/1/da"><img src="http://feedads.g.doubleclick.net/~a/t3x_Y2J5AolmPKJI2YICoRtHcg8/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Vijaykirancom?a=MmgBOCvZeyI:fDOu5sOxBGA:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Vijaykirancom?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Vijaykirancom?a=MmgBOCvZeyI:fDOu5sOxBGA:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/Vijaykirancom?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Vijaykirancom?a=MmgBOCvZeyI:fDOu5sOxBGA:6W8y8wAjSf4"><img src="http://feeds.feedburner.com/~ff/Vijaykirancom?d=6W8y8wAjSf4" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Vijaykirancom/~4/MmgBOCvZeyI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.vijaykiran.com/2011/10/13/murudeshwar-karnataka/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.vijaykiran.com/2011/10/13/murudeshwar-karnataka/</feedburner:origLink></item>
		<item>
		<title>Death of Steve Jobs</title>
		<link>http://feedproxy.google.com/~r/Vijaykirancom/~3/t124nqBlLDg/</link>
		<comments>http://www.vijaykiran.com/2011/10/07/death-of-steve-jobs/#comments</comments>
		<pubDate>Fri, 07 Oct 2011 18:18:04 +0000</pubDate>
		<dc:creator>Vijay Kiran</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[steve jobs]]></category>

		<guid isPermaLink="false">http://www.vijaykiran.com/?p=3418</guid>
		<description><![CDATA[Nothing in life has any intrinsic value &#8211; any value that we think an object/person has is just perceived value. No matter how valuable object is lost, &#8220;the universe continues unabated&#8221;. This is one of &#8220;valuable&#8221; (pardon the pun) lessons I learnt when my father died. I was in a completely different world surrounded by [...]]]></description>
			<content:encoded><![CDATA[<p>Nothing in life has any intrinsic value &#8211; any value that we think an object/person has is just perceived value. No matter how valuable object is lost, &#8220;the universe continues unabated&#8221;. This is one of &#8220;valuable&#8221; (pardon the pun) lessons I learnt when my father died. </p>
<p>I was in a completely different world surrounded by completely different people when I heard that Steve Jobs was dead. I deeply sighed and told someone sitting near me about the news. She asked me &#8220;Who&#8217;s Steve Jobs?&#8221;. I tried to explain how valuable his contributions are to the Software/Computer industry etc. But there was a clear indifference among the people who were paying attention to what I was talking. They clearly don&#8217;t see the value and they are right.</p>
<p>Anyway, so far the following is the most level headed response to Jobs&#8217;s death that I&#8217;ve seen so far among the overly-empathetic media and blogs/tweets.</p>
<blockquote><p>“I don’t want to take anything away from the guy, he was brilliant and uncompromising and wonderful, but there’s a level of adulation that goes beyond what is merited,” said Tim O’Reilly, chief executive of the tech publisher O’Reilly Media. “There will be revolutions and revolutionaries to come.”</p></blockquote>
<p>It will be interesting to see if Jobs&#8217;s &#8220;values&#8221; will be carried forward. Of course we&#8217;ll never see an exact replica of Steve Jobs, but I&#8217;m sure there are brighter minds and leaders to come from human race.</p>

<p><a href="http://feedads.g.doubleclick.net/~a/PkG5K_uGn2VzGrBQ6BJ6FznbpCQ/0/da"><img src="http://feedads.g.doubleclick.net/~a/PkG5K_uGn2VzGrBQ6BJ6FznbpCQ/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/PkG5K_uGn2VzGrBQ6BJ6FznbpCQ/1/da"><img src="http://feedads.g.doubleclick.net/~a/PkG5K_uGn2VzGrBQ6BJ6FznbpCQ/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Vijaykirancom?a=t124nqBlLDg:77Enbbvw3Sk:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Vijaykirancom?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Vijaykirancom?a=t124nqBlLDg:77Enbbvw3Sk:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/Vijaykirancom?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Vijaykirancom?a=t124nqBlLDg:77Enbbvw3Sk:6W8y8wAjSf4"><img src="http://feeds.feedburner.com/~ff/Vijaykirancom?d=6W8y8wAjSf4" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Vijaykirancom/~4/t124nqBlLDg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.vijaykiran.com/2011/10/07/death-of-steve-jobs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.vijaykiran.com/2011/10/07/death-of-steve-jobs/</feedburner:origLink></item>
		<item>
		<title>★ Hannover</title>
		<link>http://feedproxy.google.com/~r/Vijaykirancom/~3/zw-zwpgqiJU/</link>
		<comments>http://www.vijaykiran.com/2011/09/26/hannover/#comments</comments>
		<pubDate>Mon, 26 Sep 2011 12:43:09 +0000</pubDate>
		<dc:creator>Vijay Kiran</dc:creator>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[Photography]]></category>
		<category><![CDATA[hannover]]></category>
		<category><![CDATA[photos]]></category>
		<category><![CDATA[travel]]></category>

		<guid isPermaLink="false">http://www.vijaykiran.com/?p=3383</guid>
		<description><![CDATA[Last weekend I went to Hannover for a quick weekend get away. The trip was fantastic and memorable. I walked around and shot some photos, made new friends! Click on "Read More" to see some selected photos from the trip.
]]></description>
			<content:encoded><![CDATA[<p>Last weekend I went to Hannover for a quick weekend get away. The trip was fantastic and memorable. I walked around and shot some photos, made new friends! Except for the lack of free wifi the trip was very nice. Hannover is a very pedestrian friendly city, and especially I like the idea of <a href="http://www.hannover.de/english/tourism_culture/sightseeing/city_tours/roter_faden/index.html">&#8220;Red Thread&#8221;</a> &#8211; it is a red floor line around the sidewalk, that guides you to see the main attractions in the city. Here are some selected photos from the trip.</p>
<p><span id="more-3383"></span><br />
<a class="enlarge" rel="hannover2011" href="http://www.vijaykiran.com/wp-content/uploads/2011/09/hannover-4.jpg"><img class="aligncenter size-large wp-image-3388" title="hannover (4)" src="http://www.vijaykiran.com/wp-content/uploads/2011/09/hannover-4-620x413.jpg" alt="" width="620" height="413" /></a></p>
<p style="text-align: center;">One of the Three Nanas by <a href="http://en.wikipedia.org/wiki/Niki_de_Saint_Phalle">Niki de Saint Phalle</a></p>
<p><a class="enlarge"  rel="hannover2011" href="http://www.vijaykiran.com/wp-content/uploads/2011/09/hannover1.jpg"><img class="aligncenter size-large wp-image-3397" title="hannover" src="http://www.vijaykiran.com/wp-content/uploads/2011/09/hannover1-620x473.jpg" alt="" width="620" height="473" /></a></p>
<p><a class="enlarge"  rel="hannover2011" href="http://www.vijaykiran.com/wp-content/uploads/2011/09/hannover-12.jpg"><img class="aligncenter size-large wp-image-3396" title="hannover (12)" src="http://www.vijaykiran.com/wp-content/uploads/2011/09/hannover-12-620x413.jpg" alt="" width="620" height="413" /></a></p>
<p><a class="enlarge"  rel="hannover2011" href="http://www.vijaykiran.com/wp-content/uploads/2011/09/hannover-11.jpg"><img class="aligncenter size-large wp-image-3395" title="hannover (11)" src="http://www.vijaykiran.com/wp-content/uploads/2011/09/hannover-11-620x413.jpg" alt="" width="620" height="413" /></a></p>
<p><a class="enlarge"  rel="hannover2011" href="http://www.vijaykiran.com/wp-content/uploads/2011/09/hannover-9.jpg"><img class="aligncenter size-large wp-image-3393" title="hannover (9)" src="http://www.vijaykiran.com/wp-content/uploads/2011/09/hannover-9-620x413.jpg" alt="" width="620" height="413" /></a></p>
<p><a class="enlarge"  rel="hannover2011" href="http://www.vijaykiran.com/wp-content/uploads/2011/09/hannover-8.jpg"><img class="aligncenter size-large wp-image-3392" title="hannover (8)" src="http://www.vijaykiran.com/wp-content/uploads/2011/09/hannover-8-620x413.jpg" alt="" width="620" height="413" /></a></p>
<p><a class="enlarge"  rel="hannover2011" href="http://www.vijaykiran.com/wp-content/uploads/2011/09/hannover-7.jpg"><img class="aligncenter size-large wp-image-3391" title="hannover (7)" src="http://www.vijaykiran.com/wp-content/uploads/2011/09/hannover-7-620x413.jpg" alt="" width="620" height="413" /></a></p>
<p><a class="enlarge"  rel="hannover2011" href="http://www.vijaykiran.com/wp-content/uploads/2011/09/hannover-6.jpg"><img class="aligncenter size-large wp-image-3390" title="hannover (6)" src="http://www.vijaykiran.com/wp-content/uploads/2011/09/hannover-6-620x413.jpg" alt="" width="620" height="413" /></a></p>
<p><a class="enlarge"  rel="hannover2011" href="http://www.vijaykiran.com/wp-content/uploads/2011/09/hannover-3.jpg"><img class="aligncenter size-large wp-image-3387" title="hannover (3)" src="http://www.vijaykiran.com/wp-content/uploads/2011/09/hannover-3-620x413.jpg" alt="" width="620" height="413" /></a></p>
<p><a class="enlarge"  rel="hannover2011" href="http://www.vijaykiran.com/wp-content/uploads/2011/09/hannover-2.jpg"><img class="aligncenter size-large wp-image-3386" title="hannover (2)" src="http://www.vijaykiran.com/wp-content/uploads/2011/09/hannover-2-413x620.jpg" alt="" width="413" height="620" /></a></p>
<p><a  class="enlarge"  rel="hannover2011"  href="http://www.vijaykiran.com/wp-content/uploads/2011/09/hannover2.jpg"><img src="http://www.vijaykiran.com/wp-content/uploads/2011/09/hannover2-620x595.jpg" alt="" title="hannover" width="620" height="595" class="aligncenter size-large wp-image-3412" /></a></p>

<p><a href="http://feedads.g.doubleclick.net/~a/-BuZaypbx8NswJ7TdYaJVu0LTbI/0/da"><img src="http://feedads.g.doubleclick.net/~a/-BuZaypbx8NswJ7TdYaJVu0LTbI/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/-BuZaypbx8NswJ7TdYaJVu0LTbI/1/da"><img src="http://feedads.g.doubleclick.net/~a/-BuZaypbx8NswJ7TdYaJVu0LTbI/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Vijaykirancom?a=zw-zwpgqiJU:rFPmFUlch74:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Vijaykirancom?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Vijaykirancom?a=zw-zwpgqiJU:rFPmFUlch74:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/Vijaykirancom?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Vijaykirancom?a=zw-zwpgqiJU:rFPmFUlch74:6W8y8wAjSf4"><img src="http://feeds.feedburner.com/~ff/Vijaykirancom?d=6W8y8wAjSf4" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Vijaykirancom/~4/zw-zwpgqiJU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.vijaykiran.com/2011/09/26/hannover/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.vijaykiran.com/2011/09/26/hannover/</feedburner:origLink></item>
		<item>
		<title>★ Misty Morning</title>
		<link>http://feedproxy.google.com/~r/Vijaykirancom/~3/8onJSuTRuQk/</link>
		<comments>http://www.vijaykiran.com/2011/09/24/misty-morning/#comments</comments>
		<pubDate>Sat, 24 Sep 2011 06:34:47 +0000</pubDate>
		<dc:creator>Vijay Kiran</dc:creator>
				<category><![CDATA[Photography]]></category>
		<category><![CDATA[photos]]></category>

		<guid isPermaLink="false">http://www.vijaykiran.com/?p=3376</guid>
		<description />
			<content:encoded><![CDATA[<p><a href="http://farm7.static.flickr.com/6158/6177302840_d37b3ace66_b.jpg" class="enlarge"><img src="http://farm7.static.flickr.com/6158/6177302840_d37b3ace66_z.jpg" /></a></p>

<p><a href="http://feedads.g.doubleclick.net/~a/R6RJOEEu7Z-ZYlC1cGQsD6DOCDE/0/da"><img src="http://feedads.g.doubleclick.net/~a/R6RJOEEu7Z-ZYlC1cGQsD6DOCDE/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/R6RJOEEu7Z-ZYlC1cGQsD6DOCDE/1/da"><img src="http://feedads.g.doubleclick.net/~a/R6RJOEEu7Z-ZYlC1cGQsD6DOCDE/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Vijaykirancom?a=8onJSuTRuQk:n_1N8FtzhkM:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Vijaykirancom?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Vijaykirancom?a=8onJSuTRuQk:n_1N8FtzhkM:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/Vijaykirancom?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Vijaykirancom?a=8onJSuTRuQk:n_1N8FtzhkM:6W8y8wAjSf4"><img src="http://feeds.feedburner.com/~ff/Vijaykirancom?d=6W8y8wAjSf4" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Vijaykirancom/~4/8onJSuTRuQk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.vijaykiran.com/2011/09/24/misty-morning/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.vijaykiran.com/2011/09/24/misty-morning/</feedburner:origLink></item>
		<item>
		<title>★ Red Ride</title>
		<link>http://feedproxy.google.com/~r/Vijaykirancom/~3/VSidAE22GRI/</link>
		<comments>http://www.vijaykiran.com/2011/09/22/red-ride/#comments</comments>
		<pubDate>Thu, 22 Sep 2011 20:35:15 +0000</pubDate>
		<dc:creator>Vijay Kiran</dc:creator>
				<category><![CDATA[Photography]]></category>
		<category><![CDATA[red ride]]></category>

		<guid isPermaLink="false">http://www.vijaykiran.com/?p=3371</guid>
		<description />
			<content:encoded><![CDATA[<p><a class="enlarge" href="http://farm7.static.flickr.com/6157/6173343662_a94dea83dc_b.jpg"><img src="http://farm7.static.flickr.com/6157/6173343662_a94dea83dc_z.jpg" alt="" /></a></p>

<p><a href="http://feedads.g.doubleclick.net/~a/0KzCA97Hwqj2k21cuRm12v-PHJs/0/da"><img src="http://feedads.g.doubleclick.net/~a/0KzCA97Hwqj2k21cuRm12v-PHJs/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/0KzCA97Hwqj2k21cuRm12v-PHJs/1/da"><img src="http://feedads.g.doubleclick.net/~a/0KzCA97Hwqj2k21cuRm12v-PHJs/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Vijaykirancom?a=VSidAE22GRI:3PembcpXlfY:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Vijaykirancom?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Vijaykirancom?a=VSidAE22GRI:3PembcpXlfY:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/Vijaykirancom?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Vijaykirancom?a=VSidAE22GRI:3PembcpXlfY:6W8y8wAjSf4"><img src="http://feeds.feedburner.com/~ff/Vijaykirancom?d=6W8y8wAjSf4" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Vijaykirancom/~4/VSidAE22GRI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.vijaykiran.com/2011/09/22/red-ride/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.vijaykiran.com/2011/09/22/red-ride/</feedburner:origLink></item>
	</channel>
</rss>

