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

<channel>
	<title>Shey's Rebellion &#187; Erlang</title>
	<atom:link href="http://www.sheysrebellion.net/blog/category/programming/erlang/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sheysrebellion.net/blog</link>
	<description>I sleep with pillows on my head.</description>
	<lastBuildDate>Fri, 22 Jan 2010 00:10:42 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Erlang Exercise: Implementing Talk with Distributed Erlang</title>
		<link>http://www.sheysrebellion.net/blog/2009/07/02/erlang-exercise-implementing-talk-with-distributed-erlang/</link>
		<comments>http://www.sheysrebellion.net/blog/2009/07/02/erlang-exercise-implementing-talk-with-distributed-erlang/#comments</comments>
		<pubDate>Thu, 02 Jul 2009 15:52:26 +0000</pubDate>
		<dc:creator>Sheheryar Sewani</dc:creator>
				<category><![CDATA[Erlang]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.sheysrebellion.net/blog/?p=342</guid>
		<description><![CDATA[Here’s my solution for the Talk with Distributed Erlang exercise.
You can run the program by calling the start function, but first you must generate a cookie and start two named Erlang nodes using the following commands:

echo -n &#8220;dh32d8yhd8&#8243; &#62; erlang.cookie
erl -name Node1 -cookie
erl -name Node2 -cookie




Share and Enjoy:


	
	
	
	
	


]]></description>
			<content:encoded><![CDATA[<p>Here’s my solution for the <a href="http://www.erlang.org/course/exercises.html#talk" target="_blank">Talk with Distributed Erlang exercise</a>.</p>
<script src="http://gist.github.com/139295.js"></script>
<p>You can run the program by calling the start function, but first you must generate a cookie and start two named Erlang nodes using the following commands:</p>
<ol>
<li>echo -n &#8220;dh32d8yhd8&#8243; &gt; erlang.cookie</li>
<li>erl -name Node1 -cookie</li>
<li>erl -name Node2 -cookie</li>
</ol>

<div class="sociable">
<div class="sociable_tagline">
<strong>Share and Enjoy:</strong>
</div>
<ul>
	<li><a rel="nofollow" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.sheysrebellion.net%2Fblog%2F2009%2F07%2F02%2Ferlang-exercise-implementing-talk-with-distributed-erlang%2F&amp;title=Erlang%20Exercise%3A%20Implementing%20Talk%20with%20Distributed%20Erlang" title="del.icio.us"><img src="http://www.sheysrebellion.net/blog/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.sheysrebellion.net%2Fblog%2F2009%2F07%2F02%2Ferlang-exercise-implementing-talk-with-distributed-erlang%2F&amp;title=Erlang%20Exercise%3A%20Implementing%20Talk%20with%20Distributed%20Erlang" title="Reddit"><img src="http://www.sheysrebellion.net/blog/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.sheysrebellion.net%2Fblog%2F2009%2F07%2F02%2Ferlang-exercise-implementing-talk-with-distributed-erlang%2F&amp;t=Erlang%20Exercise%3A%20Implementing%20Talk%20with%20Distributed%20Erlang" title="Facebook"><img src="http://www.sheysrebellion.net/blog/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" href="http://identi.ca/notice/new?status_textarea=http%3A%2F%2Fwww.sheysrebellion.net%2Fblog%2F2009%2F07%2F02%2Ferlang-exercise-implementing-talk-with-distributed-erlang%2F" title="Identi.ca"><img src="http://www.sheysrebellion.net/blog/wp-content/plugins/sociable/images/identica.png" title="Identi.ca" alt="Identi.ca" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" href="http://twitter.com/home?status=http%3A%2F%2Fwww.sheysrebellion.net%2Fblog%2F2009%2F07%2F02%2Ferlang-exercise-implementing-talk-with-distributed-erlang%2F" title="TwitThis"><img src="http://www.sheysrebellion.net/blog/wp-content/plugins/sociable/images/twitter.gif" title="TwitThis" alt="TwitThis" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.sheysrebellion.net/blog/2009/07/02/erlang-exercise-implementing-talk-with-distributed-erlang/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Programming Collective intelligence in Erlang</title>
		<link>http://www.sheysrebellion.net/blog/2009/04/20/programming-collective-intelligence-in-erlang/</link>
		<comments>http://www.sheysrebellion.net/blog/2009/04/20/programming-collective-intelligence-in-erlang/#comments</comments>
		<pubDate>Mon, 20 Apr 2009 17:11:46 +0000</pubDate>
		<dc:creator>Sheheryar Sewani</dc:creator>
				<category><![CDATA[Erlang]]></category>
		<category><![CDATA[datamining]]></category>

		<guid isPermaLink="false">http://www.sheysrebellion.net/blog/2009/04/20/programming-collective-intelligence-in-erlang/</guid>
		<description><![CDATA[Inspired by Matthew Podwysocki’s Functional Programming and Collective Intelligence post I decided to recreate some of the similarity algorithms discussed in the Programming Collective Intelligence in Erlang.
Collective Intelligence is a shared intelligence that emerges from the collaboration or competition amongst many individuals, it is used by online retailers such as Amazon.com and Netflix to recommend [...]]]></description>
			<content:encoded><![CDATA[<p align="justify">Inspired by Matthew Podwysocki’s <a href="http://codebetter.com/blogs/matthew.podwysocki/archive/2009/03/30/functional-programming-and-collective-intelligence.aspx" target="_blank">Functional Programming and Collective Intelligence</a> post I decided to recreate some of the similarity algorithms discussed in the <a href="http://www.sheysrebellion.net/blog/2009/02/19/programming-collective-intelligence/">Programming Collective Intelligence</a> in Erlang.</p>
<p align="justify">Collective Intelligence is a shared intelligence that emerges from the collaboration or competition amongst many individuals, it is used by online retailers such as Amazon.com and Netflix to recommend books and movies.  Today we’ll use these algorithms to compare user preference, and in subsequent posts apply see how these algorithms are used in recommendation systems and clustering algorithms.</p>
<p align="justify">Before we continue, there are two unfamiliar concepts which we need to review: list Comprehensions and dictionaries.</p>
<p align="justify"><strong>List comprehensions</strong> are expressions (which are very common to functional programming languages) that allow you to create lists without having to use funs, maps, or filters. This helps you to write programs which are shorter and easier to debug. In Erlang, the syntax is:</p>
<pre>[ F(X) || X &lt;- L]</pre>
<p align="justify">which means, create a list of F(X) where F is a function and X is an element taken from the list L. Additionally, in Erlang we can use qualifiers to filter out elements of the list L.</p>
<p align="justify"><strong>Dictionaries </strong>(Hashes/Maps) are not directly supported by Erlang and to use them in your code you must use the <strong><a href="http://erlang.org/doc/man/dict.html" target="_blank">dict module</a></strong>. The module includes the function dict:from_list which converts a list of two element tuples into a dictionary; it also includes the function dict:fetch which takes the Key and the dictionary as an argument and returns the value which matches the key.</p>
<p><strong>Similarity</strong></p>
<p>Below is a list of movie ratings by user</p>
<table border="1" cellspacing="0" cellpadding="2" width="589">
<tbody>
<tr>
<td width="100" valign="top">
<p align="left">
</td>
<td width="85" valign="top">
<p align="left"><strong>Lady in The Water</strong></p>
</td>
<td width="78" valign="top">
<p align="left"><strong>Snakes on a Plane</strong></p>
</td>
<td width="55" valign="top">
<p align="left"><strong>Just My Luck</strong></p>
</td>
<td width="55" valign="top">
<p align="left"><strong>Superman Returns</strong></p>
</td>
<td width="101" valign="top">
<p align="left"><strong>You, me and Dupree</strong></p>
</td>
<td width="113" valign="top">
<p align="left"><strong>The Night Listener</strong></p>
</td>
</tr>
<tr>
<td width="100" valign="top"><strong>Lisa Rose</strong></td>
<td width="85" valign="top">2.5</td>
<td width="78" valign="top">3.5</td>
<td width="55" valign="top">3.0</td>
<td width="55" valign="top">3.5</td>
<td width="101" valign="top">2.5</td>
<td width="113" valign="top">3.0</td>
</tr>
<tr>
<td width="100" valign="top"><strong>Mick LaSalle</strong></td>
<td width="85" valign="top">3.0</td>
<td width="78" valign="top">4.0</td>
<td width="55" valign="top">2.0</td>
<td width="55" valign="top">3.0</td>
<td width="101" valign="top">2.0</td>
<td width="113" valign="top">3.0</td>
</tr>
<tr>
<td width="100" valign="top"><strong>Jack Mathews</strong></td>
<td width="85" valign="top">3.0</td>
<td width="78" valign="top">4.0</td>
<td width="55" valign="top">5.0</td>
<td width="55" valign="top"></td>
<td width="101" valign="top">3.5</td>
<td width="113" valign="top">3.0</td>
</tr>
<tr>
<td width="100" valign="top"><strong>Sheheryar</strong></td>
<td width="85" valign="top"></td>
<td width="78" valign="top">2.5</td>
<td width="55" valign="top"></td>
<td width="55" valign="top">3.0</td>
<td width="101" valign="top">3.0</td>
<td width="113" valign="top"></td>
</tr>
</tbody>
</table>
<p>which we can store in Erlang as a dictionary:</p>
<pre>  dict:from_list([
	{
	"Lisa Rose",
	dict:from_list( [{"Lady in the Water", 2.5},{"Snakes on a Plane", 3.5},
				 {"Just My Luck", 3.0},{"Superman Returns", 3.5},
				 {"You, Me and Dupree", 2.5},{"The Night Listener", 3.0}])
	},
	{"Mick LaSalle",
	dict:from_list( [{"Lady in the Water", 3.0},{"Snakes on a Plane", 4.0},
				 {"Just My Luck", 2.0},{"Superman Returns", 3.0},
				 {"You, Me and Dupree", 2.0},{"The Night Listener", 3.0}])
	},
	{"Jack Matthews",
	dict:from_list( [{"Lady in the Water", 3.0},{"Snakes on a Plane", 4.0},
				 {"Superman Returns", 5.0},{"You, Me and Dupree", 3.5},
				 {"The Night Listener", 3.0}])
	},
	{"Shey",
	dict:from_list( [{"Snakes on a Plane", 2.5},{"Superman Returns", 3.0},
				 {"You, Me and Dupree", 3.0}])}
	]).</pre>
<p align="justify">To determine how similar two users preferences are we need to compute a similarity score. An easy way to calculate similarity is to use the scaled <a href="http://en.wikipedia.org/wiki/Euclidean_distance" target="_blank">Euclidean Distance</a> formula which we learned back in high school geometry. The function returns a value between 0 and 1, where a value of 1 means that two people have identical tastes.</p>
<pre>sim_distance(List1, List2) <strong>when</strong> length(List1) /= 0, length(List1) == length(List1)  -&gt;
  Sum_of_squares = lists:sum([ math:pow(X-Y,2) || {X,Y} &lt;- lists:zip(List1,List2) ]),
  1.0 / (1.0 + math:sqrt(Sum_of_squares)).</pre>
<p align="justify">The function accepts two lists, each lists contains the user’s rating of a movie, where the <em>ith</em> element of each lists represents the user’s rating for the same movie. Note the use of the lists:zip function which takes two lists of equal length and returns one list of tuples with two elements each, where the first element of each tuple is taken from the first list and the second element is taken from corresponding element in the second list. Finally, the function also has two guard expressions that prevent the user from calling the function with empty lists or lists of unequal length.  Another simple distance metric is the <a href="http://en.wikipedia.org/wiki/Taxicab_geometry" target="_blank">Manhattan distance</a>, it represents the absolute differences between coordinates of a pair of objects:</p>
<pre>sim_manhattan(X,Y) when length(X) /= 0,  length(X) == length(Y)  -&gt;
  Sum = lists:sum([ abs(Xn-Yn) || {Xn,Yn} &lt;- lists:zip(X,Y)]),
  1.0/ (1.0 + Sum).</pre>
<p align="justify">In this scenario, a slightly better way to determine the similarity between two objects is to use a <a href="http://en.wikipedia.org/wiki/Pearson_product-moment_correlation_coefficient" target="_blank">Pearson correlation coefficient</a>. The correlation coefficient is a measure of how well two sets of data fit on a straight line and it gives better results in when the data isn’t well normalized&#8211; for example, if critics’ movie rankings are routinely harsher than average. You can read about other other distance metrics for comparing items on <a href="http://en.wikipedia.org/wiki/Metric_(mathematics)#Examples" target="_blank">Wikipedia</a>.</p>
<pre>sim_pearson(X, Y) when length(X) == length(Y)  -&gt;
  Len = length(X),

  %% sum
  SumX = lists:sum(X),
  SumY = lists:sum(Y),

  %% sum of squares
  SumXSq=lists:sum([math:pow(N,2) || N &lt;- X]),
  SumYSq=lists:sum([math:pow(N,2) || N &lt;- Y]),

  %% sum of products
  Sum_products = lists:sum( [ A*B || {A,B} &lt;- lists:zip(X,Y)]),

  %% Calculate Pearson Score
  Numer = Sum_products - (SumX*SumY/Len),

  case math:sqrt( (SumXSq - math:pow(SumX,2) /Len) * (SumYSq - math:pow(SumY,2)/Len)) of
    0.0 -&gt;
      0.0;
    Denom -&gt;
      Numer/Denom %% Don't put a comma or semi-colon here
  end.</pre>
<p align="justify">A complete listing of the <a href="http://paste.lisp.org/display/78901">code</a> is available online; you can experiment with the different distance metrics using the main function, but due to some limitations of the command line interface, you’ll have to assign the function to a variable before passing it to the main function:</p>
<pre>1&gt; c(pci).
2&gt; SimPearson = fun(X,Y) -&gt; pci:sim_pearson(X,Y) end.
3&gt; pci:main("Mick LaSalle", "Lisa Rose", SimPearson).</pre>
<p align="justify">While this code is (mostly) functional, we haven’t taken advantage of Erlang’s distributed processes, soon we’ll explore the K-Means clustering algorithm which is very well suited to parallel implementations.</p>
<p align="justify">Your comments and Feedback are appreciated.</p>

<div class="sociable">
<div class="sociable_tagline">
<strong>Share and Enjoy:</strong>
</div>
<ul>
	<li><a rel="nofollow" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.sheysrebellion.net%2Fblog%2F2009%2F04%2F20%2Fprogramming-collective-intelligence-in-erlang%2F&amp;title=Programming%20Collective%20intelligence%20in%20Erlang" title="del.icio.us"><img src="http://www.sheysrebellion.net/blog/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.sheysrebellion.net%2Fblog%2F2009%2F04%2F20%2Fprogramming-collective-intelligence-in-erlang%2F&amp;title=Programming%20Collective%20intelligence%20in%20Erlang" title="Reddit"><img src="http://www.sheysrebellion.net/blog/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.sheysrebellion.net%2Fblog%2F2009%2F04%2F20%2Fprogramming-collective-intelligence-in-erlang%2F&amp;t=Programming%20Collective%20intelligence%20in%20Erlang" title="Facebook"><img src="http://www.sheysrebellion.net/blog/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" href="http://identi.ca/notice/new?status_textarea=http%3A%2F%2Fwww.sheysrebellion.net%2Fblog%2F2009%2F04%2F20%2Fprogramming-collective-intelligence-in-erlang%2F" title="Identi.ca"><img src="http://www.sheysrebellion.net/blog/wp-content/plugins/sociable/images/identica.png" title="Identi.ca" alt="Identi.ca" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" href="http://twitter.com/home?status=http%3A%2F%2Fwww.sheysrebellion.net%2Fblog%2F2009%2F04%2F20%2Fprogramming-collective-intelligence-in-erlang%2F" title="TwitThis"><img src="http://www.sheysrebellion.net/blog/wp-content/plugins/sociable/images/twitter.gif" title="TwitThis" alt="TwitThis" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.sheysrebellion.net/blog/2009/04/20/programming-collective-intelligence-in-erlang/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Erlang Exercise: N Processes in a Star</title>
		<link>http://www.sheysrebellion.net/blog/2009/04/13/erlang-exercise-n-processes-in-a-star/</link>
		<comments>http://www.sheysrebellion.net/blog/2009/04/13/erlang-exercise-n-processes-in-a-star/#comments</comments>
		<pubDate>Mon, 13 Apr 2009 16:45:17 +0000</pubDate>
		<dc:creator>Sheheryar Sewani</dc:creator>
				<category><![CDATA[Erlang]]></category>
		<category><![CDATA[concurrency]]></category>

		<guid isPermaLink="false">http://www.sheysrebellion.net/blog/2009/04/13/erlang-exercise-n-processes-in-a-star/</guid>
		<description><![CDATA[Here’s my solution for the N processes in a star concurrency exercise, you can run the program by calling the main function—comments appreciated.
-module(star).
-export([main/3, vertex_node/0, center_node/4]).

%% Write a function which starts N processes in a star,
%% and sends a message to each of them M times.
%% After the messages have been sent the processes
%% should terminate [...]]]></description>
			<content:encoded><![CDATA[<p>Here’s my solution for the N processes in a star <a href="http://erlang.org/course/exercises.html#conc">concurrency exercise</a>, you can run the program by calling the main function—comments appreciated.</p>
<pre>-module(star).
-export([main/3, vertex_node/0, center_node/4]).

%% Write a function which starts N processes in a star,
%% and sends a message to each of them M times.
%% After the messages have been sent the processes
%% should terminate gracefully.

vertex_node() -&gt;
  receive
    {stop, Center_PID} -&gt;
      io:format("recieved ~w, from ~w, exiting~n", [stop, Center_PID]),
	  exit(ok);
	{Something, Center_PID} -&gt;
		io:format("recieved message: ~s, from ~w~n", [Something, Center_PID]),
		Center_PID ! {self(), ok},
		vertex_node()
  end.

center_node(_, _, 0, Original_Nodes ) -&gt;
	lists:map(fun(Vertex_Node) -&gt; Vertex_Node ! {stop, self()} end, Original_Nodes);

center_node(Message, [], Count, Origingal_Nodes) -&gt;
	center_node(Message, Origingal_Nodes, Count -1, Origingal_Nodes);

center_node(Message, Nodes, Count, Original_Node_List) -&gt;
	[Vertex_Node | Remaining_Nodes] = Nodes,
	Vertex_Node ! {Message, self()},
	receive
		{Pid, Msg} -&gt;
			io:format("center received ack: ~w, from ~w~n", [Msg, Pid])
	end,
	center_node(Message, Remaining_Nodes, Count, Original_Node_List).

main(Processes, Messages, Message) -&gt;
	Nodes = lists:map(fun(X) -&gt; spawn(star, vertex_node, []) end, lists:seq(1, Processes)),
	spawn(star, center_node, [Message, Nodes, Messages, Nodes]).</pre>
<p>A nicely formatted version is available <a href="http://paste.lisp.org/display/78493">here</a>.</p>
<p>P.S. If anyone knows how to do add syntax highlighting for Erlang to Windows Live Writer, please let me know.</p>

<div class="sociable">
<div class="sociable_tagline">
<strong>Share and Enjoy:</strong>
</div>
<ul>
	<li><a rel="nofollow" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.sheysrebellion.net%2Fblog%2F2009%2F04%2F13%2Ferlang-exercise-n-processes-in-a-star%2F&amp;title=Erlang%20Exercise%3A%20N%20Processes%20in%20a%20Star" title="del.icio.us"><img src="http://www.sheysrebellion.net/blog/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.sheysrebellion.net%2Fblog%2F2009%2F04%2F13%2Ferlang-exercise-n-processes-in-a-star%2F&amp;title=Erlang%20Exercise%3A%20N%20Processes%20in%20a%20Star" title="Reddit"><img src="http://www.sheysrebellion.net/blog/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.sheysrebellion.net%2Fblog%2F2009%2F04%2F13%2Ferlang-exercise-n-processes-in-a-star%2F&amp;t=Erlang%20Exercise%3A%20N%20Processes%20in%20a%20Star" title="Facebook"><img src="http://www.sheysrebellion.net/blog/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" href="http://identi.ca/notice/new?status_textarea=http%3A%2F%2Fwww.sheysrebellion.net%2Fblog%2F2009%2F04%2F13%2Ferlang-exercise-n-processes-in-a-star%2F" title="Identi.ca"><img src="http://www.sheysrebellion.net/blog/wp-content/plugins/sociable/images/identica.png" title="Identi.ca" alt="Identi.ca" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" href="http://twitter.com/home?status=http%3A%2F%2Fwww.sheysrebellion.net%2Fblog%2F2009%2F04%2F13%2Ferlang-exercise-n-processes-in-a-star%2F" title="TwitThis"><img src="http://www.sheysrebellion.net/blog/wp-content/plugins/sociable/images/twitter.gif" title="TwitThis" alt="TwitThis" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.sheysrebellion.net/blog/2009/04/13/erlang-exercise-n-processes-in-a-star/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Processes in Erlang</title>
		<link>http://www.sheysrebellion.net/blog/2009/04/09/processes-in-erlang/</link>
		<comments>http://www.sheysrebellion.net/blog/2009/04/09/processes-in-erlang/#comments</comments>
		<pubDate>Thu, 09 Apr 2009 15:55:36 +0000</pubDate>
		<dc:creator>Sheheryar Sewani</dc:creator>
				<category><![CDATA[Erlang]]></category>
		<category><![CDATA[concurrency]]></category>

		<guid isPermaLink="false">http://www.sheysrebellion.net/blog/2009/04/09/processes-in-erlang/</guid>
		<description><![CDATA[Most programming languages implement concurrency poorly, Erlang has taken a different approach to concurrency than today’s popular programming language, as we&#8217;ve seen, it is easy to create parallel processes of execution in Erlang. Lets look more closely at how to create and communicate with these processes in Erlang by creating a small (contrived and basic) [...]]]></description>
			<content:encoded><![CDATA[<p>Most programming languages implement concurrency poorly, Erlang has taken a different approach to concurrency than today’s popular programming language, as we&#8217;ve seen, it is easy to <a href="http://www.sheysrebellion.net/blog/2009/04/06/more-erlang-adding-concurrency/">create parallel processes</a> of execution in Erlang. Lets look more closely at how to create and communicate with these processes in Erlang by creating a small (contrived and basic) program which simulates a buyer buying stocks from a seller.</p>
<p>We need three Erlang primitives to work with processes: <tt>spawn</tt>,  <tt>!</tt> and <tt>receive</tt>.  The built-in <tt>spawn</tt> function creates a new process executing a function and returns the new process&#8217; process id. The <code>!</code> operator sends a message to a process and processes use the <tt>receive...end</tt> function to match messages in the mailbox to patterns and execute the appropriate functions.</p>
<p>To send a message “BUY MSFT” to the Seller process, we use:</p>
<pre>   Seller ! {{buy, msft} , Buyer}</pre>
<p>we include the variable Buyer which contains the process id of the buyer, this lets the seller know which process to send the acknowledgment to.  Now we need to create the Seller process, we do this by calling the spawn/3 function&#8211; the first argument to spawn is the module name, followed by the function name and ending with a list of arguments:</p>
<pre>   Seller_pid = spawn(exchange, seller, [])</pre>
<p>Both the Buyer and Seller processes can handle the message using pattern matching in the <tt>receive..end</tt> clause, Here the Seller process receives the {buy, Symbol} message, processes it, and then acknowledges the transaction by sending an “ok” to the buyer:</p>
<pre>seller() -&gt;
     receive
        {finished, _} -&gt;
            io:format("Received finished. no one is buying~n", []);
        {{buy, Symbol}, Buyer_pid} -&gt;
            io:format("sold ~s to buyer~n", [Symbol]),
            Buyer_pid ! ok,
            seller();
    end.</pre>
<p>Now, lets put these pieces together in a program in which the Buyer process buys Stocks from the Seller and in return, the Seller process acknowledges the sale; the program terminates when the Buyer has run out of Stocks to buy.</p>
<pre>-module(exchange).
-export([start/0, buyer/2, seller/0]).

buyer([], Seller_pid) -&gt;
    Seller_pid ! {finished, self()},
    %% note there's a ";" instead of a "." at the end of the next clause
    io:format("buyer finished~n", []);

buyer(List, Seller_pid) -&gt;
	[Head|Tail] = List,
    Seller_pid ! {Head, self()},
    receive
        ok -&gt;
            io:format("buyer received seller confirmation~n", [])
    end,
    buyer(Tail, Seller_pid).

seller() -&gt;
     receive
        {finished, _} -&gt;
            io:format("Received finished. no one is buying~n", []);
        {{buy, Symbol}, Buyer_pid} -&gt;
            io:format("sold ~s to buyer~n", [Symbol]),
            Buyer_pid ! ok,
            seller()
            %% note there's, no ";" or "," before the end
    end.

start() -&gt;
  Things_to_buy = [{buy, sina}, {buy, msft}, {buy, intc}],
  Seller_pid = spawn(exchange, seller, []),
  spawn(exchange, buyer, [Things_to_buy, Seller_pid]).</pre>
<p>The program illustrates the most basic ways to use Erlang processes, I’ve completely skipped over guards, error handling, timeouts and registered processes, but several detailed documents on these topics and  <a href="http://ftp.nl.freebsd.org/os/FreeBSD/distfiles/erlang/">Erlang design principles</a> are available on there ftp site.</p>

<div class="sociable">
<div class="sociable_tagline">
<strong>Share and Enjoy:</strong>
</div>
<ul>
	<li><a rel="nofollow" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.sheysrebellion.net%2Fblog%2F2009%2F04%2F09%2Fprocesses-in-erlang%2F&amp;title=Processes%20in%20Erlang" title="del.icio.us"><img src="http://www.sheysrebellion.net/blog/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.sheysrebellion.net%2Fblog%2F2009%2F04%2F09%2Fprocesses-in-erlang%2F&amp;title=Processes%20in%20Erlang" title="Reddit"><img src="http://www.sheysrebellion.net/blog/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.sheysrebellion.net%2Fblog%2F2009%2F04%2F09%2Fprocesses-in-erlang%2F&amp;t=Processes%20in%20Erlang" title="Facebook"><img src="http://www.sheysrebellion.net/blog/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" href="http://identi.ca/notice/new?status_textarea=http%3A%2F%2Fwww.sheysrebellion.net%2Fblog%2F2009%2F04%2F09%2Fprocesses-in-erlang%2F" title="Identi.ca"><img src="http://www.sheysrebellion.net/blog/wp-content/plugins/sociable/images/identica.png" title="Identi.ca" alt="Identi.ca" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" href="http://twitter.com/home?status=http%3A%2F%2Fwww.sheysrebellion.net%2Fblog%2F2009%2F04%2F09%2Fprocesses-in-erlang%2F" title="TwitThis"><img src="http://www.sheysrebellion.net/blog/wp-content/plugins/sociable/images/twitter.gif" title="TwitThis" alt="TwitThis" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.sheysrebellion.net/blog/2009/04/09/processes-in-erlang/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>More Erlang: Adding Concurrency</title>
		<link>http://www.sheysrebellion.net/blog/2009/04/06/more-erlang-adding-concurrency/</link>
		<comments>http://www.sheysrebellion.net/blog/2009/04/06/more-erlang-adding-concurrency/#comments</comments>
		<pubDate>Mon, 06 Apr 2009 18:35:51 +0000</pubDate>
		<dc:creator>Sheheryar Sewani</dc:creator>
				<category><![CDATA[Erlang]]></category>
		<category><![CDATA[concurrency]]></category>

		<guid isPermaLink="false">http://www.sheysrebellion.net/blog/2009/04/06/more-erlang-adding-concurrency/</guid>
		<description><![CDATA[Erlang&#8217;s main strength is its support for concurrency&#8211; now I’ll extend the previous Erlang example to fetch the stock quotes for multiple symbols in parallel. 
Because I love abstractions, I’ll use the function pmap&#8211; pmap works like map, but when the function is called it creates one parallel process to evaluate each argument in the [...]]]></description>
			<content:encoded><![CDATA[<p>Erlang&#8217;s main strength is its support for concurrency&#8211; now I’ll extend the <a href="http://www.sheysrebellion.net/blog/2009/03/30/learning-erlang-retrieving-stock-quotes-from-google-finance/">previous Erlang example</a> to fetch the stock quotes for multiple symbols in parallel. </p>
<p>Because I love abstractions, I’ll use the function <tt>pmap</tt>&#8211; pmap works like map, but when the function is called it creates one parallel process to evaluate each argument in the list. You can find a copy of the code on the <a href="http://www.pragprog.com/titles/jaerlang/source_code">book’s website.</a> Generally, it&#8217;s not advisable to use pmap when the the list is very small or very large. Ideally, the implementation of pmap should be modified to spawn <em>n</em> processes, but that is something that I&#8217;m not comfortable doing yet.</p>
<p><strong>Full Listing</strong></p>
<div class="csharpcode">
<pre class="alt"><span class="lnum">   1:  </span>-module(quote).</pre>
<pre><span class="lnum">   2:  </span>-import(json_parser).</pre>
<pre class="alt"><span class="lnum">   3:  </span>&#160;</pre>
<pre><span class="lnum">   4:  </span>-export([get_stock_quote/1, get_data_in_parallel/0]).</pre>
<pre class="alt"><span class="lnum">   5:  </span>&#160;</pre>
<pre><span class="lnum">   6:  </span>-define(BASE_URL, <span class="str">&quot;http://www.google.com/finance/info?client=ig&amp;q=&quot;</span>.</pre>
<pre class="alt"><span class="lnum">   7:  </span>&#160;</pre>
<pre><span class="lnum">   8:  </span>symbols() -&gt;</pre>
<pre class="alt"><span class="lnum">   9:  </span>    [ <span class="str">&quot;MSFT&quot;</span>, <span class="str">&quot;RHIE&quot;</span>, <span class="str">&quot;INTC&quot;</span>, <span class="str">&quot;DPTR&quot;</span>, </pre>
<pre><span class="lnum">  10:  </span>      <span class="str">&quot;RVSB&quot;</span>, <span class="str">&quot;BBGI&quot;</span>, <span class="str">&quot;SRDD&quot;</span>, <span class="str">&quot;DEAR&quot;</span>,</pre>
<pre class="alt"><span class="lnum">  11:  </span>      <span class="str">&quot;ALKS&quot;</span>, <span class="str">&quot;GOOG&quot;</span>, <span class="str">&quot;QQQQ&quot;</span>, <span class="str">&quot;AAPL&quot;</span>,</pre>
<pre><span class="lnum">  12:  </span>      <span class="str">&quot;RIMM&quot;</span>, <span class="str">&quot;GEOY&quot;</span>, <span class="str">&quot;CBST&quot;</span>, <span class="str">&quot;ANGO&quot;</span></pre>
<pre class="alt"><span class="lnum">  13:  </span>    ].</pre>
<pre><span class="lnum">  14:  </span>    </pre>
<pre class="alt"><span class="lnum">  15:  </span>    </pre>
<pre><span class="lnum">  16:  </span>get_google_url(Symbol) -&gt;</pre>
<pre class="alt"><span class="lnum">  17:  </span>    ?BASE_URL ++ Symbol.</pre>
<pre><span class="lnum">  18:  </span>   </pre>
<pre class="alt"><span class="lnum">  19:  </span>get_stock_quote(Symbol) -&gt;</pre>
<pre><span class="lnum">  20:  </span>    %% moved inets:start() outside this function</pre>
<pre class="alt"><span class="lnum">  21:  </span>    URL =  get_google_url(Symbol),</pre>
<pre><span class="lnum">  22:  </span>    { ok, {_Status, _Headers, Body }} = http:request(URL),</pre>
<pre class="alt"><span class="lnum">  23:  </span>    PureData = lists:subtract(lists:subtract(Body, <span class="str">&quot;// [ &quot;</span>), <span class="str">&quot;] &quot;</span>),</pre>
<pre><span class="lnum">  24:  </span>    {_,{_,RealData},_} = json_parser:dvm_parser(list_to_binary(PureData)),</pre>
<pre class="alt"><span class="lnum">  25:  </span>    RealData.</pre>
<pre><span class="lnum">  26:  </span>    </pre>
<pre class="alt"><span class="lnum">  27:  </span>&#160;</pre>
<pre><span class="lnum">  28:  </span>get_data_in_parallel() -&gt;</pre>
<pre class="alt"><span class="lnum">  29:  </span>    inets:start(),</pre>
<pre><span class="lnum">  30:  </span>    lib_misc:pmap(fun get_stock_quote/1, symbols()).</pre>
</div>
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>

<div class="sociable">
<div class="sociable_tagline">
<strong>Share and Enjoy:</strong>
</div>
<ul>
	<li><a rel="nofollow" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.sheysrebellion.net%2Fblog%2F2009%2F04%2F06%2Fmore-erlang-adding-concurrency%2F&amp;title=More%20Erlang%3A%20Adding%20Concurrency" title="del.icio.us"><img src="http://www.sheysrebellion.net/blog/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.sheysrebellion.net%2Fblog%2F2009%2F04%2F06%2Fmore-erlang-adding-concurrency%2F&amp;title=More%20Erlang%3A%20Adding%20Concurrency" title="Reddit"><img src="http://www.sheysrebellion.net/blog/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.sheysrebellion.net%2Fblog%2F2009%2F04%2F06%2Fmore-erlang-adding-concurrency%2F&amp;t=More%20Erlang%3A%20Adding%20Concurrency" title="Facebook"><img src="http://www.sheysrebellion.net/blog/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" href="http://identi.ca/notice/new?status_textarea=http%3A%2F%2Fwww.sheysrebellion.net%2Fblog%2F2009%2F04%2F06%2Fmore-erlang-adding-concurrency%2F" title="Identi.ca"><img src="http://www.sheysrebellion.net/blog/wp-content/plugins/sociable/images/identica.png" title="Identi.ca" alt="Identi.ca" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" href="http://twitter.com/home?status=http%3A%2F%2Fwww.sheysrebellion.net%2Fblog%2F2009%2F04%2F06%2Fmore-erlang-adding-concurrency%2F" title="TwitThis"><img src="http://www.sheysrebellion.net/blog/wp-content/plugins/sociable/images/twitter.gif" title="TwitThis" alt="TwitThis" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.sheysrebellion.net/blog/2009/04/06/more-erlang-adding-concurrency/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Learning Erlang: Retrieving Stock Quotes From Google Finance</title>
		<link>http://www.sheysrebellion.net/blog/2009/03/30/learning-erlang-retrieving-stock-quotes-from-google-finance/</link>
		<comments>http://www.sheysrebellion.net/blog/2009/03/30/learning-erlang-retrieving-stock-quotes-from-google-finance/#comments</comments>
		<pubDate>Mon, 30 Mar 2009 15:55:40 +0000</pubDate>
		<dc:creator>Sheheryar Sewani</dc:creator>
				<category><![CDATA[Erlang]]></category>
		<category><![CDATA[Finance]]></category>

		<guid isPermaLink="false">http://www.sheysrebellion.net/blog/?p=175</guid>
		<description><![CDATA[Inspired by Dave Thomas’ “A First Erlang” post I decided to use Erlang to retrieve stock quotes from Google’s Finance API.  I wrote a simple Erlang program that let me explore third party JSON libraries and Erlang’s http library.
In Erlang, the -module directive defines an Erlang module, which is how code is organized in Erlang, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.sheysrebellion.net/blog/wp-content/uploads/2009/03/erlang-logo.png"><img style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; margin: 0px 15px 0px 0px; border-right-width: 0px" title="Erlang_logo" src="http://www.sheysrebellion.net/blog/wp-content/uploads/2009/03/erlang-logo-thumb.png" border="0" alt="Erlang_logo" width="118" height="100" align="left" /></a>Inspired by Dave Thomas’ “A First Erlang” post I decided to use Erlang to retrieve stock quotes from Google’s Finance API.  I wrote a simple Erlang program that let me explore third party JSON libraries and Erlang’s http library.</p>
<p align="justify">In Erlang, the <tt>-module</tt> directive defines an Erlang module, which is how code is organized in Erlang, the <tt>-export</tt> directive tells Erlang which functions in this module to expose. My Erlang module is called <code>quote</code>, and I&#8217;m storing it in the file <tt>quote.erl</tt>. I’m also exposing a single function <tt>get_stock_quote</tt> which accepts a single parameter.</p>
<div>
<pre>-module(quote).
-export([get_stock_quote/1]).</pre>
</div>
<p align="justify">Next I’ll define an Erlang macro called BASE_URL which contains the base URL of the Google Finance API. The function <tt>get_google_url</tt> builds the full URL by appending the symbol to the base URL.</p>
<div>
<pre>-define(BASE_URL, "http://www.google.com/finance/info?client=ig&amp;q=".
get_google_url(Symbol) -&gt;
  ?BASE_URL ++ Symbol.</pre>
</div>
<p align="justify">After retrieving a stock quote for <a href="http://www.google.com/finance/info?client=ig&amp;q=MSFT" target="_blank">MSFT</a> in our browser I noticed that the data  returned from Google Finance is a JSON(ish) object surrounded by some extraneous text which has to be removed before we can do anything else.  Later I&#8217;ll use an external library to convert the string into a JSON object and extract the price and date.</p>
<div>
<pre>get_stock_quote(Symbol) -&gt;
  %% Don't know why I need the following line
  %% mentioned in inets documentation
  inets:start(),
  URL = get_google_url(Symbol),
  { ok, {_Status, _Headers, Body }} = http:request(URL),
  PureData = lists:subtract(lists:subtract(Body, "// [ "), "] ").</pre>
</div>
<p align="justify">The code to make http request is simple, http:request() returns the HTTP status, headers and body but the call was throwing an exception on my machine; after reading the http documentation included with Erlang I learned that a call <tt>inets:start()</tt> has to be made before making a http request.  The variable <tt>PureData</tt> contains the string which will transform into our JSON object, I had to use the <tt>lists:subtract</tt> function to remove extra characters from the beginning and end of the string.</p>
<p align="justify">After some searching (and cursing) I found a third party library, <a href="http://cean.process-one.net/packages/index.yaws?action=detail&amp;name=jsonparser" target="_blank">json_parser</a>, on Process One’s Comprehensive Erlang Archive Network. I downloaded a copy of the development version, renamed the source file to <tt>json_parser.erl</tt>, compiled json_praser and referenced it from <tt>quotes.erl</tt> with the <tt>-import(json_parser)</tt> import directive.</p>
<p align="justify">The documentation for json_parser is fairly sparse—the dvm_parser function in the library returns a tuple with more data then I need and I’m only interested in the actual JSON data which I’ parsed into the RealData variable and passed onto the <tt>parse_json_tuple</tt> function which extracts the fields I’m interested in.</p>
<pre>{_,{_,RealData},_} = json_parser:dvm_parser(list_to_binary(PureData)),
parse_json_tuple(list_to_tuple(RealData)).</pre>
<p align="justify">Finally, I parse the data in the RealData tuple and returned the CurrentPrice and Quote time:</p>
<pre>parse_json_tuple(RealData) -&gt;
  %% this is ugly and needs to be refactored
  {_,_,_,_,{_,CurrentPrice},_,{_,CurrentTime},_,_,_} = RealData,
  {CurrentPrice, CurrentTime}.</pre>
<p align="justify">To use the code, you have to compile the <tt>quote.erl</tt> file by calling the  <tt>c(quote)</tt> function in the Erlang Shell, then call the get_stock_quote function with the a stock symbol: <tt>quote:get_stock_quote(“MSFT”)</tt> from the Erlang shell.</p>
<p align="justify">This isn’t the best use of Erlang, but I wanted to ease into Erlang before exploring the more complicated recursive and distributed functionality, later I’ll refactor the code to be more Erlang-y and modify the program to retrieve quotes in parallel using Erlang’s  concurrency magic.</p>
<p><strong>*Edit*</strong>I Just discovered that Google Finance returns a slightly different dataset when the market is closed, I&#8217;ll update the parse_json_tuple function with the changes soon.</p>
<p align="justify"><strong>Full Listing</strong></p>
<div class="csharpcode">
<pre class="alt"><span class="lnum">   1:  </span>-module(quote).</pre>
<pre><span class="lnum">   2:  </span>-export([get_stock_quote/1]).</pre>
<pre class="alt"><span class="lnum">   3:  </span>-import(json_parser).</pre>
<pre><span class="lnum">   4:  </span></pre>
<pre class="alt"><span class="lnum">   5:  </span>-define(BASE_URL, <span class="str">"http://www.google.com/finance/info?client=ig&amp;q="</span>.</pre>
<pre><span class="lnum">   6:  </span></pre>
<pre class="alt"><span class="lnum">   7:  </span>get_google_url(Symbol) -&gt;</pre>
<pre><span class="lnum">   8:  </span>    ?BASE_URL ++ Symbol.</pre>
<pre class="alt"><span class="lnum">   9:  </span></pre>
<pre><span class="lnum">  10:  </span>parse_json_tuple(RealData) -&gt;</pre>
<pre class="alt"><span class="lnum">  11:  </span>    %% <span class="kwrd">this</span> <span class="kwrd">is</span> ugly and needs to be refactored</pre>
<pre><span class="lnum">  12:  </span>   {_,_,_,_,{_,CurrentPrice},_,{_,CurrentTime},_,_,_} = RealData,</pre>
<pre class="alt"><span class="lnum">  13:  </span>    {CurrentPrice, CurrentTime}.</pre>
<pre><span class="lnum">  14:  </span></pre>
<pre class="alt"><span class="lnum">  15:  </span>get_stock_quote(Symbol) -&gt;</pre>
<pre><span class="lnum">  16:  </span>    %% Don't know why I need the following line</pre>
<pre class="alt"><span class="lnum">  17:  </span>    %% mentioned <span class="kwrd">in</span> inets documentation</pre>
<pre><span class="lnum">  18:  </span>    inets:start(),</pre>
<pre class="alt"><span class="lnum">  19:  </span>    URL =  get_google_url(Symbol),</pre>
<pre><span class="lnum">  20:  </span>    { ok, {_Status, _Headers, Body }} = http:request(URL),</pre>
<pre class="alt"><span class="lnum">  21:  </span>    PureData = lists:subtract(lists:subtract(Body, <span class="str">"// [ "</span>), <span class="str">"] "</span>),</pre>
<pre><span class="lnum">  22:  </span>    {_,{_,RealData},_} = json_parser:dvm_parser(list_to_binary(PureData)),</pre>
<pre class="alt"><span class="lnum">  23:  </span>    parse_json_tuple(list_to_tuple(RealData)).</pre>
</div>
<p><!--.csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } --></p>

<div class="sociable">
<div class="sociable_tagline">
<strong>Share and Enjoy:</strong>
</div>
<ul>
	<li><a rel="nofollow" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.sheysrebellion.net%2Fblog%2F2009%2F03%2F30%2Flearning-erlang-retrieving-stock-quotes-from-google-finance%2F&amp;title=Learning%20Erlang%3A%20Retrieving%20Stock%20Quotes%20From%20Google%20Finance" title="del.icio.us"><img src="http://www.sheysrebellion.net/blog/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.sheysrebellion.net%2Fblog%2F2009%2F03%2F30%2Flearning-erlang-retrieving-stock-quotes-from-google-finance%2F&amp;title=Learning%20Erlang%3A%20Retrieving%20Stock%20Quotes%20From%20Google%20Finance" title="Reddit"><img src="http://www.sheysrebellion.net/blog/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.sheysrebellion.net%2Fblog%2F2009%2F03%2F30%2Flearning-erlang-retrieving-stock-quotes-from-google-finance%2F&amp;t=Learning%20Erlang%3A%20Retrieving%20Stock%20Quotes%20From%20Google%20Finance" title="Facebook"><img src="http://www.sheysrebellion.net/blog/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" href="http://identi.ca/notice/new?status_textarea=http%3A%2F%2Fwww.sheysrebellion.net%2Fblog%2F2009%2F03%2F30%2Flearning-erlang-retrieving-stock-quotes-from-google-finance%2F" title="Identi.ca"><img src="http://www.sheysrebellion.net/blog/wp-content/plugins/sociable/images/identica.png" title="Identi.ca" alt="Identi.ca" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow" href="http://twitter.com/home?status=http%3A%2F%2Fwww.sheysrebellion.net%2Fblog%2F2009%2F03%2F30%2Flearning-erlang-retrieving-stock-quotes-from-google-finance%2F" title="TwitThis"><img src="http://www.sheysrebellion.net/blog/wp-content/plugins/sociable/images/twitter.gif" title="TwitThis" alt="TwitThis" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.sheysrebellion.net/blog/2009/03/30/learning-erlang-retrieving-stock-quotes-from-google-finance/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>
