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

<channel>
	<title>Zein&#039;s place on the net &#187; RoR</title>
	<atom:link href="http://ahmed.elze.in/blog/category/code/ror/feed/" rel="self" type="application/rss+xml" />
	<link>http://ahmed.elze.in/blog</link>
	<description>my views on Australia, Egypt, Linux and other stuff</description>
	<lastBuildDate>Tue, 19 Apr 2011 04:40:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2</generator>
		<item>
		<title>Caching the book cover images</title>
		<link>http://ahmed.elze.in/blog/2006/12/02/caching-the-book-cover-images/</link>
		<comments>http://ahmed.elze.in/blog/2006/12/02/caching-the-book-cover-images/#comments</comments>
		<pubDate>Sat, 02 Dec 2006 18:31:24 +0000</pubDate>
		<dc:creator>Ahmed</dc:creator>
				<category><![CDATA[mybooklist]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[RoR]]></category>

		<guid isPermaLink="false">http://www.azein.com/blog/?p=42</guid>
		<description><![CDATA[In my &#8220;mybooklist&#8221; application I deal with lots of images! My current method has been to store the uploaded book covers in public/images/bookcovers/isbnnumber.png&#8221; and creating thumbnails on the fly in the list and grid views! Of course this is a very bad thing to do! The load on my server was going crazy with all [...]]]></description>
			<content:encoded><![CDATA[<p>In my &#8220;mybooklist&#8221; application I deal with lots of images! My current method has been to store the uploaded book covers in public/images/bookcovers/isbnnumber.png&#8221; and creating thumbnails on the fly in the list and grid views!</p>
<p>Of course this is a very bad thing to do! The load on my server was going crazy with all the CPU intensive image manipulation going on! I had to do something.</p>
<p>The task required to different solutions. The first was client side caching to prevent the browser downloading the image multiple times! to achieve this I modified the show browser function like so:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;"># 2. we see if we need to send the file or not</span>
        lastmod = <span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">stat</span><span style="color:#006600; font-weight:bold;">&#40;</span>filepath<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">mtime</span>
        minTime = <span style="color:#CC00FF; font-weight:bold;">Time</span>.<span style="color:#9900CC;">rfc2822</span><span style="color:#006600; font-weight:bold;">&#40;</span>@request.<span style="color:#9900CC;">env</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;HTTP_IF_MODIFIED_SINCE&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">rescue</span> <span style="color:#0000FF; font-weight:bold;">nil</span>
        <span style="color:#9966CC; font-weight:bold;">if</span> minTime <span style="color:#9966CC; font-weight:bold;">and</span> lastmod <span style="color:#006600; font-weight:bold;">&lt;</span> = minTime
            <span style="color:#008000; font-style:italic;"># use cached version</span>
            render_text <span style="color:#996600;">''</span>, <span style="color:#996600;">'304 Not Modified'</span>
        <span style="color:#9966CC; font-weight:bold;">else</span>
            <span style="color:#008000; font-style:italic;"># send image</span></pre></div></div>

<p>now I only send the image to the client only in I need to!</p>
<p>The second area of improvement was the thumbnail creation on the fly! I first tried the rails</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">caches_page <span style="color:#ff3333; font-weight:bold;">:show_cover</span></pre></div></div>

<p> but I found myself in a situation where I was sending the image to the client every time because rails was sending the cached image without ever running the show_cover function (and my browser cache code)!</p>
<p>I guess I am just going to generate the thumbnails in the create and update functions. The app should feel a lot different and the load on the server should stay low!</p>
]]></content:encoded>
			<wfw:commentRss>http://ahmed.elze.in/blog/2006/12/02/caching-the-book-cover-images/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My first open source project</title>
		<link>http://ahmed.elze.in/blog/2006/11/26/my-first-open-source-project/</link>
		<comments>http://ahmed.elze.in/blog/2006/11/26/my-first-open-source-project/#comments</comments>
		<pubDate>Sun, 26 Nov 2006 05:06:26 +0000</pubDate>
		<dc:creator>Ahmed</dc:creator>
				<category><![CDATA[books]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[RoR]]></category>

		<guid isPermaLink="false">http://www.azein.com/blog/?p=34</guid>
		<description><![CDATA[After looking for a simple clean application to hold my book collection and coming up empty, I decided to write one myself! The application is written in Ruby on Rails (ROR) and will have the following features! admin user to update and edit book grabber from amazon (enter the ISBN and all the data is [...]]]></description>
			<content:encoded><![CDATA[<p>After looking for a simple clean application to hold my book collection and coming up empty, I decided to write one myself!</p>
<p>The application is written in Ruby on Rails (ROR) and will have the following features!</p>
<ul>
<li>admin user to update and edit</li>
<li>book grabber from amazon (enter the ISBN and all the data is entered automagicly -including the image of the front cover-)</li>
<li>search by author, category ,book title or publisher</li>
<li>list or grid view</li>
<li>sexy smart looking with a very clean interface!</li>
<li>rate books</li>
<li>wish list</li>
<li>mark as borrowed with the borrowers name</li>
</ul>
<p>I have registered a project at sourceforge.com and will upload the source as soon as the project is approved!</p>
<p>here are a couple of screen shots:</p>
<p><a class="imagelink" title="books grid view" href="http://www.azein.com/blog/wp-content/uploads/2006/11/books-grid.png"><img width="328" height="206" id="image35" alt="books grid view" src="http://www.azein.com/blog/wp-content/uploads/2006/11/books-grid.png" /></a></p>
<p><a class="imagelink" title="books list view" href="http://www.azein.com/blog/wp-content/uploads/2006/11/books-list.png"><img width="331" height="210" id="image36" alt="books list view" src="http://www.azein.com/blog/wp-content/uploads/2006/11/books-list.png" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://ahmed.elze.in/blog/2006/11/26/my-first-open-source-project/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

