<?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>Rusty Razor Blade &#187; erlang</title>
	<atom:link href="http://www.rustyrazorblade.com/category/erlang/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.rustyrazorblade.com</link>
	<description>Tech Thoughts, Mostly on LAMP - by Jon Haddad</description>
	<lastBuildDate>Fri, 03 Feb 2012 20:03:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Another Attempt At Python</title>
		<link>http://www.rustyrazorblade.com/2011/04/another-attempt-at-python/</link>
		<comments>http://www.rustyrazorblade.com/2011/04/another-attempt-at-python/#comments</comments>
		<pubDate>Fri, 22 Apr 2011 20:32:13 +0000</pubDate>
		<dc:creator>jon</dc:creator>
				<category><![CDATA[erlang]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.rustyrazorblade.com/?p=1390</guid>
		<description><![CDATA[<p>I tried Python out a while ago, but stopped trying it to learn it after some major frustrations. Maybe I didn&#8217;t dig deep enough into it. I found the documentation hard to read, and the module layout seemed a little random at times. For some reason I found <a href="http://docs.python.org/library/subprocess.html">executing an external process</a> and getting [...]]]></description>
			<content:encoded><![CDATA[<p>I tried Python out a while ago, but stopped trying it to learn it after some major frustrations.  Maybe I didn&#8217;t dig deep enough into it.  I found the documentation hard to read, and the module layout seemed a little random at times.  For some reason I found <a href="http://docs.python.org/library/subprocess.html">executing an external process</a> and getting the results to be a little convoluted.  (Since then I&#8217;ve learned to use popen(..).communicate())</p>
<p><a href="http://www.rustyrazorblade.com/wp-content/uploads/2011/04/Cover-Image-For-Seven-Languages-in-Seven-Weeks.jpeg"><img src="http://www.rustyrazorblade.com/wp-content/uploads/2011/04/Cover-Image-For-Seven-Languages-in-Seven-Weeks.jpeg" alt="" title="Cover Image For Seven Languages in Seven Weeks" width="190" height="228" class="alignright size-full wp-image-1411" /></a>I ended up messing with other languages to try to find one that suits my tastes, like <a href="http://www.erlang.org/">Erlang</a> and <a href="http://www.digitalmars.com/d/index.html">D</a>.  I read through <a href="http://pragprog.com/titles/btlang/seven-languages-in-seven-weeks">7 languages in 7 weeks</a>, and not really getting a lot out of it.  I didn&#8217;t fall in love with <a href="http://www.ruby-lang.org/en/">ruby</a> at all and I&#8217;m not going to actually use <a href="http://www.swi-prolog.org/">Prolog</a> anywhere, even if I thought it was pretty cool.  I never liked <a href="http://www.java.com/en/">Java</a>, and I wasn&#8217;t impressed with <a href="http://www.scala-lang.org/">Scala</a>. </p>
<p>The closest I&#8217;ve gotten to a new favorite is Erlang.  I&#8217;ve written a <a href="/category/erlang/">whole slew of posts</a> about it.  I like Erlang&#8217;s process management, message passing, and the OTP libraries.  I like talking about it with people and I advocate it&#8217;s advantages.  But when it comes time to write it, I find it to be clumsy and awkward, the syntax annoying and the external libraries painful.  For instance, trying to work with a MongoDB database just doesn&#8217;t feel right.  My mind likes OO code, and I&#8217;m done fighting it.  So time to try something else.</p>
<p>I thought D was really interesting, but unfortunately it looks like no one is using it.  It&#8217;s not even clear which compiler I should use, and the installation instructions were incorrect when I tried to set it up.  Not a big selling point, and I gave that up pretty quickly.</p>
<p><a href="http://www.rustyrazorblade.com/wp-content/uploads/2011/04/python-logo.gif"><img src="http://www.rustyrazorblade.com/wp-content/uploads/2011/04/python-logo.gif" alt="" title="python-logo" width="211" height="71" class="alignright size-full wp-image-1408" /></a>So, another look at Python.  Working with threads in Python kind of sucks.  If you have multiple cores, it doesn&#8217;t really care.  That&#8217;s unfortunate.  However, after reading through convos in IRC (#python on freenode) I&#8217;ve found a few things that are making me give it another look.  For instance, the <a href="http://docs.python.org/library/multiprocessing.html">multiprocessing module</a> seems to address my gripes about processes / threads.  Yes we&#8217;re creating OS processes, but I really only need a few (5, 10 maybe?) so having a few running shouldn&#8217;t be a problem, and the OS will take care of loading up my cores for me.  It&#8217;s got great support for MongoDB (my shiny new toy) and I like it&#8217;s clean syntax.  I think tornado looks really cool and I&#8217;m excited to write a stand alone server that I can bundle instead of requiring nginx configs and complicated setups.</p>
<p>So&#8230; I&#8217;m back writing Python.  We&#8217;ll see how it goes.  </p>
]]></content:encoded>
			<wfw:commentRss>http://www.rustyrazorblade.com/2011/04/another-attempt-at-python/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Combining iWatch with Reloader</title>
		<link>http://www.rustyrazorblade.com/2011/03/combining-iwatch-with-reloader/</link>
		<comments>http://www.rustyrazorblade.com/2011/03/combining-iwatch-with-reloader/#comments</comments>
		<pubDate>Sat, 26 Mar 2011 16:48:36 +0000</pubDate>
		<dc:creator>jon</dc:creator>
				<category><![CDATA[erlang]]></category>

		<guid isPermaLink="false">http://www.rustyrazorblade.com/?p=1357</guid>
		<description><![CDATA[<p>I had written a post about <a href="http://www.rustyrazorblade.com/2010/12/erlang-code-auto-reloader/">how to set up reloader.erl</a> about a year ago. Reloader.erl is an incredibly useful library included in <a target="_blank" href="https://github.com/mochi/mochiweb">mochiweb</a> for automatically reloading erlang libraries if they&#8217;ve been recompiled.</p> <p>I had also written a post about <a href="/2011/02/using-iwatch-to-automatically-run-unit-tests-linux/">iWatch and phpunit</a> to follow source directories and automatically run a [...]]]></description>
			<content:encoded><![CDATA[<p>I had written a post about <a href="http://www.rustyrazorblade.com/2010/12/erlang-code-auto-reloader/">how to set up reloader.erl</a> about a year ago.  Reloader.erl is an incredibly useful library included in <a target="_blank" href="https://github.com/mochi/mochiweb">mochiweb</a> for automatically reloading erlang libraries if they&#8217;ve been recompiled.</p>
<p>I had also written a post about <a href="/2011/02/using-iwatch-to-automatically-run-unit-tests-linux/">iWatch and phpunit</a> to follow source directories and automatically run a unit test (or other command) when src files change.  Really great for rapid development &#8211; you can code in one window and just glance over to know if things are working as expected.</p>
<p>Today I started using iWatch to automatically recompile my erlang files, and reloader automatically runs the tests on those files for me as well.  It&#8217;s kind of awesome.</p>
<p><code>iwatch -e modify -v -c '/usr/local/bin/erlc -o ebin/ %f'  src</code></p>
<p>Enjoy constant compilation and testing with the above 1 liner.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rustyrazorblade.com/2011/03/combining-iwatch-with-reloader/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Erlang Code Auto Reloader &#8211; Auto Run Unit Tests and Hot Load Code after a Build</title>
		<link>http://www.rustyrazorblade.com/2010/12/erlang-code-auto-reloader/</link>
		<comments>http://www.rustyrazorblade.com/2010/12/erlang-code-auto-reloader/#comments</comments>
		<pubDate>Thu, 16 Dec 2010 06:13:19 +0000</pubDate>
		<dc:creator>jon</dc:creator>
				<category><![CDATA[erlang]]></category>

		<guid isPermaLink="false">http://www.rustyrazorblade.com/?p=1255</guid>
		<description><![CDATA[<p>I wrote <a href="/2010/09/smarter-erlang-programming-with-emakefile-options-and-user_default/">this post</a> a few months ago when I was developing a new Erlang application. I eventually ended up using the reloader I mentioned at the end, but never documented it. Now I&#8217;m about to start writing a new app, and I&#8217;m on a different machine. </p> <p>First, <a href="http://code.google.com/p/mochiweb/source/browse/trunk/src/reloader.erl">get the reloader</a>. It [...]]]></description>
			<content:encoded><![CDATA[<p>I wrote <a href="/2010/09/smarter-erlang-programming-with-emakefile-options-and-user_default/">this post</a> a few months ago when I was developing a new Erlang application.   I eventually ended up using the reloader I mentioned at the end, but never documented it.  Now I&#8217;m about to start writing a new app, and I&#8217;m on a different machine. </p>
<p>First, <a href="http://code.google.com/p/mochiweb/source/browse/trunk/src/reloader.erl">get the reloader</a>.  It was developed as part of mochiweb but functions just fine on it&#8217;s own.  Just put it somewhere accessible &#8211; I use the ebin directory in my home folder.  (yes, I just copied &#038; pasted the source)  Then compile it like so:</p>
<blockquote><p>erlc reloader.erl</p></blockquote>
<p>Now you can load the reloader automatically on startup by adding this to your ~/.erlang  config file:</p>
<blockquote><p>
code:load_abs(&#8220;/path/to/your/ebin/reloader&#8221;).<br />
reloader:start().
</p></blockquote>
<p>Change your path to match your reloader.  Do not add the .beam extension.  See <a href="http://www.erlang.org/doc/man/code.html#load_abs-1">the code module documentation.</a></p>
<p>When you start your Eshell, you&#8217;ll automatically get the reloader running.  If you didn&#8217;t do it right, you&#8217;ll get output that looks like this:</p>
<blockquote><p>
computer:~ jhaddad$ erl<br />
Erlang R14B (erts-5.8.1) [source] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false]</p>
<p>{&#8220;init terminating in do_boot&#8221;,{undef,[{reloader,start,[]},{init,start_it,1},{init,start_em,1}]}}
</p></blockquote>
<p>After loading a module, if you rebuild it, it&#8217;ll automatically get reloaded.  If you&#8217;ve added the eunit .hrl file, it&#8217;ll also run your unit tests for you.  </p>
<p>There&#8217;s not a lot of documentation out there on this incredibly useful library &#8211; hopefully this helps a few of you out.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rustyrazorblade.com/2010/12/erlang-code-auto-reloader/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Smarter Erlang Programming with Emakefile Options and user_default</title>
		<link>http://www.rustyrazorblade.com/2010/09/smarter-erlang-programming-with-emakefile-options-and-user_default/</link>
		<comments>http://www.rustyrazorblade.com/2010/09/smarter-erlang-programming-with-emakefile-options-and-user_default/#comments</comments>
		<pubDate>Mon, 13 Sep 2010 23:31:28 +0000</pubDate>
		<dc:creator>jon</dc:creator>
				<category><![CDATA[erlang]]></category>

		<guid isPermaLink="false">http://www.rustyrazorblade.com/?p=1174</guid>
		<description><![CDATA[<p>Say you&#8217;ve got an Erlang app with the standard file system layout, with your source code in src/ and your compiled code in ebin/. I&#8217;ve found this makes using the interactive shell interpreter a little harder. </p> <p>Lets use the Emakefile that Erlang supports to let us recompile and reload our code on the fly.</p> [...]]]></description>
			<content:encoded><![CDATA[<p>Say you&#8217;ve got an Erlang app with the standard file system layout, with your source code in src/ and your compiled code in ebin/.  I&#8217;ve found this makes using the interactive shell interpreter a little harder.  </p>
<p>Lets use the Emakefile that Erlang supports to let us recompile and reload our code on the fly.</p>
<p>Create a file called Emakefile, and put the below line in it.  There&#8217;s other options, but this keeps things simple.</p>
<pre>{"src/*", [report, verbose, {i, "include"}, {outdir, "ebin"}] }.</pre>
<p>Now you can recompile &#038; load everything like this:</p>
<pre>1> make:all([load]).</pre>
<p>But as far as I can tell, it won&#8217;t see your ebin directory.  Keep reading.</p>
<p>Lets kick it up a notch.  Typing make:all([load]) is obnoxious &#8211; lets use the power of user_default as written below.</p>
<p><a target="_blank" href="http://medevyoujane.com/blog/2010/1/3/erlang-quick-tip-the-user_default-module.html">http://medevyoujane.com/blog/2010/1/3/erlang-quick-tip-the-user_default-module.html</a></p>
<p>I wasn&#8217;t able to get the user_default module to work unless I specifically loaded it as follows:</p>
<pre>code:load_abs("/Users/jhaddad/ebin/user_default").</pre>
<p>(Found on <a href="http://amiest-devblog.blogspot.com/2008/01/reloading-all-code-from-erlang-shell_16.html">http://amiest-devblog.blogspot.com/2008/01/reloading-all-code-from-erlang-shell_16.html</a>)</p>
<p>Here&#8217;s all I have in there &#8211; I really just needed r() to work to reload everything.</p>
<pre>
-module(user_default).
-compile(export_all).
r( ) ->
    make:all( [load] ).
</pre>
<p>I&#8217;ve been told there&#8217;s a reloader script in mochiweb that will auto load everything for you &#8211; that&#8217;ll be the subject of a later blog post.  (edit: <a href="/2010/12/erlang-code-auto-reloader/">finally wrote the autoloader how to</a>)</p>
<p><strong>References</strong></p>
<ul>
<li>Make module documentation: <a href="http://www.erlang.org/doc/man/make.html">http://www.erlang.org/doc/man/make.html</a></li>
<li>Compile options: <a href="http://www.erlang.org/doc/man/compile.html">http://www.erlang.org/doc/man/compile.html</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.rustyrazorblade.com/2010/09/smarter-erlang-programming-with-emakefile-options-and-user_default/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Debugging with Erlang</title>
		<link>http://www.rustyrazorblade.com/2010/07/debugging-with-erlang/</link>
		<comments>http://www.rustyrazorblade.com/2010/07/debugging-with-erlang/#comments</comments>
		<pubDate>Thu, 15 Jul 2010 23:58:12 +0000</pubDate>
		<dc:creator>jon</dc:creator>
				<category><![CDATA[erlang]]></category>

		<guid isPermaLink="false">http://www.rustyrazorblade.com/?p=1110</guid>
		<description><![CDATA[<p>First, make sure you have the compile flag (+debug_info) set when compiling your source, then fire up the debugger:</p> 1> i:im(). <p>My Erlang Makefile:</p> EBIN_DIR := ebin SRC_DIR := src EXAMPLES_DIR := examples INCLUDE_DIR := include ERLC := erlc ERLC_FLAGS := +debug_info +native -W -I $(INCLUDE_DIR) -o $(EBIN_DIR) all: @mkdir -p $(EBIN_DIR) $(ERLC) $(ERLC_FLAGS) $(SRC_DIR)/*.erl [...]]]></description>
			<content:encoded><![CDATA[<p>First, make sure you have the compile flag (+debug_info) set when compiling your source, then fire up the debugger:</p>
<pre>1> i:im(). </pre>
<p>My Erlang Makefile:</p>
<pre>
EBIN_DIR := ebin
SRC_DIR := src
EXAMPLES_DIR := examples
INCLUDE_DIR := include
ERLC := erlc
ERLC_FLAGS := +debug_info +native -W -I $(INCLUDE_DIR) -o $(EBIN_DIR)

all:
	@mkdir -p $(EBIN_DIR)
	$(ERLC) $(ERLC_FLAGS) $(SRC_DIR)/*.erl

clean:
	@rm -rf $(EBIN_DIR)/*
	@rm -f erl_crash.dump
</pre>
<p><a href="http://www.erlang.org/doc/apps/debugger/debugger_chapter.html">Read up on the Erlang docs.</a></p>
<p>The debugger can be a bit weird in that it doesn&#8217;t always find your ebin directory (if you&#8217;re compiling to a separate ebin dir)&#8230; it took me a bit to figure out.  Also on the Mac it seems to either crash or not launch timetimes.  </p>
]]></content:encoded>
			<wfw:commentRss>http://www.rustyrazorblade.com/2010/07/debugging-with-erlang/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Running Erlang Code from the Command Line</title>
		<link>http://www.rustyrazorblade.com/2010/07/running-erlang-code-from-the-command-line/</link>
		<comments>http://www.rustyrazorblade.com/2010/07/running-erlang-code-from-the-command-line/#comments</comments>
		<pubDate>Fri, 09 Jul 2010 18:31:31 +0000</pubDate>
		<dc:creator>jon</dc:creator>
				<category><![CDATA[erlang]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://www.rustyrazorblade.com/?p=1105</guid>
		<description><![CDATA[<p>This was really useful for me in scripting TextEdit to run my unit tests, as Erlide has been crashing every time I use it.</p> erl -run mymodule myfunc -run init stop -noshell <p><a href='Running Erlang Code From the Command Line'>http://www.trapexit.org/Running_Erlang_Code_From_The_Command_Line</a></p>]]></description>
			<content:encoded><![CDATA[<p>This was really useful for me in scripting TextEdit to run my unit tests, as Erlide has been crashing every time I use it.</p>
<pre>
erl -run mymodule myfunc -run init stop -noshell
</pre>
<p><a href='Running Erlang Code From the Command Line'>http://www.trapexit.org/Running_Erlang_Code_From_The_Command_Line</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rustyrazorblade.com/2010/07/running-erlang-code-from-the-command-line/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Erlang: Understanding gen_server</title>
		<link>http://www.rustyrazorblade.com/2009/04/erlang-understanding-gen_server/</link>
		<comments>http://www.rustyrazorblade.com/2009/04/erlang-understanding-gen_server/#comments</comments>
		<pubDate>Wed, 22 Apr 2009 18:08:47 +0000</pubDate>
		<dc:creator>jon</dc:creator>
				<category><![CDATA[erlang]]></category>
		<category><![CDATA[gen_server]]></category>

		<guid isPermaLink="false">http://www.rustyrazorblade.com/?p=538</guid>
		<description><![CDATA[<p>Gen_server is a great way to create simple servers without having to write a lot of code at all. Here&#8217;s a brief overview to get you started.</p> <p>For some reason, figuring out how the <a href="http://erlang.org/doc/man/gen_server.html">gen_server </a>behavior works in erlang was kind of a pain for me. I think it&#8217;s because I can&#8217;t just implement [...]]]></description>
			<content:encoded><![CDATA[<p>Gen_server is a great way to create simple servers without having to write a lot of code at all.  Here&#8217;s a brief overview to get you started.</p>
<p>For some reason, figuring out how the <a href="http://erlang.org/doc/man/gen_server.html">gen_server </a>behavior works in erlang was kind of a pain for me.  I think it&#8217;s because I can&#8217;t just implement something, I need to know <em>why</em> it works.  Well, now I know.</p>
<p>So, lets get started.  <a href="http://erlang.org/doc/man/gen_server.html">Gen_server </a>is built into erlang.  It abstracts the message passing away.  As far as I can tell, yes, you could write this functionality yourself.  But why would you want to when it&#8217;s done for you?</p>
<p>For starters, there&#8217;s a few functions you need to implement.  If you&#8217;re using <a href="http://erlide.sourceforge.net/">Erlide</a>, you can create a new module and choose <a href="http://erlang.org/doc/man/gen_server.html">gen_server </a>as the behavior, and it&#8217;ll give you a skeleton.  Nifty.  I strongly recommend going this route, as it has a lot of helpful comments in the code.  </p>
<p>Lets write an addition and subtraction server.  It&#8217;s really not that useful, but it&#8217;s enough to get started and understand what&#8217;s happening.</p>
<p><strong>Init</strong></p>
<blockquote><p>
%% &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
%% Function: init/1<br />
%% Description: Initiates the server<br />
%% Returns: {ok, State}          |<br />
%%          {ok, State, Timeout} |<br />
%%          ignore               |<br />
%%          {stop, Reason}<br />
%% &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br />
init([]) -><br />
    {ok, 0}.
</p></blockquote>
<p>Here&#8217;s a very important thing to understand.   <strong>A <a href="http://erlang.org/doc/man/gen_server.html">gen_server </a>maintains a state.</strong>  The State that&#8217;s returned above is the starting state of the server.  In our case, the initial state will be zero.</p>
<p><strong>handle_call</strong><br />
Now we want to add some functionality.  Lets add addition and subtraction.  We&#8217;ll need to export our new functions as well, so lets make sure we put this in with the exports:</p>
<blockquote><p>-export([add/1, start/0, subtract/1]).</p></blockquote>
<p>And the actual code:</p>
<blockquote><p>add(Num) -> gen_server:call( ?MODULE, {add, Num}).<br />
subtract(Num) -> gen_server:call( ?MODULE, {subtract, Num}).</p>
<p>handle_call({add, Num}, _From, State) -> {reply, State + Num, State + Num};<br />
handle_call({subtract, Num}, _From, State) -> {reply, State &#8211; Num, State &#8211; Num};
</p></blockquote>
<p>When you call counting:add, it will in turn call the gen_server:call function, which takes a module and a parameter.  It will then call &#8220;handle_call&#8221; with this paramater, the Pid it came from, and the State of the server.  The parameter can be anything, so if we use a tuple, we can take advantage of erlang&#8217;s pattern matching.  handle_call will return what the gen_server should do next &#8211; reply (return a result), noreply, or stop.  In this case, we&#8217;re replying.  </p>
<p>The second parameter is the reply.  We&#8217;re just going to return the current count here.  </p>
<p>We also need to return the new server state in parameter 3.  I chose to put the new state in param 2 because it&#8217;s useful, but we could just as easily put anything there &#8211; an atom, a random string, whatever.  </p>
<p>There&#8217;s a lot of options within there, so you might want to check the docs.</p>
<p>I STRONGLY recommend using <a href="http://erlide.sourceforge.net/">Erlide </a>for your development.  It auto compiles and gives you an interactive shell right in the editor.  It made Erlang development so much easier.  It&#8217;ll also create the stubs for the other functions you&#8217;ll need (terminate, code change, handle_info, handle_cast).</p>
<p>FYI, If you get an error like this:</p>
<blockquote><p>** exception exit: {noproc,{gen_server,call,[calculator,{add,1}]}}<br />
     in function  gen_server:call/2</p></blockquote>
<p>It&#8217;s because your gen_server isn&#8217;t actually running.  Make sure you start it before you test with </p>
<blockquote><p>calculator:start().</p></blockquote>
<p>Hopefully this is enough to get you started.  Read up more in the <a href="http://erlang.org/doc/man/gen_server.html">official Erlang docs for gen_server</a>.  Scroll to the bottom to find the specifications on what functions you must implement, and what they need to return.</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rustyrazorblade.com/2009/04/erlang-understanding-gen_server/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Erlang: Create schema before starting mnesia</title>
		<link>http://www.rustyrazorblade.com/2009/04/erlang-create-schema-before-starting-mnesia/</link>
		<comments>http://www.rustyrazorblade.com/2009/04/erlang-create-schema-before-starting-mnesia/#comments</comments>
		<pubDate>Fri, 17 Apr 2009 23:57:19 +0000</pubDate>
		<dc:creator>jon</dc:creator>
				<category><![CDATA[erlang]]></category>

		<guid isPermaLink="false">http://www.rustyrazorblade.com/?p=591</guid>
		<description><![CDATA[<p>If you&#8217;re running into trouble with Mnesia not writing your data to disk, make sure you create the schema BEFORE you start mnesia. Otherwise you&#8217;ll get errors like</p> <p>opt_disc. Directory &#8220;c:/Documents and Settings/jhaddad/workspace/Mnesia.localhost@whatever&#8221; is NOT used.</p>]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re running into trouble with Mnesia not writing your data to disk, make sure you create the schema BEFORE you start mnesia.  Otherwise you&#8217;ll get errors like</p>
<blockquote><p>opt_disc. Directory &#8220;c:/Documents and Settings/jhaddad/workspace/Mnesia.localhost@whatever&#8221; is NOT used.</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.rustyrazorblade.com/2009/04/erlang-create-schema-before-starting-mnesia/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Erlang Records Cheatsheet</title>
		<link>http://www.rustyrazorblade.com/2008/11/erlang-records-cheatsheet/</link>
		<comments>http://www.rustyrazorblade.com/2008/11/erlang-records-cheatsheet/#comments</comments>
		<pubDate>Wed, 12 Nov 2008 02:59:06 +0000</pubDate>
		<dc:creator>jon</dc:creator>
				<category><![CDATA[erlang]]></category>

		<guid isPermaLink="false">http://www.rustyrazorblade.com/?p=382</guid>
		<description><![CDATA[<p>I hate looking stuff up. I just like having this type of thing 1 click away, in a nice summary. This post is mostly for me.</p> <p>Define a record:</p> <p>-record( rule, {ruleid, site, rule, original} ).</p> <p>You can define a record in the shell using rd:</p> <p>99> rd(rule, {ruleid, site, rule, original} ).<br /> rule</p> [...]]]></description>
			<content:encoded><![CDATA[<p>I hate looking stuff up.  I just like having this type of thing 1 click away, in a nice summary.  This post is mostly for me.</p>
<p><strong>Define a record:</strong></p>
<blockquote><p>-record( rule, {ruleid, site, rule, original} ).</p></blockquote>
<p>You can define a record in the shell using rd:</p>
<blockquote><p>99> rd(rule, {ruleid, site, rule, original} ).<br />
rule</p></blockquote>
<p><strong>Create an instance of a record:</strong></p>
<blockquote><p>100> A = #rule{ ruleid=1, site=2, rule=2, original=3}.<br />
#rule{ruleid = 1,site = 2,rule = 2,original = 3}</p></blockquote>
<p><strong>Access a single field in a record:</strong></p>
<blockquote><p>101> A#rule.original.<br />
3</p></blockquote>
<p><strong>Extracting multiple fields:</strong></p>
<blockquote><p>102> #rule{ruleid=B, site=C, rule=D, original=E} = A.<br />
#rule{ruleid = 1,site = 2,rule = 2,original = 3}<br />
103> B.<br />
1<br />
104> C.<br />
2<br />
105> D.<br />
2<br />
106> E.<br />
3</p></blockquote>
<p><strong>Recommended Reading</strong><br />
<a href="http://20bits.com/articles/erlang-an-introduction-to-records/">Introduction to Records</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rustyrazorblade.com/2008/11/erlang-records-cheatsheet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Erlang: Installing Leex</title>
		<link>http://www.rustyrazorblade.com/2008/11/erlang-installing-leex/</link>
		<comments>http://www.rustyrazorblade.com/2008/11/erlang-installing-leex/#comments</comments>
		<pubDate>Tue, 11 Nov 2008 01:59:23 +0000</pubDate>
		<dc:creator>jon</dc:creator>
				<category><![CDATA[erlang]]></category>
		<category><![CDATA[leex]]></category>

		<guid isPermaLink="false">http://www.rustyrazorblade.com/?p=348</guid>
		<description><![CDATA[<p>Leex is an erlang version of <a href="http://dinosaur.compilertools.net/lex/">Lex</a>, a Lexical Analyzer Generator written by Robert Virding. Robert (and several others in #erlang on freenode) were incredibly helpful and considerate in helping me understand these tools.</p> <p>Leex is a tokenizer. It breaks the pieces of your file or text into tokens. You can then use a [...]]]></description>
			<content:encoded><![CDATA[<p>Leex is an erlang version of <a href="http://dinosaur.compilertools.net/lex/">Lex</a>, a Lexical Analyzer Generator written by Robert Virding.  Robert (and several others in #erlang on freenode) were incredibly helpful and considerate in helping me understand these tools.</p>
<p>Leex is a tokenizer.  It breaks the pieces of your file or text into tokens. You can then use a tool like yecc to take these tokens and generate useful parsers.</p>
<p>First, you&#8217;ll need the source.  <a href="http://www.trapexit.org/forum/viewtopic.php?p=43929">Leex source is available here</a>.  Go down to the last post in the forum, download the attached file.</p>
<ol>
<li>Create a directory for your erlang packages.  I chose ~/erlang.</li>
<li>Drop the leex directory in your new erlang package directory.</li>
<li>Edit your ~/.erlang file (it probably doesn&#8217;t exist yet) to include this line, making sure to use the path to your erlang package directory instead of mine:<br />
<blockquote><p>code:add_pathz(&#8220;/Users/jhaddad/erlang/leex/ebin&#8221;).</p></blockquote>
</li>
</ol>
<p>You should be able to use the leex libraries now.  </p>
]]></content:encoded>
			<wfw:commentRss>http://www.rustyrazorblade.com/2008/11/erlang-installing-leex/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

