<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-970528744702948483</id><updated>2011-11-11T13:58:15.159-08:00</updated><category term='articles'/><category term='clustering'/><category term='yahoo'/><category term='xml parsing'/><category term='erlang'/><category term='spawn'/><category term='function programming'/><category term='highavailability'/><category term='parsing'/><category term='ei'/><category term='http'/><category term='erlsom'/><category term='iolist'/><category term='binary'/><category term='xmerl'/><category term='bing'/><category term='gen_tcp'/><category term='tips'/><category term='rss'/><category term='tuning'/><category term='rabbitmq'/><category term='performance'/><category term='open standards'/><category term='strings'/><category term='c++'/><category term='scripts'/><category term='database'/><category term='object-oriented-design'/><category term='mnesia'/><category term='linux'/><category term='xml'/><category term='commandline'/><category term='feed'/><category term='messagequeue'/><category term='loops'/><category term='php'/><category term='auto-discovery'/><category term='howto'/><category term='programming'/><category term='ejabberd'/><category term='tutorial'/><category term='tcp'/><category term='ibrowse'/><category term='etop'/><category term='coding'/><category term='atom'/><category term='search'/><category term='microsoft'/><category term='ei_interface'/><category term='google'/><title type='text'>Concurrent future...</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://dudefrommangalore.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://dudefrommangalore.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Dude From Mangalore</name><uri>http://www.blogger.com/profile/11648794788677197501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>60</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-970528744702948483.post-2988384213775607673</id><published>2011-06-21T13:13:00.001-07:00</published><updated>2011-06-21T13:16:07.704-07:00</updated><title type='text'>Moving blog</title><content type='html'>I have moved my blog from here to &lt;a href="http://dudefrommangalore.wordpress.com/"&gt;wordpress&lt;/a&gt; for no apparent reason.  Using &lt;a href="http://feedburner.google.com"&gt;feedburner&lt;/a&gt; to make the &lt;a href="http://feeds.feedburner.com/DudefrommangaloresWeblog"&gt;subscription&lt;/a&gt; easier.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/970528744702948483-2988384213775607673?l=dudefrommangalore.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dudefrommangalore.blogspot.com/feeds/2988384213775607673/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=970528744702948483&amp;postID=2988384213775607673' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/2988384213775607673'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/2988384213775607673'/><link rel='alternate' type='text/html' href='http://dudefrommangalore.blogspot.com/2011/06/moving-blog.html' title='Moving blog'/><author><name>Dude From Mangalore</name><uri>http://www.blogger.com/profile/11648794788677197501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-970528744702948483.post-1806800968273016160</id><published>2010-10-14T12:38:00.000-07:00</published><updated>2010-10-14T12:48:40.802-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='function programming'/><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='php'/><title type='text'>PHP author(s) doesn't understand functional programming</title><content type='html'>PHP try to emulate functional programming by providing the functions like &lt;a href="http://www.php.net/manual/en/function.array-reduce.php"&gt;array_reduce&lt;/a&gt;. But what they lack is the knowledge of principals of functional programming.&lt;br /&gt;&lt;br /&gt;I had a problem where there are multiple arrays and need to be merged. array_merge function works only on 2 arrays. Merging multiple arrays need a for loop OR use array_reduce function [I thought]. But it turns out that array_reduce function is not functional as I imagined. Even though the documentation say that the last parameter to this function is the initial value for the array &lt;a href="http://en.wikipedia.org/wiki/Fold_%28higher-order_function%29"&gt;fold&lt;/a&gt; function, actually it is not.&lt;br /&gt;&lt;br /&gt;If the initial parameter is not an integer, PHP will default to zero. For the above problem I tried the following&lt;br /&gt;&lt;br /&gt;array_reduce($my_arrays, "array_merge", array());&lt;br /&gt;&lt;br /&gt;What I expected it is to work as&lt;br /&gt;&lt;br /&gt;$initial = array();&lt;br /&gt;foreach ( $my_arrays as $m ) { $initial = array_merge($initial, $m); }&lt;br /&gt;&lt;br /&gt;What I got was&lt;br /&gt;PHP Warning:  array_merge(): Argument #1 is not an array in Command line code on line 1&lt;br /&gt;PHP Warning:  array_merge(): Argument #1 is not an array in Command line code on line 1&lt;br /&gt;&lt;br /&gt;These kind of behavior will lead to serious problem in the system and is hard to debug.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/970528744702948483-1806800968273016160?l=dudefrommangalore.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dudefrommangalore.blogspot.com/feeds/1806800968273016160/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=970528744702948483&amp;postID=1806800968273016160' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/1806800968273016160'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/1806800968273016160'/><link rel='alternate' type='text/html' href='http://dudefrommangalore.blogspot.com/2010/10/php-authors-doesnt-understand.html' title='PHP author(s) doesn&apos;t understand functional programming'/><author><name>Dude From Mangalore</name><uri>http://www.blogger.com/profile/11648794788677197501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-970528744702948483.post-5251725372126044723</id><published>2010-10-10T11:58:00.000-07:00</published><updated>2010-10-10T12:27:42.204-07:00</updated><title type='text'>State of the Interview process</title><content type='html'>I have attended several interviews and also have interviewed several people. I have seen the difference between the people I interviewed with and the way I do interview.&lt;br /&gt;&lt;br /&gt;In the interviews I have given for several job positions at companies I don't want to mention here, most of the time I felt that the person who is interviewing me is not at all achieving his goal of the interview. What that person is trying to do is to prove to me that he/she is smarter than me in all respect.&lt;br /&gt;&lt;br /&gt;For me interview is a combination of 2 words "inter" and "view". That means exchanging views among people involved in the process. Thus what I expect is to have a debate on the subject in question. But mostly what happens is not a debate.&lt;br /&gt;&lt;br /&gt;In one interview, I was given a problem to solve. Instead of listening to my solution and to have a debate on my solution, the Interviewer was playing some game on this iPhone. I was explaning the solution to him and that person was not even listening to me. Instead he was trying to be an smart ass, saying your solution is wrong. My question is how can a solution be wrong if it can solve the problem. The solution may be not efficient enough. Nevertheless solution is never wrong. Other person may have different solution in mind (which may or may not be the efficient one), but still the purpose of the interview is not achieved.&lt;br /&gt;&lt;br /&gt;What I like to do when I am conducting an interview is not to prove that I am smarter than the interviewee (which I am :-)). What I am trying to gauge is the knowledge and the potential of the person opposite to me. I am a believer a person willing to learn and push his/her limit can do wonders. No one is born smart. Smartness is achieved by hard work and will to gain more knowledge. I always try to find a person who can fit into my immediate job description and is smart/hard working enough to achieve more in the near future.&lt;br /&gt;&lt;br /&gt;At least in the technology field, what I find is that interview is a lost cause. Most people are I interviewed with are trying to prove that they are smarter than me or they are the smartest people in the world. They are not even try to find if I can fit into the current job and can do more in the future.&lt;br /&gt;&lt;br /&gt;Another thing I try to achieve in the interview is the personality of the person I am interviewing. No matter how smart one is unless that person has the right attitude and the personality, he/she cannot fit into the team. It takes only one bad apple to disintegrate the whole basket of good apples. It is all about team work.&lt;br /&gt;&lt;br /&gt;Without a good team dynamics, it is not possible to achieve the long term goals. I takes ne person with wrong attitude in the a big team to lead the project to failure. What happens is that this person will demotivate others in the team. It is the responsibility of the manager solve this problem and also the responsibility of the team members to raise the issue. Again it is the responsibility of the manager to see the signs and take actions at the early stage.&lt;br /&gt;&lt;br /&gt;Having the social skills is equally important as the knowledge of the current field he/she is working in. Social skills refers to personality, how comfortable one can make others, how good of a team player one can be etc. etc.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/970528744702948483-5251725372126044723?l=dudefrommangalore.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dudefrommangalore.blogspot.com/feeds/5251725372126044723/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=970528744702948483&amp;postID=5251725372126044723' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/5251725372126044723'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/5251725372126044723'/><link rel='alternate' type='text/html' href='http://dudefrommangalore.blogspot.com/2010/10/state-of-interview-process.html' title='State of the Interview process'/><author><name>Dude From Mangalore</name><uri>http://www.blogger.com/profile/11648794788677197501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-970528744702948483.post-5651381322181007180</id><published>2010-09-09T14:01:00.001-07:00</published><updated>2010-09-09T14:09:13.755-07:00</updated><title type='text'>Content vs Ads</title><content type='html'>Looking at several websites known to provide content, I am wondering what is important for these websites.. Content or Ads.&lt;br /&gt;&lt;br /&gt;There was a time when I used to get ads within the content, but now a days I am searching for content within ads. Page is full of ads and somewhere hidden is a small pre-text of content. I have to click on several ads (or real links) to figure out what is the actual content. Most of the time I end up clicking on ads which look like content (thanks to Google adsense ads buried in the content). Google makes it easy for publishers to format the ads so that it looks like the content. "ads by Google" is like a fine-print in the terms of service notice. It is barely visible.&lt;br /&gt;&lt;br /&gt;Apart from them, even big names like CNN is also doing it but in a different way. They are displaying big banner ads at the top of the page which pushes the content below the first fold of the page. They make sure that y&lt;a href="http://3.bp.blogspot.com/_cGnNm7nFABs/TIlMU0CsB0I/AAAAAAAABQ8/7mBMxBtBlpM/s1600/cnn-window.png"&gt;&lt;img style="float: left; margin: 0pt 10px 10px 0pt; cursor: pointer; width: 320px; height: 194px;" src="http://3.bp.blogspot.com/_cGnNm7nFABs/TIlMU0CsB0I/AAAAAAAABQ8/7mBMxBtBlpM/s320/cnn-window.png" alt="" id="BLOGGER_PHOTO_ID_5515023139142895426" border="0" /&gt;&lt;/a&gt;ou view the ads.  Whether or not you click on the ads is not important, they are banner ads mostly used for brand awareness anyways.&lt;br /&gt;&lt;br /&gt;Look at this page from CNN. Big BMW ad at the top of the page covering approximately 80% of the page.&lt;br /&gt;&lt;br /&gt;Only title of the article is viewable on the first fold of the content. Hello... I know the title of the article from the website (in this case Yahoo! Finance). I am here to read the content of the article. You are already making money by the content distribution. Please stop throwing the ads at my face...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/970528744702948483-5651381322181007180?l=dudefrommangalore.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dudefrommangalore.blogspot.com/feeds/5651381322181007180/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=970528744702948483&amp;postID=5651381322181007180' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/5651381322181007180'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/5651381322181007180'/><link rel='alternate' type='text/html' href='http://dudefrommangalore.blogspot.com/2010/09/content-vs-ads.html' title='Content vs Ads'/><author><name>Dude From Mangalore</name><uri>http://www.blogger.com/profile/11648794788677197501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_cGnNm7nFABs/TIlMU0CsB0I/AAAAAAAABQ8/7mBMxBtBlpM/s72-c/cnn-window.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-970528744702948483.post-5292521180236657788</id><published>2010-09-06T19:14:00.001-07:00</published><updated>2010-09-06T19:19:03.254-07:00</updated><title type='text'>Spelling checker in Craigslist</title><content type='html'>In-spite of being a market leader in listing business, I don't think craigslist understand anything about search. People do mistake while typing search term. So now a days it is absolutely necessary to have a spelling checker and correction service along with the search. It is missing in Craigslist. I found out today when I was searching for car. I typed "toyta car". Instead of giving no results and suggesting corrected spelling, it is threw just a no result page at my face.&lt;br /&gt;&lt;br /&gt;Now a days it is not hard to build spelling correction in the system. It is not required to build you own spelling correction system. There are lot of APIs available. BOSS API is one of the prominent one which does provide spelling correction API.&lt;br /&gt;&lt;br /&gt;http://boss.yahooapis.com/ysearch/spelling/v1/toyta+car?appid=&lt;your appid here&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/970528744702948483-5292521180236657788?l=dudefrommangalore.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dudefrommangalore.blogspot.com/feeds/5292521180236657788/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=970528744702948483&amp;postID=5292521180236657788' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/5292521180236657788'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/5292521180236657788'/><link rel='alternate' type='text/html' href='http://dudefrommangalore.blogspot.com/2010/09/spelling-checker-in-craigslist.html' title='Spelling checker in Craigslist'/><author><name>Dude From Mangalore</name><uri>http://www.blogger.com/profile/11648794788677197501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-970528744702948483.post-700701981695296836</id><published>2010-08-27T17:31:00.000-07:00</published><updated>2010-08-27T18:33:34.657-07:00</updated><title type='text'>HTML Message Ajax Design Pattern</title><content type='html'>Having more and more browsers supporting XMLHTTPRequest object to send the data to server and get the response from server without reloading the page, it is possible to refresh only a part of the page. There are various techniques to do this. One such technique is that the server send the XML back to the browser and the Javascript on the browser will convert the XML into HTML by creating the DOM nodes on the fly. This is useful but has some limitations.&lt;br /&gt;&lt;br /&gt; * If the Javascript is turned off, there is no graceful degradation of application&lt;br /&gt; * Since the Javascript is running on the browser (client side), changing the structure of the generated HTML is hard&lt;br /&gt; * This is not feasible when HTML generated is complex&lt;br /&gt;&lt;br /&gt;One can overcome these limitations by sending the HTML snippet in the response. Instead of sending the XML back to browser, generate the HTML on the server side itself. On the browser side, replace the content of the DOM node with the response HTML response from the server.&lt;br /&gt;&lt;br /&gt; If the Javascript is turned off on the browser, user will see at least the content of the HTML on the browser instead of just the XML content. So there is a graceful degradation of service on the client side&lt;br /&gt;&lt;br /&gt; If HTML generated need to be changed, application is not dependent on changing the Javascript and hoping that the client will reload the page and will get new Javascript. Even if the Javascript is changed, some web proxies may not pull the new Javascript, resulting in the browsers (clients) behind the proxies will continue to get the old Javascript and old HTML will get rendered.&lt;br /&gt;&lt;br /&gt; There are various frameworks like Symfony, Django make it possible to generate the complex HTML possible with least effort. In case the request is not made via XMLHTTPRequest, it is possible to send the whole page (with header, footer etc.) in the response. If the request is made via XMLHTTPRequest object, send the response without the layout decoration (just the HTML snippet). Javascript running on client side will replace the content of the DOM node as required.&lt;br /&gt;&lt;br /&gt; Take for example, there is an application where the page loaded has many graphics and only a part of the page changes when user take some action like filling a form for sending the email. It is absolutely unnecessary to generate the whole page again just for a simple action of sending an email. I will make an attempt to explain with the example of sending the feedback via a form embedded in the page. I will try to explain this with PHP Symfony framework and Javascript (AJAX).&lt;br /&gt;&lt;br /&gt; The URL for the page is /new-page. This page has a feedback form in it. The action of this form is handled by /feedback. Server side code for /feedback expect a form having a text content, sends an email to the product manager and send same page as new-page but replacing the form with thank you note.&lt;br /&gt;&lt;br /&gt;Below is a code for the new-page action.&lt;br /&gt;&lt;script src="http://gist.github.com/554498.js"&gt; &lt;/script&gt;&lt;br /&gt;&lt;br /&gt;Code for new-page response.&lt;br /&gt;&lt;script src="http://gist.github.com/554496.js"&gt; &lt;/script&gt;&lt;br /&gt;&lt;br /&gt;Now is the magic of jQuery Javascript library to submit the content to /feedback url and use the response content to replace the HTML form.&lt;br /&gt;&lt;br /&gt;&lt;script src="http://gist.github.com/554508.js?file=feedback-form-javascript.js"&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;Server side code for handling the post from the browser to /feedback &lt;br /&gt;&lt;br /&gt;&lt;script src="http://gist.github.com/554511.js?file=feedback-handler-action.php"&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;HTML response from /feedback&lt;br /&gt;&lt;script src="http://gist.github.com/554513.js?file=feedback-handler-response.html"&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;In Symfony framework it is possible disable/enable the layout during run-time via setLayout() method of sfAction instance. Setting the parameter to false will disable the layout and send only the content of the action template back to the caller.&lt;br /&gt;&lt;br /&gt;There you go.. A simple way to improve the usability of the site even without Javascript support.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/970528744702948483-700701981695296836?l=dudefrommangalore.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dudefrommangalore.blogspot.com/feeds/700701981695296836/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=970528744702948483&amp;postID=700701981695296836' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/700701981695296836'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/700701981695296836'/><link rel='alternate' type='text/html' href='http://dudefrommangalore.blogspot.com/2010/08/html-message-ajax-design-pattern.html' title='HTML Message Ajax Design Pattern'/><author><name>Dude From Mangalore</name><uri>http://www.blogger.com/profile/11648794788677197501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-970528744702948483.post-5273660419628573581</id><published>2010-08-25T16:58:00.001-07:00</published><updated>2010-08-25T17:02:27.874-07:00</updated><title type='text'>Execute action within another action</title><content type='html'>In the current project I am working on (using Symfony framework), I came across a situation where I had to call one action within another action and capture the content of 2nd action. This content is included within the result from 1st action. After doing some research found that it it possible to do so by calling getPresentationFor method of the controller object.&lt;br /&gt;&lt;br /&gt;Within the action's execute method,&lt;br /&gt;&lt;br /&gt;  $content = $this-&gt;getController()-&gt;getPresentationFor($module, 'my2ndAction');&lt;br /&gt;  $this-&gt;content = $content;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/970528744702948483-5273660419628573581?l=dudefrommangalore.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dudefrommangalore.blogspot.com/feeds/5273660419628573581/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=970528744702948483&amp;postID=5273660419628573581' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/5273660419628573581'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/5273660419628573581'/><link rel='alternate' type='text/html' href='http://dudefrommangalore.blogspot.com/2010/08/execute-action-within-another-action.html' title='Execute action within another action'/><author><name>Dude From Mangalore</name><uri>http://www.blogger.com/profile/11648794788677197501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-970528744702948483.post-4346156070985124279</id><published>2010-08-05T23:17:00.000-07:00</published><updated>2010-08-05T23:21:04.895-07:00</updated><title type='text'>File System Over SSH</title><content type='html'>Some of the development I am doing require me to do the development on some remote machine. Since the development is done in Java, I need Eclipse environment. On the remote system I cannot run Eclipse as it is a server box and does not have display attached to it. I found an elegant solution for this. Thanx for &lt;a href="http://www.macfusionapp.org/"&gt;Macfusion&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;I can mount remote machine's directory on my local machine and work as if it is a local directory. All the dirty work of communication is taken care. I don't need nfs mounting which is not secure. Macfusion let me mount the directory on remote machine over ssh&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/970528744702948483-4346156070985124279?l=dudefrommangalore.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dudefrommangalore.blogspot.com/feeds/4346156070985124279/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=970528744702948483&amp;postID=4346156070985124279' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/4346156070985124279'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/4346156070985124279'/><link rel='alternate' type='text/html' href='http://dudefrommangalore.blogspot.com/2010/08/file-system-over-ssh.html' title='File System Over SSH'/><author><name>Dude From Mangalore</name><uri>http://www.blogger.com/profile/11648794788677197501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-970528744702948483.post-5367514243832519366</id><published>2010-07-11T12:21:00.000-07:00</published><updated>2010-08-24T10:01:24.103-07:00</updated><title type='text'>Why Erlang scares managers?</title><content type='html'>Managing is all about control. Managing is about knowing (almost) everything about what one is controlling. If the team is using something manager don't understand or willing to understand, manager is loosing control. Again it is all about control. &lt;br /&gt;&lt;br /&gt;99% of managers are comfortable with technologies like PHP, Java etc. Languages with new ideas like Erlang, LISP are far fetched for many managers. They don't want to learn about these new technologies or new ideas. Having these new technologies in the team force them to come out of the comfort zone and take the control away from them. This is not a good news for them. One argument I have heard every time I make a case for why Erlang (is better in-terms of hardware utilization and lines of code) is that "It is hard to hire Erlang developers than PHP/Java developers'. As I see competent developers want to learn new things than putting themselves in the same-old-same-old world. Competent developers are capable of learning new technologies and new ideas. &lt;br /&gt;&lt;br /&gt;Off course, there is a initial learning curve. It is always there anywhere you go. Developers/Engineers need to learn the new way of doing things anywhere they go. Some companies are willing to give more time to developers to get familiar with the internal technologies and some don't. But it is a absolute necessity. Everyone does not follow the same development methods or procedures. In a big organization, this changes from group to group.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/970528744702948483-5367514243832519366?l=dudefrommangalore.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dudefrommangalore.blogspot.com/feeds/5367514243832519366/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=970528744702948483&amp;postID=5367514243832519366' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/5367514243832519366'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/5367514243832519366'/><link rel='alternate' type='text/html' href='http://dudefrommangalore.blogspot.com/2010/07/why-erlang-scares-managers.html' title='Why Erlang scares managers?'/><author><name>Dude From Mangalore</name><uri>http://www.blogger.com/profile/11648794788677197501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-970528744702948483.post-4943430942910220984</id><published>2010-06-27T15:07:00.000-07:00</published><updated>2010-06-27T15:10:43.165-07:00</updated><title type='text'>To stay or to leave....</title><content type='html'>There comes a time when one has to stop doing the things one was doing for along time. It is hard to do that... Sometime it feels it is impossible.. Some people lack courage to do that, some people lack motivation and for some people situation don't let them.. &lt;br /&gt;&lt;br /&gt;Once the decision is taken, is it possible to revert that decision.. Yes.. I think it is possible to that. Question is what it the cost of reverting the decision. I don't think it is much..&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/970528744702948483-4943430942910220984?l=dudefrommangalore.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dudefrommangalore.blogspot.com/feeds/4943430942910220984/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=970528744702948483&amp;postID=4943430942910220984' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/4943430942910220984'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/4943430942910220984'/><link rel='alternate' type='text/html' href='http://dudefrommangalore.blogspot.com/2010/06/to-stay-or-to-leave.html' title='To stay or to leave....'/><author><name>Dude From Mangalore</name><uri>http://www.blogger.com/profile/11648794788677197501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-970528744702948483.post-6030984251897397901</id><published>2010-04-20T15:14:00.000-07:00</published><updated>2010-04-20T15:15:21.306-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='programming'/><category scheme='http://www.blogger.com/atom/ns#' term='object-oriented-design'/><title type='text'>Dog is not Cat</title><content type='html'>While talking to my friend today, something struck me regarding the notion of object oriented programming, hierarchy of classes and how these concepts are over used.&lt;br /&gt;&lt;br /&gt;Objected oriented design is heavily used for thousands of years. For example, constructing a home. If you think about it, home is built in a very modular way (aka object oriented way). Every part of home is a object [door, window, wall, roof etc.]. They can be put together in many ways to construct a home. The final shape of home may change, but the the basic building blocks remain the same.&lt;br /&gt;&lt;br /&gt;Now to the point of using this in computer programming. I think object oriented programming is misunderstood in the software industry. People seems to confuse reusability of the code with object orientation. For example, take the hierarchy of animals. Animal is a base class, cat is derived from class Animal. Now let's say I want to declare a new class Dog. Since Dog class was not considered while implementing Cat class, common functionality of Animal (like see, listen etc.) are implemented in Cat class. Now when one want to design Dog class, since Cat already has the functionalities required by Dog, derive Dog from Cat. This is so wrong. Logically when you derive one class from another, you are implying "is-a" relation. That means, by deriving Dog from Cat [just because you have functionality required by Dog is implemented in Cat], you are implying that Dog is a Cat. &lt;br /&gt;&lt;br /&gt;Cases like these, it is better to sit back and think a little. May be code re-factoring will help here. One can move the functionalities that are required by both Dog and Cat [may be Elephant, Tiger etc.] can be moved into the Animal class and implement those functionalities in terms of some abstract concepts like eyes, legs, ears etc.&lt;br /&gt;&lt;br /&gt;Now enough of messing your brain.. Go back to work and start thinking about the designs you have done earlier and how you could have done it better [not that what you did earlier was wrong].&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/970528744702948483-6030984251897397901?l=dudefrommangalore.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dudefrommangalore.blogspot.com/feeds/6030984251897397901/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=970528744702948483&amp;postID=6030984251897397901' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/6030984251897397901'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/6030984251897397901'/><link rel='alternate' type='text/html' href='http://dudefrommangalore.blogspot.com/2010/04/dog-is-not-cat.html' title='Dog is not Cat'/><author><name>Dude From Mangalore</name><uri>http://www.blogger.com/profile/11648794788677197501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-970528744702948483.post-8220837191461674206</id><published>2010-01-30T12:33:00.000-08:00</published><updated>2010-01-30T12:43:46.584-08:00</updated><title type='text'>Hacking search suggestions</title><content type='html'>Opensearch specification has extension for &lt;a href="http://www.opensearch.org/Specifications/OpenSearch/Extensions/Suggestions/1.1"&gt;search suggestions&lt;/a&gt;. Major search providers have their own search suggestion entry points. After looking doing a search of my own, I found the entry points for the 3 major search providers&lt;br /&gt;&lt;br /&gt;Bing - http://api.search.live.com/osjson.aspx?query={Search Term}&lt;br /&gt;Google - http://suggestqueries.google.com/complete/search?q={Search Term}&amp;client=firefox&lt;br /&gt;Yahoo - http://ff.search.yahoo.com/gossip?output=fxjson&amp;command={searchTerms}&lt;br /&gt;&lt;br /&gt;For Google entry point, removing client parameter will also provide the number of results in the response. This format is not as per the Opensearch standards.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/970528744702948483-8220837191461674206?l=dudefrommangalore.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dudefrommangalore.blogspot.com/feeds/8220837191461674206/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=970528744702948483&amp;postID=8220837191461674206' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/8220837191461674206'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/8220837191461674206'/><link rel='alternate' type='text/html' href='http://dudefrommangalore.blogspot.com/2010/01/hacking-search-suggestions.html' title='Hacking search suggestions'/><author><name>Dude From Mangalore</name><uri>http://www.blogger.com/profile/11648794788677197501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-970528744702948483.post-4316316884402013485</id><published>2010-01-30T12:01:00.000-08:00</published><updated>2010-01-30T12:06:18.581-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='atom'/><category scheme='http://www.blogger.com/atom/ns#' term='bing'/><category scheme='http://www.blogger.com/atom/ns#' term='yahoo'/><category scheme='http://www.blogger.com/atom/ns#' term='search'/><category scheme='http://www.blogger.com/atom/ns#' term='google'/><category scheme='http://www.blogger.com/atom/ns#' term='open standards'/><category scheme='http://www.blogger.com/atom/ns#' term='microsoft'/><category scheme='http://www.blogger.com/atom/ns#' term='feed'/><category scheme='http://www.blogger.com/atom/ns#' term='rss'/><category scheme='http://www.blogger.com/atom/ns#' term='auto-discovery'/><title type='text'>Who is more open? Google or Yahoo or Bing?</title><content type='html'>While looking at the search result page HTML from Google, Yahoo and Bing, I discovered that Google does not add &lt;a href="http://jeremy.zawodny.com/blog/archives/000967.html"&gt;auto discovery&lt;/a&gt; to its search result page. Where as Yahoo and Bing does. &lt;br /&gt;&lt;br /&gt;That makes me wonder why Yahoo and Bing does not get as much credit as Google for adopting the open technologies/standards?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/970528744702948483-4316316884402013485?l=dudefrommangalore.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dudefrommangalore.blogspot.com/feeds/4316316884402013485/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=970528744702948483&amp;postID=4316316884402013485' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/4316316884402013485'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/4316316884402013485'/><link rel='alternate' type='text/html' href='http://dudefrommangalore.blogspot.com/2010/01/who-is-more-open-google-or-yahoo-or.html' title='Who is more open? Google or Yahoo or Bing?'/><author><name>Dude From Mangalore</name><uri>http://www.blogger.com/profile/11648794788677197501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-970528744702948483.post-3786791321843353658</id><published>2010-01-22T15:34:00.000-08:00</published><updated>2010-01-22T18:04:41.459-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='performance'/><category scheme='http://www.blogger.com/atom/ns#' term='http'/><category scheme='http://www.blogger.com/atom/ns#' term='howto'/><category scheme='http://www.blogger.com/atom/ns#' term='erlang'/><category scheme='http://www.blogger.com/atom/ns#' term='tutorial'/><title type='text'>http request pipeline in Erlang</title><content type='html'>I tried to use Erlang's http module for high concurrent requests. It was not performing well due to pipelining and persistent connection issues. This seems to be solved in R13 version. I figured out how to use the http profiles to do selective pipelining/persistent connections to one server but not for others [if application is sending requests to multiple hosts].&lt;br /&gt;&lt;br /&gt;First step in the process is to create a new http profile. It can be done in 2 ways. First one is to run a stand along http connection manager (httpc_manager).&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="erl"&gt;&lt;br /&gt;{ok, Pid} = inets:start( httpc, [{profile, other}] ).&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;As per the documentation, this is not desirable as all benefits of OTP framework is lost.&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;Dynamically started services will not be handled by application takeover and failover behavior when inets is run as a distributed application. Nor will they be automatically restarted when the inets application is restarted, but as long as the inets application is up and running they will be supervised and may be soft code upgraded. Services started as stand_alone, e.i. the service is not started as part of the inets application, will lose all OTP application benefits such as soft upgrade. The "stand_alone-service" will be linked to the process that started it. In most cases some of the supervision functionality will still be in place and in some sense the calling process has now become the top supervisor&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;2nd method is to run it as a part of inets application via configuration file&lt;br /&gt;&lt;br /&gt;Have a config file with the following content (say inets.config)&lt;br /&gt;&lt;pre name="code" class="erl"&gt;&lt;br /&gt;[{inets, &lt;br /&gt;[{services,[{httpc,[{profile, server1}]},&lt;br /&gt;            {httpc, [{profile, server2}]}]}]&lt;br /&gt;}].&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Run the erlang shell as &lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;erl -config inets.config&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;This will start 3 http profiles [server1, server2 and default]. &lt;br /&gt;&lt;br /&gt;Now the question is how to use the newly created profiles. Let's say the application is using 2 web services hosted at foo1.example.com and foo2.example.com. Web service hosted at foo1.example.com is hosted on a web server which can support lot of persistent connections [keep alive connections]. Web service hosted foo2.example.com is hosted on a normal web server which is not optimized for large number of persistent connectinons.&lt;br /&gt;&lt;br /&gt;In the application set the profile for server1 for the connections to foo1.example.com. This can be done by changing the http options  listed &lt;a href="http://www.erlang.org/doc/man/http.html#set_options-1"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="erl"&gt;&lt;br /&gt;http:set_options([{max_sessions, 20}, {pipeline_timeout, 20000}], server1).&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;NOTE:&lt;/span&gt;It is required to set the pipeline timeout in order to enable &lt;a href="http://en.wikipedia.org/wiki/HTTP_pipelining"&gt;http pipelining&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Profile can be specified during the request time.&lt;br /&gt;&lt;br /&gt;&lt;pre class="code" name="erl"&gt;&lt;br /&gt;http:request( "http://foo1.example.com/v1/get_info/dudefrommangalore", server1).&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;There is no interface provided by httpc_manager or inets to get the info on the number of sessions open to a server.  But good news is that the session information is kept in the ets table. One can query the ets table to get the list of persistent connections.&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="erl"&gt;&lt;br /&gt;ets:tab2list(httpc_manager_server1_session_db).&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Output is something like&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;{tcp_session,{{"fo11.example.com",80},&lt;br /&gt;               &lt;0.103.0&gt;},&lt;br /&gt;              false,http,#Port&lt;0.1032&gt;,...}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;0.103.0&gt; is a Pid of httpc_handler gen server process. It is possible to get the status of this process via standard OTP sys module.&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="erl"&gt;&lt;br /&gt;sys:get_status(erlang:list_to_pid("&lt;0.103.0&gt;")).&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;It is also possible to get all the pipelined requests on each persistent connections. For that it is necessary to get the pid of the httpc_manager via inets:services_info(). This call will return the pid of the httpc_manager.&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="erl"&gt;&lt;br /&gt;[{httpc,&lt;0.52.0&gt;,[{profile,server1}]},&lt;br /&gt; {httpc,&lt;0.53.0&gt;,[{profile,server2}]},&lt;br /&gt; {httpc,&lt;0.41.0&gt;,[{profile,default}]}]&lt;br /&gt;&lt;/pre&gt; &lt;br /&gt;&lt;br /&gt;From the pid, get the status of httpc_manager gen server process.&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="erl"&gt;&lt;br /&gt;sys:get_status(erlang:list_to_pid( "&lt;0.52.0&gt;")).&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;ets table name is in bold here.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;15&gt; sys:get_status(erlang:list_to_pid("&lt;0.52.0&gt;")).&lt;br /&gt;{status,&lt;0.52.0&gt;,&lt;br /&gt;        {module,gen_server},&lt;br /&gt;        [[{'$ancestors',[httpc_profile_sup,httpc_sup,inets_sup,&lt;br /&gt;                         &lt;0.36.0&gt;]},&lt;br /&gt;          {'$initial_call',{httpc_manager,init,1}}],&lt;br /&gt;         running,&lt;0.40.0&gt;,[],&lt;br /&gt;         [httpc_manager_server1,&lt;br /&gt;          {state,[],&lt;span style="font-weight:bold;"&gt;24596&lt;/span&gt;,&lt;br /&gt;                 {undefined,28693},&lt;br /&gt;                 httpc_manager_server1_session_db,httpc_manager_server1,&lt;br /&gt;                 {options,{undefined,[]},&lt;br /&gt;                          0,2,5,120000,2,disabled,false,inet,default,...}},&lt;br /&gt;          httpc_manager,infinity]]}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Get the content of the ets table to get the pipelined connection&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="erl"&gt;&lt;br /&gt;ets:tab2list(24596).&lt;br /&gt;&lt;/pre&gt; &lt;br /&gt;&lt;br /&gt;Application can tune the http options to utilize the network bandwidth better, get the most of the machine and network.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/970528744702948483-3786791321843353658?l=dudefrommangalore.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dudefrommangalore.blogspot.com/feeds/3786791321843353658/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=970528744702948483&amp;postID=3786791321843353658' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/3786791321843353658'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/3786791321843353658'/><link rel='alternate' type='text/html' href='http://dudefrommangalore.blogspot.com/2010/01/http-request-pipeline-in-erlang.html' title='http request pipeline in Erlang'/><author><name>Dude From Mangalore</name><uri>http://www.blogger.com/profile/11648794788677197501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-970528744702948483.post-4696605595262363909</id><published>2010-01-19T16:22:00.000-08:00</published><updated>2010-01-19T16:29:47.096-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='performance'/><category scheme='http://www.blogger.com/atom/ns#' term='erlang'/><title type='text'>Erlang process mailbox performance</title><content type='html'>I came across this performance issue in Erlang while doing the pattern matching against the mailbox [a.k.a. selective message processing]. Here is the orignal code:&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="erl"&gt;&lt;br /&gt;-module (perf).&lt;br /&gt;&lt;br /&gt;-export( [start/0] ).&lt;br /&gt;&lt;br /&gt;start() -&gt;&lt;br /&gt;  S = erlang:now(),&lt;br /&gt;  Pids = spawn_n(fun test/1, 10000, []),&lt;br /&gt;  wait(Pids),&lt;br /&gt;  E = erlang:now(),&lt;br /&gt;  io:format( "Total time: ~p~n", [timer:now_diff(E, S)/1000] ).&lt;br /&gt;&lt;br /&gt;spawn_n(_F, 0, Acc) -&gt; Acc;&lt;br /&gt;spawn_n(F, N, Acc) -&gt; &lt;br /&gt;  Me = self(),&lt;br /&gt;  Pid = spawn(fun() -&gt; F(Me) end),&lt;br /&gt;  spawn_n(F, N-1, [Pid|Acc]).&lt;br /&gt;&lt;br /&gt;test(Pid) -&gt; Pid ! {self(), ok}.&lt;br /&gt;&lt;br /&gt;wait([]) -&gt; ok;&lt;br /&gt;wait([Pid|Pids]) -&gt; &lt;br /&gt;    receive {Pid, ok} -&gt; ok end,&lt;br /&gt;    wait(Pids).&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Run time for perf:start() was 1.3 seconds&lt;br /&gt;&lt;br /&gt;Erlang (BEAM) emulator version 5.6.5 [source] [smp:2] [async-threads:0] [hipe] [kernel-poll:false]&lt;br /&gt;&lt;br /&gt;Eshell V5.6.5  (abort with ^G)&lt;br /&gt;1&gt; perf:start().&lt;br /&gt;Total time: 1368.038&lt;br /&gt;ok&lt;br /&gt;2&gt; &lt;br /&gt;&lt;br /&gt;Now I changed &lt;span style="font-weight:bold;"&gt;wait(Pids)&lt;/span&gt; to &lt;span style="font-weight:bold;"&gt;wait(lists:reverse(Pids))&lt;/span&gt;. After this change, run time for perf:start() was 83 milliseconds.&lt;br /&gt;&lt;br /&gt;1&gt; perf:start().&lt;br /&gt;Total time: 83.037&lt;br /&gt;ok&lt;br /&gt;&lt;br /&gt;15x improvement just by changing the way mailbox scan is done. &lt;br /&gt;&lt;br /&gt;Little things like this are usually overlooked and the language is blamed for the performance issues.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/970528744702948483-4696605595262363909?l=dudefrommangalore.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dudefrommangalore.blogspot.com/feeds/4696605595262363909/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=970528744702948483&amp;postID=4696605595262363909' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/4696605595262363909'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/4696605595262363909'/><link rel='alternate' type='text/html' href='http://dudefrommangalore.blogspot.com/2010/01/erlang-process-mailbox-performance.html' title='Erlang process mailbox performance'/><author><name>Dude From Mangalore</name><uri>http://www.blogger.com/profile/11648794788677197501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-970528744702948483.post-8111177393862212969</id><published>2010-01-18T13:54:00.000-08:00</published><updated>2010-01-29T19:15:28.976-08:00</updated><title type='text'>Concurrency in Java - Part 2</title><content type='html'>In the &lt;a href="http://dudefrommangalore.blogspot.com/2010/01/concurrency-in-java.html"&gt;earlier post&lt;/a&gt; I covered the basic cached thread pool. &lt;br /&gt;&lt;br /&gt;Another facility offered by Java's concurrency framework is to schedule a thread after certain time or at regular interval (like standard unix cron job). There are 2 ways to schedule the thread at regular interval. First one is to run a task at regular interval regardless of the previous job. Second one is to run a task and wait for the certain interval after the previous job is done.&lt;br /&gt;&lt;br /&gt;Second one is helpful in situation like crawlers. It is necessary to download the pages with some politeness factor [wait for sometime before downloading a page from the same website].&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;ScheduledExecutorService executionService = Executors.newScheduledThreadPool(2);&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Above code snippet create a pool of 2 threads. This service can schedule the threads at regular interval.&lt;br /&gt;&lt;br /&gt;ScheduledExecutorService provide a method schedule&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;Runnable task = new Runnable() {&lt;br /&gt;   public void run() {&lt;br /&gt;      System.out.println( "I am responsible for downloading a page" );&lt;br /&gt;      return;&lt;br /&gt;   }&lt;br /&gt;};&lt;br /&gt;/* TimeUnit is defined within java.util.concurrent package */&lt;br /&gt;Future&lt;?&gt; future = executionService.schedule(task, 2000, TimeUnit.MILLISECONDS);&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The above code schedule a task to run after 2 seconds [2000 milliseconds]. schedule method return a future object. This future object can be used to check the status of the task [isDone method] or to cancel the task [cancel method]. Read more about the future object and the methods available &lt;a href="http://java.sun.com/javase/6/docs/api/java/util/concurrent/Future.html"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;ScheduledExecutorService also support repeated execution of a task via scheduleAtFixedRate and scheduleWithFixedDelay.&lt;br /&gt;&lt;br /&gt;scheduleAtFixedRate method schedule the task at regular interval. This method does not check if the previously scheduled task is finshed or not.&lt;br /&gt;&lt;br /&gt;scheduleWithFixedDelay method is similar to scheduleAtFixedRate except that this method wait for the previous execution to finish, wait for the fixed interval and then schedule the task again.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/970528744702948483-8111177393862212969?l=dudefrommangalore.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dudefrommangalore.blogspot.com/feeds/8111177393862212969/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=970528744702948483&amp;postID=8111177393862212969' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/8111177393862212969'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/8111177393862212969'/><link rel='alternate' type='text/html' href='http://dudefrommangalore.blogspot.com/2010/01/concurrency-in-java-part-2.html' title='Concurrency in Java - Part 2'/><author><name>Dude From Mangalore</name><uri>http://www.blogger.com/profile/11648794788677197501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-970528744702948483.post-2098405236247038522</id><published>2010-01-17T19:03:00.000-08:00</published><updated>2010-01-18T00:05:10.389-08:00</updated><title type='text'>Concurrency in Java</title><content type='html'>Java 5.x introduced the concurrency framework. It make the life of developer easier to run multiple threads. This framework also take care of thread caching this reducing the number of spawned threads in the system.&lt;br /&gt;&lt;br /&gt;When the concepts of thread was introduced in the operating systems, it was considered light-weight processes. As the clock speed of the CPU is increasing dramatically and also number of CPU cores available for the programs are increasing, even this light-weight processes are deemed to costly to start. Thus introduced the concept of cached threads. Erlang solve this problem by introducing ultra-light-weight processes. Millions of such processes can be spawned within few seconds. This is not the case in kernel threads. Even when kernel threads are used, there is a cost of context switching to schedule those threads from wait state to run state.&lt;br /&gt;&lt;br /&gt;I am new to Java concurrency framework. So I am taking baby steps to learn to use the classes available in Java 5.x. All the concurrency related classes are in &lt;a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/package-summary.html"&gt;&lt;span style="font-weight:bold;"&gt;java.util.concurrent&lt;/span&gt;&lt;/a&gt; package.&lt;br /&gt;&lt;br /&gt;First step in start using these classes is to introduce Executors class. This class has several class methods to create thread pools.&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;import java.util.concurrent.Executors;&lt;br /&gt;import java.util.concurrent.ExecutorService;&lt;br /&gt;&lt;br /&gt;ExecutorService threadPool = Executors.newCachedThreadPool();&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The above code create a cached thread pool. Behavior of this thread pool is documented &lt;a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/Executors.html#newCachedThreadPool()"&gt;&lt;span style="font-weight:bold;"&gt;here&lt;/span&gt;&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;Creates a thread pool that creates new threads as needed, but will reuse previously constructed threads when they are available. These pools will typically improve the performance of programs that execute many short-lived asynchronous tasks. Calls to execute will reuse previously constructed threads if available. If no existing thread is available, a new thread will be created and added to the pool. Threads that have not been used for sixty seconds are terminated and removed from the cache. Thus, a pool that remains idle for long enough will not consume any resources. Note that pools with similar properties but different details (for example, timeout parameters) may be created using ThreadPoolExecutor constructors&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;A task can be submitted to the newly created thread pool for execution. A task must be an instance of Runnable interface. Submitting a task to the ExecutorService will return an instance of &lt;a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/Future.html"&gt;&lt;span style="font-weight:bold;"&gt;Future&lt;/span&gt;&lt;/a&gt; interface. This is a wrapper around the task submitted. This instance can be used to query the submitted task for completion, as well as to cancel the task.&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;&lt;br /&gt;Future&lt;?&gt; task = threadPool.submit( new Runnable() {&lt;br /&gt;       public void run() {&lt;br /&gt;          System.out.println( "Hello world from within the thread pool" );&lt;br /&gt;       }&lt;br /&gt;  });&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Finally wait for the task to be completed&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;  while ( !task.isDone() ) {&lt;br /&gt;  }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Once the task is completed and thread pool is no-longer necessary, send shutdown message to the thread pool to terminate all the threads created.&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;  threadPool.shutdown();&lt;br /&gt;  while (!thread.isTerminated()) {&lt;br /&gt;  }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;There it is. First Hello world code using the Concurrent Thread Pool in Java. As and when I learn new methods in this framework, I will write about that here.&lt;br /&gt;&lt;br /&gt;&lt;script src="http://gist.github.com/279874.js"&gt;&lt;/script&gt;&lt;br /&gt;&lt;br /&gt;Until then, happy thread pooling and utilizing all the cores on the system.&lt;br /&gt;&lt;br /&gt;Update: Download the source from &lt;span style="font-weight:bold;"&gt;&lt;a href="http://github.com/dudefrommangalore/Java-Concurrency/raw/master/src/org/baliga/java/concurrency/CachedThreads.java"&gt;here&lt;/a&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/970528744702948483-2098405236247038522?l=dudefrommangalore.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dudefrommangalore.blogspot.com/feeds/2098405236247038522/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=970528744702948483&amp;postID=2098405236247038522' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/2098405236247038522'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/2098405236247038522'/><link rel='alternate' type='text/html' href='http://dudefrommangalore.blogspot.com/2010/01/concurrency-in-java.html' title='Concurrency in Java'/><author><name>Dude From Mangalore</name><uri>http://www.blogger.com/profile/11648794788677197501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-970528744702948483.post-260061481956214398</id><published>2009-10-08T15:33:00.000-07:00</published><updated>2009-10-08T15:34:21.091-07:00</updated><title type='text'>What do you mean by giving more than 100%?</title><content type='html'>Here is a little something someone sent me that is _indisputable_ mathematical logic. (It also made me Laugh Out Loud.) &lt;br /&gt;&lt;br /&gt;Remember, this is a strictly mathematical viewpoint. It goes like this: &lt;br /&gt;&lt;br /&gt;What Makes 100%? What does it mean to give MORE than 100%? Ever wonder about those people who say they are giving more than 100%? We have all been to those meetings where someone wants you to give over 100%. How about achieving 103%? What makes up 100% in life? &lt;br /&gt;&lt;br /&gt;Here's a little mathematical formula that might help you answer these questions: &lt;br /&gt;&lt;br /&gt;If: &lt;br /&gt;A B C D E F G H I J K L M N O P Q R S T U V W X Y Z &lt;br /&gt;&lt;br /&gt;is represented as: &lt;br /&gt;1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26. &lt;br /&gt;&lt;br /&gt;Then: &lt;br /&gt;&lt;br /&gt;H-A-R-D-W-O-R-K &lt;br /&gt;8+1+18+4+23+15+18+11 = 98%* &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;and &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;K-N-O-W-L-E-D-G-E &lt;br /&gt;11+14+15+23+12+5+4+7+5= 96% &lt;br /&gt;&lt;br /&gt;But,* &lt;br /&gt;&lt;br /&gt;A-T-T-I-T-U-D-E &lt;br /&gt;1+20+20+9+20+21+4+5 = 100% &lt;br /&gt;&lt;br /&gt;And, &lt;br /&gt;&lt;br /&gt;B-U-L-L-S-H-I-T &lt;br /&gt;2+21+12+12+19+8+9+20 = 103% &lt;br /&gt;&lt;br /&gt;AND, look how far ass kissing will take you. &lt;br /&gt;&lt;br /&gt;A-S-S-K-I-S-S-I-N-G &lt;br /&gt;1+19+19+11+9+19+19+9+14+7 = 118% &lt;br /&gt;So, one can conclude with _mathematical certainty_, that while* Hardwork* and *Knowledge *will get you close, and* Attitude *will get you there, its the *Bullshit*  and *Ass kissing* that will put you over the top.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/970528744702948483-260061481956214398?l=dudefrommangalore.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dudefrommangalore.blogspot.com/feeds/260061481956214398/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=970528744702948483&amp;postID=260061481956214398' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/260061481956214398'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/260061481956214398'/><link rel='alternate' type='text/html' href='http://dudefrommangalore.blogspot.com/2009/10/what-do-you-mean-by-giving-more-than.html' title='What do you mean by giving more than 100%?'/><author><name>Dude From Mangalore</name><uri>http://www.blogger.com/profile/11648794788677197501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-970528744702948483.post-912704702600616446</id><published>2009-09-29T17:25:00.000-07:00</published><updated>2009-11-18T08:56:41.616-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='erlang'/><category scheme='http://www.blogger.com/atom/ns#' term='etop'/><title type='text'>How to see the running processes in erlang shell</title><content type='html'>Erlang provides a built-in utility called etop, that is same as standard top utility on Unix. Instead of monitoring processes on the operating system, etop show the current running/active Erlang processes. By default it starts a GUI window to show the processes running. Sometimes GUI is not desirable especially when the Erlang shell is running on production servers. Documentation does not show any way to start etop in text mode. Here is how to run it&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="erl"&gt;&lt;br /&gt;etop:start([{output, text}]).&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/970528744702948483-912704702600616446?l=dudefrommangalore.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dudefrommangalore.blogspot.com/feeds/912704702600616446/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=970528744702948483&amp;postID=912704702600616446' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/912704702600616446'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/912704702600616446'/><link rel='alternate' type='text/html' href='http://dudefrommangalore.blogspot.com/2009/09/how-to-see-running-processes-in-erlang.html' title='How to see the running processes in erlang shell'/><author><name>Dude From Mangalore</name><uri>http://www.blogger.com/profile/11648794788677197501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-970528744702948483.post-8528700944715941703</id><published>2009-09-29T16:14:00.000-07:00</published><updated>2009-09-29T16:24:49.531-07:00</updated><title type='text'>Detecting rejected file upload in PHP code</title><content type='html'>PHP can be configured to reject the file uploads exceeding some limit via upload_max_filesize server configuration parameter (in php.ini). As per the documentation &lt;a href="http://www.php.net/manual/en/features.file-upload.post-method.php"&gt;here&lt;/a&gt;, even though the file upload is rejected, an entry is made in $_FILES array with error code set to UPLOAD_ERR_INI_SIZE. This is documented &lt;a href="http://us3.php.net/manual/en/features.file-upload.errors.php"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Practically speaking this is not the case. When the uploaded content size exceed &lt;span style="font-weight:bold;"&gt;upload_max_filesize&lt;/span&gt;, $_FILES array is empty. This array cannot be inspected to find the reason for the error. I found a hack to do this. &lt;br /&gt;&lt;br /&gt;   * For file uploads, $_SERVER['CONTENT_TYPE'] is always set to &lt;span style="font-weight:bold;"&gt;multipart/form-data&lt;/span&gt; followed by the multipart boundary string.&lt;br /&gt;   * $_SERVER['CONTENT_LENGTH'] will be set to the content-length in the http header.&lt;br /&gt;&lt;br /&gt;Combination of above 2 can be used to detect the file upload exceeding &lt;span style="font-weight:bold;"&gt;upload_max_filesize&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;if ( stripos( $_SERVER['CONTENT_TYPE'], 'multipart/form-data') === 0 &amp;&amp; intval($_SERVER['CONTENT_LENGTH']) &gt; 0 &amp;&amp;&lt;br /&gt;        count($_FILES) == 0) {&lt;br /&gt;   error_log( 'File upload rejected due to file size exceeding upload_max_filesize limit' );&lt;br /&gt;}&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/970528744702948483-8528700944715941703?l=dudefrommangalore.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dudefrommangalore.blogspot.com/feeds/8528700944715941703/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=970528744702948483&amp;postID=8528700944715941703' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/8528700944715941703'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/8528700944715941703'/><link rel='alternate' type='text/html' href='http://dudefrommangalore.blogspot.com/2009/09/detecting-rejected-file-upload-in-php.html' title='Detecting rejected file upload in PHP code'/><author><name>Dude From Mangalore</name><uri>http://www.blogger.com/profile/11648794788677197501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-970528744702948483.post-707538970903765304</id><published>2009-09-26T13:45:00.000-07:00</published><updated>2009-09-26T13:48:30.920-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='function programming'/><category scheme='http://www.blogger.com/atom/ns#' term='erlang'/><title type='text'>Load balancing in Erlang using pg2 process groups</title><content type='html'>While working with some project @ my current workplace, we came across a situation where we are using pg2 process group. Apparently pg2 does not load balance across processes registered in the pg2 group. It usually done in round robin way. So it may happen that even though many processes are registered under same group, but all messages will get queues in single process. &lt;br /&gt;&lt;br /&gt;My co-worker and I came with an algorithm to solve this. It is describe &lt;a href="http://lethain.com/entry/2009/sep/12/load-balancing-across-erlang-process-groups/"&gt;here&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/970528744702948483-707538970903765304?l=dudefrommangalore.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dudefrommangalore.blogspot.com/feeds/707538970903765304/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=970528744702948483&amp;postID=707538970903765304' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/707538970903765304'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/707538970903765304'/><link rel='alternate' type='text/html' href='http://dudefrommangalore.blogspot.com/2009/09/load-balancing-in-erlang-using-pg2.html' title='Load balancing in Erlang using pg2 process groups'/><author><name>Dude From Mangalore</name><uri>http://www.blogger.com/profile/11648794788677197501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-970528744702948483.post-4887266209145611080</id><published>2009-08-21T19:09:00.001-07:00</published><updated>2009-08-21T19:39:58.390-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='messagequeue'/><category scheme='http://www.blogger.com/atom/ns#' term='highavailability'/><category scheme='http://www.blogger.com/atom/ns#' term='rabbitmq'/><category scheme='http://www.blogger.com/atom/ns#' term='erlang'/><category scheme='http://www.blogger.com/atom/ns#' term='clustering'/><title type='text'>Clustering RabbitMQ servers for High Availability</title><content type='html'>&lt;a href="http://www.rabbitmq.com/clustering.html"&gt;Clustering guide&lt;/a&gt; on rabbitmq website is a good start. But it does not seem to work out of the box.&lt;br /&gt;&lt;br /&gt;Default rabbitmq-server script uses -sname (short node name) option on the erlang shell command line. This makes it impossible to setup the cluster as it is not possible to put a node into the cluster when short name is given. So first step is remove that line from the rabbitmq-server script&lt;br /&gt;&lt;br /&gt;By default erlang shell generate a random cookie and save that in the .erlang.cookie file in the home directory. Since the cookie generated is random, unless the same cookie file copied onto the other nodes, it is not possible to setup the cluster. Better idea is to set the cookie on the command line itself. This can done via the environment variable RABBITMQ_SERVER_START_ARGS.&lt;br /&gt;&lt;br /&gt;Also by default, rabbitmq-server do not set the full node name. One need to specify that on the command line argument. Better place is to set the environment variable RABBITMQ_SERVER_START_ARGS (same as the one used to set the cookie)&lt;br /&gt;&lt;br /&gt;Erlang's DNS lookup is done via inet module. By default it uses /etc/hosts as the first one to resolve the hostname. Therefore in some environments (at least in my environment), short name does not resolve to long name when I use inet:gethostbyname(Shortname) function. I get short name back in hostent structure. Workaround for this is to force the use of native library for dns lookup. This can be done via inetrc file. By default Erlang uses $HOME/.inetrc file (if exists). Non-standard location can be specified via ERL_INETRC environment variable. Don't forget to set the full path name.&lt;br /&gt;&lt;br /&gt;Content of the inetrc file will look like&lt;br /&gt;&lt;br /&gt;{lookup, [native]}.&lt;br /&gt;&lt;br /&gt;Other possible options are file,yp,dns.&lt;br /&gt;&lt;br /&gt;It is good to know some other environment variables.&lt;br /&gt;&lt;br /&gt;RABBITMQ_LOG_BASE -&gt; log location (default /var/log/rabbitmq)&lt;br /&gt;RABBITMQ_NODENAME -&gt; node name to be used (default rabbit)&lt;br /&gt;RABBITMQ_MNESIA_BASE -&gt; location for mnesia database (default /var/lib/rabbitmq/mnesia)&lt;br /&gt;&lt;br /&gt;If your machine has multiple network interfaces, by default RabbitMQ binds to all the network interfaces. In some cases it is not desirable. One can force it to bind to only one network interface by setting the environment varaible RABBITMQ_NODE_IP_ADDRESS to the ip address of the network interface.&lt;br /&gt;&lt;br /&gt;Here is a summary of all environment variables required&lt;br /&gt;&lt;br /&gt;RABBITMQ_SERVER_START_ARGS="-name rabbit@`hostname` -setcookie rabbit"&lt;br /&gt;RABBITMQ_LOG_BASE=/home/baliga/rabbit&lt;br /&gt;RABBITMQ_NODENAME=rabbit&lt;br /&gt;RABBITMQ_MNESIA_BASE=/home/baliga/rabbit&lt;br /&gt;ERL_INETRC=/home/baliga/inetrc&lt;br /&gt;&lt;br /&gt;Now it is time to start rabbitmq server on all the nodes.&lt;br /&gt;&lt;br /&gt;rabbitmq-server -detached&lt;br /&gt;&lt;br /&gt;To setup the cluster rabbitmqctl script is used. By default this script too has -sname option setup on the command line. Delete this line from rabbitmqctl file. In order for this script to communicate with the node, long name and cookie required. Set this via RABBITMQ_CTL_ERL_ARGS environment variable&lt;br /&gt;&lt;br /&gt;export RABBITMQ_CTL_ERL_ARGS="-name rabbitmqctl@`hostname` -setcookie rabbit"&lt;br /&gt;&lt;br /&gt;Note that the cookie should be same as that of the rabbitmq-server instance.&lt;br /&gt;&lt;br /&gt;Now you can run the rabbitmqctl to setup the cluster.&lt;br /&gt;&lt;br /&gt;On each of the node, run the following command&lt;br /&gt;&lt;br /&gt;   1. rabbitmqctl stop_app&lt;br /&gt;   2. rabbitmqctl reset&lt;br /&gt;   3. rabbitmqctl cluster &lt;long name of node&gt;&lt;br /&gt;   4. Repeat step 3 for all nodes in the cluster except for itself.&lt;br /&gt;   4. rabbitmqctl start_app&lt;br /&gt;&lt;br /&gt;Now the cluster is ready to be used.&lt;br /&gt;&lt;br /&gt;Some questions are not answered here like how the clustering works when nodes are behind separate firewalls. What ports need to be opened in firewall for clustering to work. I am still doing the research on it. Will post the findings soon.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/970528744702948483-4887266209145611080?l=dudefrommangalore.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dudefrommangalore.blogspot.com/feeds/4887266209145611080/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=970528744702948483&amp;postID=4887266209145611080' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/4887266209145611080'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/4887266209145611080'/><link rel='alternate' type='text/html' href='http://dudefrommangalore.blogspot.com/2009/08/clustering-rabbitmq-servers-for-high.html' title='Clustering RabbitMQ servers for High Availability'/><author><name>Dude From Mangalore</name><uri>http://www.blogger.com/profile/11648794788677197501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-970528744702948483.post-1983433909105326002</id><published>2009-08-13T19:14:00.001-07:00</published><updated>2010-08-24T10:01:54.420-07:00</updated><title type='text'>Is parallel computing/concurrency  hard to get?</title><content type='html'>Regarding this subject, first question I would like to ask is why one need concurrency? My one line answer would be "As we go into the future, number of cores available on even desktops will increase dramatically". That's why one need to think in terms of parallel operations instead of serial operations. Many libraries are already there to achieive this like MPM. &lt;br /&gt;&lt;br /&gt;In my opinion, these libraries are hard to use and still need to deal with the underlying network architecture. But it is not necessary. It can be achieved without getting into the low level functions. Only thing is require is "changing the way we think of designing the system". &lt;br /&gt;&lt;br /&gt;Functional is my answer to this problem. Just thinking functional is not enough. But one should get the real feel of it. One need to forget everything he/she knows and start thinking like a child. Start to learn things from the begining. &lt;br /&gt;&lt;br /&gt;When I started thinking functional, even though I was thinking functional but that functional always turned out to be serial. Then I got introduced to this wonderful language called "Erlang". This really force one to think and do things not only in functional but do things in concurrency.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/970528744702948483-1983433909105326002?l=dudefrommangalore.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dudefrommangalore.blogspot.com/feeds/1983433909105326002/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=970528744702948483&amp;postID=1983433909105326002' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/1983433909105326002'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/1983433909105326002'/><link rel='alternate' type='text/html' href='http://dudefrommangalore.blogspot.com/2009/08/is-parallel-computingconcurrency-hard.html' title='Is parallel computing/concurrency  hard to get?'/><author><name>Dude From Mangalore</name><uri>http://www.blogger.com/profile/11648794788677197501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-970528744702948483.post-1429287163014210535</id><published>2009-08-11T23:15:00.001-07:00</published><updated>2009-08-11T23:16:40.353-07:00</updated><title type='text'>Nice photography!</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://mail.google.com/mail/?ui=2&amp;ik=6812c99797&amp;view=att&amp;th=121aa5759d8cb2f2&amp;attid=0.1&amp;disp=emb&amp;realattid=0.1.1&amp;zw"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 399px; height: 255px;" src="http://mail.google.com/mail/?ui=2&amp;ik=6812c99797&amp;view=att&amp;th=121aa5759d8cb2f2&amp;attid=0.1&amp;disp=emb&amp;realattid=0.1.1&amp;zw" border="0" alt="" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/970528744702948483-1429287163014210535?l=dudefrommangalore.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dudefrommangalore.blogspot.com/feeds/1429287163014210535/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=970528744702948483&amp;postID=1429287163014210535' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/1429287163014210535'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/1429287163014210535'/><link rel='alternate' type='text/html' href='http://dudefrommangalore.blogspot.com/2009/08/nice-photography.html' title='Nice photography!'/><author><name>Dude From Mangalore</name><uri>http://www.blogger.com/profile/11648794788677197501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-970528744702948483.post-6611371158485066969</id><published>2009-08-04T08:51:00.000-07:00</published><updated>2009-08-04T08:56:01.992-07:00</updated><title type='text'>New and improved delicious released</title><content type='html'>Today Yahoo! Delicious released a new cool features.&lt;br /&gt;&lt;br /&gt;   * Integration with Twitter. See the related tweets.&lt;br /&gt;   * Share interesting links not just with delicious users, but also with your friends via &lt;span style="font-weight:bold;"&gt;email&lt;/span&gt;.&lt;br /&gt;   * Search is ever more improved now. You can see the search results on timeline. Find the activity for your search terms over time (even though it is not done with Yahoo! Search)&lt;br /&gt;   * You can watch youtube and other  videos inline now. No need to leave delicious search page.&lt;br /&gt;   * Flickr images are also displayed inline.&lt;br /&gt;&lt;br /&gt;Congratulations to delicious team.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/970528744702948483-6611371158485066969?l=dudefrommangalore.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dudefrommangalore.blogspot.com/feeds/6611371158485066969/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=970528744702948483&amp;postID=6611371158485066969' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/6611371158485066969'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/6611371158485066969'/><link rel='alternate' type='text/html' href='http://dudefrommangalore.blogspot.com/2009/08/new-and-improved-delicious-released.html' title='New and improved delicious released'/><author><name>Dude From Mangalore</name><uri>http://www.blogger.com/profile/11648794788677197501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-970528744702948483.post-978965011090646386</id><published>2009-08-03T12:21:00.000-07:00</published><updated>2009-08-03T12:34:01.470-07:00</updated><title type='text'>Module inherittance in Erlang</title><content type='html'>Erlang support module inheritance via &lt;span style="font-weight:bold;"&gt;extends&lt;/span&gt; module property. &lt;br /&gt;&lt;br /&gt;Here is the example code:&lt;br /&gt;&lt;br /&gt;parent.erl&lt;br /&gt;-------------&lt;br /&gt;&lt;br /&gt;-module (parent).&lt;br /&gt;-export( [fun1/0, fun2/0] ).&lt;br /&gt;&lt;br /&gt;fun1() -&gt; &lt;br /&gt;   io:format( "In parent::fun1/0~n" ).&lt;br /&gt;&lt;br /&gt;fun2() -&gt;&lt;br /&gt;   io:format( "In parent:fun2/0~n" ).&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;child.erl&lt;br /&gt;----------&lt;br /&gt;&lt;br /&gt;-module (child).&lt;br /&gt;-extends(parent).&lt;br /&gt;-export( [fun1/0] ).&lt;br /&gt;&lt;br /&gt;fun1() -&gt;&lt;br /&gt;   io:format( "In child:fun1/0~n" ).&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Testing this:&lt;br /&gt;&lt;br /&gt;erl&lt;br /&gt;&lt;br /&gt;&gt; c(parent), c(child).&lt;br /&gt;{ok,child}.&lt;br /&gt;&gt; parent:fun1().&lt;br /&gt;In parent:fun1/0&lt;br /&gt;&gt; parent:fun2().&lt;br /&gt;In parent:fun2/0.&lt;br /&gt;&gt; child:fun1().&lt;br /&gt;In child:fun1/0.&lt;br /&gt;&gt; child:fun2().&lt;br /&gt;In parent:fun2/0&lt;br /&gt;&lt;br /&gt;Even though fun2 is not defined/exported in child module, calling child:fun2/0 is a valid call as parent has exported fun2/0 function.&lt;br /&gt;&lt;br /&gt;If you call module_info() on child, you won't see fun2 function in the exported function list. Erlang VM find the extended module via attributes property of the module.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/970528744702948483-978965011090646386?l=dudefrommangalore.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dudefrommangalore.blogspot.com/feeds/978965011090646386/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=970528744702948483&amp;postID=978965011090646386' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/978965011090646386'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/978965011090646386'/><link rel='alternate' type='text/html' href='http://dudefrommangalore.blogspot.com/2009/08/module-inherittance-in-erlang.html' title='Module inherittance in Erlang'/><author><name>Dude From Mangalore</name><uri>http://www.blogger.com/profile/11648794788677197501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-970528744702948483.post-8760318199370236484</id><published>2009-07-10T07:42:00.001-07:00</published><updated>2009-07-10T07:43:02.158-07:00</updated><title type='text'>Obama, what are you doing?</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://d.yimg.com/a/p/rids/20090709/i/r3356552547.jpg?x=400&amp;y=340&amp;q=85&amp;sig=_dbUibuGcHSmlg8QoaQV7A--"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 399px; height: 340px;" src="http://d.yimg.com/a/p/rids/20090709/i/r3356552547.jpg?x=400&amp;y=340&amp;q=85&amp;sig=_dbUibuGcHSmlg8QoaQV7A--" border="0" alt="" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/970528744702948483-8760318199370236484?l=dudefrommangalore.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dudefrommangalore.blogspot.com/feeds/8760318199370236484/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=970528744702948483&amp;postID=8760318199370236484' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/8760318199370236484'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/8760318199370236484'/><link rel='alternate' type='text/html' href='http://dudefrommangalore.blogspot.com/2009/07/obama-what-are-you-doing.html' title='Obama, what are you doing?'/><author><name>Dude From Mangalore</name><uri>http://www.blogger.com/profile/11648794788677197501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-970528744702948483.post-493353559229889946</id><published>2009-06-20T19:57:00.000-07:00</published><updated>2009-07-01T23:43:33.689-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='xml parsing'/><category scheme='http://www.blogger.com/atom/ns#' term='erlang'/><category scheme='http://www.blogger.com/atom/ns#' term='xmerl'/><category scheme='http://www.blogger.com/atom/ns#' term='articles'/><title type='text'>SAX Xml parsing in Erlang - Part 1</title><content type='html'>Erlang has a default XML parser called &lt;a href="http://erlang.org/doc/apps/xmerl/index.html"&gt;xmerl&lt;/a&gt;. Even there is a documetation associated with this module, it is not adequate enough to start writing the code. Especially SAX parsing is the least documented and least understood. There is not much literature (infact no documentation at all) for the SAX parsing. I had to do lot of code reading to figure out the SAX parsing module.&lt;br /&gt;&lt;br /&gt;In this article I will make an attempt to explain the &lt;a href="http://erlang.org/doc/man/xmerl_eventp.html"&gt;SAX parsing module&lt;/a&gt;. &lt;br /&gt;&lt;br /&gt;SAX parsing is done via xmerl_eventp:stream/2 and xmerl_eventp:stream_sax/4. &lt;br /&gt;&lt;br /&gt;I did not find xmerl_eventp:stream_sax/4 useful as user state is not maintained across all events. Also accumulate function cannot be overridden. So it is not useful when you do not need to accumulate all the elements (for large file parsing). I was trying to use this function to parse large file ( &gt; 10MB ) and extract only some part of the whole file. Since it is not possible to override accumulate, this function was out of question. If one need to accumulate all the elements in the document, I would rather do xmerl_scan:file/1 or xmerl_scan:string/1 which will scan the file/string and generate in-memory document.&lt;br /&gt;&lt;br /&gt;xmerl_eventp:stream/2 function take 2 arguments.&lt;br /&gt;   * File name&lt;br /&gt;   * List of options&lt;br /&gt;&lt;br /&gt;For this post, 3 options are important. They are user_state, event_fun and acc_fun. &lt;br /&gt;&lt;br /&gt;user_state is any term which can be accessed from event_fun and acc_fun. event_fun is called for every event during the SAX parsing. acc_fun is called for every element (after parsing end of element). &lt;br /&gt;&lt;br /&gt;event_fun has a signature fun/2. First parameter is of type #xmerl_event. Second parameter is a global state. user_state from this global state can be accessed via xmerl_scan:user_state/1 function. User state can be modified via xmerl_scan:user_state/2 function. event_fun should return the new global state.&lt;br /&gt;&lt;br /&gt;Example of event_fun:&lt;br /&gt;&lt;br /&gt;event_function(#xmerl_event{event = Event, data = Data}, GlobalState) -&gt;&lt;br /&gt;   UserState = xmerl_scan:user_state(GlobalState),&lt;br /&gt;   NewUserState = do_something(UserState),&lt;br /&gt;   NewGlobalState = xmerl_scan:user_state(NewUserState, GlobalState),&lt;br /&gt;   NewGlobalState.&lt;br /&gt;&lt;br /&gt;Possible values for #xmerl_event.event are started and ended.&lt;br /&gt;&lt;br /&gt;#xmerl_event.data is set to document at the beginning of document parsing and after all the elements are parsed.&lt;br /&gt;&lt;br /&gt;event_function( #xmerl_event{event = started, data = document}, GlobalState) -&gt;&lt;br /&gt;   % get the user state&lt;br /&gt;   % do something with the user state&lt;br /&gt;   % set the new user state in global state&lt;br /&gt;   % return global state&lt;br /&gt;&lt;br /&gt;One may want to open a file or open a socket connection at the beginning of the document parsing. In subsequent event, one may want to write the content to the previously opened file or socket connection. &lt;br /&gt;&lt;br /&gt;End of document parsing event can be used to close the previously opened file handle or socket connection.&lt;br /&gt;&lt;br /&gt;acc_fun can be used to accumulate the content. acc_fun is of the form fun/3. First parameter is the current xml element.  Second parameter is the accumulator. Third parameter is the global state. &lt;br /&gt;&lt;br /&gt;This function should return a new tuple of 2 elements. First element is the new accumulator and 2nd element is a new global state (user state can be changed in the new global state as explained earlier).&lt;br /&gt;&lt;br /&gt;user_state can be any Erlang term. &lt;br /&gt;&lt;br /&gt;In the next article, I will discuss an implementation of SAX parsing to transform an XML into CSV.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/970528744702948483-493353559229889946?l=dudefrommangalore.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dudefrommangalore.blogspot.com/feeds/493353559229889946/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=970528744702948483&amp;postID=493353559229889946' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/493353559229889946'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/493353559229889946'/><link rel='alternate' type='text/html' href='http://dudefrommangalore.blogspot.com/2009/06/sax-xml-parsing-in-erlang-part-1.html' title='SAX Xml parsing in Erlang - Part 1'/><author><name>Dude From Mangalore</name><uri>http://www.blogger.com/profile/11648794788677197501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-970528744702948483.post-8346812019202643505</id><published>2009-06-20T19:51:00.000-07:00</published><updated>2009-06-20T19:53:56.730-07:00</updated><title type='text'>What is the longest word in English?</title><content type='html'>Longest english word is "Pneumonoultramicroscopicsilicovolcanocon". As per Wikipedia,&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;a factitious word alleged to mean 'a lung disease caused by the inhalation of very fine silica dust, causing inflammation in the lungs.&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;More &lt;a href="http://answers.yahoo.com/question/index;_ylc=X3oDMTB2Y2t1c212BF9TAzIxMTUzMDA5ODgEc2VjA2ZwBHNsawN0b2RheXE-?qid=20090602004051AA33EO3"&gt;here&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/970528744702948483-8346812019202643505?l=dudefrommangalore.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dudefrommangalore.blogspot.com/feeds/8346812019202643505/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=970528744702948483&amp;postID=8346812019202643505' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/8346812019202643505'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/8346812019202643505'/><link rel='alternate' type='text/html' href='http://dudefrommangalore.blogspot.com/2009/06/what-is-longest-word-in-english.html' title='What is the longest word in English?'/><author><name>Dude From Mangalore</name><uri>http://www.blogger.com/profile/11648794788677197501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-970528744702948483.post-1288419439932517668</id><published>2009-04-06T11:41:00.000-07:00</published><updated>2009-04-06T11:44:39.311-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='erlang'/><title type='text'>Controlling a node from stop script</title><content type='html'>There is no command line option on Erlang to terminate a node in a graceful manor and report the same. Here is a module I came up with.&lt;br /&gt;&lt;br /&gt;-module (node_ctrl).&lt;br /&gt;&lt;br /&gt;-export ([stop/1]).&lt;br /&gt;&lt;br /&gt;stop([Node]) -&gt;&lt;br /&gt;    io:format( "Stopping ~p: ", [Node] ),&lt;br /&gt;    case net_kernel:connect_node(Node) of&lt;br /&gt;        false -&gt; io:format( "not reachable~n", [] );&lt;br /&gt;        true -&gt;&lt;br /&gt;            net_kernel:monitor_nodes(true),&lt;br /&gt;            rpc:call(Node, init, stop, [] ),&lt;br /&gt;            receive &lt;br /&gt;                {nodedown, Node} -&gt; io:format( "done~n", [])&lt;br /&gt;                after 20000 -&gt; io:format( "refused to die~n", [])&lt;br /&gt;            end&lt;br /&gt;    end,&lt;br /&gt;    init:stop().&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Usage:&lt;br /&gt;&lt;br /&gt;erl -name foo@example.foo.com -setcookie mycookie -s node_ctrl stop "targetnode@example.foo.com"&lt;br /&gt;&lt;br /&gt;Assumptions:&lt;br /&gt;  * foo@example.foo.com is started with &lt;span style="font-weight:bold;"&gt;mycookie&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/970528744702948483-1288419439932517668?l=dudefrommangalore.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dudefrommangalore.blogspot.com/feeds/1288419439932517668/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=970528744702948483&amp;postID=1288419439932517668' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/1288419439932517668'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/1288419439932517668'/><link rel='alternate' type='text/html' href='http://dudefrommangalore.blogspot.com/2009/04/controlling-node-from-stop-script.html' title='Controlling a node from stop script'/><author><name>Dude From Mangalore</name><uri>http://www.blogger.com/profile/11648794788677197501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-970528744702948483.post-6146848280434955255</id><published>2009-04-03T16:40:00.000-07:00</published><updated>2009-10-07T18:47:36.563-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='performance'/><category scheme='http://www.blogger.com/atom/ns#' term='ejabberd'/><category scheme='http://www.blogger.com/atom/ns#' term='erlang'/><category scheme='http://www.blogger.com/atom/ns#' term='erlsom'/><category scheme='http://www.blogger.com/atom/ns#' term='parsing'/><category scheme='http://www.blogger.com/atom/ns#' term='xml'/><category scheme='http://www.blogger.com/atom/ns#' term='xmerl'/><title type='text'>Erlang XML parser comparison</title><content type='html'>I am looking into various XML parsing in Erlang. I found mainly 3 of them.&lt;br /&gt;&lt;br /&gt;   * &lt;a href="http://www.erlang.org/doc/man/xmerl.html"&gt;Xmerl&lt;/a&gt; from Erlang distribution&lt;br /&gt;   * &lt;a href="http://erlsom.sourceforge.net/erlsom.htm"&gt;Erlsom&lt;/a&gt;&lt;br /&gt;   * Linked-in driver based on libexpat from ejabberd&lt;br /&gt;&lt;br /&gt;I did some benchmarking for 3 parsers. Parsing was done on 42K sized XML. &lt;br /&gt;&lt;br /&gt;xmerl took 124ms, erlsom took 28ms and linked-in driver based parser took 7ms.&lt;br /&gt;&lt;br /&gt;libexpat based parser is the fastest. But it has some drawbacks. &lt;br /&gt;   * It cannot do callbacks for SAX parser as linked-in driver cannot do rpc call into the host VM. So it is not good for parsing huge XML data. &lt;br /&gt;   * With this one will loose the platform independence. Need to compile the linked-in driver for the platform one is working on.&lt;br /&gt;&lt;br /&gt;Erlsom seems to be better than the default xmerl parser. &lt;br /&gt;   * It also generate a Erlang data structure (tuples and list). &lt;br /&gt;   * Provides continuation function callback when data not enough data is there for parsing.&lt;br /&gt;   * Convert the XML to erlang data structure as per the XS&lt;br /&gt;   * SAX based parsing&lt;br /&gt;   * Some limitations are listed &lt;a href="http://erlsom.sourceforge.net/erlsom.htm#_Toc181008883"&gt;here&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Linked-in driver libexpat based parser is the fastest one. It is not flexible enough. It returns list of tuples where first element of tuple is an integer which indicate the begining of element, end of element and cdata/character content. Some parser is necessary to convert this to xmerl structure or any other desired structure. &lt;br /&gt;   * Since this does not provide callbacks, it is not desirable to parse huge files&lt;br /&gt;   * DOM generated need re-parsing&lt;br /&gt;   * Since it is libexpat based parser, it check for utf-8 validity etc.&lt;br /&gt;&lt;br /&gt;I heard that next version of xmerl is going to be faster than what it is now. I have not gotten the latest xmerl parser yet. Once I have it, I will do the benchmarking and do another post on my findings.&lt;br /&gt;&lt;br /&gt;UPDATE: xmerl also support validating XML against XSD via xmerl_xsd module.&lt;br /&gt;           {ok, Xml}  = xmerl_scan:string(XmlString),&lt;br /&gt;           {ok, Schema} = xmerl_xsd:proces_schema(XsdFile),&lt;br /&gt;           xmerl_xsd:validate(Xml, Schema)&lt;br /&gt;&lt;br /&gt;UPDATE: Tried xmerl_scan:file/1 with R13 release. It is a significant improvement in performance. Now it can do 44K file in 35-40ms. Still slower than erlsom and expat based parser.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/970528744702948483-6146848280434955255?l=dudefrommangalore.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dudefrommangalore.blogspot.com/feeds/6146848280434955255/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=970528744702948483&amp;postID=6146848280434955255' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/6146848280434955255'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/6146848280434955255'/><link rel='alternate' type='text/html' href='http://dudefrommangalore.blogspot.com/2009/04/erlang-xml-parser-comparison.html' title='Erlang XML parser comparison'/><author><name>Dude From Mangalore</name><uri>http://www.blogger.com/profile/11648794788677197501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-970528744702948483.post-2303435501146542055</id><published>2009-03-31T15:09:00.001-07:00</published><updated>2009-03-31T15:54:48.588-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='erlang'/><category scheme='http://www.blogger.com/atom/ns#' term='ei_interface'/><category scheme='http://www.blogger.com/atom/ns#' term='ei'/><title type='text'>RPC from Erlang Linked-in driver port</title><content type='html'>Developing SAX based XML parser (using libexpat) as a linked-in driver for Erlang, I came across the requirement to do the callback within linked-in driver. I have done it earlier in the c-node via ei_rpc C API. This require linked-in driver to run as a c-node. I was looking for a way to avoid it.&lt;br /&gt;&lt;br /&gt;Then I came across this function &lt;a href="https://www.cs.tcd.ie/~htewari/4D1/erlang/erts-5.1.2/doc/html/erl_driver.html#driver_send_term"&gt;driver_send_term&lt;/a&gt;. This can be used to send a term to any PID within the local VM. It is easy to send the term to the same process which did port_cmd. The PID for that process can be obtained using &lt;a href="https://www.cs.tcd.ie/~htewari/4D1/erlang/erts-5.1.2/doc/html/erl_driver.html#driver_caller"&gt;driver_caller&lt;/a&gt; C API.&lt;br /&gt;&lt;br /&gt;My requirement is to send it to some other PID than the calling process. There is no standard API to do so. But going through the source code for erlang, I figured the way to convert erlang_pid sent by the caller to the one usable within driver_send_term call.&lt;br /&gt;&lt;br /&gt;ErlDrvTermData pid = ((ErlDrvTermData) ( ((callbackPid.serial &lt;&lt; 15 | callbackPid.num)) &lt;&lt; 4 | (0x0 &lt;&lt; 2 | 0x3)) );&lt;br /&gt;&lt;br /&gt;This works with R12 and R13 version of Erlang. This is not guaranteed to work in the future releases. But till then I am going to use it. &lt;br /&gt;&lt;br /&gt;I wonder why Erlang did not provide the standard interface to convert erlang_pid to ErlDrvTermData to be used within driver_send_term.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/970528744702948483-2303435501146542055?l=dudefrommangalore.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dudefrommangalore.blogspot.com/feeds/2303435501146542055/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=970528744702948483&amp;postID=2303435501146542055' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/2303435501146542055'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/2303435501146542055'/><link rel='alternate' type='text/html' href='http://dudefrommangalore.blogspot.com/2009/03/rpc-from-erlang-linked-in-driver-port.html' title='RPC from Erlang Linked-in driver port'/><author><name>Dude From Mangalore</name><uri>http://www.blogger.com/profile/11648794788677197501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-970528744702948483.post-7345997987402899616</id><published>2009-03-30T18:26:00.000-07:00</published><updated>2009-03-30T18:40:57.355-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='erlang'/><category scheme='http://www.blogger.com/atom/ns#' term='binary'/><category scheme='http://www.blogger.com/atom/ns#' term='iolist'/><title type='text'>Sharing binary data and reference counting</title><content type='html'>&lt;a href="http://www.erlang.org/pipermail/erlang-questions/2009-March/042758.html"&gt;This&lt;/a&gt; email thread discussion concludes that&lt;br /&gt;&lt;blockquote&gt;constants in erlang code are stored in a constant pool memory instead of process memory. So there is no copying of this data in the process memory. This is more efficient when one knows that the data is not going to change.&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;Example for this kind of data is configuration. If configuration is known at the compile time, well and good. But what if the configuration is read from the file during run-time. This data will get copied into the process memory. &lt;br /&gt;&lt;br /&gt;I got the &lt;a href="http://www.erlang.org/pipermail/erlang-questions/2009-March/042778.html"&gt;suggestion&lt;/a&gt; to generate the code during run-time and load that code. Thus erlang VM will ensure that these configuration elements are in constant pool memory and the data is not copied into process memory.&lt;br /&gt;&lt;br /&gt;I decided to give it a try. Generated the code and stored it in a file.&lt;br /&gt;&lt;br /&gt;ConfigFetcher = list_to_atom("fetch_" ++ atom_to_list(Module) ++ "_config"),&lt;br /&gt;FileName = code:priv_dir(Module) ++ "/" ++ atom_to_list(ConfigFetcher) ++ ".erl",&lt;br /&gt;file:write_file(FileName, GeneratedCode).&lt;br /&gt;&lt;br /&gt;Compiled it using &lt;br /&gt;&lt;br /&gt;compile:file(FileName, [{outdir, code:lib_dir(Module, ebin)}]).&lt;br /&gt;&lt;br /&gt;Load the compiled file,&lt;br /&gt;&lt;br /&gt;code:load_file(ConfigFetcher)&lt;br /&gt;&lt;br /&gt;Let's say that fetch is a function exported in the generated module. Using this fetch function for fetching the configuration for a given value, ran a small test to find the performance improvement.&lt;br /&gt;&lt;br /&gt;The numbers I saw were mind boggling. Using old method I could get 11k fetches per second. With new method (code generation and loading), I got 500k fetcher per second.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/970528744702948483-7345997987402899616?l=dudefrommangalore.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dudefrommangalore.blogspot.com/feeds/7345997987402899616/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=970528744702948483&amp;postID=7345997987402899616' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/7345997987402899616'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/7345997987402899616'/><link rel='alternate' type='text/html' href='http://dudefrommangalore.blogspot.com/2009/03/sharing-binary-data-and-reference.html' title='Sharing binary data and reference counting'/><author><name>Dude From Mangalore</name><uri>http://www.blogger.com/profile/11648794788677197501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-970528744702948483.post-5771492024999317301</id><published>2009-03-29T17:32:00.000-07:00</published><updated>2009-03-29T17:48:26.470-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='rabbitmq'/><category scheme='http://www.blogger.com/atom/ns#' term='erlang'/><title type='text'>AMPQ Client gotchas!</title><content type='html'>There is a small change required in this article on Introducing &lt;a href="http://hopper.squarespace.com/blog/2008/1/12/introducing-the-erlang-amqp-client.html"&gt;The Erlang AMQP Client&lt;/a&gt;. &lt;br /&gt;&lt;br /&gt;In this article, code for subscribing to an queue is&lt;br /&gt;&lt;br /&gt;#'basic.consume_ok'{consumer_tag = ConsumerTag}&lt;br /&gt;    = amqp_channel:call(Channel, BasicConsume, self()),&lt;br /&gt;&lt;br /&gt;This throws exception&lt;br /&gt;&lt;br /&gt;Channel 1 is shutting down due to: {{badmatch,false},&lt;br /&gt;                                    [{rabbit_writer,assemble_frames,4},&lt;br /&gt;                                     {rabbit_writer,&lt;br /&gt;                                      internal_send_command_async,5},&lt;br /&gt;                                     {rabbit_writer,handle_message,2},&lt;br /&gt;                                     {rabbit_writer,mainloop,1}]}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Change it to amqp_channel:subscribe(Channel, BasicConsume, self())&lt;br /&gt;&lt;br /&gt;NOTE: Download rabbitmq erlang client from &lt;a href="http://hg.rabbitmq.com/rabbitmq-erlang-client/file/3c6f7b5e67ae"&gt;here&lt;/a&gt;. The version from &lt;a href="http://www.rabbitmq.com/download.html"&gt;this&lt;/a&gt; page does not work.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/970528744702948483-5771492024999317301?l=dudefrommangalore.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dudefrommangalore.blogspot.com/feeds/5771492024999317301/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=970528744702948483&amp;postID=5771492024999317301' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/5771492024999317301'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/5771492024999317301'/><link rel='alternate' type='text/html' href='http://dudefrommangalore.blogspot.com/2009/03/ampq-client-gotchas.html' title='AMPQ Client gotchas!'/><author><name>Dude From Mangalore</name><uri>http://www.blogger.com/profile/11648794788677197501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-970528744702948483.post-4026997355779851838</id><published>2009-03-26T11:02:00.000-07:00</published><updated>2009-03-26T11:12:57.330-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='gen_tcp'/><category scheme='http://www.blogger.com/atom/ns#' term='erlang'/><title type='text'>TCP server in Erlang</title><content type='html'>Came across this &lt;a href="http://www.joeandmotorboat.com/2008/11/12/a-simple-concurrent-erlang-tcp-server/"&gt;good article&lt;/a&gt; on writing a TCP server in Erlang. Author forgot to mention one thing here.&lt;br /&gt;&lt;br /&gt;connect(Listen) -&gt;&lt;br /&gt;  {ok, Socket} = gen_tcp:accept(Listen),&lt;br /&gt;  inet:setopts(Socket, ?TCP_OPTS),&lt;br /&gt;  % kick off another process to handle connections concurrently&lt;br /&gt;  spawn(fun() -&gt; connect(Listen) end),&lt;br /&gt;  recv_loop(Socket),&lt;br /&gt;  gen_tcp:close(Socket).&lt;br /&gt;&lt;br /&gt;In the above code snipper (from the above mentioned blog), it is to be noted that after getting the connection via gen_tcp:accept/1, a process is spawned to continue listen on the socket and the client is served from the same process unlike in any other language where a thread is spawned to serve the incoming client request and main thread continue to listen on the socket. This is very important to note as the incoming client socket has a ownership relationship with the process. If you spawn a process to serve the client, it won't work as the messages won't be delivered to the new process instead are delivered to the process in which gen_tcp:accept/1 was executed.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/970528744702948483-4026997355779851838?l=dudefrommangalore.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dudefrommangalore.blogspot.com/feeds/4026997355779851838/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=970528744702948483&amp;postID=4026997355779851838' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/4026997355779851838'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/4026997355779851838'/><link rel='alternate' type='text/html' href='http://dudefrommangalore.blogspot.com/2009/03/tcp-server-in-erlang.html' title='TCP server in Erlang'/><author><name>Dude From Mangalore</name><uri>http://www.blogger.com/profile/11648794788677197501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-970528744702948483.post-5956772979743175686</id><published>2009-03-24T22:43:00.000-07:00</published><updated>2009-03-24T22:45:39.794-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='erlang'/><category scheme='http://www.blogger.com/atom/ns#' term='tips'/><title type='text'>string:tokens/2 does not handle empty tokens</title><content type='html'>string:tokens("A,,,,,", ",") returns ["A"] where as I expect it to return ["A", "", "", "", ""]. This can be solved using regexp:split function.&lt;br /&gt;&lt;br /&gt;regexp:split("A,,,,,", ",") returns ["A", [], [], [], []]&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/970528744702948483-5956772979743175686?l=dudefrommangalore.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dudefrommangalore.blogspot.com/feeds/5956772979743175686/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=970528744702948483&amp;postID=5956772979743175686' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/5956772979743175686'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/5956772979743175686'/><link rel='alternate' type='text/html' href='http://dudefrommangalore.blogspot.com/2009/03/stringtokens2-does-not-handle-empty.html' title='string:tokens/2 does not handle empty tokens'/><author><name>Dude From Mangalore</name><uri>http://www.blogger.com/profile/11648794788677197501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-970528744702948483.post-9149288355925426502</id><published>2009-03-21T16:59:00.000-07:00</published><updated>2009-03-21T17:11:09.823-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='function programming'/><category scheme='http://www.blogger.com/atom/ns#' term='erlang'/><category scheme='http://www.blogger.com/atom/ns#' term='loops'/><title type='text'>Imperative language constructs in Erlang</title><content type='html'>"How can I do for loop in Erlang?", "How can I do while loop in Erlang?"....&lt;br /&gt;&lt;br /&gt;These are the common questions people ask when they get into the world of functional programming from imperative language(s). It is easy to switch to functional programming in Python, Ruby etc as they are the mixture of functional and imperative language constructs. Programming languages like Erlang (probably Haskell) do not provide explicit for, while constructs. Here are the equivalents way to implement some of the imperative language constructs.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;For Loop&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;for_loop(N, Fun) -&gt;&lt;br /&gt;   lists:foreach(Fun, lists:seq(1, N))&lt;br /&gt;&lt;br /&gt;for_loop(0, Fun) -&gt; ok;&lt;br /&gt;for_loop(N, Fun) -&gt;&lt;br /&gt;   Fun(N),&lt;br /&gt;   for_loop(N-1, Fun).&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;While loop&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;while_loop(Predicate, Fun, State) -&gt;&lt;br /&gt;   while_loop(Predicate(State), Predicate, Fun, State).&lt;br /&gt;&lt;br /&gt;while_loop(PredResult, Predicate, Fun, State) when PredResult == false -&gt; ok;&lt;br /&gt;while_loop(_PredResult, Predicate, Fun, State) -&gt;&lt;br /&gt;    NewState = Fun(State),&lt;br /&gt;    whle_loop(PredResult(State), Predicate, Fun, NewState).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/970528744702948483-9149288355925426502?l=dudefrommangalore.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dudefrommangalore.blogspot.com/feeds/9149288355925426502/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=970528744702948483&amp;postID=9149288355925426502' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/9149288355925426502'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/9149288355925426502'/><link rel='alternate' type='text/html' href='http://dudefrommangalore.blogspot.com/2009/03/imperative-language-constructs-in.html' title='Imperative language constructs in Erlang'/><author><name>Dude From Mangalore</name><uri>http://www.blogger.com/profile/11648794788677197501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-970528744702948483.post-5835061071281599604</id><published>2009-03-18T15:19:00.000-07:00</published><updated>2009-03-18T15:26:16.578-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='erlang'/><category scheme='http://www.blogger.com/atom/ns#' term='mnesia'/><category scheme='http://www.blogger.com/atom/ns#' term='tutorial'/><category scheme='http://www.blogger.com/atom/ns#' term='database'/><title type='text'>Auto increment in Mnesia database</title><content type='html'>Mnesia provides some obscure API called dirty_increment_update/3. This can be used to generate unique ids. Here is an example.&lt;br /&gt;&lt;br /&gt;-module (uniqueid).&lt;br /&gt;&lt;br /&gt;-export( [test/0] ).&lt;br /&gt;&lt;br /&gt;-record( unique_ids, {type, id} ).&lt;br /&gt;&lt;br /&gt;test() -&gt;&lt;br /&gt;   mnesia:start(),&lt;br /&gt;   mnesia:create_table( unique_ids, [{attributes, record_info(fields, unique_ids)}] ),&lt;br /&gt;   Id = mnesia:dirty_update_counter(unique_ids, record_type, 1),&lt;br /&gt;   io:format( "Id =&gt; ~p~n", [Id] ),&lt;br /&gt;   Id1 = mnesia:dirty_update_counter(unique_ids, record_type, 1),&lt;br /&gt;   io:format( "Id =&gt; ~p~n", [Id1] ),&lt;br /&gt;   Id2 = mnesia:dirty_update_counter(unique_ids, another_type, 1),&lt;br /&gt;   io:format( "Id =&gt; ~p~n", [Id2] ),&lt;br /&gt;   &lt;br /&gt;&lt;br /&gt;The output you will get is&lt;br /&gt;&lt;br /&gt;Id =&gt; 1&lt;br /&gt;Id =&gt; 2&lt;br /&gt;Id =&gt; 1&lt;br /&gt;&lt;br /&gt;A single table can be used to generate the unique ids for other tables. In this example, unique ids are generated for record_type and another_type.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/970528744702948483-5835061071281599604?l=dudefrommangalore.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dudefrommangalore.blogspot.com/feeds/5835061071281599604/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=970528744702948483&amp;postID=5835061071281599604' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/5835061071281599604'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/5835061071281599604'/><link rel='alternate' type='text/html' href='http://dudefrommangalore.blogspot.com/2009/03/auto-increment-in-mnesia-database.html' title='Auto increment in Mnesia database'/><author><name>Dude From Mangalore</name><uri>http://www.blogger.com/profile/11648794788677197501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-970528744702948483.post-3525604181972059569</id><published>2009-03-12T18:51:00.000-07:00</published><updated>2009-03-12T18:55:23.763-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='tuning'/><category scheme='http://www.blogger.com/atom/ns#' term='tcp'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><title type='text'>Tuning TCP stack on Linux</title><content type='html'>TCP stack on most of the Linux distributions are tuned for the desktop. Using Linux distribution on servers having high load require some tuning on TCP stack. Here is what I found.&lt;br /&gt;&lt;br /&gt;Add the following lines into /etc/sysctl.conf&lt;br /&gt;&lt;br /&gt;# tcp tuning&lt;br /&gt;net.core.rmem_max=16777216&lt;br /&gt;net.core.wmem_max=16777216&lt;br /&gt;net.ipv4.tcp_wmem=4096 65536 16777216&lt;br /&gt;net.ipv4.tcp_rmem=4095 87380 16777216&lt;br /&gt;net.ipv4.tcp_no_metrics_save=1&lt;br /&gt;&lt;br /&gt;Run &lt;br /&gt;&lt;br /&gt;   sudo sysctl -p&lt;br /&gt;&lt;br /&gt;Restart your application(s).&lt;br /&gt;&lt;br /&gt;This is effective especially when clients are on slow connection. These configuration change will change the tcp write and read memory size so that lot many bytes can be sent over to client in a single packet.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/970528744702948483-3525604181972059569?l=dudefrommangalore.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dudefrommangalore.blogspot.com/feeds/3525604181972059569/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=970528744702948483&amp;postID=3525604181972059569' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/3525604181972059569'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/3525604181972059569'/><link rel='alternate' type='text/html' href='http://dudefrommangalore.blogspot.com/2009/03/tuning-tcp-stack-on-linux.html' title='Tuning TCP stack on Linux'/><author><name>Dude From Mangalore</name><uri>http://www.blogger.com/profile/11648794788677197501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-970528744702948483.post-8048275729027228072</id><published>2009-03-04T10:52:00.001-08:00</published><updated>2009-04-05T12:46:25.019-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='scripts'/><category scheme='http://www.blogger.com/atom/ns#' term='erlang'/><category scheme='http://www.blogger.com/atom/ns#' term='commandline'/><category scheme='http://www.blogger.com/atom/ns#' term='tips'/><category scheme='http://www.blogger.com/atom/ns#' term='spawn'/><title type='text'>Gracefully terminating erlang VM</title><content type='html'>Once started usually it is not required to stop erlang VM. We can stop the services running as well as erlang VM in a graceful manner with init:stop/0 function. Trick is to call this function on the target VM via remote shell.&lt;br /&gt;&lt;br /&gt;For example, to stop the VM running as foo@example.foo.com with cookie foo&lt;br /&gt;&lt;br /&gt;erl -name bar@example.foo.com -remsh foo@example.foo.com -setcookie foo -s init stop&lt;br /&gt;&lt;br /&gt;The above command will not work as init:stop() is executed within bar@localhost VM, not in foo@localhost. Another way is to do spawn in the target.&lt;br /&gt;&lt;br /&gt;erl -name bar@localhost -remsh foo@localhost -setcookie foo -s proc_lib spawn 'foo@example.foo.com' init stop "" -s init stop&lt;br /&gt;&lt;br /&gt;The above command will try to execute proc_lib:spawn( 'foo@example.foo.com', init, stop, []). There is a small caveat here. -s option pass all the paramter to proc_lib:spawn/4 as a list, not as a individual parameter. &lt;br /&gt;&lt;br /&gt;proc_lib:spawn( ['foo@example.foo.com', init, stop, [] ] ).&lt;br /&gt;&lt;br /&gt;Since there is no such function defined, it will not work. &lt;br /&gt;&lt;br /&gt;Only other solution is to create a module with one exported function which will spawn a function init:stop/0 on a remote shell.&lt;br /&gt;&lt;br /&gt;-module (ctrl).&lt;br /&gt;&lt;br /&gt;-export([stop/1]).&lt;br /&gt;&lt;br /&gt;stop(Node) -&gt; &lt;br /&gt;  proc_lib:spawn( hd(Node), init, stop, [] ).&lt;br /&gt;&lt;br /&gt;Note that ctrl:stop/1 function gets list as an argument and it taking only the head element from it.&lt;br /&gt;&lt;br /&gt;erl -name bar@example.foo.com -remsh foo@example.foo.com -setcookie foo -s ctrl stop 'foo@example.foo.com' -s init stop&lt;br /&gt;&lt;br /&gt;The above command line execute ctrl:stop(['foo@example.foo.com']), init:stop()&lt;br /&gt;&lt;br /&gt;UPDATE: This can be done from command line without using any other module. All you have to do is to use -eval option on erl command line.&lt;br /&gt;&lt;br /&gt;erl -name bar@example.foo.com -setcookie foo -eval "rpc:call('foo@example.foo.com', init, stop, []), init:stop()."&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/970528744702948483-8048275729027228072?l=dudefrommangalore.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dudefrommangalore.blogspot.com/feeds/8048275729027228072/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=970528744702948483&amp;postID=8048275729027228072' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/8048275729027228072'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/8048275729027228072'/><link rel='alternate' type='text/html' href='http://dudefrommangalore.blogspot.com/2009/03/gracefully-terminating-erlang-vm.html' title='Gracefully terminating erlang VM'/><author><name>Dude From Mangalore</name><uri>http://www.blogger.com/profile/11648794788677197501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-970528744702948483.post-3619364891913491948</id><published>2009-02-28T18:52:00.000-08:00</published><updated>2009-02-28T19:29:04.518-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='performance'/><category scheme='http://www.blogger.com/atom/ns#' term='http'/><category scheme='http://www.blogger.com/atom/ns#' term='erlang'/><category scheme='http://www.blogger.com/atom/ns#' term='ibrowse'/><title type='text'>ibrowse module for erlang</title><content type='html'>In the project I am working ( cannot disclose what it is for now ), I had to do a lot of web service calls over http. The server is written in erlang as a gen_server which spawn the process for each request. &lt;br /&gt;&lt;br /&gt;Apache is used as the user facing http server. We have written a content handle (apache module) which acts as a c-node by connecting to a local or remote (configured) erlang VM. gen_server in erlang VM registered as a named process (let's say foo). Each incoming user request is sent to the registered process and response from the registered process is sent back to the user (XML or JSON). &lt;br /&gt;&lt;br /&gt;Process spawned by gen_server make one or more web service call to the back-end servers. We were using erlang's http client. Apparently it is hard to configure as there is not much documentation available to maintain a persistent connection to the back-end (web service) servers. Thus there is a lot of socket churning as web service calls are http connections and were getting opened and closed. Location of the back-end servers are not necessarily near to our servers (physically). That means there is not only communication overhead but also http connection overhead. If ping time between our server and remote server is 25ms, each http connection will take 75ms (3-way hand shake). Having a persistent connection will solve this problem. &lt;br /&gt;&lt;br /&gt;We came across &lt;a href="http://github.com/dizzyd/ibrowse/tree/master"&gt;ibrowse&lt;/a&gt; module. This has a simple configuration to maintain persistent connection as well as configuration for maximum number of connection and maximum number of http requests that can be &lt;a href="http://en.wikipedia.org/wiki/HTTP_pipelining"&gt;pipelined&lt;/a&gt; on each connection. This improved our latency by 60% at 400qps and there is plenty of room to grow till 1000qps (on single box).&lt;br /&gt;&lt;br /&gt;I can also revert back to erlang's default http client provided I can set the profile for httpc while starting inets. I did not find a decent document to do so. If anyone know about it, let me know.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/970528744702948483-3619364891913491948?l=dudefrommangalore.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dudefrommangalore.blogspot.com/feeds/3619364891913491948/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=970528744702948483&amp;postID=3619364891913491948' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/3619364891913491948'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/3619364891913491948'/><link rel='alternate' type='text/html' href='http://dudefrommangalore.blogspot.com/2009/02/ibrowse-module-for-erlang.html' title='ibrowse module for erlang'/><author><name>Dude From Mangalore</name><uri>http://www.blogger.com/profile/11648794788677197501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-970528744702948483.post-2853422079432168385</id><published>2009-02-18T11:25:00.001-08:00</published><updated>2009-02-18T12:54:28.641-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='performance'/><category scheme='http://www.blogger.com/atom/ns#' term='erlang'/><category scheme='http://www.blogger.com/atom/ns#' term='strings'/><category scheme='http://www.blogger.com/atom/ns#' term='iolist'/><title type='text'>iolost vs list in Eralng</title><content type='html'>I started using Erlang few months back. Erlang has very little documentation (in most cases) and no documentation (in some cases). &lt;br /&gt;&lt;br /&gt;In Erlang strings are implemented in terms of list. Unlike C, string is a linked list. So every character in a string occupy 2 machine words, one for the character and another for the next pointer. On a 32-bit machine, each byte translates to 8 bytes and on 64-bit box 16 bytes. This is an issue when you are dealing with transporting string over the network. &lt;br /&gt;&lt;br /&gt;This becomes an issue when transporting data between erlang VM and c-node. If string is transported as internal representation, erlang will transport 8x number of bytes for a plain string. It is better to transport string as a binary (use erlang:list_to_binary/1 function). This will reduce the network overhead by 8x (on 32-bit machine).&lt;br /&gt;&lt;br /&gt;If a string is constructed in VM and is transported to C-node, it is easier to construct a iolist and use iolist_to_binary at the end to transport it as a binary. This will reduce the overhead of string concats and also save a lot on the garbage collection.&lt;br /&gt;&lt;br /&gt;For example,&lt;br /&gt;&lt;br /&gt;construct_string() -&gt;&lt;br /&gt;  [[&lt;&lt;"this is"&gt;&gt;, &lt;&lt;" a"&gt;&gt;], [" very long", &lt;&lt;" string."&gt;&gt;], &lt;&lt;" This string will go to c-node"&gt;&gt;].&lt;br /&gt;&lt;br /&gt;transport_to_code() -&gt;&lt;br /&gt;  iolist_to_binary(construct_string()).&lt;br /&gt;&lt;br /&gt;I saw huge improvement in memory as well as CPU utilization by using binaries instead of strings. Lesson learned is that do not use strings unless it is absolutely required. If binaries will do the work, use it.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/970528744702948483-2853422079432168385?l=dudefrommangalore.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dudefrommangalore.blogspot.com/feeds/2853422079432168385/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=970528744702948483&amp;postID=2853422079432168385' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/2853422079432168385'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/2853422079432168385'/><link rel='alternate' type='text/html' href='http://dudefrommangalore.blogspot.com/2009/02/iolost-vs-list-in-eralng.html' title='iolost vs list in Eralng'/><author><name>Dude From Mangalore</name><uri>http://www.blogger.com/profile/11648794788677197501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-970528744702948483.post-2988040615947628145</id><published>2008-12-21T10:18:00.001-08:00</published><updated>2008-12-21T10:38:12.886-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='erlang'/><category scheme='http://www.blogger.com/atom/ns#' term='coding'/><title type='text'>Pattern matching for string and list in erlang</title><content type='html'>Earlier I wrote a &lt;a href="http://dudefrommangalore.blogspot.com/2008/12/differentiate-string-from-regular-list.html"&gt;post&lt;/a&gt; on how to distinguish string from list. &lt;a href="http://steve.vinoski.net/blog/"&gt;Steve&lt;/a&gt; and &lt;a href="http://www.blogger.com/profile/16779655885724193555"&gt;Justin&lt;/a&gt;pointed that my approach will not work for a list of anythingg other than string.&lt;br /&gt;&lt;br /&gt;Here is what I am trying to solve. I have a main configuratin file and client specific configuration files. Client specific configuration file can override or add more values from main configuration file. If the value in main configuration file is a string, I want the client configuration to override the value of main configuration. If the value in main configuration is a list, I want to append the list from the client configuration to the main configuration. &lt;br /&gt;&lt;br /&gt;For example, main configuration file is&lt;br /&gt;&lt;br /&gt;[{blacklist, ["foo.com", "aaa.com"]},&lt;br /&gt; {source_host, "http://www.bar.com"}].&lt;br /&gt;&lt;br /&gt;and client configuration file is&lt;br /&gt;&lt;br /&gt;[{blacklist, [ "bar.com" ]},&lt;br /&gt; {source_host, "http://www.something.com"}].&lt;br /&gt;&lt;br /&gt;After merging above 2 configuration, I want the final configuration to look like,&lt;br /&gt;&lt;br /&gt;[{blacklist, [ "foo.com", "aaa.com", "bar.com" ]},&lt;br /&gt; {source_host, "http://www.something.com"}].&lt;br /&gt;&lt;br /&gt;The code reading the configuration files and merging them does not know the first element of the tuple ahead of time. The code is generic to read a file of list of tuples and merge the values to generate the final configuration.&lt;br /&gt;&lt;br /&gt;Since Erlang implement string as a list, using is_list guard for a function will not work. If anybody has solved this problem earlier, please comment on this blog.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/970528744702948483-2988040615947628145?l=dudefrommangalore.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dudefrommangalore.blogspot.com/feeds/2988040615947628145/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=970528744702948483&amp;postID=2988040615947628145' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/2988040615947628145'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/2988040615947628145'/><link rel='alternate' type='text/html' href='http://dudefrommangalore.blogspot.com/2008/12/pattern-matching-for-string-and-list-in.html' title='Pattern matching for string and list in erlang'/><author><name>Dude From Mangalore</name><uri>http://www.blogger.com/profile/11648794788677197501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-970528744702948483.post-4490446229594647015</id><published>2008-12-13T16:13:00.000-08:00</published><updated>2008-12-13T16:23:42.147-08:00</updated><title type='text'>Differentiate string from regular list in Erlang</title><content type='html'>Erlang is a great language to work with. I need to concentrate on the business logic rather than nifty details about the distributed computing like communication between nodes, handle node failures, restart apps etc. All these details are already taken care by the language itself. Yes.. distributed computing and concurrent programming is a integrated part of the language. &lt;br /&gt;&lt;br /&gt;Erlang implement string in terms of list. So it is tricky to distinguish regular string from the list. For example,&lt;br /&gt;&lt;br /&gt;&lt;span class="fullpost"&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="html:py"&gt;&lt;br /&gt;foo(C) when is_string(C) -&gt;&lt;br /&gt;   % do something with string;&lt;br /&gt;foo(C) when is_list(C) -&gt;&lt;br /&gt;   % do something with list.&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;First of all there is no function called "is_string" in Erlang. (I just made it up). But the point here is that how to distinguish regular string from the list. I came up with this solution.&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="html:py"&gt;&lt;br /&gt;foo(C) when lists:flatten(C) == C -&gt;&lt;br /&gt;   % do something with string;&lt;br /&gt;foo(C) when is_list(C) -&gt;&lt;br /&gt;   % do something with list.&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Somewhat inefficient because of call to lists:flatten/1 call. But for small strings, it is not an issue at all.&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/970528744702948483-4490446229594647015?l=dudefrommangalore.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dudefrommangalore.blogspot.com/feeds/4490446229594647015/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=970528744702948483&amp;postID=4490446229594647015' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/4490446229594647015'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/4490446229594647015'/><link rel='alternate' type='text/html' href='http://dudefrommangalore.blogspot.com/2008/12/differentiate-string-from-regular-list.html' title='Differentiate string from regular list in Erlang'/><author><name>Dude From Mangalore</name><uri>http://www.blogger.com/profile/11648794788677197501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-970528744702948483.post-4740091263231315543</id><published>2008-12-06T10:51:00.001-08:00</published><updated>2008-12-06T10:58:47.959-08:00</updated><title type='text'>Shame on you Mr. Manmohan Singh....</title><content type='html'>&lt;a href="http://www.ndtv.com/convergence/ndtv/story.aspx?id=NEWEN20080075492"&gt;Here &lt;/a&gt;is a comment from Condoleezza Rice:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;US Secretary of State Condoleezza Rice has told Pakistan that there is "irrefutable evidence" of involvement of elements in this country in the Mumbai terror attacks and it had no option but to act urgently "otherwise, the US will act."&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;Dispute with Pakistan is of India's own. Should Indian government wait for USA to protect it inspite of having one of the biggest and powerful army in the world? Shame on you the respected prime minister of Manmohan Singh. I expected such a statement to come from Indian government as soon as India had enough proof to implicate "Elements within Pakistan" for the attack on Mumbai on 26/11. Why should Indian government present the proof to US government and wait for them to act on behalf of us? Isn't that shameful? &lt;br /&gt;&lt;br /&gt;I am not supporting war with Pakistan as it is bad for the people of India as well as Pakistan. The terroists activity in Mumbai has nothing to do with the people of Pakistan. It is some groups freely operating within Pakistan is responsible for it. Punishing the whole country for the act of few people is not a wise idea. But India should have acted against the group immediately. Do what US did in Afghanistan. Ask the government to hand over the people responsible. If they don't, get in and take them out yourself. Don't wait for some other country to do that for you.&lt;br /&gt;&lt;br /&gt;Shame.. Shame.. Shame...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/970528744702948483-4740091263231315543?l=dudefrommangalore.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dudefrommangalore.blogspot.com/feeds/4740091263231315543/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=970528744702948483&amp;postID=4740091263231315543' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/4740091263231315543'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/4740091263231315543'/><link rel='alternate' type='text/html' href='http://dudefrommangalore.blogspot.com/2008/12/shame-on-you-mr-manmohan-singh.html' title='Shame on you Mr. Manmohan Singh....'/><author><name>Dude From Mangalore</name><uri>http://www.blogger.com/profile/11648794788677197501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-970528744702948483.post-2352892883459742954</id><published>2008-12-02T16:23:00.001-08:00</published><updated>2008-12-02T16:27:37.193-08:00</updated><title type='text'>A Letter to the Prime Minsiter of India</title><content type='html'>Today I received this email from one of my colleague. It really captured my attention. Here is the letter.&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;&lt;br /&gt;                         LETTER TO PRIME MINISTER&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Dear Mr. Prime minister&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I am a typical mouse from Mumbai. In the local train compartment which has capacity of 100 persons, I travel with 500 more mouse. Mouse at least squeak but we don't even do that.&lt;br /&gt;&lt;br /&gt;Today I heard your speech. In which you said 'NO BODY WOULD BE SPARED'. I would like to remind you that fourteen years has passed since serial bomb blast in Mumbai took place. Dawood was the main conspirator. Till today he is not caught. All our bolywood actors, our builders, our Gutka king meets him but your Government can not catch him. Reason is simple; all your ministers are hand in glove with him. If any attempt is made to catch him everybody will be exposed. Your statement 'NOBODY WOULD BE SPARED' is nothing but a cruel joke on this unfortunate people of India.&lt;br /&gt;&lt;br /&gt;Enough is enough. As such after seeing terrorist attack carried out by about a dozen young boys I realize that if same thing continues days are not away when terrorist will attack by air, destroy our nuclear reactor and there will be one more Hiroshima.&lt;br /&gt;&lt;br /&gt;We the people are left with only one mantra. Womb to Bomb to Tomb. You promised Mumbaikar Shanghai what you have given us is alianwala Baug.&lt;br /&gt;&lt;br /&gt;Today only your home minister resigned. What took you so long to kick out this joker? Only reason was that he was loyal to Gandhi family. Loyalty to Gandhi family is more important than blood of innocent people, isn't it?&lt;br /&gt;&lt;br /&gt;I am born and bought up in Mumbai for last fifty eight years. Believe me corruption in Maharashtra is worse than that in Bihar. Look at all the politician, Sharad Pawar, Chagan Bhujbal, Narayan Rane, Bal Thackray, Gopinath Munde, Raj Thackray, Vilasrao Deshmukh all are rolling in money. Vilasrao Deshmukh is one of the worst Chief minister I have seen. His only business is to increase the FSI every other day, make money and send it to Delhi so Congress can fight next election. Now the clown has found new way and will increase FSI for fisherman so they can build concrete house right on sea shore. Next time terrorist can comfortably live in those house, enjoy the beauty of sea and then attack the Mumbai at their will.&lt;br /&gt;&lt;br /&gt;Recently I had to purchase house in Mumbai. I met about two dozen builders. Everybody wanted about 30% in black. A common person like me knows this and with all your intelligent agency &amp; CBI you and your finance minister are not aware of it. Where all the black money goes? To the underworld isn't it? Our politicians take help of these goondas to vacate people by force. I myself was victim of it. If you have time please come to me, I will tell you everything.&lt;br /&gt;&lt;br /&gt;If this has been land of fools, idiots then I would not have ever cared to write you this letter. Just see the tragedy, on one side we are reaching moon, people are so intelligent and on other side you politician has converted nectar into deadly poison. I am everything Hindu, Muslim, Christian, Schedule caste, OBC, Muslim OBC, Christian Schedule caste, Creamy Schedule caste only what I am not is INDIAN. You politician have raped every part of mother India by your policy of divide and rule.&lt;br /&gt;&lt;br /&gt;Take example of former president Abdul Kalam. Such a intelligent person, such a fine human being. You politician didn't even spare him.  Your party along with opposition joined the hands, because politician feels they are supreme and there is no place for good person.&lt;br /&gt;&lt;br /&gt;Dear Mr Prime minister you are one of the most intelligent person, most learned person. Just wake up, be a real SARDAR. First and foremost expose all selfish politician. Ask Swiss bank to give name of all Indian account holder. Give reins of CBI to independent agency. Let them find wolf among us. There will be political upheaval but that will better than dance of death which we are witnessing every day.  Just give us ambient where we can work honestly and without fear. Let there be rule of law. Everything else&lt;br /&gt;will be taken care of.&lt;br /&gt;&lt;br /&gt;Choice is yours Mr. Prime Minister. Do you want to be lead by one person or you want to lead the nation of 100 Crore people?&lt;br /&gt;&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/970528744702948483-2352892883459742954?l=dudefrommangalore.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dudefrommangalore.blogspot.com/feeds/2352892883459742954/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=970528744702948483&amp;postID=2352892883459742954' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/2352892883459742954'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/2352892883459742954'/><link rel='alternate' type='text/html' href='http://dudefrommangalore.blogspot.com/2008/12/letter-to-prime-minsiter-of-india.html' title='A Letter to the Prime Minsiter of India'/><author><name>Dude From Mangalore</name><uri>http://www.blogger.com/profile/11648794788677197501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-970528744702948483.post-5443642201348318876</id><published>2008-11-29T11:12:00.000-08:00</published><updated>2008-11-29T11:17:25.435-08:00</updated><title type='text'>What should India do about Mumbai attacks?</title><content type='html'>&lt;blockquote&gt;During his preliminary interrogation, Qasad believed to have reportedly told police, "I have done right and I have no regrets." He has also admitted to being a member of the Lashkar.&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;This what Qasad said who was captured by NSG in Mumbai. Should India listen to this and keep quite? I say NO... Make him regret. Whatever means necessary.&lt;br /&gt;&lt;br /&gt;If I was given control, I would make him regret by making his loved one loose their life in front of his eyes and set an example for the future. Make people think about the consequences if at all they decide to do something like what happened in Mumbai.&lt;br /&gt;&lt;br /&gt;For those who say I am cold, I would say bring it on.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/970528744702948483-5443642201348318876?l=dudefrommangalore.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dudefrommangalore.blogspot.com/feeds/5443642201348318876/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=970528744702948483&amp;postID=5443642201348318876' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/5443642201348318876'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/5443642201348318876'/><link rel='alternate' type='text/html' href='http://dudefrommangalore.blogspot.com/2008/11/what-should-india-do-about-mumbai.html' title='What should India do about Mumbai attacks?'/><author><name>Dude From Mangalore</name><uri>http://www.blogger.com/profile/11648794788677197501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-970528744702948483.post-3314591551367525451</id><published>2008-11-28T23:33:00.000-08:00</published><updated>2008-11-28T23:38:29.045-08:00</updated><title type='text'>Who is responsible for Mumbai attack?</title><content type='html'>&lt;blockquote&gt;US expert on South Asia dubs Mumbai attacks as India's "domestic issue"&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;Here is what he said:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;This is a domestic issue. India's domestic problems and long tensions between local communities were at the root of the rise of terrorism in the country&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;How come when the attack is in US, it is global terrorism and when the attack is on other countries (ofcourse other than the so called friends of US) it is domestic issue.&lt;br /&gt;&lt;br /&gt;This guy failed to check that the attackers were not from India, but everyone of them were from Pakistan. More over, Pakistan reverted its decision to send the head of ISI to India to share the information on this terrorist attack.&lt;br /&gt;&lt;br /&gt;Mr/Ms. Christine Fair, get your facts right before making any statements.&lt;br /&gt;&lt;br /&gt;Read more about it &lt;a href="http://in.news.yahoo.com/139/20081129/874/twl-us-expert-on-south-asia-dubs-mumbai.html"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Wah bhai wah!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/970528744702948483-3314591551367525451?l=dudefrommangalore.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dudefrommangalore.blogspot.com/feeds/3314591551367525451/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=970528744702948483&amp;postID=3314591551367525451' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/3314591551367525451'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/3314591551367525451'/><link rel='alternate' type='text/html' href='http://dudefrommangalore.blogspot.com/2008/11/who-is-responsible-for-mumbai-attack.html' title='Who is responsible for Mumbai attack?'/><author><name>Dude From Mangalore</name><uri>http://www.blogger.com/profile/11648794788677197501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-970528744702948483.post-6665397278017899814</id><published>2008-11-14T23:33:00.000-08:00</published><updated>2008-11-14T23:48:48.628-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='function programming'/><category scheme='http://www.blogger.com/atom/ns#' term='erlang'/><title type='text'>Parallel assignment</title><content type='html'>Today I was working on some problem (off course in Erlang). What I am trying to achieve was to execute a function in parallel and assign result of function to a variable.&lt;br /&gt;&lt;br /&gt;&lt;pre class="html:py" name="code"&gt;&lt;br /&gt;Func = fun(Arg) -&gt;&lt;br /&gt;          Parent = self(),&lt;br /&gt;          Pid = spawn( fun() -&gt; timer:sleep(1000), Parent ! {self(), Arg + 2} end ),&lt;br /&gt;          receive {Pid, Val} -&gt; Val&lt;br /&gt;       end,&lt;br /&gt;RetVal = Func(),&lt;br /&gt;SomeOtherValue = 10,&lt;br /&gt;% rest of the code&lt;br /&gt;io:format( "~p~n", [RetVal] ),&lt;br /&gt;% more code here&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;In the above code, calling Func() block the execution until receive loop within Func is done receiving the data from the spawned process. SomeOtherValue is assigned only after the execution of Func.&lt;br /&gt;&lt;br /&gt;What I want is not that. I want the execution to continue even if the execution of &lt;strong&gt;Func&lt;/strong&gt; is not finished. I want to block only when I am trying to use &lt;strong&gt;RetVal&lt;/strong&gt; variable.&lt;br /&gt;&lt;br /&gt;Currently I am acheiving this by waiting for the response from the spawned process only when I need the data from the process, i.e., same as blocking when the variable is accessed.&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="html:py"&gt;&lt;br /&gt;Func = fun(Arg) -&gt;&lt;br /&gt;          Parent = self(),&lt;br /&gt;          Pid = spawn( fun() -&gt; timer:sleep(1000), Parent ! {self(), Arg + 2} end ),&lt;br /&gt;       end,&lt;br /&gt;Pid = Func(),&lt;br /&gt;SomeOtherValue = 10,&lt;br /&gt;% rest of the code&lt;br /&gt;RetVal = receive {self(), Val} -&gt; Val end,&lt;br /&gt;io:format( "~p~n", [RetVal] ),&lt;br /&gt;% more code here&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Even though it is a trivial code change, I would like if the parallel assignment is allowed and block when I try to use it (if necessary).&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/970528744702948483-6665397278017899814?l=dudefrommangalore.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dudefrommangalore.blogspot.com/feeds/6665397278017899814/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=970528744702948483&amp;postID=6665397278017899814' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/6665397278017899814'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/6665397278017899814'/><link rel='alternate' type='text/html' href='http://dudefrommangalore.blogspot.com/2008/11/parallel-assignment.html' title='Parallel assignment'/><author><name>Dude From Mangalore</name><uri>http://www.blogger.com/profile/11648794788677197501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-970528744702948483.post-7595525762180909133</id><published>2008-11-13T07:00:00.000-08:00</published><updated>2008-11-13T08:51:09.946-08:00</updated><title type='text'>Erlang and Garbage collection</title><content type='html'>&lt;p&gt;In my new project, we did the whole coding in erlang. Yaws is our front-end. When running a load test, we observed that memory usage goes high and ultimately crash the erlang virtual machine. We did a thorough analysis of our code to find any possible memory leak (not possible as erlang uses garbage collection) and also studied the code for any possible recursion instead of tail recursion. We did not find any. It was pretty puzzling. Then I did find one strange thing. This is all about erlang garbage collection works.&lt;/p&gt;&lt;span class="fullpost"&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;In turns out that Erlang's garbage collection works per process. Each process has its own heap and stack. If a process is a long running one and does lot of things for each call, memory gets accumulated and will get released very slowly. When Erlang virtual machine is busy doing things, garbage collection thread gets lower priority and may never get called. Even if it is called, it may not do the whole memory garbage collection. Thus, memory keeps on growing.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;In our code, we were running a gen server. This gen server was doing lot of work in the same process. We were running several hundreds of these gen_servers (monitored by a supervisor). Child specs for the supervisor was created dynamically depending on the initial configuration. In nutshell, it was doin the following&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="html:python" name="code"&gt;&lt;br /&gt;-module(foo_server)&lt;br /&gt;-behaviour(gen_server)&lt;br /&gt;&lt;br /&gt;% Not outlining all methods exported here, only the required ones&lt;br /&gt;&lt;br /&gt;execute(Params) -&gt;&lt;br /&gt;   gen_server:call({run, Params}).&lt;br /&gt;&lt;br /&gt;handle_call({run, Params}, _From, State) -&gt;&lt;br /&gt;  some_module:execute(Params). % some_module:execute does most of the work here.&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Note that here some_module:execute/1 runs in the same process as gen_server. Idea here was that gen_server is monitored by supervisor and we get free process monitoring. But since same process gets called over and over again, memory accumulates. Running load test was increasing memory usage.&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Now Erlang process comes to rescue. Because of functional aspect, it got pretty easy to change the code to run some_module:execute/1 in a different process and return the result to the caller via process message passing. I did the following changes&lt;br /&gt;&lt;br /&gt;&lt;pre class="html:python" name="code"&gt;&lt;br /&gt;-module(foo_server)&lt;br /&gt;&lt;br /&gt;execute(Params) -&gt;&lt;br /&gt;  MySelf = self(),&lt;br /&gt;  spawn( fun() -&gt; Result = some_module:execute(Params), MySelf ! {MySelf, Result} end),&lt;br /&gt;  receive &lt;br /&gt;      {MySelf, R} -&gt; R;&lt;br /&gt;      after 1000 -&gt; {error, timeout}&lt;br /&gt;  end.&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Eureka! Running the same load test did not result in increased memory usage. Memory was pretty stable even after running the load test for more than an hour.&lt;/p&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/970528744702948483-7595525762180909133?l=dudefrommangalore.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dudefrommangalore.blogspot.com/feeds/7595525762180909133/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=970528744702948483&amp;postID=7595525762180909133' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/7595525762180909133'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/7595525762180909133'/><link rel='alternate' type='text/html' href='http://dudefrommangalore.blogspot.com/2008/11/erlang-and-garbage-collection.html' title='Erlang and Garbage collection'/><author><name>Dude From Mangalore</name><uri>http://www.blogger.com/profile/11648794788677197501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-970528744702948483.post-1190646410879845634</id><published>2008-11-10T11:49:00.000-08:00</published><updated>2008-11-10T11:59:55.486-08:00</updated><title type='text'>URL Shortcut in Firefox</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.mozilla.com/img/tignish/home/feature-logo.png"&gt;&lt;img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer; width: 351px; height: 102px;" src="http://www.mozilla.com/img/tignish/home/feature-logo.png" alt="" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Firefox has this amazingly useful but hidden feature of adding shortcut for a bookmark. This is not just restricted to search based urls. Here is how to do this.&lt;br /&gt;&lt;br /&gt;1. Bookmark your favorite URL&lt;br /&gt;2. Go to Bookmarks -&gt; Organize Bookmarks... menu&lt;br /&gt;3. Choose the bookmark from (1)&lt;br /&gt;4. In the bottom panel, click on "More"&lt;br /&gt;5. Enter shortcut word or letter in "Keyword" text box&lt;br /&gt;6. Close "Organize Bookmarks" window&lt;br /&gt;7. In the address bar, type the word or letter from (5)&lt;br /&gt;8. Viola!&lt;br /&gt;9. Enjoy the time saved in taking the mouse pointer to Bookmarks menu and selecting the bookmark :-)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/970528744702948483-1190646410879845634?l=dudefrommangalore.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dudefrommangalore.blogspot.com/feeds/1190646410879845634/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=970528744702948483&amp;postID=1190646410879845634' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/1190646410879845634'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/1190646410879845634'/><link rel='alternate' type='text/html' href='http://dudefrommangalore.blogspot.com/2008/11/url-shortcut-in-firefox.html' title='URL Shortcut in Firefox'/><author><name>Dude From Mangalore</name><uri>http://www.blogger.com/profile/11648794788677197501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-970528744702948483.post-8150765474175860418</id><published>2008-11-08T12:16:00.001-08:00</published><updated>2008-11-08T12:16:16.830-08:00</updated><title type='text'>Quatum of Solace...</title><content type='html'>&lt;script type="text/javascript" src="http://widgets.clearspring.com/o/48092dcdadf7b025/4915f38f1d0bd895/48114b71bf1cb26c/86a58f22/widget.js"&gt;&lt;/script&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/970528744702948483-8150765474175860418?l=dudefrommangalore.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dudefrommangalore.blogspot.com/feeds/8150765474175860418/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=970528744702948483&amp;postID=8150765474175860418' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/8150765474175860418'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/8150765474175860418'/><link rel='alternate' type='text/html' href='http://dudefrommangalore.blogspot.com/2008/11/quatum-of-solace.html' title='Quatum of Solace...'/><author><name>Dude From Mangalore</name><uri>http://www.blogger.com/profile/11648794788677197501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-970528744702948483.post-4783827176449415327</id><published>2008-11-03T19:17:00.000-08:00</published><updated>2008-11-03T20:18:32.971-08:00</updated><title type='text'>Java is like writing story.</title><content type='html'>Here is a code to get md5 signature for a text&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="html:java"&gt;&lt;br /&gt;public static String MD5(String text) &lt;br /&gt;        throws NoSuchAlgorithmException, UnsupportedEncodingException  {&lt;br /&gt;                MessageDigest md;&lt;br /&gt;                md = MessageDigest.getInstance("MD5");                &lt;br /&gt;                byte[] md5hash = new byte[32];   &lt;br /&gt;                md.update(text.getBytes("iso-8859-1"), 0, text.length());&lt;br /&gt;                md5hash = md.digest();&lt;br /&gt;                return convertToHex(md5hash);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;private static String convertToHex(byte[] data) {&lt;br /&gt;        StringBuffer buf = new StringBuffer();&lt;br /&gt;        for (int i = 0; i &lt; data.length; i++) {&lt;br /&gt;                int halfbyte = (data[i] &gt;&gt;&gt; 4) &amp; 0x0F;&lt;br /&gt;                int two_halfs = 0;&lt;br /&gt;                do {&lt;br /&gt;                        if ((0 &lt;= halfbyte) &amp;&amp; (halfbyte &lt;= 9))&lt;br /&gt;                        buf.append((char) ('0' + halfbyte));&lt;br /&gt;                    else&lt;br /&gt;                        buf.append((char) ('a' + (halfbyte - 10)));&lt;br /&gt;                        halfbyte = data[i] &amp; 0x0F;&lt;br /&gt;                } while(two_halfs++ &lt; 1);&lt;br /&gt;        }&lt;br /&gt;        return buf.toString();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Here is code in perl&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="html:py"&gt;&lt;br /&gt;use Digest::MD5 qw(md5_hex);&lt;br /&gt;my $digest = md5_hex($text);&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;This is 20+ lines vs. 3 lines. Java seems to make everything over-object-oriented. Why do I need to getInstance(), update and then call digest() to just get the md5 of the string?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/970528744702948483-4783827176449415327?l=dudefrommangalore.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dudefrommangalore.blogspot.com/feeds/4783827176449415327/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=970528744702948483&amp;postID=4783827176449415327' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/4783827176449415327'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/4783827176449415327'/><link rel='alternate' type='text/html' href='http://dudefrommangalore.blogspot.com/2008/11/java-is-like-writing-story.html' title='Java is like writing story.'/><author><name>Dude From Mangalore</name><uri>http://www.blogger.com/profile/11648794788677197501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-970528744702948483.post-8239942949684636008</id><published>2008-10-16T18:18:00.001-07:00</published><updated>2008-10-16T18:25:13.147-07:00</updated><title type='text'>Viewing PDF from within Firefox on Mac</title><content type='html'>I was searching for the firefox plugin to view pdf files within the browser (embedded). I was not able to find the anything useful via google search. But Yahoo! search got me the &lt;a href="http://search.yahoo.com/search?p=firefox+pdf+viewer+embedded+mac&amp;amp;ei=UTF-8&amp;amp;fr=moz2"&gt;result&lt;/a&gt;, that too first one...&lt;br /&gt;&lt;br /&gt;Here is the &lt;a href="http://dev.upian.com/hotlinks/?tag=pdf&amp;amp;n=1"&gt;page&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Hurray.. At last I can read PDFs within Firefox without downloading it on to my desktop. No more folder clutter..&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/970528744702948483-8239942949684636008?l=dudefrommangalore.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dudefrommangalore.blogspot.com/feeds/8239942949684636008/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=970528744702948483&amp;postID=8239942949684636008' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/8239942949684636008'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/8239942949684636008'/><link rel='alternate' type='text/html' href='http://dudefrommangalore.blogspot.com/2008/10/viewing-pdf-from-within-firefox-on-mac.html' title='Viewing PDF from within Firefox on Mac'/><author><name>Dude From Mangalore</name><uri>http://www.blogger.com/profile/11648794788677197501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-970528744702948483.post-7473963167653528257</id><published>2008-10-07T19:07:00.000-07:00</published><updated>2008-11-05T21:19:18.996-08:00</updated><title type='text'>How to setup grid using Erlang?</title><content type='html'>Erlang is a functional programming language with the built-in support for concurrency and distributed computing. Nodes running erlang virtual machine can communicate with each other without any additional coding.&lt;br /&gt;&lt;br /&gt;Erlang use light weight process model to achieve the distributed computing. Erlang processes are lighter than linux thread. One erlang node can run more than 10k (sometime more than 100k) processes on a single node.&lt;br /&gt;&lt;br /&gt;Erlang process is started using spawn or spawn_link function. A process can be started on the current vm (virtual machine) or on any other vm in the grid by just adding one additional parameter to these functions.&lt;br /&gt;&lt;br /&gt;In order for 2 nodes to communicate with each other, both nodes should have the same cookie. In a grid, all erlang nodes should have the same secret (set via -setcookie command line option or using erlang:set_cookie/2 function)&lt;br /&gt;&lt;br /&gt;Erlang nodes follow the following naming convention.&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;strong&gt;name@hostname&lt;/strong&gt; where &lt;strong&gt;&lt;em&gt;name&lt;/em&gt;&lt;/strong&gt; can be any arbitrary name&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;In this example, I am assuming that I have 2 hosts namely node1.example.com and node2.example.com&lt;br /&gt;&lt;br /&gt;Run the erlang vm on each node with short name&lt;br /&gt;&lt;br /&gt;On node1.example.com,&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;erl -sname foo -setcookie mysecret&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;On node2.example.com,&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;erl -sname bar -setcookie mysecret &lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;On node1.example.com, ping node2.&lt;br /&gt;&lt;br /&gt;net_adm:ping('bar@node2.example.com').&lt;br /&gt;pong&lt;br /&gt;nodes().&lt;br /&gt;['bar@node2.example.com']&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/970528744702948483-7473963167653528257?l=dudefrommangalore.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dudefrommangalore.blogspot.com/feeds/7473963167653528257/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=970528744702948483&amp;postID=7473963167653528257' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/7473963167653528257'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/7473963167653528257'/><link rel='alternate' type='text/html' href='http://dudefrommangalore.blogspot.com/2008/10/how-to-setup-grid-using-erlang.html' title='How to setup grid using Erlang?'/><author><name>Dude From Mangalore</name><uri>http://www.blogger.com/profile/11648794788677197501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-970528744702948483.post-7948666145774885665</id><published>2008-10-01T09:17:00.001-07:00</published><updated>2008-10-01T09:19:41.145-07:00</updated><title type='text'>Why Microsoft just don't get it?</title><content type='html'>Today Microsoft's Live Search announced &lt;span style="font-weight:bold;"&gt;SearchPerks&lt;/span&gt; program. Users are given point when they use Live Search. These points can be re-deemed for X-Box games, t-shirts etc. But the catch is you have to use Internet Explorer 6.0 or higher.&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;To earn value for your searches and join the SearchPerks! promotion you must have Internet Explorer 6.0 or higher to participate&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;Microsoft just don't get that Internet is a open space and users should be allowed to use whatever browser they are using.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/970528744702948483-7948666145774885665?l=dudefrommangalore.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dudefrommangalore.blogspot.com/feeds/7948666145774885665/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=970528744702948483&amp;postID=7948666145774885665' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/7948666145774885665'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/7948666145774885665'/><link rel='alternate' type='text/html' href='http://dudefrommangalore.blogspot.com/2008/10/why-microsoft-just-dont-get-it.html' title='Why Microsoft just don&apos;t get it?'/><author><name>Dude From Mangalore</name><uri>http://www.blogger.com/profile/11648794788677197501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-970528744702948483.post-2832113405463567353</id><published>2008-09-29T16:13:00.000-07:00</published><updated>2008-09-29T16:15:23.385-07:00</updated><title type='text'>I can do everything in C or in Java..</title><content type='html'>Here is the philosophy that should be used by programmers&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;As a programmer you should spend your time expressing your ideas, not jumping through hoops to accommodate a language. If you spend the majority of your time doing the latter, the language you're working in probably isn't very good.&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;From &lt;a href="http://wiki.reia-lang.org/wiki/Philosophy#A_language_shouldn.27t_get_in_your_way"&gt;here&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/970528744702948483-2832113405463567353?l=dudefrommangalore.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dudefrommangalore.blogspot.com/feeds/2832113405463567353/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=970528744702948483&amp;postID=2832113405463567353' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/2832113405463567353'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/2832113405463567353'/><link rel='alternate' type='text/html' href='http://dudefrommangalore.blogspot.com/2008/09/i-can-do-everything-in-c-or-in-java.html' title='I can do everything in C or in Java..'/><author><name>Dude From Mangalore</name><uri>http://www.blogger.com/profile/11648794788677197501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-970528744702948483.post-1843926207501386097</id><published>2008-09-29T10:14:00.000-07:00</published><updated>2008-09-29T10:16:39.145-07:00</updated><title type='text'>No shadow building</title><content type='html'>&lt;blockquote&gt;Le Project Triangle is one of those buildings that make us think that we may actually drive flying cars one day. To be completed by 2014 in the Porte de Versailles area in Paris, its most impressive feature is that, according to the architects, it won't cast shadows on adjacent buildings. The trick is the orientation and it's shape: While it looks like a massive pyramid from one side, the other side shows that it really is an ultra-thin triangle resembling a shark's fin&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;More &lt;a href="http://gizmodo.com/5056228/new-paris-building-casts-no-shadows-generates-electricity"&gt;here&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/970528744702948483-1843926207501386097?l=dudefrommangalore.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dudefrommangalore.blogspot.com/feeds/1843926207501386097/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=970528744702948483&amp;postID=1843926207501386097' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/1843926207501386097'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/1843926207501386097'/><link rel='alternate' type='text/html' href='http://dudefrommangalore.blogspot.com/2008/09/no-shadow-building.html' title='No shadow building'/><author><name>Dude From Mangalore</name><uri>http://www.blogger.com/profile/11648794788677197501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-970528744702948483.post-8129120434045288080</id><published>2008-09-26T12:13:00.000-07:00</published><updated>2008-09-26T12:19:03.231-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><title type='text'>Threads are at last in C++ standard</title><content type='html'>It's been decades since I am doing thread programming in C++. It was so painful to use POSIX thread APIs. It is like writing a same novel many times. Not anymore... C++0x standard is out there now. Yahoooooo.. Thread is included in the standard now. Read more about it &lt;a href="http://www.devx.com/SpecialReports/Article/38883/1954?pf=true"&gt;here&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/970528744702948483-8129120434045288080?l=dudefrommangalore.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dudefrommangalore.blogspot.com/feeds/8129120434045288080/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=970528744702948483&amp;postID=8129120434045288080' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/8129120434045288080'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/8129120434045288080'/><link rel='alternate' type='text/html' href='http://dudefrommangalore.blogspot.com/2008/09/threads-are-at-last-in-c-standard.html' title='Threads are at last in C++ standard'/><author><name>Dude From Mangalore</name><uri>http://www.blogger.com/profile/11648794788677197501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-970528744702948483.post-4665911596808526323</id><published>2008-09-26T10:32:00.000-07:00</published><updated>2008-09-26T12:18:36.811-07:00</updated><title type='text'>Illustration of Boost shared_ptr</title><content type='html'>&lt;object codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" id="doc_146417907980755" name="doc_146417907980755" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" align="middle" height="500" width="100%"&gt;  &lt;param name="movie" value="http://documents.scribd.com/ScribdViewer.swf?document_id=6229492&amp;access_key=key-raq7dme13bz0mixxaor&amp;page=&amp;version=1&amp;auto_size=true&amp;viewMode="&gt;   &lt;param name="quality" value="high"&gt;   &lt;param name="play" value="true"&gt;  &lt;param name="loop" value="true"&gt;   &lt;param name="scale" value="showall"&gt;  &lt;param name="wmode" value="opaque"&gt;   &lt;param name="devicefont" value="false"&gt;  &lt;param name="bgcolor" value="#ffffff"&gt;   &lt;param name="menu" value="true"&gt;  &lt;param name="allowFullScreen" value="true"&gt;   &lt;param name="allowScriptAccess" value="always"&gt;   &lt;param name="salign" value=""&gt;      &lt;embed src="http://documents.scribd.com/ScribdViewer.swf?document_id=6229492&amp;access_key=key-raq7dme13bz0mixxaor&amp;page=&amp;version=1&amp;auto_size=true&amp;viewMode=" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" play="true" loop="true" scale="showall" wmode="opaque" devicefont="false" bgcolor="#ffffff" name="doc_146417907980755_object" menu="true" allowfullscreen="true" allowscriptaccess="always" salign="" type="application/x-shockwave-flash" align="middle"  height="500" width="100%"&gt;&lt;/embed&gt; &lt;/object&gt;&lt;div style="font-size:10px;text-align:center;width:100%"&gt;&lt;a href="http://www.scribd.com/doc/6229492/Illustration-of-Boost-Shared-Pointer"&gt;Illustration of Boost Shared Pointer&lt;/a&gt; - &lt;a href="http://www.scribd.com/upload"&gt;Upload a Document to Scribd&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/970528744702948483-4665911596808526323?l=dudefrommangalore.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dudefrommangalore.blogspot.com/feeds/4665911596808526323/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=970528744702948483&amp;postID=4665911596808526323' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/4665911596808526323'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/970528744702948483/posts/default/4665911596808526323'/><link rel='alternate' type='text/html' href='http://dudefrommangalore.blogspot.com/2008/09/illustration-of-boost-sharedptr.html' title='Illustration of Boost shared_ptr'/><author><name>Dude From Mangalore</name><uri>http://www.blogger.com/profile/11648794788677197501</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
