<?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>ibananti&#039;s blog &#187; web</title>
	<atom:link href="http://blog.boyandi.net/category/web/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.boyandi.net</link>
	<description>notes about ui, web development, visualization. links, tips and tricks</description>
	<lastBuildDate>Tue, 29 Jun 2010 15:11:25 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Processing.js</title>
		<link>http://blog.boyandi.net/2009/03/19/processingjs/</link>
		<comments>http://blog.boyandi.net/2009/03/19/processingjs/#comments</comments>
		<pubDate>Thu, 19 Mar 2009 14:22:57 +0000</pubDate>
		<dc:creator>Ilya Boyandin</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[visualization]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://blog.boyandi.net/?p=16</guid>
		<description><![CDATA[John Resig released a port of the Processing language to JavaScript. The demos are very inspiring.

]]></description>
			<content:encoded><![CDATA[<p>John Resig <a href="http://ejohn.org/blog/processingjs/">released</a> a port of the <a href="http://processing.org/">Processing language</a> to JavaScript. The demos are very inspiring.</p>
<p><a href="http://ejohn.org/apps/processing.js/examples/custom/snake.html"><img src="http://ejohn.org/apps/processing.js/screens/Picture%2015.png" title="Snake" alt="Snake" border="0" width="320" height="240" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.boyandi.net/2009/03/19/processingjs/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Problems with Hibernate</title>
		<link>http://blog.boyandi.net/2009/02/17/problems-with-hibernate/</link>
		<comments>http://blog.boyandi.net/2009/02/17/problems-with-hibernate/#comments</comments>
		<pubDate>Tue, 17 Feb 2009 14:17:06 +0000</pubDate>
		<dc:creator>Ilya Boyandin</dc:creator>
				<category><![CDATA[db]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://blog.boyandi.net/?p=15</guid>
		<description><![CDATA[After 8 months of development of a new project with extensive use of Hibernate I can now tell about my experiences with it. In general, Hibernate is a very useful tool. It saves a lot of time, because you don&#8217;t have to write SQL queries. If you make changes, you usually don&#8217;t have to rewrite [...]]]></description>
			<content:encoded><![CDATA[<p>After 8 months of development of a new project with extensive use of Hibernate I can now tell about my experiences with it. In general, Hibernate is a very useful tool. It saves a lot of time, because you don&#8217;t have to write SQL queries. If you make changes, you usually don&#8217;t have to rewrite queries, because there are only a few of them. The configuration using annotations is simple and powerful (and I personally prefer it to writing mappings in XML). Hibernate is able to generate database tables from mapped classes automatically and even update them as you add new fields to a class. Hibernate caching facilities are very useful. Finally, Hibernate allows to develop database vendor indepentent applications.</p>
<p>But there are few problems which I experienced:</p>
<ol>
<li>The most frustrating is in fact <a href="http://www.hibernate.org/hib_docs/reference/en/html/performance.html#performance-fetching-proxies">described in the Hibernate docs</a>. An object returned by session.load() isn&#8217;t necessarily an object of the expected class:

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">Cat cat <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>Cat<span style="color: #009900;">&#41;</span> session.<span style="color: #006633;">load</span><span style="color: #009900;">&#40;</span>Cat.<span style="color: #000000; font-weight: bold;">class</span>, id<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// instantiate a proxy (does not hit the db)</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>cat.<span style="color: #006633;">isDomesticCat</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>                  <span style="color: #666666; font-style: italic;">// hit the db to initialize the proxy</span>
    DomesticCat dc <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>DomesticCat<span style="color: #009900;">&#41;</span> cat<span style="color: #339933;">;</span>       <span style="color: #666666; font-style: italic;">// Error!</span>
    ....
<span style="color: #009900;">&#125;</span></pre></div></div>

</li>
<li>No inheritance mapping for value objects: here is the <a href="http://opensource.atlassian.com/projects/hibernate/browse/HHH-1152">JIRA issue</a> that never gets fixed, and a <a href="http://priyanshugoyal.wordpress.com/2007/11/15/hibernate-component-value-object-inheritance-mapping/">workaround</a>.</li>
<li>The strong <a href="http://www.hibernate.org/hib_docs/annotations/reference/en/html/entity.html#entity-mapping-association-collections">suggestion in the Hibernate documentation</a> to use a join table for every unidirectional one-to-many association (in the section 2.2.5.3.2.2. &#8220;Unidirectional&#8221;). Another suggestion <a href="http://forum.hibernate.org/viewtopic.php?t=954178&amp;highlight=unidirectional+null+foriegn+foreign+key">is discussed here</a>.</li>
<li>2nd level caching should be used with caution: after deleting an object the stale version can still stay in cache which can lead to an ObjectNotFoundException. I found no other solution except disabling the 2nd level cache for the class.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://blog.boyandi.net/2009/02/17/problems-with-hibernate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Werkzeug allows debugging a web app directly on an error page</title>
		<link>http://blog.boyandi.net/2008/05/12/werkzeug/</link>
		<comments>http://blog.boyandi.net/2008/05/12/werkzeug/#comments</comments>
		<pubDate>Mon, 12 May 2008 10:37:49 +0000</pubDate>
		<dc:creator>Ilya Boyandin</dc:creator>
				<category><![CDATA[python]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://blog.boyandi.net/?p=13</guid>
		<description><![CDATA[At the Grazer Linuxtage I liked most the Armin Ronacher&#8217;s talk about Werkzeug which is a Python library for building web applications that doesn&#8217;t limit you in the way you build your web app (like many of the existing frameworks do). Werkzeug is rather a handy set of tools and utilities for making web apps [...]]]></description>
			<content:encoded><![CDATA[<p>At the <a href="http://www.linuxtage.at/">Grazer Linuxtage</a> I liked most the <a href="http://glt08.linuxtage.at/slides/glt08-ronacher_werkzeug_en.pdf">Armin Ronacher&#8217;s talk</a> about <a href="http://werkzeug.pocoo.org/">Werkzeug</a> which is a Python library for building web applications that doesn&#8217;t limit you in the way you build your web app (like many of the existing frameworks do). Werkzeug is rather a handy set of tools and utilities for making web apps than a framework.</p>
<p>The most impressive part of the talk was when Armin demonstrated the &#8220;online&#8221; debugging feature on a standard error page generated by Werkzeug. Upon each error the context in which it happens is stored on the server (only if the app is in the debug mode). Thus on the error page itself you can directly interact with the Python interpreter which is &#8220;frozen&#8221; in the very state in which the error happened. So you can use the full power of the interactive Python interpreter directly on the standard error page. That&#8217;s awesome.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.boyandi.net/2008/05/12/werkzeug/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JSP recursion</title>
		<link>http://blog.boyandi.net/2007/11/21/jsp-recursion/</link>
		<comments>http://blog.boyandi.net/2007/11/21/jsp-recursion/#comments</comments>
		<pubDate>Wed, 21 Nov 2007 15:44:14 +0000</pubDate>
		<dc:creator>Ilya Boyandin</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://blog.boyandi.net/?p=11</guid>
		<description><![CDATA[If you need to render a tree-like structure here&#8217;s a way of implementing recursion in JSP/JSTL:

${node.title}
&#60;div class=&#34;children&#34;&#62;
&#60;c:forEach var=&#34;node&#34; items=&#34;${node.children}&#34;&#62;
	&#60;c:set var=&#34;node&#34; value=&#34;${node}&#34; scope=&#34;request&#34;/&#62;
	&#60;jsp:include page=&#34;node.jsp&#34;/&#62;
&#60;/c:forEach&#62;
&#60;/div&#62;

The tricky thing is that when you use jsp:include (and for recursion you have to use the dynamic inclusion), normally, you loose all the variables defined in the parent JSP. But if you [...]]]></description>
			<content:encoded><![CDATA[<p>If you need to render a tree-like structure here&#8217;s a way of implementing recursion in JSP/JSTL:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">${node.title}
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;children&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;c:forEach</span> <span style="color: #000066;">var</span>=<span style="color: #ff0000;">&quot;node&quot;</span> <span style="color: #000066;">items</span>=<span style="color: #ff0000;">&quot;${node.children}&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;c:set</span> <span style="color: #000066;">var</span>=<span style="color: #ff0000;">&quot;node&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;${node}&quot;</span> <span style="color: #000066;">scope</span>=<span style="color: #ff0000;">&quot;request&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;jsp:include</span> <span style="color: #000066;">page</span>=<span style="color: #ff0000;">&quot;node.jsp&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/c:forEach<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>The tricky thing is that when you use jsp:include (and for recursion you have to use the dynamic inclusion), normally, you loose all the variables defined in the parent JSP. But if you redefine the variables you need in the &#8220;request&#8221; scope, then they will be visible in the included JSP too. I assumed that this very JSP is named &#8220;node.jsp&#8221; and omitted the declarations. Surprisingly, I found neither this nor any other solution on the Web, so I had to invent one.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.boyandi.net/2007/11/21/jsp-recursion/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Processing rolling logfiles backwards with Perl</title>
		<link>http://blog.boyandi.net/2007/11/05/processing-rolling-logfiles-with-perl/</link>
		<comments>http://blog.boyandi.net/2007/11/05/processing-rolling-logfiles-with-perl/#comments</comments>
		<pubDate>Mon, 05 Nov 2007 10:14:07 +0000</pubDate>
		<dc:creator>Ilya Boyandin</dc:creator>
				<category><![CDATA[perl]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://blog.boyandi.net/?p=10</guid>
		<description><![CDATA[I needed to write a script which runs on the server, gets daily statistics from our rolling log files and sends them by email. The log is splitted into 64Mb files and the total size is limited by 1GB. I didn&#8217;t want to parse the whole gigabyte of logs, so I decided to start from [...]]]></description>
			<content:encoded><![CDATA[<p>I needed to write a script which runs on the server, gets daily statistics from our rolling log files and sends them by email. The log is splitted into 64Mb files and the total size is limited by 1GB. I didn&#8217;t want to parse the whole gigabyte of logs, so I decided to start from the most recent file and read it in the backward order till the previous date. I found two approaches to read file backwards with perl. The first approach is slower but requires a fixed amount of memory (in my case about 2 mins and up to 16Mb RAM):</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #000066;">tie</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">@lines</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;Tie::File&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$fname</span><span style="color: #339933;">,</span> mode <span style="color: #339933;">=</span><span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">or</span> <span style="color: #000066;">die</span> <span style="color: #ff0000;">&quot;Can't tie $fname: $!&quot;</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">$max_lines</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$#lines</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$i</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$max_lines</span><span style="color: #339933;">;</span> <span style="color: #0000ff;">$i</span><span style="color: #339933;">;</span> <span style="color: #0000ff;">$i</span><span style="color: #339933;">--</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #b1b100;">not</span> <span style="color: #0000ff;">&amp;amp</span><span style="color: #339933;">;</span><span style="color: #0000ff;">$apply</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$lines</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000066;">return</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The second approach is faster but requires at least as much available memory as the size of the log file, in fact more than twice as much when processing several files one by one (in my case, 1:02 min and up to 150Mb RAM):</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #000066;">open</span><span style="color: #009900;">&#40;</span>LOG<span style="color: #339933;">,</span> <span style="color: #0000ff;">$fname</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">or</span> <span style="color: #000066;">die</span> <span style="color: #ff0000;">&quot;Can't open $fname: $!&quot;</span><span style="color: #339933;">;;</span>
<span style="color: #0000ff;">@lines</span> <span style="color: #339933;">=</span> <span style="color: #000066;">reverse</span> <span style="color: #0000ff;">&amp;lt</span><span style="color: #339933;">;</span>LOG<span style="color: #0000ff;">&amp;gt</span><span style="color: #339933;">;;</span>
<span style="color: #b1b100;">foreach</span> <span style="color: #0000ff;">$line</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">@lines</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000066;">chomp</span> <span style="color: #0000ff;">$line</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #b1b100;">not</span> <span style="color: #0000ff;">&amp;amp</span><span style="color: #339933;">;</span><span style="color: #0000ff;">$apply</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$line</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000066;">close</span><span style="color: #009900;">&#40;</span>LOG<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000066;">return</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000066;">close</span><span style="color: #009900;">&#40;</span>LOG<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>So I chose the first approach, because I thought that stable memory footprint on the server is more important than the time the script takes to complete. Here is the full code for the package I wrote that provides handy functions for scanning rolling logfiles forwards and backwards: <a href="http://blog.boyandi.net/wp-content/uploads/2007/10/logscan_pl.txt" title="logscan_pl.txt">logscan_pl.txt</a></p>
<p>And here is a usage sample:</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #000066;">require</span> <span style="color: #ff0000;">'logscan.pl'</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">$errors</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
logscan<span style="color: #339933;">::</span><span style="color: #006600;">scan</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Joanna&quot;</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">sub</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #0000ff;">$_</span> <span style="color: #339933;">=</span> <span style="color: #000066;">shift</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/(.*) INFO.*Returning error by [([^]]*)].*user=[([^]]*)].*roles=[([^]]*)]/</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">my</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$time</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$uri</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$user</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$role</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$1</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$2</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$3</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #0000ff;">$errors</span><span style="color: #339933;">++;</span>
		<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;$time $uri $user $rolen&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000066;">return</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\\</span>n<span style="color: #000099; font-weight: bold;">\\</span>nTotal errors: $errors<span style="color: #000099; font-weight: bold;">\\</span>n&quot;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.boyandi.net/2007/11/05/processing-rolling-logfiles-with-perl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
